@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"));
 }
 @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));
 }
  @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());
  }
 @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;
         }
       };
 }
 @Test
 public void getFormPayload_shouldGetTheFormDataPayload() throws Exception {
   formData.setJsonPayload("payload");
   assertThat(store.getFormPayload(), is("payload"));
 }