### Question:
JooqHangarDAO extends AbstractJooqDAO implements HangarDAO { @Override public Optional<Hangar> findWithPlanetId(UUID planetId) { Preconditions.checkNotNull(planetId, "planetId"); LOGGER.debug("Finding hangar for planet {}", planetId); Result<Record> result = context().select().from(HANGAR).leftOuterJoin(HANGAR_SHIPS).on(HANGAR_SHIPS.HANGAR_ID.eq(HANGAR.ID)).where(HANGAR.PLANET_ID.eq(planetId)).fetch(); if (result.isEmpty()) { return Optional.empty(); } Record firstRecord = result.get(0); UUID id = firstRecord.getValue(HANGAR.ID); UUID playerId = firstRecord.getValue(HANGAR.PLAYER_ID); Map<ShipType, Integer> ships = Maps.newHashMap(); for (Record record : result) { Integer shipType = record.getValue(HANGAR_SHIPS.TYPE); Integer amount = record.getValue(HANGAR_SHIPS.AMOUNT); if (shipType != null && amount != null) { ships.put(ShipType.fromId(shipType), amount); } } return Optional.of(new Hangar(id, planetId, playerId, new Ships(ships))); } @Inject  JooqHangarDAO(UnitOfWorkService unitOfWorkService); @Override Optional<Hangar> findWithPlanetId(UUID planetId); @Override void update(Hangar hangar); @Override void insert(Hangar hangar);  }### Answer:
@Test public void testFindWithPlanetId() throws Exception { Hangar expected = BasicScenario.Player1.Planet1.HANGAR; Optional<Hangar> hangar = sut.findWithPlanetId(expected.getPlanetId()); assertThat(hangar.isPresent(), is(true)); assertThat(hangar.get(), is(expected)); }
@Test public void testFindWithPlanetId2() throws Exception { Optional<Hangar> hangar = sut.findWithPlanetId(UUID.randomUUID()); assertThat(hangar.isPresent(), is(false)); }