Search in sources :

Example 6 with HashParameters

use of io.helidon.common.http.HashParameters in project helidon by oracle.

the class HashParametersTest method addNull.

@Test
public void addNull() throws Exception {
    HashParameters hashParameters = HashParameters.create();
    hashParameters.add("a", ((String[]) null));
    hashParameters.add("a", "value");
    hashParameters.add("a", ((String[]) null));
    hashParameters.add("a", (Iterable<String>) null);
    assertThat(hashParameters.all("a"), contains(is("value")));
    assertThat(hashParameters.first("a").get(), is("value"));
}
Also used : HashParameters(io.helidon.common.http.HashParameters) Test(org.junit.jupiter.api.Test)

Example 7 with HashParameters

use of io.helidon.common.http.HashParameters in project helidon by oracle.

the class HashParametersTest method addMultipleAtOnce.

@SuppressWarnings("unchecked")
@Test
public void addMultipleAtOnce() throws Exception {
    HashParameters hashParameters = HashParameters.create();
    hashParameters.add("a", "v1", "v2");
    assertThat(hashParameters.all("a"), contains(is("v1"), is("v2")));
    assertThat(hashParameters.first("a").get(), is("v1"));
}
Also used : HashParameters(io.helidon.common.http.HashParameters) Test(org.junit.jupiter.api.Test)

Example 8 with HashParameters

use of io.helidon.common.http.HashParameters in project helidon by oracle.

the class HashParametersTest method addMultipleOneByOne.

@SuppressWarnings("unchecked")
@Test
public void addMultipleOneByOne() throws Exception {
    HashParameters hashParameters = HashParameters.create();
    hashParameters.add("a", "v1");
    hashParameters.add("a", "v2");
    assertThat(hashParameters.all("a"), contains(is("v1"), is("v2")));
    assertThat(hashParameters.first("a").get(), is("v1"));
}
Also used : HashParameters(io.helidon.common.http.HashParameters) Test(org.junit.jupiter.api.Test)

Example 9 with HashParameters

use of io.helidon.common.http.HashParameters in project helidon by oracle.

the class HashParametersTest method addAll.

@Test
public void addAll() throws Exception {
    HashParameters hp = HashParameters.create();
    hp.put("a", "a1", "a2");
    hp.put("b", "b1", "b2");
    HashParameters hp2 = HashParameters.create();
    hp2.put("c", "c1", "c2");
    hp2.put("b", "b3", "b4");
    hp.addAll(hp2);
    assertThat(hp.all("a"), contains("a1", "a2"));
    assertThat(hp.all("b"), contains("b1", "b2", "b3", "b4"));
    assertThat(hp.all("c"), contains("c1", "c2"));
    hp.addAll(null);
    assertThat(hp.all("b"), contains("b1", "b2", "b3", "b4"));
}
Also used : HashParameters(io.helidon.common.http.HashParameters) Test(org.junit.jupiter.api.Test)

Example 10 with HashParameters

use of io.helidon.common.http.HashParameters in project helidon by oracle.

the class HashParametersTest method concatNullAndEmpty.

@Test
public void concatNullAndEmpty() throws Exception {
    Parameters[] prms = null;
    HashParameters concat = HashParameters.concat(prms);
    assertThat(concat, notNullValue());
    prms = new Parameters[10];
    concat = HashParameters.concat(prms);
    assertThat(concat, notNullValue());
    concat = HashParameters.concat();
    assertThat(concat, notNullValue());
}
Also used : HashParameters(io.helidon.common.http.HashParameters) Parameters(io.helidon.common.http.Parameters) HashParameters(io.helidon.common.http.HashParameters) Test(org.junit.jupiter.api.Test)

Aggregations

HashParameters (io.helidon.common.http.HashParameters)15 Test (org.junit.jupiter.api.Test)15 ArrayList (java.util.ArrayList)3 Parameters (io.helidon.common.http.Parameters)2 List (java.util.List)2 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Optional.empty (java.util.Optional.empty)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 IsCollectionWithSize (org.hamcrest.collection.IsCollectionWithSize)1 IsCollectionWithSize.hasSize (org.hamcrest.collection.IsCollectionWithSize.hasSize)1 IsIterableContainingInOrder.contains (org.hamcrest.collection.IsIterableContainingInOrder.contains)1 Is.is (org.hamcrest.core.Is.is)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1