CakeViewImpl implements View { public void render() { cakeBakingService.getAllCakes().stream().forEach(cake -> LOGGER.info(cake.toString())); } CakeViewImpl(CakeBakingService cakeBakingService); void render();  }
@Test public void testRender() { final List<CakeLayerInfo> layers = new ArrayList<>(); layers.add(new CakeLayerInfo("layer1", 1000)); layers.add(new CakeLayerInfo("layer2", 2000)); layers.add(new CakeLayerInfo("layer3", 3000)); final List<CakeInfo> cakes = new ArrayList<>(); final CakeInfo cake = new CakeInfo(new CakeToppingInfo("topping", 1000), layers); cakes.add(cake); final CakeBakingService bakingService = mock(CakeBakingService.class); when(bakingService.getAllCakes()).thenReturn(cakes); final CakeViewImpl cakeView = new CakeViewImpl(bakingService); assertEquals(0, appender.getLogSize()); cakeView.render(); assertEquals(cake.toString(), appender.getLastMessage()); }