### Question:
CommanderUnit extends Unit { @Override public UnitExtension getUnitExtension(String extensionName) { if (extensionName.equals("CommanderExtension")) { if (unitExtension == null) { unitExtension = new Commander(this); } return unitExtension; } return super.getUnitExtension(extensionName); } CommanderUnit(String name); @Override UnitExtension getUnitExtension(String extensionName);  }### Answer:
@Test public void getUnitExtension() { final Unit unit = new CommanderUnit("CommanderUnitName"); assertNull(unit.getUnitExtension("SoldierExtension")); assertNull(unit.getUnitExtension("SergeantExtension")); assertNotNull(unit.getUnitExtension("CommanderExtension")); }
@Test public void getUnitExtension() throws Exception { final Unit unit = new CommanderUnit("CommanderUnitName"); assertNull(unit.getUnitExtension("SoldierExtension")); assertNull(unit.getUnitExtension("SergeantExtension")); assertNotNull((CommanderExtension) unit.getUnitExtension("CommanderExtension")); }