### Question:
UnitPool { UnitInPool createUnit(Tag tag) { Optional<UnitInPool> existing = getUnit(tag); if (existing.isPresent()) { UnitInPool unitInPool = existing.get(); existingPool.put(tag, unitInPool); return unitInPool; } UnitInPool newUnitInPool = new UnitInPool(tag); pool.put(tag, newUnitInPool); existingPool.put(tag, newUnitInPool); return newUnitInPool; }    }### Answer:
@Test void addsUnitToPools() { UnitPool unitPool = new UnitPool(); UnitInPool unitInPool = unitPool.createUnit(TAG); assertThatUnitInPoolIsAddedCorrectly(unitPool, unitInPool); }
@Test void addsUnitToExistingPoolIfIsPresentInPool() { UnitPool unitPool = new UnitPool(); unitPool.createUnit(TAG); UnitInPool unitInPool = unitPool.createUnit(TAG); assertThatUnitInPoolIsAddedCorrectly(unitPool, unitInPool); }