use of io.helidon.common.http.HashParameters in project helidon by oracle.
the class HashParametersTest method unmodifiabilityEmpty.
@Test
public void unmodifiabilityEmpty() throws Exception {
HashParameters hashParameters = HashParameters.create();
assertThrows(UnsupportedOperationException.class, () -> {
hashParameters.all("a").add("this should fail");
});
}
use of io.helidon.common.http.HashParameters in project helidon by oracle.
the class HashParametersTest method remove.
@Test
public void remove() throws Exception {
HashParameters hp = HashParameters.create();
List<String> removed = hp.remove("a");
assertThat(removed, IsCollectionWithSize.hasSize(0));
hp.put("a", "v1", "v2");
removed = hp.remove("a");
assertThat(removed, contains("v1", "v2"));
assertThat(hp.all("a"), IsCollectionWithSize.hasSize(0));
}
use of io.helidon.common.http.HashParameters in project helidon by oracle.
the class HashParametersTest method unmodifiabilityNonEmpty.
@Test
public void unmodifiabilityNonEmpty() throws Exception {
HashParameters hashParameters = HashParameters.create();
hashParameters.add("a", "v1", "v2");
assertThrows(UnsupportedOperationException.class, () -> {
hashParameters.all("a").add("this should fail");
});
}
use of io.helidon.common.http.HashParameters in project helidon by oracle.
the class HashParametersTest method put.
@Test
public void put() throws Exception {
HashParameters hp = HashParameters.create();
List<String> result = hp.put("a", "v1", "v2", "v3");
assertThat(hp.all("a"), contains("v1", "v2", "v3"));
assertThat(result, IsCollectionWithSize.hasSize(0));
result = hp.put("a", "x1", "x2");
assertThat(result, contains("v1", "v2", "v3"));
assertThat(hp.all("a"), contains("x1", "x2"));
List<String> l = new ArrayList<>(Arrays.asList("y1", "y2"));
hp.put("a", l);
assertThat(hp.all("a"), contains("y1", "y2"));
l.add("y3");
assertThat(hp.all("a").size(), is(2));
hp.put("a");
assertThat(hp.first("a").isPresent(), is(false));
hp.put("b", "b1", "b2");
hp.put("b", (Iterable<String>) null);
assertThat(hp.first("b").isPresent(), is(false));
}
use of io.helidon.common.http.HashParameters in project helidon by oracle.
the class HashParametersTest method toMap.
@Test
public void toMap() throws Exception {
HashParameters hp = HashParameters.create();
hp.put("a", "v1", "v2");
hp.put("b", "v3", "v4");
Map<String, List<String>> map = hp.toMap();
assertThat(map.size(), is(2));
assertThat(map.get("a"), contains("v1", "v2"));
assertThat(map.get("b"), contains("v3", "v4"));
}
Aggregations