Search in sources :

Example 31 with Location

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

the class LocationTest method locationWithParametersPath_emptyParams.

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

Example 32 with Location

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

the class LocationTest method toggleTrailingSlash.

@Test
public void toggleTrailingSlash() {
    assertEquals("foo", new Location("foo/").toggleTrailingSlash().getPath());
    assertEquals("foo/", new Location("foo").toggleTrailingSlash().getPath());
}
Also used : Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 33 with Location

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

the class LocationTest method parseLocationWithEndingSlash.

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

Example 34 with Location

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

the class LocationTest method noSubLocation_emptyOptional.

@Test
public void noSubLocation_emptyOptional() {
    Location location = new Location("foo");
    Optional<Location> maybeSubLocation = location.getSubLocation();
    Assert.assertFalse(maybeSubLocation.isPresent());
}
Also used : Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 35 with Location

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

the class LocationTest method umlautInLocation.

@Test
public void umlautInLocation() {
    Location location = new Location("foo/åäö/bar");
    assertEquals("foo", location.getSegments().get(0));
    assertEquals("åäö", location.getSegments().get(1));
    assertEquals("bar", location.getSegments().get(2));
}
Also used : 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