### Question:
AdvancedWizard implements Wizard { @Override public void smoke() { tobacco.smoke(this); } AdvancedWizard(Tobacco tobacco); @Override void smoke();  }### Answer:
@Test public void testSmokeEveryThing() throws Exception { List<Tobacco> tobaccos = List.of( new OldTobyTobacco(), new RivendellTobacco(), new SecondBreakfastTobacco() ); tobaccos.forEach(tobacco -> { final AdvancedWizard advancedWizard = new AdvancedWizard(tobacco); advancedWizard.smoke(); String lastMessage = appender.getLastMessage(); assertEquals("AdvancedWizard smoking " + tobacco.getClass().getSimpleName(), lastMessage); }); assertEquals(tobaccos.size(), appender.getLogSize()); }
@Test public void testSmokeEveryThing() throws Exception { final Tobacco[] tobaccos = { new OldTobyTobacco(), new RivendellTobacco(), new SecondBreakfastTobacco() }; for (final Tobacco tobacco : tobaccos) { final AdvancedWizard advancedWizard = new AdvancedWizard(tobacco); advancedWizard.smoke(); assertEquals("AdvancedWizard smoking " + tobacco.getClass().getSimpleName(), appender.getLastMessage()); } assertEquals(tobaccos.length, appender.getLogSize()); }
@Test public void testSmokeEveryThing() throws Exception { final Tobacco[] tobaccos = { new OldTobyTobacco(), new RivendellTobacco(), new SecondBreakfastTobacco() }; for (final Tobacco tobacco : tobaccos) { final AdvancedWizard advancedWizard = new AdvancedWizard(tobacco); advancedWizard.smoke(); verify(getStdOutMock(), times(1)).println("AdvancedWizard smoking " + tobacco.getClass().getSimpleName()); verifyNoMoreInteractions(getStdOutMock()); } }