Search in sources :

Example 1 with QueryParameters

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

the class LocationTest method locationWithParametersPath_withTrailingSlash.

@Test
public void locationWithParametersPath_withTrailingSlash() {
    String initialPath = "foo/bar/";
    QueryParameters queryParams = getQueryParameters();
    Location location = new Location(initialPath, queryParams);
    String pathWithParameters = location.getPathWithQueryParameters();
    assertEquals(initialPath + '?' + queryParams.getQueryString(), pathWithParameters);
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 2 with QueryParameters

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

the class LocationTest method locationWithParamsInUrl.

@Test
public void locationWithParamsInUrl() {
    String initialPath = "foo/bar/";
    QueryParameters queryParams = getQueryParameters();
    Location location = new Location(initialPath, queryParams);
    assertEquals("foo/bar/", location.getPath());
    assertEquals(queryParams.getParameters(), location.getQueryParameters().getParameters());
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 3 with QueryParameters

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

the class QueryParametersTest method simpleParameters.

@Test
public void simpleParameters() {
    QueryParameters simpleParams = QueryParameters.simple(getSimpleInputParameters());
    Map<String, List<String>> expectedFullParams = new HashMap<>();
    expectedFullParams.put("one", Collections.singletonList("1"));
    expectedFullParams.put("two", Collections.singletonList("2"));
    expectedFullParams.put("three", Collections.singletonList("3"));
    assertEquals(expectedFullParams, simpleParams.getParameters());
}
Also used : HashMap(java.util.HashMap) List(java.util.List) QueryParameters(com.vaadin.flow.router.QueryParameters) Test(org.junit.Test)

Example 4 with QueryParameters

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

the class QueryParametersTest method simpleParametersToQueryString.

@Test
public void simpleParametersToQueryString() {
    QueryParameters simpleParams = QueryParameters.simple(getSimpleInputParameters());
    String queryString = simpleParams.getQueryString();
    assertTrue(queryString.contains("one=1"));
    assertTrue(queryString.contains("two=2"));
    assertTrue(queryString.contains("three=3"));
    assertTrue(queryString.contains("&"));
    assertNumberOfOccurences(queryString, 2, "&");
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Test(org.junit.Test)

Example 5 with QueryParameters

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

the class QueryParametersTest method complexParameters.

@Test
public void complexParameters() {
    QueryParameters fullParams = QueryParameters.full(getFullInputParameters());
    Map<String, List<String>> expectedFullParams = new HashMap<>();
    expectedFullParams.put("one", Arrays.asList("1", "11"));
    expectedFullParams.put("two", Arrays.asList("2", "22"));
    expectedFullParams.put("three", Collections.singletonList("3"));
    assertEquals(expectedFullParams, fullParams.getParameters());
}
Also used : HashMap(java.util.HashMap) List(java.util.List) 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