MalariaDataReportViewModelToMalariaProgramMapper { public MalariaProgram map(MalariaDataReportViewModel malariaDataReportViewModel, MalariaProgram malariaProgram) throws LMISException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (malariaProgram == null) { return generateMalariaProgramFromScratch(malariaDataReportViewModel); } return generateMalariaProgramFrom(malariaDataReportViewModel, malariaProgram); }  MalariaProgram map(MalariaDataReportViewModel malariaDataReportViewModel, MalariaProgram malariaProgram);  }
@Test public void shouldMapUsername() throws Exception { mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getUsername(), is(user.getUsername())); }
@Test public void shouldMapReportedDate() throws Exception { mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getReportedDate(), is(now())); }
@Test public void shouldMapPeriodStartDate() throws Exception { mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getStartPeriodDate(), is(malariaDataReportViewModel.getStartPeriodDate())); }
@Test public void shouldMapPeriodEndDate() throws Exception { mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getEndPeriodDate(), is(malariaDataReportViewModel.getEndPeriodDate())); }
@Test public void shouldMapImplementations() throws Exception { mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getImplementations(), is(expectedImplementations)); }
@Test public void shouldMapUsernameWhenMalariaIsNotDefined() throws Exception { malariaProgram = null; malariaProgram = mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getUsername(), is(user.getUsername())); }
@Test public void shouldMapReportedDateWhenMalariaIsNotDefined() throws Exception { malariaProgram = null; malariaProgram = mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getReportedDate(), is(now())); }
@Test public void shouldMapPeriodStartDateWhenMalariaIsNotDefined() throws Exception { malariaProgram = null; malariaProgram = mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getStartPeriodDate(), is(malariaDataReportViewModel.getStartPeriodDate())); }
@Test public void shouldMapPeriodEndDateWhenMalariaIsNotDefined() throws Exception { malariaProgram = null; malariaProgram = mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getEndPeriodDate(), is(malariaDataReportViewModel.getEndPeriodDate())); }
@Test public void shouldMapImplementationsWhenMalariaIsNotDefined() throws Exception { malariaProgram = null; when(implementationReportsMapper.map(mockedUsImplementations, mockedApeImplementations)).thenReturn(expectedImplementations); malariaProgram = mapper.map(malariaDataReportViewModel, malariaProgram); assertThat(malariaProgram.getImplementations(), is(expectedImplementations)); }