### Question:
ClearanceService { public void cleanDatabase() { Calendar cal = GregorianCalendar.getInstance(Locale.GERMANY); cal.set(Calendar.DATE, cal.get(Calendar.DATE) - (30 * monthsBeforeDeletion)); System.out.println("************************************************"); System.out.println("\t Clearance-Prozess gestartet um " + GregorianCalendar.getInstance(Locale.GERMANY).getTime()); Iterable<Profile> unusedProfiles = profileRepository.findAllByLastProfileContactBefore(cal.getTime()); System.out.println("\t Anzahl geloeschter Profile: " + unusedProfiles.spliterator().getExactSizeIfKnown()); profileRepository.delete(unusedProfiles); try { RestTemplate restTemplate = new RestTemplate(); String url = adress + ":" + port + "/" + databaseName + "/" + "_compact"; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<String>("", headers); restTemplate.exchange(url, HttpMethod.POST, entity, String.class); System.out.println("\t Compact-Befehl durchgeführt: true"); } catch (Exception e) { System.out.println("\t Compact-Befehl durchgeführt: false"); e.printStackTrace(); } System.out.println("\t Clearance-Prozess beendet um " + GregorianCalendar.getInstance(Locale.GERMANY).getTime()); System.out.println("************************************************"); } ClearanceService(); void cleanDatabase();  }### Answer:
@Test public void testCleanDatabase() { assertThat(profileRepository.count()).isEqualTo(this.outdatedProfiles.length + this.upToDateProfiles.length); clearanceService.cleanDatabase(); assertThat(profileRepository.count()).isEqualTo(this.upToDateProfiles.length); Iterable<Profile> listUpToDateProfilesInDB = profileRepository.findAll(); assertThat(listUpToDateProfilesInDB.toString()).isEqualTo(Arrays.asList(this.upToDateProfiles).toString()); String[] outdatedProfilesIds = new String[outdatedProfiles.length]; for (int i = 0; i < outdatedProfiles.length; ++i) { outdatedProfilesIds[i] = outdatedProfiles[i].get_id(); } Iterable<Profile> listOutdatedProfilesInDB = profileRepository.findAll(Arrays.asList(outdatedProfilesIds)); assertThat(listOutdatedProfilesInDB).isNullOrEmpty(); }