### Question:
ShipUtils { public Hangar getOrCreateHangar(HangarDAO hangarDAO, UUIDFactory uuidFactory, UUID planetId, UUID playerId) { Optional<Hangar> mayBeHangar = hangarDAO.findWithPlanetId(planetId); Hangar hangar = mayBeHangar.orElse(new Hangar(uuidFactory.create(), planetId, playerId, Ships.EMPTY)); if (!mayBeHangar.isPresent()) { hangarDAO.insert(hangar); } return hangar; }  long calculateStorageCapacity(Ships ships, ShipMechanics shipMechanics); double findSpeedOfSlowestShip(Ships ships, ShipMechanics shipMechanics); Hangar getOrCreateHangar(HangarDAO hangarDAO, UUIDFactory uuidFactory, UUID planetId, UUID playerId);  }### Answer:
@Test public void testGetOrCreateHangar() throws Exception { HangarDAO hangarDAO = mock(HangarDAO.class); UUIDFactory uuidFactory = mock(UUIDFactory.class); UUID planetId = UUID.randomUUID(); UUID playerId = UUID.randomUUID(); UUID hangarId = UUID.randomUUID(); when(uuidFactory.create()).thenReturn(hangarId); when(hangarDAO.findWithPlanetId(planetId)).thenReturn(Optional.empty()); Hangar actualHangar = utils.getOrCreateHangar(hangarDAO, uuidFactory, planetId, playerId); assertEquals(actualHangar.getId(), hangarId); assertEquals(actualHangar.getPlanetId(), planetId); assertEquals(actualHangar.getPlayerId(), playerId); assertTrue(actualHangar.getShips().isEmpty()); }