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