@Test public void shouldVerifyAllObservationsAndRelatedEntitiesAreSaved() throws EncounterController.SaveEncounterException, ConceptController.ConceptSaveException, ObservationController.SaveObservationException { htmlFormObservationCreator.createAndPersistObservations(readFile(),formDataUuid); verify(encounterController).saveEncounters(encounterArgumentCaptor.capture()); assertThat(encounterArgumentCaptor.getValue().size(), is(1)); verify(conceptController).saveConcepts(conceptArgumentCaptor.capture()); List<Concept> value = conceptArgumentCaptor.getValue(); assertThat(value.size(), is(33)); verify(observationController).saveObservations(observationArgumentCaptor.capture()); assertThat(observationArgumentCaptor.getValue().size(), is(30)); }
public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } }
HTMLFormObservationCreator { public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } } }
HTMLFormObservationCreator { public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } } HTMLFormObservationCreator(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); }
HTMLFormObservationCreator { public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } } HTMLFormObservationCreator(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); void createAndPersistObservations(String jsonResponse,String formDataUuid); void createObservationsAndRelatedEntities(String jsonResponse,String formDataUuid); List<Observation> getObservations(); Encounter getEncounter(); List<Concept> getNewConceptList(); Date getEncounterDateFromFormDate(String jsonResponse); }
HTMLFormObservationCreator { public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } } HTMLFormObservationCreator(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); void createAndPersistObservations(String jsonResponse,String formDataUuid); void createObservationsAndRelatedEntities(String jsonResponse,String formDataUuid); List<Observation> getObservations(); Encounter getEncounter(); List<Concept> getNewConceptList(); Date getEncounterDateFromFormDate(String jsonResponse);  }