예제 #1
0
 @Test
 public void save_shouldSaveFormDataWithStatus()
     throws Exception, FormController.FormDataSaveException {
   store.save("data", "xmldata", "status");
   verify(controller).saveFormData(formData);
   verify(activity).finish();
   assertThat(formData.getJsonPayload(), is("data"));
   assertThat(formData.getStatus(), is("status"));
 }
예제 #2
0
 @Test
 public void shouldCreateANewPatientAndStoreHisUUIDAsPatientUUID() throws Exception {
   String tempUUIDAssignedByDevice = "newUUID";
   formData.setPatientUuid(null);
   formData.setDiscriminator(FORM_DISCRIMINATOR_REGISTRATION);
   Patient patient = new Patient();
   patient.setUuid(tempUUIDAssignedByDevice);
   when(controller.createNewPatient("data")).thenReturn(patient);
   store.save("data", "xmlData", "complete");
   assertThat(formData.getXmlPayload(), is("xmlData"));
   assertThat(formData.getPatientUuid(), is(tempUUIDAssignedByDevice));
 }
예제 #3
0
  @Test
  public void shouldParseObservationsInProvidedPayloadWhenSavingAsFinal()
      throws ConceptController.ConceptSaveException, ParseException, XmlPullParserException,
          PatientController.PatientLoadException, ConceptController.ConceptFetchException,
          ConceptController.ConceptParseException, IOException,
          ObservationController.ParseObservationException {
    String xmlPayload = "xmldata";
    store.save("data", xmlPayload, Constants.STATUS_COMPLETE);

    verify(formParser).parseAndSaveObservations(xmlPayload, formData.getUuid());
  }
예제 #4
0
 @Before
 public void setUp() throws Exception {
   initMocks(this);
   controller = mock(FormController.class);
   activity = mock(FormWebViewActivity.class);
   formData = new FormData();
   formData.setPatientUuid("adasdssd");
   muzimaApplication = mock(MuzimaApplication.class);
   obsController = mock(ObservationController.class);
   when(muzimaApplication.getObservationController()).thenReturn(obsController);
   when(activity.getApplicationContext()).thenReturn(muzimaApplication);
   store =
       new FormDataStore(activity, controller, formData) {
         @Override
         public FormParser getFormParser() {
           return formParser;
         }
       };
 }
예제 #5
0
 @Test
 public void getFormPayload_shouldGetTheFormDataPayload() throws Exception {
   formData.setJsonPayload("payload");
   assertThat(store.getFormPayload(), is("payload"));
 }