@Test public void createHousekeeping() throws Exception { when(curationStatusRepository.findByStatus("Awaiting Curation")).thenReturn(AWAITING_CURATION); when(curatorRepository.findByLastName("Level 1 Curator")).thenReturn(LEVEL_1_CURATOR); Housekeeping housekeeping = housekeepingOperationsService.createHousekeeping(); verify(curationStatusRepository, times(1)).findByStatus("Awaiting Curation"); verify(curatorRepository, times(1)).findByLastName("Level 1 Curator"); verify(housekeepingRepository, times(1)).save(Matchers.any(Housekeeping.class)); verifyZeroInteractions(studyRepository); assertThat(housekeeping).extracting(curator -> curator.getCurator().getLastName()).contains("Level 1 Curator"); assertThat(housekeeping).extracting(curationStatus -> curationStatus.getCurationStatus().getStatus()).contains("Awaiting Curation"); assertThat(housekeeping.getStudyAddedDate()).isToday(); }
public Housekeeping createHousekeeping() { Housekeeping housekeeping = new Housekeeping(); java.util.Date studyAddedDate = new java.util.Date(); housekeeping.setStudyAddedDate(studyAddedDate); CurationStatus status = curationStatusRepository.findByStatus("Awaiting Curation"); housekeeping.setCurationStatus(status); Curator curator = curatorRepository.findByLastName("Level 1 Curator"); housekeeping.setCurator(curator); housekeepingRepository.save(housekeeping); return housekeeping; }
HousekeepingOperationsService { public Housekeeping createHousekeeping() { Housekeeping housekeeping = new Housekeeping(); java.util.Date studyAddedDate = new java.util.Date(); housekeeping.setStudyAddedDate(studyAddedDate); CurationStatus status = curationStatusRepository.findByStatus("Awaiting Curation"); housekeeping.setCurationStatus(status); Curator curator = curatorRepository.findByLastName("Level 1 Curator"); housekeeping.setCurator(curator); housekeepingRepository.save(housekeeping); return housekeeping; } }
HousekeepingOperationsService { public Housekeeping createHousekeeping() { Housekeeping housekeeping = new Housekeeping(); java.util.Date studyAddedDate = new java.util.Date(); housekeeping.setStudyAddedDate(studyAddedDate); CurationStatus status = curationStatusRepository.findByStatus("Awaiting Curation"); housekeeping.setCurationStatus(status); Curator curator = curatorRepository.findByLastName("Level 1 Curator"); housekeeping.setCurator(curator); housekeepingRepository.save(housekeeping); return housekeeping; } @Autowired  HousekeepingOperationsService(HousekeepingRepository housekeepingRepository,
                                         CuratorRepository curatorRepository,
                                         CurationStatusRepository curationStatusRepository,
                                         StudyRepository studyRepository); }
HousekeepingOperationsService { public Housekeeping createHousekeeping() { Housekeeping housekeeping = new Housekeeping(); java.util.Date studyAddedDate = new java.util.Date(); housekeeping.setStudyAddedDate(studyAddedDate); CurationStatus status = curationStatusRepository.findByStatus("Awaiting Curation"); housekeeping.setCurationStatus(status); Curator curator = curatorRepository.findByLastName("Level 1 Curator"); housekeeping.setCurator(curator); housekeepingRepository.save(housekeeping); return housekeeping; } @Autowired  HousekeepingOperationsService(HousekeepingRepository housekeepingRepository,
                                         CuratorRepository curatorRepository,
                                         CurationStatusRepository curationStatusRepository,
                                         StudyRepository studyRepository); Housekeeping createHousekeeping(); void saveHousekeeping(Study study, Housekeeping housekeeping); }
HousekeepingOperationsService { public Housekeeping createHousekeeping() { Housekeeping housekeeping = new Housekeeping(); java.util.Date studyAddedDate = new java.util.Date(); housekeeping.setStudyAddedDate(studyAddedDate); CurationStatus status = curationStatusRepository.findByStatus("Awaiting Curation"); housekeeping.setCurationStatus(status); Curator curator = curatorRepository.findByLastName("Level 1 Curator"); housekeeping.setCurator(curator); housekeepingRepository.save(housekeeping); return housekeeping; } @Autowired  HousekeepingOperationsService(HousekeepingRepository housekeepingRepository,
                                         CuratorRepository curatorRepository,
                                         CurationStatusRepository curationStatusRepository,
                                         StudyRepository studyRepository); Housekeeping createHousekeeping(); void saveHousekeeping(Study study, Housekeeping housekeeping);  }