use of com.vaadin.flow.router.Location in project flow by vaadin.
the class LocationTest method parseLocationWithQueryString_emptyValue.
@Test
public void parseLocationWithQueryString_emptyValue() {
Location location = new Location("path?query=");
assertEquals("path", location.getPath());
assertEquals(Collections.singletonMap("query", Collections.singletonList("")), location.getQueryParameters().getParameters());
assertEquals("path?query=", location.getPathWithQueryParameters());
}
use of com.vaadin.flow.router.Location in project flow by vaadin.
the class LocationTest method locationWithParamAndEmptyValue.
@Test
public void locationWithParamAndEmptyValue() {
Location location = new Location("foo?param=¶m=bar");
Assert.assertEquals("param=¶m=bar", location.getQueryParameters().getQueryString());
}
use of com.vaadin.flow.router.Location in project flow by vaadin.
the class RouteLocationTest method walkRouteWithInvalidWildcard.
@Test(expected = IllegalArgumentException.class)
public void walkRouteWithInvalidWildcard() {
RouteLocation location = new RouteLocation(new Location("foo/*/*"));
RouteSegmentVisitor visitor = EasyMock.createMock(RouteSegmentVisitor.class);
location.visitSegments(visitor);
}
use of com.vaadin.flow.router.Location in project flow by vaadin.
the class RouteLocationTest method testWalkRoute.
@Test
public void testWalkRoute() {
RouteLocation location = new RouteLocation(new Location("foo/{bar}/*"));
AtomicInteger calls = new AtomicInteger();
location.visitSegments(new RouteSegmentVisitor() {
@Override
public void acceptSegment(String segmentName) {
Assert.assertEquals("foo", segmentName);
Assert.assertEquals(1, calls.incrementAndGet());
}
@Override
public void acceptPlaceholder(String placeholderName) {
Assert.assertEquals("bar", placeholderName);
Assert.assertEquals(2, calls.incrementAndGet());
}
@Override
public void acceptWildcard() {
Assert.assertEquals(3, calls.incrementAndGet());
}
});
Assert.assertEquals(3, calls.get());
}
use of com.vaadin.flow.router.Location in project flow by vaadin.
the class RouterConfigurationTest method testParentViewsWithParent.
@Test
public void testParentViewsWithParent() {
UI ui = new UI();
Router router = new Router();
router.reconfigure(conf -> {
conf.setRoute("route", TestView.class, ParentView.class);
conf.setParentView(ParentView.class, AnotherParentView.class);
});
router.navigate(ui, new Location("route"), NavigationTrigger.PROGRAMMATIC);
Assert.assertEquals(ParentView.class, router.getConfiguration().getParentView(TestView.class).get());
Assert.assertEquals(AnotherParentView.class, router.getConfiguration().getParentView(ParentView.class).get());
Assert.assertEquals(Arrays.asList(TestView.class, ParentView.class, AnotherParentView.class), getViewChainTypes(ui));
}
Aggregations