use of uk.ac.ebi.spot.goci.builder.StudyBuilder in project goci by EBISPOT.
the class StudyOperationServiceTest method setUpMock.
@Before
public void setUpMock() {
studyOperationsService = new StudyOperationsService(associationRepository, mailService, housekeepingRepository, publishStudyCheckService, studyRepository, curatorRepository, curationStatusRepository, trackingOperationService, eventTypeService, housekeepingOperationsService, studyNoteService, studyNoteOperationsService, curatorService);
// Create these objects before each test
Housekeeping CURRENT_HOUSEKEEPING = new HousekeepingBuilder().setId(799L).setCurationStatus(AWAITING_CURATION).setCurator(UNASSIGNED).build();
STU1 = new StudyBuilder().setId(802L).setHousekeeping(CURRENT_HOUSEKEEPING).build();
}
use of uk.ac.ebi.spot.goci.builder.StudyBuilder in project goci by EBISPOT.
the class StudyOperationServiceTest method testUnpublishStudy.
@Test
public void testUnpublishStudy() {
// Create clones of our study/housekeeping before the method runs
Housekeeping housekeepingBeforeUnpublish = new HousekeepingBuilder().setId(799L).setCurationStatus(AWAITING_CURATION).setCurator(UNASSIGNED).build();
Study beforeUnPublish = new StudyBuilder().setId(802L).setHousekeeping(housekeepingBeforeUnpublish).build();
// Stubbing
when(studyRepository.findOne(STU1.getId())).thenReturn(STU1);
when(housekeepingRepository.findOne(STU1.getHousekeeping().getId())).thenReturn(STU1.getHousekeeping());
when(curationStatusRepository.findByStatus("Unpublished from catalog")).thenReturn(UNPUBLISH);
when(eventTypeService.determineEventTypeFromStatus(UNPUBLISH)).thenReturn("STUDY_STATUS_CHANGE_UNPUBLISHED_FROM_CATALOG");
studyOperationsService.unpublishStudy(STU1.getId(), Matchers.any(UnpublishReason.class), SECURE_USER);
verify(studyRepository, times(1)).findOne(STU1.getId());
verify(housekeepingRepository, times(1)).findOne(STU1.getHousekeeping().getId());
verify(curationStatusRepository, times(1)).findByStatus("Unpublished from catalog");
verify(eventTypeService, times(1)).determineEventTypeFromStatus(STU1.getHousekeeping().getCurationStatus());
verify(trackingOperationService, times(1)).update(STU1, SECURE_USER, "STUDY_STATUS_CHANGE_UNPUBLISHED_FROM_CATALOG");
verify(studyRepository, times(1)).save(STU1);
verifyZeroInteractions(mailService);
verifyZeroInteractions(publishStudyCheckService);
verifyZeroInteractions(associationRepository);
// Check housekeeping was saved
assertThat(STU1).isEqualToIgnoringGivenFields(beforeUnPublish, "housekeeping");
assertThat(STU1.getHousekeeping()).isEqualToIgnoringGivenFields(housekeepingBeforeUnpublish, "catalogUnpublishDate", "lastUpdateDate", "curationStatus");
assertThat(STU1.getHousekeeping().getCurationStatus()).extracting("status").contains("Unpublished from catalog");
assertThat(STU1.getHousekeeping().getCatalogUnpublishDate()).isToday();
}
Aggregations