Skip to content

Commit

Permalink
WW-5370 Simplifies code
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Dec 12, 2023
1 parent c40978f commit 7bea060
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static Builder create() {

public HttpParameters remove(Set<String> paramsToRemove) {
for (String paramName : paramsToRemove) {
parameters.entrySet().removeIf(p -> p.getKey().equalsIgnoreCase(paramName));
parameters.remove(paramName);
}
return this;
}
Expand Down Expand Up @@ -112,10 +112,10 @@ public boolean containsValue(Object value) {

@Override
public Parameter get(Object key) {
if (key != null && contains(String.valueOf(key))) {
return parameters.get(key);
if (key != null) {
return parameters.get(String.valueOf(key));
} else {
return new Parameter.Empty(String.valueOf(key));
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.util.HashMap;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

public class HttpParametersTest {
Expand All @@ -40,6 +42,18 @@ public void shouldGetBeCaseInsensitive() {
assertEquals("value1", params.get("pAraM1").getValue());
}

@Test
public void shouldRemoveBeCaseInsensitive() {
// given
HttpParameters params = HttpParameters.create(new HashMap<String, Object>() {{
put("param1", "value1");
}}).build();

// then
assertFalse(params.remove("Param1").contains("param1"));
assertNull(params.get("param1"));
}

@Test
public void shouldAppendSameParamsIgnoringCase() {
// given
Expand Down

0 comments on commit 7bea060

Please sign in to comment.