@Test public void testEnter() throws Exception { final Wizard[] wizards = new Wizard[]{ new Wizard("Gandalf"), new Wizard("Dumbledore"), new Wizard("Oz"), new Wizard("Merlin") }; final WizardTowerProxy proxy = new WizardTowerProxy(new IvoryTower()); for (Wizard wizard : wizards) { proxy.enter(wizard); } assertTrue(appender.logContains("Gandalf enters the tower.")); assertTrue(appender.logContains("Dumbledore enters the tower.")); assertTrue(appender.logContains("Oz enters the tower.")); assertTrue(appender.logContains("Merlin is not allowed to enter!")); assertEquals(4, appender.getLogSize()); }
@Override public void enter(Wizard wizard) { if (numWizards < NUM_WIZARDS_ALLOWED) { tower.enter(wizard); numWizards++; } else { LOGGER.info("{} is not allowed to enter!", wizard); } }
WizardTowerProxy implements WizardTower { @Override public void enter(Wizard wizard) { if (numWizards < NUM_WIZARDS_ALLOWED) { tower.enter(wizard); numWizards++; } else { LOGGER.info("{} is not allowed to enter!", wizard); } } }
WizardTowerProxy implements WizardTower { @Override public void enter(Wizard wizard) { if (numWizards < NUM_WIZARDS_ALLOWED) { tower.enter(wizard); numWizards++; } else { LOGGER.info("{} is not allowed to enter!", wizard); } } WizardTowerProxy(WizardTower tower); }
WizardTowerProxy implements WizardTower { @Override public void enter(Wizard wizard) { if (numWizards < NUM_WIZARDS_ALLOWED) { tower.enter(wizard); numWizards++; } else { LOGGER.info("{} is not allowed to enter!", wizard); } } WizardTowerProxy(WizardTower tower); @Override void enter(Wizard wizard); }
WizardTowerProxy implements WizardTower { @Override public void enter(Wizard wizard) { if (numWizards < NUM_WIZARDS_ALLOWED) { tower.enter(wizard); numWizards++; } else { LOGGER.info("{} is not allowed to enter!", wizard); } } WizardTowerProxy(WizardTower tower); @Override void enter(Wizard wizard);  }