### Question:
BuildingServiceImpl implements BuildingService { @Override public void finishConstructionSites() { long round = roundService.getCurrentRound(); List<ConstructionSite> finishedConstructionSites = constructionSiteDAO.findWithDone(round); for (ConstructionSite constructionSite : finishedConstructionSites) { LOGGER.debug("Found finished construction site {}", constructionSite); if (constructionSite.getLevel() == 1) { UUID id = uuidFactory.create(); Building building = new Building(id, constructionSite.getType(), constructionSite.getLevel(), constructionSite.getPlanetId()); LOGGER.debug("Construction new building {}", building); buildingDAO.insert(building); } else { Building existingBuilding = buildingDAO.findWithPlanetIdAndType(constructionSite.getPlanetId(), constructionSite.getType()).orElseThrow(AssertionError::new); Building updatedBuilding = existingBuilding.withLevel(constructionSite.getLevel()); LOGGER.debug("Updating building {}", updatedBuilding); buildingDAO.update(updatedBuilding); } eventService.createBuildingCompletedEvent(constructionSite.getPlayerId(), constructionSite.getPlanetId()); constructionSiteDAO.delete(constructionSite); } } @Inject  BuildingServiceImpl(UUIDFactory uuidFactory, BuildingDAO buildingDAO, RoundService roundService, ConstructionSiteDAO constructionSiteDAO, PlanetDAO planetDAO, EventService eventService, TechnologyDAO technologyDAO, BuildingMechanics buildingMechanics, TechnologyMechanics technologyMechanics); @Override Buildings findBuildingsOnPlanet(Planet planet); @Override List<ConstructionSite> findConstructionSitesOnPlanet(Planet planet); @Override void manifestBuilding(Planet planet, BuildingType type, int level); @Override ConstructionSite constructBuilding(Planet planet, BuildingType type); @Override ConstructionSite upgradeBuilding(Planet planet, BuildingType type); @Override ConstructionSite constructOrUpgradeBuilding(Planet planet, BuildingType type); @Override Resources calculateBuildCostWithoutBonuses(BuildingType type, int level); @Override void finishConstructionSites(); @Override long calculateBuildTime(BuildingType type, int level, Technologies technologies, Buildings buildings); @Override long calculateBuildTimeWithoutBonuses(BuildingType type, int level); @Override Resources calculateBuildCost(BuildingType type, int level, Technologies technologies);  }### Answer:
@Test(description = "Constructs a new shipyard") public void testFinishConstructionSites() throws Exception { UUID id = UUID.randomUUID(); when(uuidFactory.create()).thenReturn(id); when(constructionSiteDAO.findWithDone(1)).thenReturn(Arrays.asList(Data.Player1.Planet1.CONSTRUCTION_SITE)); sut.finishConstructionSites(); Building expected = new Building(id, BuildingType.SHIPYARD, 1, Data.Player1.Planet1.PLANET.getId()); verify(buildingDAO).insert(expected); }
@Test(description = "Upgrades the command center") public void testFinishConstructionSites2() throws Exception { UUID id = UUID.randomUUID(); when(uuidFactory.create()).thenReturn(id); ConstructionSite constructionSite = new ConstructionSite(UUID.randomUUID(), BuildingType.COMMAND_CENTER, 2, Data.Player1.Planet1.PLANET.getId(), Data.Player1.PLAYER.getId(), 1, 1, new Resources(1, 2, 3)); when(constructionSiteDAO.findWithDone(1)).thenReturn(Arrays.asList(constructionSite)); sut.finishConstructionSites(); Building expected = Data.Player1.Planet1.COMMAND_CENTER.withLevel(2); verify(buildingDAO).update(expected); }