Search in sources :

Example 11 with QueryParameters

use of com.vaadin.flow.router.QueryParameters in project flow by vaadin.

the class QueryParametersTest method underlyingMapUnmodifiable_simple.

@Test(expected = UnsupportedOperationException.class)
public void underlyingMapUnmodifiable_simple() {
    QueryParameters params = QueryParameters.simple(getSimpleInputParameters());
    params.getParameters().put("one", Collections.emptyList());
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Test(org.junit.Test)

Example 12 with QueryParameters

use of com.vaadin.flow.router.QueryParameters in project flow by vaadin.

the class QueryParametersTest method emptyParameters.

@Test
public void emptyParameters() {
    QueryParameters emptyParams = QueryParameters.empty();
    assertEquals(Collections.emptyMap(), emptyParams.getParameters());
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Test(org.junit.Test)

Example 13 with QueryParameters

use of com.vaadin.flow.router.QueryParameters in project flow by vaadin.

the class QueryParametersTest method parameterWithoutValue.

@Test
public void parameterWithoutValue() {
    QueryParameters params = new QueryParameters(Collections.singletonMap("foo", Collections.emptyList()));
    Assert.assertEquals("foo", params.getQueryString());
    params = new QueryParameters(Collections.singletonMap("foo", Arrays.asList(null, "bar")));
    Assert.assertEquals("foo&foo=bar", params.getQueryString());
    params = new QueryParameters(Collections.singletonMap("foo", Arrays.asList("bar", null)));
    Assert.assertEquals("foo=bar&foo", params.getQueryString());
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Test(org.junit.Test)

Example 14 with QueryParameters

use of com.vaadin.flow.router.QueryParameters in project flow by vaadin.

the class QueryParametersTest method complexParametersToQueryString.

@Test
public void complexParametersToQueryString() {
    QueryParameters fullParams = QueryParameters.full(getFullInputParameters());
    String queryString = fullParams.getQueryString();
    assertTrue(queryString.contains("one=1"));
    assertTrue(queryString.contains("one=11"));
    assertTrue(queryString.contains("two=2"));
    assertTrue(queryString.contains("two=22"));
    assertTrue(queryString.contains("three=3"));
    assertNumberOfOccurences(queryString, 4, "&");
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Test(org.junit.Test)

Example 15 with QueryParameters

use of com.vaadin.flow.router.QueryParameters in project flow by vaadin.

the class QueryParametersTest method emptyParametersToQueryString.

@Test
public void emptyParametersToQueryString() {
    QueryParameters emptyParams = QueryParameters.empty();
    assertEquals("", emptyParams.getQueryString());
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Test(org.junit.Test)

Aggregations

QueryParameters (com.vaadin.flow.router.QueryParameters)17 Test (org.junit.Test)15 Location (com.vaadin.flow.router.Location)7 List (java.util.List)4 Router (com.vaadin.flow.router.Router)2 MockVaadinSession (com.vaadin.flow.server.MockVaadinSession)2 VaadinResponse (com.vaadin.flow.server.VaadinResponse)2 MockUI (com.vaadin.tests.util.MockUI)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ExtendedClientDetails (com.vaadin.flow.component.page.ExtendedClientDetails)1 History (com.vaadin.flow.component.page.History)1 HistoryStateChangeEvent (com.vaadin.flow.component.page.History.HistoryStateChangeEvent)1 Element (com.vaadin.flow.dom.Element)1 Node (com.vaadin.flow.dom.Node)1 NodeVisitor (com.vaadin.flow.dom.NodeVisitor)1 AbstractTextElementStateProvider (com.vaadin.flow.dom.impl.AbstractTextElementStateProvider)1 CurrentInstance (com.vaadin.flow.internal.CurrentInstance)1 StateNode (com.vaadin.flow.internal.StateNode)1