IncidentFormServiceImpl implements IncidentFormService { public boolean isReady() { IncidentForm incidentForm = incidentFormDao.getIncidentForm(PrimeroAppConfiguration .MODULE_ID_GBV, PrimeroAppConfiguration.getApiBaseUrl()); return incidentForm != null && incidentForm.getForm() != null; } IncidentFormServiceImpl(IncidentFormDao incidentFormDao); boolean isReady(); @Override IncidentTemplateForm getGBVTemplate(); void saveOrUpdate(IncidentForm incidentForm); @Override List<String> getViolenceTypeList(); @Override List<String> getLocationList(); static final String TAG; static final String SECTION_TYPE_OF_VIOLENCE; static final String SECTION_GBV_INCIDENT; }
@Test public void should_be_true_when_form_is_ready() { IncidentForm incidentForm = new IncidentForm(); incidentForm.setForm(new Blob()); when(incidentFormDao.getIncidentForm(PrimeroAppConfiguration.MODULE_ID_GBV, PrimeroAppConfiguration .getApiBaseUrl())).thenReturn (incidentForm); boolean result = incidentFormService.isReady(); assertThat(result, is(true)); verify(incidentFormDao, times(1)).getIncidentForm(PrimeroAppConfiguration.MODULE_ID_GBV, PrimeroAppConfiguration.getApiBaseUrl()); }
@Test public void should_be_false_when_form_is_not_exist_in_db() { when(incidentFormDao.getIncidentForm(PrimeroAppConfiguration.MODULE_ID_GBV, PrimeroAppConfiguration.getApiBaseUrl())).thenReturn(null); assertThat(incidentFormService.isReady(), is(false)); verify(incidentFormDao, times(1)).getIncidentForm(PrimeroAppConfiguration.MODULE_ID_GBV, PrimeroAppConfiguration.getApiBaseUrl()); }
@Test public void should_be_false_when_incident_form_can_not_get_form() { IncidentForm incidentForm = new IncidentForm(); when(incidentFormDao.getIncidentForm(PrimeroAppConfiguration.MODULE_ID_GBV, PrimeroAppConfiguration.getApiBaseUrl())).thenReturn (incidentForm); assertThat(incidentFormService.isReady(), is(false)); verify(incidentFormDao, times(1)).getIncidentForm(PrimeroAppConfiguration.MODULE_ID_GBV, PrimeroAppConfiguration.getApiBaseUrl()); }