Divisor implements GameLifeCycle { @Override public void launch() { gameContext.setLimiterAvailable(); final Target target; final ImageLibrary imageLibrary; if (isRabbit) { imageLibrary = ImageUtils.createCustomizedImageLibrary(null, "divisor/rabbit/images"); initBackground(); gameContext.resetBordersToFront(); } else { imageLibrary = ImageUtils.createImageLibrary(Utils.getImagesSubdirectory("portraits")); } this.stats.notifyNewRoundReady(); gameContext.getGazeDeviceManager().addStats(stats); stats.incrementNumberOfGoalsToReach(15); target = new Target(gameContext, stats, imageLibrary, 0,System.currentTimeMillis(), this, this.gameContext.getRandomPositionGenerator().newRandomPosition(100), isRabbit); gameContext.getChildren().add(target); gameContext.firstStart(); } Divisor(final IGameContext gameContext, final Stats stats, final boolean isRabbit); @Override void launch(); void restart(); @Override void dispose();  }
@Test void shouldLaunchRabbits() { Divisor divisor = new Divisor(mockGameContext, mockStats, true); divisor.launch(); verify(mockProvider, atLeastOnce()).getDimension2D(); assertEquals(2, children.size()); Target target = (Target) children.get(1); assertTrue(target.getImgLib().pickRandomImage().getUrl().contains("rabbit")); }
@Test void shouldLaunchCustom() { new MockUp<Utils>() { @mockit.Mock public File getImagesSubdirectory(String dir) { return new File(localDataFolder, "images/" + dir); } }; Divisor divisor = new Divisor(mockGameContext, mockStats, false); divisor.launch(); assertEquals(1, children.size()); Target target = (Target) children.get(0); assertTrue(target.getImgLib().pickRandomImage().getUrl().contains("biscuit")); }
@Test void shouldLaunchDefault() { new MockUp<Utils>() { @mockit.Mock public File getImagesSubdirectory(String dir) { return new File("wrong/path"); } }; Divisor divisor = new Divisor(mockGameContext, mockStats, false); divisor.launch(); assertEquals(1, children.size()); Target target = (Target) children.get(0); assertTrue(target.getImgLib().pickRandomImage().getUrl().contains("common/default/images")); }