Created
March 25, 2016 01:13
-
-
Save djazayeri/e13403f3694a2ae6a1ab to your computer and use it in GitHub Desktop.
additional test that shows an exception being thrown by controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testErrorInPatientIdentifier() throws Exception { | |
FragmentModel model = new FragmentModel(); | |
Patient patient = new Patient(); | |
String resourcePath = "emr:htmlforms/patientIdentifierTest.xml"; | |
when(resourceFactory.getResourceAsString("emr", "htmlforms/patientIdentifierTest.xml")).thenReturn(PATIENT_IDENTIFIER_TEST_FORM_DEFINITION); | |
FragmentConfiguration config = new FragmentConfiguration(); | |
config.put("patient", patient); | |
config.put("definitionUiResource", resourcePath); | |
controller.controller(config, sessionContext, ui, htmlFormEntryService, adtService, formService, resourceFactory, featureToggles, patient, null, null, null, null, resourcePath, null, null, null, null, true, model, null); | |
// now the form is persisted in the DB | |
FormEntrySession command = (FormEntrySession) model.getAttribute("command"); | |
String html = command.getHtmlToDisplay(); | |
System.out.println(html); | |
HtmlForm hf = htmlFormEntryService.getHtmlFormByForm(formService.getFormByUuid("form-uuid")); | |
MockHttpServletRequest request = new MockHttpServletRequest(); | |
request.addParameter("w1", "invalid-identifier"); | |
request.addParameter("w3", "1"); // value for the hidden widget for identifier type | |
request.addParameter("w4", "2016-03-24"); | |
request.addParameter("w6", "2"); // location = Xanadu | |
request.addParameter("w8", "502"); // provider = Hippocrates | |
SimpleObject result = controller.submit(sessionContext, patient, hf, null, null, null, null, adtService, featureToggles, ui, request); | |
System.out.println(result.toJson()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment