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