Search in sources :

Example 6 with Location

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

the class LocationTest method locationNameShouldBeAbleToHaveDotDot.

@Test
public void locationNameShouldBeAbleToHaveDotDot() {
    Location location = new Location("..element");
    assertEquals("..element", location.getFirstSegment());
    location = new Location("el..ement");
    assertEquals("el..ement", location.getFirstSegment());
}
Also used : Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 7 with Location

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

the class LocationTest method spaceInLocation.

@Test
public void spaceInLocation() {
    Location location = new Location("foo bar");
    assertEquals("foo bar", location.getFirstSegment());
}
Also used : Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 8 with Location

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

the class LocationTest method parseLocationWithQueryString_noValue.

@Test
public void parseLocationWithQueryString_noValue() {
    Location location = new Location("path?query");
    assertEquals("path", location.getPath());
    assertEquals(Collections.singletonMap("query", Collections.emptyList()), location.getQueryParameters().getParameters());
    assertEquals("path?query", location.getPathWithQueryParameters());
}
Also used : Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 9 with Location

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

the class LocationTest method locationFromSegments.

@Test
public void locationFromSegments() {
    Location location = new Location(Arrays.asList("one", "two"));
    assertEquals(Arrays.asList("one", "two"), location.getSegments());
    assertEquals("one/two", location.getPath());
}
Also used : Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 10 with Location

use of com.vaadin.flow.router.Location 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)

Aggregations

Location (com.vaadin.flow.router.Location)51 Test (org.junit.Test)40 UI (com.vaadin.flow.component.UI)15 Router (com.vaadin.flow.router.legacy.Router)15 NavigationEvent (com.vaadin.flow.router.NavigationEvent)10 NavigationHandler (com.vaadin.flow.router.NavigationHandler)8 RouterConfiguration (com.vaadin.flow.router.legacy.RouterConfiguration)7 HistoryStateChangeEvent (com.vaadin.flow.component.page.History.HistoryStateChangeEvent)6 TestView (com.vaadin.flow.router.legacy.ViewRendererTest.TestView)6 NavigationTrigger (com.vaadin.flow.router.NavigationTrigger)5 QueryParameters (com.vaadin.flow.router.QueryParameters)5 DefaultErrorView (com.vaadin.flow.router.legacy.DefaultErrorView)5 VaadinRequest (com.vaadin.flow.server.VaadinRequest)5 VaadinResponse (com.vaadin.flow.server.VaadinResponse)5 Optional (java.util.Optional)4 CurrentInstance (com.vaadin.flow.internal.CurrentInstance)3 RouterInterface (com.vaadin.flow.router.RouterInterface)3 ImmutableRouterConfiguration (com.vaadin.flow.router.legacy.ImmutableRouterConfiguration)3 Resolver (com.vaadin.flow.router.legacy.Resolver)3 RouteSegmentVisitor (com.vaadin.flow.router.legacy.RouteLocation.RouteSegmentVisitor)3