Search in sources :

Example 1 with StudyRepository

use of uk.ac.ebi.spot.goci.repository.StudyRepository in project goci by EBISPOT.

the class HousekeepingOperationsServiceTest method createHousekeeping.

@Test
public void createHousekeeping() throws Exception {
    // Stubbing
    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);
    // Assertions
    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();
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) CurationStatusRepository(uk.ac.ebi.spot.goci.repository.CurationStatusRepository) CuratorBuilder(uk.ac.ebi.spot.goci.builder.CuratorBuilder) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) CuratorRepository(uk.ac.ebi.spot.goci.repository.CuratorRepository) Mockito.verify(org.mockito.Mockito.verify) Mockito.verifyZeroInteractions(org.mockito.Mockito.verifyZeroInteractions) HousekeepingRepository(uk.ac.ebi.spot.goci.repository.HousekeepingRepository) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) CurationStatusBuilder(uk.ac.ebi.spot.goci.builder.CurationStatusBuilder) CurationStatus(uk.ac.ebi.spot.goci.model.CurationStatus) Study(uk.ac.ebi.spot.goci.model.Study) StudyRepository(uk.ac.ebi.spot.goci.repository.StudyRepository) StudyBuilder(uk.ac.ebi.spot.goci.builder.StudyBuilder) HousekeepingBuilder(uk.ac.ebi.spot.goci.builder.HousekeepingBuilder) Curator(uk.ac.ebi.spot.goci.model.Curator) Before(org.junit.Before) Test(org.junit.Test)

Aggregations

Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 Matchers (org.mockito.Matchers)1 Mock (org.mockito.Mock)1 Mockito.times (org.mockito.Mockito.times)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.verifyZeroInteractions (org.mockito.Mockito.verifyZeroInteractions)1 Mockito.when (org.mockito.Mockito.when)1 MockitoJUnitRunner (org.mockito.runners.MockitoJUnitRunner)1 CurationStatusBuilder (uk.ac.ebi.spot.goci.builder.CurationStatusBuilder)1 CuratorBuilder (uk.ac.ebi.spot.goci.builder.CuratorBuilder)1 HousekeepingBuilder (uk.ac.ebi.spot.goci.builder.HousekeepingBuilder)1 StudyBuilder (uk.ac.ebi.spot.goci.builder.StudyBuilder)1 CurationStatus (uk.ac.ebi.spot.goci.model.CurationStatus)1 Curator (uk.ac.ebi.spot.goci.model.Curator)1 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)1 Study (uk.ac.ebi.spot.goci.model.Study)1 CurationStatusRepository (uk.ac.ebi.spot.goci.repository.CurationStatusRepository)1