Preserve line numbers in XML validation (#1567)
* Preserve line numbers in XML validation * Test fixes
This commit is contained in:
parent
3dfb6959c1
commit
84803a02ef
|
@ -4080,22 +4080,16 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
Patient patient = new Patient();
|
||||
patient.addName().addGiven("James");
|
||||
patient.setBirthDateElement(new DateType("2011-02-02"));
|
||||
patient.addContact().setGender(AdministrativeGender.MALE);
|
||||
|
||||
String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(patient);
|
||||
HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate");
|
||||
post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
CloseableHttpResponse response = ourHttpClient.execute(post);
|
||||
try {
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(post)) {
|
||||
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(resp);
|
||||
assertEquals(412, response.getStatusLine().getStatusCode());
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
assertThat(resp, not(containsString("Resource has no id")));
|
||||
assertThat(resp, containsString("<issue><severity value=\"error\"/><code value=\"processing\"/><diagnostics value=\"SHALL at least contain a contact's details or a reference to an organization [name.exists() or telecom.exists() or address.exists() or organization.exists()]\"/><location value=\"Patient.contact[0]\"/><location value=\"Line 0, Col 0\"/></issue>"));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5308,7 +5308,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
Patient patient = new Patient();
|
||||
patient.addName().addGiven("James");
|
||||
patient.setBirthDateElement(new DateType("2011-02-02"));
|
||||
patient.addContact().setGender(AdministrativeGender.MALE);
|
||||
|
||||
String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(patient);
|
||||
HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate");
|
||||
|
@ -5317,9 +5316,8 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
try (CloseableHttpResponse response = ourHttpClient.execute(post)) {
|
||||
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(resp);
|
||||
assertEquals(412, response.getStatusLine().getStatusCode());
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
assertThat(resp, not(containsString("Resource has no id")));
|
||||
assertThat(resp, containsString("<issue><severity value=\"error\"/><code value=\"processing\"/><diagnostics value=\"SHALL at least contain a contact's details or a reference to an organization [name.exists() or telecom.exists() or address.exists() or organization.exists()]\"/><location value=\"Patient.contact[0]\"/><location value=\"Line 0, Col 0\"/></issue>"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,11 @@ public class ValidatorWrapper {
|
|||
profileSet.getCanonical().add(new ValidationProfileSet.ProfileRegistration(nextProfile, true));
|
||||
}
|
||||
|
||||
v.validate(null, messages, document, profileSet);
|
||||
String resourceAsString = theValidationContext.getResourceAsString();
|
||||
InputStream inputStream = new ReaderInputStream(new StringReader(resourceAsString), Charsets.UTF_8);
|
||||
|
||||
Manager.FhirFormat format = Manager.FhirFormat.XML;
|
||||
v.validate(null, messages, inputStream, format, profileSet);
|
||||
|
||||
} else if (encoding == EncodingEnum.JSON) {
|
||||
|
||||
|
|
|
@ -799,6 +799,8 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
|||
ourLog.info(output.getMessages().get(0).getMessage());
|
||||
assertEquals("/f:Patient", output.getMessages().get(0).getLocationString());
|
||||
assertEquals("Undefined element 'foo'", output.getMessages().get(0).getMessage());
|
||||
assertEquals(28, output.getMessages().get(0).getLocationCol().intValue());
|
||||
assertEquals(4, output.getMessages().get(0).getLocationLine().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -262,6 +262,16 @@
|
|||
<td style="background: #CEC;">4.0.0</td>
|
||||
<td style="background: #EEB;">4.1.0-e0e3caf9ba</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HAPI FHIR 4.1.0</td>
|
||||
<td>JDK8</td>
|
||||
<td style="background: #DDD;"></td>
|
||||
<td style="background: #CEC;">1.0.2</td>
|
||||
<td style="background: #EEB;">1.4.0</td>
|
||||
<td style="background: #CEC;">3.0.1</td>
|
||||
<td style="background: #CEC;">4.0.0</td>
|
||||
<td style="background: #EEB;">4.1.0-1a7623d866</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue