@Test public void shouldNotParseObservationsForIncompleteForm() throws ConceptController.ConceptSaveException, ParseException, XmlPullParserException, PatientController.PatientLoadException, ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException, IOException { store.save("data", "xmldata", Constants.STATUS_INCOMPLETE); verify(formParser, times(0)).parseAndSaveObservations(anyString(),anyString()); }
@JavascriptInterface public void save(String jsonData, String xmlData, String status) { formData.setXmlPayload(xmlData); formData.setJsonPayload(jsonData); formData.setStatus(status); try { if (isRegistrationComplete(status)) { Patient newPatient = formController.createNewPatient(applicationContext,formData); formData.setPatientUuid(newPatient.getUuid()); formWebViewActivity.startPatientSummaryView(newPatient); } parseForm(xmlData, status); formController.saveFormData(formData); formWebViewActivity.setResult(FormsActivity.RESULT_OK); formWebViewActivity.finish(); } catch (FormController.FormDataSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving form data", e); } catch (ConceptController.ConceptSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving a concept parsed from the form data", e); } catch (ObservationController.ParseObservationException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving an observation parsed from the form data", e); } catch (ConceptController.ConceptParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_concept_parse), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing a concept parsed from the form data", e); } catch (ParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing the xml payload", e); } catch (XmlPullParserException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while exploring the xml payload", e); } catch (PatientController.PatientLoadException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while loading a patient parsed from the form data", e); } catch (ConceptController.ConceptFetchException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while fetching a concept parsed from the form data", e); } catch (IOException e) { Toast.makeText(formWebViewActivity,formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "IOException occurred while saving observations parsed from the form data", e); } }
FormDataStore { @JavascriptInterface public void save(String jsonData, String xmlData, String status) { formData.setXmlPayload(xmlData); formData.setJsonPayload(jsonData); formData.setStatus(status); try { if (isRegistrationComplete(status)) { Patient newPatient = formController.createNewPatient(applicationContext,formData); formData.setPatientUuid(newPatient.getUuid()); formWebViewActivity.startPatientSummaryView(newPatient); } parseForm(xmlData, status); formController.saveFormData(formData); formWebViewActivity.setResult(FormsActivity.RESULT_OK); formWebViewActivity.finish(); } catch (FormController.FormDataSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving form data", e); } catch (ConceptController.ConceptSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving a concept parsed from the form data", e); } catch (ObservationController.ParseObservationException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving an observation parsed from the form data", e); } catch (ConceptController.ConceptParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_concept_parse), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing a concept parsed from the form data", e); } catch (ParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing the xml payload", e); } catch (XmlPullParserException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while exploring the xml payload", e); } catch (PatientController.PatientLoadException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while loading a patient parsed from the form data", e); } catch (ConceptController.ConceptFetchException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while fetching a concept parsed from the form data", e); } catch (IOException e) { Toast.makeText(formWebViewActivity,formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "IOException occurred while saving observations parsed from the form data", e); } } }
FormDataStore { @JavascriptInterface public void save(String jsonData, String xmlData, String status) { formData.setXmlPayload(xmlData); formData.setJsonPayload(jsonData); formData.setStatus(status); try { if (isRegistrationComplete(status)) { Patient newPatient = formController.createNewPatient(applicationContext,formData); formData.setPatientUuid(newPatient.getUuid()); formWebViewActivity.startPatientSummaryView(newPatient); } parseForm(xmlData, status); formController.saveFormData(formData); formWebViewActivity.setResult(FormsActivity.RESULT_OK); formWebViewActivity.finish(); } catch (FormController.FormDataSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving form data", e); } catch (ConceptController.ConceptSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving a concept parsed from the form data", e); } catch (ObservationController.ParseObservationException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving an observation parsed from the form data", e); } catch (ConceptController.ConceptParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_concept_parse), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing a concept parsed from the form data", e); } catch (ParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing the xml payload", e); } catch (XmlPullParserException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while exploring the xml payload", e); } catch (PatientController.PatientLoadException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while loading a patient parsed from the form data", e); } catch (ConceptController.ConceptFetchException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while fetching a concept parsed from the form data", e); } catch (IOException e) { Toast.makeText(formWebViewActivity,formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "IOException occurred while saving observations parsed from the form data", e); } } FormDataStore(FormWebViewActivity formWebViewActivity, FormController formController, FormData formData); }
FormDataStore { @JavascriptInterface public void save(String jsonData, String xmlData, String status) { formData.setXmlPayload(xmlData); formData.setJsonPayload(jsonData); formData.setStatus(status); try { if (isRegistrationComplete(status)) { Patient newPatient = formController.createNewPatient(applicationContext,formData); formData.setPatientUuid(newPatient.getUuid()); formWebViewActivity.startPatientSummaryView(newPatient); } parseForm(xmlData, status); formController.saveFormData(formData); formWebViewActivity.setResult(FormsActivity.RESULT_OK); formWebViewActivity.finish(); } catch (FormController.FormDataSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving form data", e); } catch (ConceptController.ConceptSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving a concept parsed from the form data", e); } catch (ObservationController.ParseObservationException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving an observation parsed from the form data", e); } catch (ConceptController.ConceptParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_concept_parse), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing a concept parsed from the form data", e); } catch (ParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing the xml payload", e); } catch (XmlPullParserException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while exploring the xml payload", e); } catch (PatientController.PatientLoadException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while loading a patient parsed from the form data", e); } catch (ConceptController.ConceptFetchException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while fetching a concept parsed from the form data", e); } catch (IOException e) { Toast.makeText(formWebViewActivity,formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "IOException occurred while saving observations parsed from the form data", e); } } FormDataStore(FormWebViewActivity formWebViewActivity, FormController formController, FormData formData); @JavascriptInterface void save(String jsonData, String xmlData, String status); @JavascriptInterface String getFormPayload(); @JavascriptInterface String getFormStatus(); @JavascriptInterface void showSaveProgressBar(); }
FormDataStore { @JavascriptInterface public void save(String jsonData, String xmlData, String status) { formData.setXmlPayload(xmlData); formData.setJsonPayload(jsonData); formData.setStatus(status); try { if (isRegistrationComplete(status)) { Patient newPatient = formController.createNewPatient(applicationContext,formData); formData.setPatientUuid(newPatient.getUuid()); formWebViewActivity.startPatientSummaryView(newPatient); } parseForm(xmlData, status); formController.saveFormData(formData); formWebViewActivity.setResult(FormsActivity.RESULT_OK); formWebViewActivity.finish(); } catch (FormController.FormDataSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving form data", e); } catch (ConceptController.ConceptSaveException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving a concept parsed from the form data", e); } catch (ObservationController.ParseObservationException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while saving an observation parsed from the form data", e); } catch (ConceptController.ConceptParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_concept_parse), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing a concept parsed from the form data", e); } catch (ParseException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while parsing the xml payload", e); } catch (XmlPullParserException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while exploring the xml payload", e); } catch (PatientController.PatientLoadException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while loading a patient parsed from the form data", e); } catch (ConceptController.ConceptFetchException e) { Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "Exception occurred while fetching a concept parsed from the form data", e); } catch (IOException e) { Toast.makeText(formWebViewActivity,formWebViewActivity.getString(R.string.error_observation_form_save), Toast.LENGTH_SHORT).show(); Log.e(getClass().getSimpleName(), "IOException occurred while saving observations parsed from the form data", e); } } FormDataStore(FormWebViewActivity formWebViewActivity, FormController formController, FormData formData); @JavascriptInterface void save(String jsonData, String xmlData, String status); @JavascriptInterface String getFormPayload(); @JavascriptInterface String getFormStatus(); @JavascriptInterface void showSaveProgressBar();  }