### Question:
JooqFightDAO extends AbstractJooqDAO implements FightDAO { @Override public Optional<FightWithPlanetAndPlayer> findWithId(UUID id) { Preconditions.checkNotNull(id, "id"); LOGGER.debug("Finding fight with id {}", id); FightRecord record = context().selectFrom(FIGHT).where(FIGHT.ID.eq(id)).fetchOne(); if (record == null) { return Optional.empty(); } Map<UUID, Result<Record>> result = selectFromFights() .where(FIGHT.ID.eq(id)) .fetchGroups(FIGHT.ID); List<FightWithPlanetAndPlayer> fight = readFights(result); assert !fight.isEmpty(); return Optional.of(fight.get(0)); } @Inject  JooqFightDAO(UnitOfWorkService unitOfWorkService); @Override Optional<FightWithPlanetAndPlayer> findWithId(UUID id); @Override void insert(Fight fight); @Override List<FightWithPlanetAndPlayer> findFightsWithPlayerSinceRound(UUID playerId, long round); static final Player ATTACKER_ALIAS; static final Player DEFENDER_ALIAS; }### Answer:
@Test public void testFindWithId() throws Exception { Fight expected = FightScenario.Player1.FIGHT; Optional<FightWithPlanetAndPlayer> fight = sut.findWithId(expected.getId()); assertThat(fight.isPresent(), is(true)); assertThat(fight.get(), is(new FightWithPlanetAndPlayer(expected, BasicScenario.Player2.Planet1.PLANET, BasicScenario.Player1.PLAYER, BasicScenario.Player2.PLAYER))); }
@Test public void testFindWithId2() throws Exception { Optional<FightWithPlanetAndPlayer> fight = sut.findWithId(UUID.randomUUID()); assertThat(fight.isPresent(), is(false)); }