Router { public void goTo(Screen nextScreen) { if (tryHandleEmptyBackstack(nextScreen)) { return; } List<Screen> fromPath = backStack.asList(); if (Screen.equals(backStack.peek(), nextScreen)) { return; } backStack.push(nextScreen); performRouteChange(fromPath, backStack.asList(), TransitionDirection.ENTER); } Router();  Router(boolean allowEmptyStack); boolean goBack(); void goTo(Screen nextScreen); void replaceWith(Screen nextScreen); void replaceAllWith(Screen... screens); void replaceAllWith(List<Screen> screens); void resetTo(Screen screen); void resetTo(Screen nextScreen, TransitionDirection direction); boolean hasActiveScreen();  }
@Test public void emptyBackstackGoTo() { router = new TestRouter(false); Screen screenA = new ScreenA(); router.goTo(screenA); assertTrue(router.fromPath.isEmpty()); assertEquals(screenA, router.toPath.get(0)); assertEquals(1, router.routeChangeCount); }
@Test public void goTo() { router = new TestRouter(false); Screen screenA = new ScreenA(); router.goTo(screenA); assertTrue(router.fromPath.isEmpty()); assertEquals(screenA, router.toPath.get(0)); assertEquals(TransitionDirection.ENTER, router.direction); assertEquals(1, router.routeChangeCount); }
@Test public void goToSameScreen() { router = new TestRouter(false); Screen screenA = new ScreenA(); Screen screenB = new ScreenA(); router.goTo(screenA); assertEquals(screenA, router.toPath.get(0)); router.goTo(screenB); assertEquals(screenA, router.toPath.get(0)); assertEquals(1, router.routeChangeCount); }