protected ScreenScooper getScreenScooper() { return new ScreenScooper(new ScreenScoopFactory()); }
public Scoop create(Scoop rootScoop, Scoop currentScreenScoop, List<Screen> fromPath, List<Screen> toPath) { Scoop finalScoop = null; List<Scoop> scoops = getCurrentScoops(fromPath, currentScreenScoop); int index = 0; while (index < fromPath.size() && currentScreenScoop != null) { Screen fromScreen = safeElementGet(fromPath, index); Screen toScreen = safeElementGet(toPath, index); Scoop scoop = scoops.get(index); if (Screen.equals(fromScreen, toScreen)) { finalScoop = scoop; } else { scoop.destroy(); break; } index++; } while (index < toPath.size()) { Screen toScreen = safeElementGet(toPath, index); if (finalScoop == null) { finalScoop = rootScoop; } finalScoop = screenScoopFactory.createScreenScoop(toScreen, finalScoop); index++; } return finalScoop; }
public final Scoop createScreenScoop(Screen screen, Scoop parentScoop) { Scoop.Builder scoopBuilder = new Scoop.Builder(screen.getClass().getSimpleName(), parentScoop) .service(Screen.SERVICE_NAME, screen); return addServices(scoopBuilder, screen, parentScoop); }
@Test public void screenAddedToScoop() { ScreenScoopFactory screenScoopFactory = new ScreenScoopFactory(); Scoop parentScoop = new Scoop.Builder("root").build(); Screen screen = new TestScreen(); Scoop childScoop = screenScoopFactory.createScreenScoop(screen, parentScoop); Assert.assertEquals(screen, Screen.fromScoop(childScoop)); }
public Scoop create(Scoop rootScoop, Scoop currentScreenScoop, List<Screen> fromPath, List<Screen> toPath) { Scoop finalScoop = null; List<Scoop> scoops = getCurrentScoops(fromPath, currentScreenScoop); int index = 0; while (index < fromPath.size() && currentScreenScoop != null) { Screen fromScreen = safeElementGet(fromPath, index); Screen toScreen = safeElementGet(toPath, index); Scoop scoop = scoops.get(index); if (Screen.equals(fromScreen, toScreen)) { finalScoop = scoop; } else { scoop.destroy(); break; } index++; } while (index < toPath.size()) { Screen toScreen = safeElementGet(toPath, index); if (finalScoop == null) { finalScoop = rootScoop; } finalScoop = screenScoopFactory.createScreenScoop(toScreen, finalScoop); index++; } return finalScoop; }
protected ScreenScooper getScreenScooper() { return new ScreenScooper(new ScreenScoopFactory()); }
public final Scoop createScreenScoop(Screen screen, Scoop parentScoop) { Scoop.Builder scoopBuilder = new Scoop.Builder(screen.getClass().getSimpleName(), parentScoop) .service(Screen.SERVICE_NAME, screen); return addServices(scoopBuilder, screen, parentScoop); }
@Test public void createScoopFromABPathToEmptyPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB()); List<Screen> toPath = Arrays.<Screen>asList(); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScoopFactory.createScreenScoop(new ScreenB(), aScoop); Scoop scoop = screenScooper.create(rootScoop, bScoop, fromPath, toPath); assertFalse(rootScoop.isDestroyed()); assertTrue(aScoop.isDestroyed()); assertTrue(bScoop.isDestroyed()); assertNull(scoop); }
@Before public void setUp() { screenScoopFactory = new ScreenScoopFactory(); screenScooper = new ScreenScooper(screenScoopFactory); rootScoop = new Scoop.Builder("root").build(); }
public final Scoop createScreenScoop(Screen screen, Scoop parentScoop) { Scoop.Builder scoopBuilder = new Scoop.Builder(screen.getClass().getSimpleName(), parentScoop) .service(Screen.SERVICE_NAME, screen); return addServices(scoopBuilder, screen, parentScoop); }
@Test public void createScoopFromABPathToAPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScoopFactory.createScreenScoop(new ScreenB(), aScoop); Scoop scoop = screenScooper.create(rootScoop, bScoop, fromPath, toPath); assertFalse(rootScoop.isDestroyed()); assertFalse(aScoop.isDestroyed()); assertTrue(bScoop.isDestroyed()); assertEquals(aScoop, scoop); }
protected ScreenScooper getScreenScooper() { return new ScreenScooper(new ScreenScoopFactory()); }
@Test public void createScoopFromABCPathToAPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB(), new ScreenC()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScoopFactory.createScreenScoop(new ScreenB(), aScoop); Scoop cScoop = screenScoopFactory.createScreenScoop(new ScreenC(), bScoop); Scoop scoop = screenScooper.create(rootScoop, cScoop, fromPath, toPath); assertTrue(bScoop.isDestroyed()); assertTrue(cScoop.isDestroyed()); assertFalse(aScoop.isDestroyed()); assertFalse(rootScoop.isDestroyed()); assertEquals(aScoop, scoop); }
@Test public void createScoopFromABPathToACPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA(), new ScreenC()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScoopFactory.createScreenScoop(new ScreenB(), aScoop); Scoop cScoop = screenScooper.create(rootScoop, bScoop, fromPath, toPath); assertFalse(rootScoop.isDestroyed()); assertFalse(aScoop.isDestroyed()); assertTrue(bScoop.isDestroyed()); assertFalse(cScoop.isDestroyed()); assertEquals(aScoop, cScoop.getParent()); }
@Test public void createScoopFromABPathToABCPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB(), new ScreenC()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScoopFactory.createScreenScoop(new ScreenB(), aScoop); Scoop cScoop = screenScooper.create(rootScoop, bScoop, fromPath, toPath); assertFalse(rootScoop.isDestroyed()); assertFalse(aScoop.isDestroyed()); assertFalse(bScoop.isDestroyed()); assertFalse(cScoop.isDestroyed()); assertEquals(rootScoop, cScoop.getParent().getParent().getParent()); }
@Test public void createScoopFromAPathToABPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScooper.create(rootScoop, aScoop, fromPath, toPath); assertFalse(rootScoop.isDestroyed()); assertFalse(aScoop.isDestroyed()); assertFalse(bScoop.isDestroyed()); assertEquals(aScoop, bScoop.getParent()); }
@Test public void createScoopFromAPathToBPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenB()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScooper.create(rootScoop, aScoop, fromPath, toPath); assertTrue(aScoop.isDestroyed()); assertFalse(bScoop.isDestroyed()); assertFalse(rootScoop.isDestroyed()); assertEquals(rootScoop, bScoop.getParent()); }
@Test public void createScoopFromABCPathToABDPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB(), new ScreenC()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB(), new ScreenD()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScoopFactory.createScreenScoop(new ScreenB(), aScoop); Scoop cScoop = screenScoopFactory.createScreenScoop(new ScreenC(), bScoop); Scoop dScoop = screenScooper.create(rootScoop, cScoop, fromPath, toPath); assertFalse(rootScoop.isDestroyed()); assertFalse(aScoop.isDestroyed()); assertFalse(bScoop.isDestroyed()); assertFalse(dScoop.isDestroyed()); assertTrue(cScoop.isDestroyed()); assertEquals(rootScoop, dScoop.getParent().getParent().getParent()); }
@Test public void createScoopFromAPathToABCPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB(), new ScreenC()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop cScoop = screenScooper.create(rootScoop, aScoop, fromPath, toPath); assertFalse(cScoop.getParent().isDestroyed()); assertFalse(cScoop.isDestroyed()); assertFalse(aScoop.isDestroyed()); assertFalse(rootScoop.isDestroyed()); assertEquals(aScoop, cScoop.getParent().getParent()); }
@Test public void createScoopFromABPathToBCPathToCCPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenB()); Scoop aScoop = screenScoopFactory.createScreenScoop(new ScreenA(), rootScoop); Scoop bScoop = screenScooper.create(rootScoop, aScoop, fromPath, toPath); assertNotEquals(aScoop, bScoop); fromPath = Arrays.<Screen>asList(new ScreenB()); toPath = Arrays.<Screen>asList(new ScreenC()); Scoop cScoop = screenScooper.create(rootScoop, bScoop, fromPath, toPath); assertNotEquals(bScoop, cScoop); fromPath = Arrays.<Screen>asList(new ScreenC()); toPath = Arrays.<Screen>asList(new ScreenC()); Scoop scoop = screenScooper.create(rootScoop, cScoop, fromPath, toPath); assertNotEquals(bScoop, scoop); }