Fix test regression
This commit is contained in:
parent
d63e289cbe
commit
74feb38085
|
@ -43,14 +43,16 @@ public class ValidateDstu3Test {
|
|||
private static CloseableHttpClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||
private static EncodingEnum ourLastEncoding;
|
||||
private static IdType ourLastId;
|
||||
private static ValidationModeEnum ourLastMode;
|
||||
public static Patient ourLastPatient;
|
||||
private static String ourLastProfile;
|
||||
private static String ourLastResourceBody;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidateDstu3Test.class);
|
||||
private static OperationOutcome ourOutcomeToReturn;
|
||||
private static int ourPort;
|
||||
|
||||
private static Server ourServer;
|
||||
public static Patient ourLastPatient;
|
||||
private static IdType ourLastId;
|
||||
|
||||
@Before()
|
||||
public void before() {
|
||||
|
@ -83,6 +85,27 @@ public class ValidateDstu3Test {
|
|||
assertThat(resp, stringContainsInOrder("<OperationOutcome"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateBlankMode() throws Exception {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setValue("001");
|
||||
patient.addIdentifier().setValue("002");
|
||||
|
||||
Parameters params = new Parameters();
|
||||
params.addParameter().setName("resource").setResource(patient);
|
||||
params.addParameter().setName("mode").setValue(new CodeType(" "));
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$validate");
|
||||
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
String resp = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateInvalidMode() throws Exception {
|
||||
|
||||
|
@ -106,27 +129,6 @@ public class ValidateDstu3Test {
|
|||
assertThat(resp, stringContainsInOrder("Invalid mode value: "AAA""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateBlankMode() throws Exception {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setValue("001");
|
||||
patient.addIdentifier().setValue("002");
|
||||
|
||||
Parameters params = new Parameters();
|
||||
params.addParameter().setName("resource").setResource(patient);
|
||||
params.addParameter().setName("mode").setValue(new CodeType(" "));
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$validate");
|
||||
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
String resp = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateMissingResource() throws Exception {
|
||||
|
||||
|
@ -148,6 +150,25 @@ public class ValidateDstu3Test {
|
|||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateWithGet() throws Exception {
|
||||
ourOutcomeToReturn = new OperationOutcome();
|
||||
ourOutcomeToReturn.addIssue().setDiagnostics("FOOBAR");
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/$validate");
|
||||
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String resp = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
assertThat(resp, stringContainsInOrder("<OperationOutcome", "FOOBAR"));
|
||||
assertEquals(null, ourLastPatient);
|
||||
assertEquals("Patient", ourLastId.getResourceType());
|
||||
assertEquals("123", ourLastId.getIdPart());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateWithNoParsed() throws Exception {
|
||||
|
||||
|
@ -186,6 +207,7 @@ public class ValidateDstu3Test {
|
|||
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
String resp = IOUtils.toString(status.getEntity().getContent());
|
||||
ourLog.info(resp);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
@ -220,25 +242,6 @@ public class ValidateDstu3Test {
|
|||
assertThat(resp, stringContainsInOrder("<OperationOutcome", "FOOBAR"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateWithGet() throws Exception {
|
||||
ourOutcomeToReturn = new OperationOutcome();
|
||||
ourOutcomeToReturn.addIssue().setDiagnostics("FOOBAR");
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/$validate");
|
||||
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String resp = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
assertThat(resp, stringContainsInOrder("<OperationOutcome", "FOOBAR"));
|
||||
assertEquals(null, ourLastPatient);
|
||||
assertEquals("Patient", ourLastId.getResourceType());
|
||||
assertEquals("123", ourLastId.getIdPart());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
|
@ -292,7 +295,7 @@ public class ValidateDstu3Test {
|
|||
}
|
||||
|
||||
@Validate()
|
||||
public MethodOutcome validatePatient(@ResourceParam Patient thePatient, @IdParam IdType theId, @Validate.Mode ValidationModeEnum theMode, @Validate.Profile String theProfile) {
|
||||
public MethodOutcome validatePatient(@ResourceParam Patient thePatient, @IdParam(optional=true) IdType theId, @Validate.Mode ValidationModeEnum theMode, @Validate.Profile String theProfile) {
|
||||
|
||||
ourLastPatient = thePatient;
|
||||
ourLastId = theId;
|
||||
|
|
Loading…
Reference in New Issue