Search in sources :

Example 1 with HousekeepingBuilder

use of uk.ac.ebi.spot.goci.builder.HousekeepingBuilder 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();
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) HousekeepingBuilder(uk.ac.ebi.spot.goci.builder.HousekeepingBuilder) StudyBuilder(uk.ac.ebi.spot.goci.builder.StudyBuilder) Before(org.junit.Before)

Example 2 with HousekeepingBuilder

use of uk.ac.ebi.spot.goci.builder.HousekeepingBuilder 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();
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Study(uk.ac.ebi.spot.goci.model.Study) HousekeepingBuilder(uk.ac.ebi.spot.goci.builder.HousekeepingBuilder) StudyBuilder(uk.ac.ebi.spot.goci.builder.StudyBuilder) UnpublishReason(uk.ac.ebi.spot.goci.model.UnpublishReason) Test(org.junit.Test)

Aggregations

HousekeepingBuilder (uk.ac.ebi.spot.goci.builder.HousekeepingBuilder)2 StudyBuilder (uk.ac.ebi.spot.goci.builder.StudyBuilder)2 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)2 Before (org.junit.Before)1 Test (org.junit.Test)1 Study (uk.ac.ebi.spot.goci.model.Study)1 UnpublishReason (uk.ac.ebi.spot.goci.model.UnpublishReason)1