use of com.vaadin.flow.router.Location in project flow by vaadin.
the class ViewRendererTest method routeParametersInEvent.
@Test
public void routeParametersInEvent() {
router.reconfigure(c -> c.setRoute("foo/{name}/*", TestView.class));
router.navigate(ui, new Location("foo/bar/baz/"), NavigationTrigger.PROGRAMMATIC);
TestView testView = (TestView) ui.getInternals().getActiveViewChain().get(0);
Assert.assertEquals("bar", testView.namePlaceholderValue);
Assert.assertEquals("baz/", testView.wildcardValue);
}
use of com.vaadin.flow.router.Location in project flow by vaadin.
the class LocationChangeEventTest method setup.
@Before
public void setup() {
UI ui = new RouterTestUI();
event = new LocationChangeEvent(ui.getRouterInterface().get(), ui, NavigationTrigger.PROGRAMMATIC, new Location(""), Arrays.asList(new AnotherTestView(), new AnotherParentView()), Collections.emptyMap());
event.getSource().reconfigure(c -> c.setParentView(TestView.class, ParentView.class));
navigationEvent = new NavigationEvent(event.getSource(), event.getLocation(), event.getUI(), event.getTrigger());
}
use of com.vaadin.flow.router.Location in project flow by vaadin.
the class LocationTest method subLocation.
@Test
public void subLocation() {
Location location = new Location(Arrays.asList("one", "two", "three"));
assertEquals("one", location.getFirstSegment());
Optional<Location> subLocation = location.getSubLocation();
assertEquals(Arrays.asList("two", "three"), subLocation.get().getSegments());
assertEquals("two/three", subLocation.get().getPath());
}
use of com.vaadin.flow.router.Location in project flow by vaadin.
the class LocationTest method locationWithParamWithAndWithoutValue.
@Test
public void locationWithParamWithAndWithoutValue() {
Location location = new Location("foo?param¶m=bar");
Assert.assertEquals("param¶m=bar", location.getQueryParameters().getQueryString());
location = new Location("foo?param=bar¶m");
Assert.assertEquals("param=bar¶m", location.getQueryParameters().getQueryString());
}
use of com.vaadin.flow.router.Location 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);
}
Aggregations