More work on test coverage

This commit is contained in:
jamesagnew 2015-06-21 12:16:33 -04:00
parent 591f16fa9d
commit b48843a128
25 changed files with 94 additions and 41 deletions

View File

@ -111,15 +111,18 @@ public @interface Child {
@CoverageIgnore
public static class NoEnumFactory implements IBaseEnumFactory<Enum<?>> {
@CoverageIgnore
private NoEnumFactory() {
// non instantiable
}
@CoverageIgnore
@Override
public Enum<?> fromCode(String theCodeString) throws IllegalArgumentException {
return null;
}
@CoverageIgnore
@Override
public String toCode(Enum<?> theCode) {
return null;

View File

@ -91,7 +91,8 @@ import ca.uhn.fhir.util.PrettyPrintWriterWrapper;
import ca.uhn.fhir.util.XmlUtil;
/**
* This class is the FHIR XML parser/encoder. Users should not interact with this class directly, but should use {@link FhirContext#newXmlParser()} to get an instance.
* This class is the FHIR XML parser/encoder. Users should not interact with this class directly, but should use
* {@link FhirContext#newXmlParser()} to get an instance.
*/
public class XmlParser extends BaseParser implements IParser {
@ -110,7 +111,8 @@ public class XmlParser extends BaseParser implements IParser {
private boolean myPrettyPrint;
/**
* Do not use this constructor, the recommended way to obtain a new instance of the XML parser is to invoke {@link FhirContext#newXmlParser()}.
* Do not use this constructor, the recommended way to obtain a new instance of the XML parser is to invoke
* {@link FhirContext#newXmlParser()}.
*
* @param theParserErrorHandler
*/
@ -187,13 +189,11 @@ public class XmlParser extends BaseParser implements IParser {
}
for (@SuppressWarnings("unchecked")
Iterator<Attribute> iter = elem.getAttributes(); iter.hasNext();) {
@SuppressWarnings("unchecked")
Iterator<Attribute> attributes = elem.getAttributes();
for (Iterator<Attribute> iter = attributes; iter.hasNext();) {
Attribute next = iter.next();
// if
// (next.getName().getLocalPart().equals("value")) {
parserState.attributeValue(next.getName().getLocalPart(), next.getValue());
// }
}
} else if (nextEvent.isAttribute()) {
@ -446,8 +446,7 @@ public class XmlParser extends BaseParser implements IParser {
theEventWriter.close();
}
private void encodeChildElementToStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, IBase nextValue, String childName, BaseRuntimeElementDefinition<?> childDef,
String theExtensionUrl, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
private void encodeChildElementToStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, IBase nextValue, String childName, BaseRuntimeElementDefinition<?> childDef, String theExtensionUrl, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
if (nextValue == null || nextValue.isEmpty()) {
if (isChildContained(childDef, theIncludedResource)) {
// We still want to go in..
@ -502,9 +501,10 @@ public class XmlParser extends BaseParser implements IParser {
case CONTAINED_RESOURCE_LIST:
case CONTAINED_RESOURCES: {
/*
* Disable per #103 for (IResource next : value.getContainedResources()) { if (getContainedResources().getResourceId(next) != null) { continue; }
* theEventWriter.writeStartElement("contained"); encodeResourceToXmlStreamWriter(next, theEventWriter, true, fixContainedResourceId(next.getId().getValue()));
* theEventWriter.writeEndElement(); }
* Disable per #103 for (IResource next : value.getContainedResources()) { if
* (getContainedResources().getResourceId(next) != null) { continue; }
* theEventWriter.writeStartElement("contained"); encodeResourceToXmlStreamWriter(next, theEventWriter, true,
* fixContainedResourceId(next.getId().getValue())); theEventWriter.writeEndElement(); }
*/
for (IBaseResource next : getContainedResources().getContainedResources()) {
IIdType resourceId = getContainedResources().getResourceId(next);
@ -548,8 +548,7 @@ public class XmlParser extends BaseParser implements IParser {
}
private void encodeCompositeElementChildrenToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, List<? extends BaseRuntimeChildDefinition> children,
boolean theIncludedResource) throws XMLStreamException, DataFormatException {
private void encodeCompositeElementChildrenToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, List<? extends BaseRuntimeChildDefinition> children, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
for (BaseRuntimeChildDefinition nextChild : children) {
if (nextChild.getElementName().equals("extension") || nextChild.getElementName().equals("modifierExtension")) {
continue;
@ -586,7 +585,8 @@ public class XmlParser extends BaseParser implements IParser {
// RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
// String childName = nextChild.getChildNameByDatatype(child.getDatatype());
// BaseRuntimeElementDefinition<?> type = child.getChildByName(childName);
// encodeChildElementToStreamWriter(theResource, theEventWriter, narr2, childName, type, null, theIncludedResource);
// encodeChildElementToStreamWriter(theResource, theEventWriter, narr2, childName, type, null,
// theIncludedResource);
// continue;
// }
}
@ -594,8 +594,7 @@ public class XmlParser extends BaseParser implements IParser {
if (nextChild instanceof RuntimeChildContainedResources) {
if (!theIncludedResource) {
encodeChildElementToStreamWriter(theResource, theEventWriter, null, nextChild.getChildNameByDatatype(null), nextChild.getChildElementDefinitionByDatatype(null), null,
theIncludedResource);
encodeChildElementToStreamWriter(theResource, theEventWriter, null, nextChild.getChildNameByDatatype(null), nextChild.getChildElementDefinitionByDatatype(null), null, theIncludedResource);
}
} else {
@ -641,8 +640,7 @@ public class XmlParser extends BaseParser implements IParser {
}
}
private void encodeCompositeElementToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition<?> theElementDefinition,
boolean theIncludedResource) throws XMLStreamException, DataFormatException {
private void encodeCompositeElementToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition<?> theElementDefinition, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
encodeExtensionsIfPresent(theResource, theEventWriter, theElement, theIncludedResource);
encodeCompositeElementChildrenToStreamWriter(theResource, theElement, theEventWriter, theElementDefinition.getExtensions(), theIncludedResource);
encodeCompositeElementChildrenToStreamWriter(theResource, theElement, theEventWriter, theElementDefinition.getChildren(), theIncludedResource);
@ -665,8 +663,9 @@ public class XmlParser extends BaseParser implements IParser {
}
/**
* This is just to work around the fact that casting java.util.List<ca.uhn.fhir.model.api.ExtensionDt> to java.util.List<? extends org.hl7.fhir.instance.model.api.IBaseExtension<?, ?>> seems to be
* rejected by the compiler some of the time.
* This is just to work around the fact that casting java.util.List<ca.uhn.fhir.model.api.ExtensionDt> to
* java.util.List<? extends org.hl7.fhir.instance.model.api.IBaseExtension<?, ?>> seems to be rejected by the
* compiler some of the time.
*/
private <Q extends IBaseExtension<?, ?>> List<IBaseExtension<?, ?>> toBaseExtensionList(final List<Q> theList) {
List<IBaseExtension<?, ?>> retVal = new ArrayList<IBaseExtension<?, ?>>(theList.size());
@ -691,11 +690,10 @@ public class XmlParser extends BaseParser implements IParser {
}
}
private void encodeResourceToStreamWriterInDstu2Format(RuntimeResourceDefinition theResDef, IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter,
BaseRuntimeElementCompositeDefinition<?> resDef, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
private void encodeResourceToStreamWriterInDstu2Format(RuntimeResourceDefinition theResDef, IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition<?> resDef, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
/*
* DSTU2 requires extensions to come in a specific spot within the encoded content - This is a bit of a messy way to make that happen, but hopefully this won't matter as much once we use the
* HL7 structures
* DSTU2 requires extensions to come in a specific spot within the encoded content - This is a bit of a messy way
* to make that happen, but hopefully this won't matter as much once we use the HL7 structures
*/
List<BaseRuntimeChildDefinition> preExtensionChildren = new ArrayList<BaseRuntimeChildDefinition>();
@ -885,8 +883,7 @@ public class XmlParser extends BaseParser implements IParser {
}
}
private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theWriter, List<? extends IBaseExtension<?, ?>> theExtensions, String tagName, boolean theIncludedResource)
throws XMLStreamException, DataFormatException {
private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theWriter, List<? extends IBaseExtension<?, ?>> theExtensions, String tagName, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
for (IBaseExtension<?, ?> next : theExtensions) {
if (next == null || (ElementUtil.isEmpty(next.getValue()) && next.getExtension().isEmpty())) {
continue;

View File

@ -20,12 +20,14 @@ package ca.uhn.fhir.rest.client.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
/**
* Represents a failure by the HAPI FHIR Client to successfully communicate
* with a FHIR server, because of IO failures, incomprehensible response, etc.
*/
@CoverageIgnore
public class FhirClientConnectionException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;

View File

@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.client.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
/**
@ -27,6 +28,7 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
* communicate with a server which is a valid FHIR server but is incompatible
* with this client for some reason.
*/
@CoverageIgnore
public class FhirClientInappropriateForServerException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;

View File

@ -20,8 +20,10 @@ package ca.uhn.fhir.rest.client.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
@CoverageIgnore
public class InvalidResponseException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;

View File

@ -25,10 +25,13 @@ import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.io.Reader;
import net.sourceforge.cobertura.CoverageIgnore;
import org.apache.commons.io.IOUtils;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
@CoverageIgnore
public class NonFhirResponseException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.rest.server.Constants;
/*
@ -25,6 +26,7 @@ import ca.uhn.fhir.rest.server.Constants;
/**
* Represents an <b>HTTP 401 Client Unauthorized</b> response, which means that the client needs to provide credentials, or has provided invalid credentials.
*/
@CoverageIgnore
public class AuthenticationException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_401_CLIENT_UNAUTHORIZED;

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@ -35,6 +36,7 @@ import ca.uhn.fhir.rest.server.Constants;
* Summary</a>.
* </p>
*/
@CoverageIgnore
public class ForbiddenOperationException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_403_FORBIDDEN;

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@ -39,6 +40,7 @@ import ca.uhn.fhir.rest.server.Constants;
*
* @see UnprocessableEntityException Which should be used for business level validation failures
*/
@CoverageIgnore
public class InternalErrorException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_500_INTERNAL_ERROR;

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@ -36,6 +37,7 @@ import ca.uhn.fhir.rest.server.Constants;
*
* @see UnprocessableEntityException Which should be used for business level validation failures
*/
@CoverageIgnore
public class InvalidRequestException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_400_BAD_REQUEST;

View File

@ -5,6 +5,7 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.server.Constants;

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@ -32,6 +33,7 @@ import ca.uhn.fhir.rest.server.Constants;
* Summary</a>.
* </p>
*/
@CoverageIgnore
public class NotImplementedOperationException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_501_NOT_IMPLEMENTED;

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@ -33,6 +34,7 @@ import ca.uhn.fhir.rest.server.Constants;
* Summary</a>.
* </p>
*/
@CoverageIgnore
public class NotModifiedException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_304_NOT_MODIFIED;

View File

@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.annotation.Update;
import ca.uhn.fhir.rest.server.Constants;
@ -30,6 +31,7 @@ import ca.uhn.fhir.rest.server.Constants;
* be specified in an HTTP header, and none was.
*/
@SuppressWarnings("deprecation")
@CoverageIgnore
public class PreconditionFailedException extends ResourceVersionNotSpecifiedException {
@SuppressWarnings("hiding")
public static final int STATUS_CODE = Constants.STATUS_HTTP_412_PRECONDITION_FAILED;

View File

@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
@ -30,6 +31,7 @@ import ca.uhn.fhir.rest.server.Constants;
* Represents an <b>HTTP 410 Resource Gone</b> response, which geenerally
* indicates that the resource has been deleted
*/
@CoverageIgnore
public class ResourceGoneException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_410_GONE;

View File

@ -20,6 +20,8 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import org.hl7.fhir.instance.model.api.IIdType;
import ca.uhn.fhir.model.api.IResource;
@ -31,6 +33,7 @@ import ca.uhn.fhir.rest.server.Constants;
/**
* Represents an <b>HTTP 404 Resource Not Found</b> response, which means that the request is pointing to a resource that does not exist.
*/
@CoverageIgnore
public class ResourceNotFoundException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;

View File

@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.annotation.Delete;
import ca.uhn.fhir.rest.annotation.Update;
@ -30,6 +31,7 @@ import ca.uhn.fhir.rest.server.Constants;
* thrown in methods which accept a version (e.g. {@link Update}, {@link Delete})
* when the operation fails because of a version conflict as specified in the FHIR specification.
*/
@CoverageIgnore
public class ResourceVersionConflictException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_409_CONFLICT;
private static final long serialVersionUID = 1L;

View File

@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@ -28,6 +29,7 @@ import ca.uhn.fhir.rest.server.Constants;
* strangely named and will be removed at some point.
*/
@Deprecated
@CoverageIgnore
public class ResourceVersionNotSpecifiedException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_412_PRECONDITION_FAILED;
private static final long serialVersionUID = 1L;

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
/*
@ -26,6 +27,7 @@ import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
* Exception for use when a response is received or being sent that does not correspond to any other exception type. An HTTP status code must be provided, and will be provided to the caller in the
* case of a server implementation.
*/
@CoverageIgnore
public class UnclassifiedServerFailureException extends BaseServerResponseException {
/**

View File

@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@ -32,6 +33,7 @@ import ca.uhn.fhir.rest.server.Constants;
*
* @see InvalidRequestException Which corresponds to an <b>HTTP 400 Bad Request</b> failure
*/
@CoverageIgnore
public class UnprocessableEntityException extends BaseServerResponseException {
private static final String DEFAULT_MESSAGE = "Unprocessable Entity";

View File

@ -62,11 +62,13 @@
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j_version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4j_version}</version>
</dependency>
<!-- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-nop</artifactId>
<version>${slf4j_version}</version> </dependency> -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback_version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
@ -215,7 +217,10 @@
<version>${maven_cobertura_plugin_version}</version>
<configuration>
<skip>false</skip>
<format>xml</format>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<maxmem>256m</maxmem>
<instrumentation>
<ignores>
@ -225,6 +230,11 @@
<ignore>**/valueset/*.class</ignore>
<ignore>**/exceptions/*.class</ignore>
</excludes>
<!--
<ignoreMethodAnnotations>
<ignoreMethodAnnotation>net.sourceforge.cobertura.CoverageIgnore</ignoreMethodAnnotation>
</ignoreMethodAnnotations>
-->
</instrumentation>
</configuration>
<executions>
@ -289,8 +299,9 @@
<configuration>
<sources>
<source>../hapi-fhir-structures-dstu/src/test/java</source>
<source>../hapi-fhir-structures-dstu2/src/test/java</source>
<source>../hapi-fhir-structures-hl7org-dstu2/src/test/java</source> <source>../hapi-fhir-jpaserver-base/src/test/java</source>
<source>../hapi-fhir-structures-dstu2/src/test/java</source>
<source>../hapi-fhir-structures-hl7org-dstu2/src/test/java</source>
<source>../hapi-fhir-jpaserver-base/src/test/java</source>
</sources>
</configuration>
</execution>

View File

@ -58,6 +58,7 @@ import org.hl7.fhir.instance.model.annotations.ResourceDef;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.xml.sax.SAXException;
@ -71,6 +72,10 @@ public class JsonParserHl7OrgTest {
private static final FhirContext ourCtx = FhirContext.forDstu2Hl7Org();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserHl7OrgTest.class);
@After
public void after() {
ourCtx.setNarrativeGenerator(null);
}
@Test
@ -1133,7 +1138,7 @@ public class JsonParserHl7OrgTest {
@Test
public void testSimpleResourceEncodeWithCustomType() throws IOException, SAXException {
String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.json"), Charset.forName("UTF-8"));
String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
MyObservationWithExtensions obs = ourCtx.newJsonParser().parseResource(MyObservationWithExtensions.class, jsonString);
assertEquals(0, obs.getExtension().size());
@ -1149,7 +1154,7 @@ public class JsonParserHl7OrgTest {
String encoded = xmlParser.encodeResourceToString(obs);
encoded = encoded.replaceAll("<!--.*-->", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
xmlString = xmlString.replaceAll("<!--.*-->", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
ourLog.info("Expected: " + xmlString);

View File

@ -1477,7 +1477,7 @@ public class XmlParserHl7OrgDstu2Test {
@Test
public void testSimpleResourceEncode() throws IOException, SAXException {
String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.json"), Charset.forName("UTF-8"));
String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
Patient obs = ourCtx.newJsonParser().parseResource(Patient.class, xmlString);
List<Extension> undeclaredExtensions = obs.getContact().get(0).getName().getFamily().get(0).getExtension();
@ -1490,7 +1490,7 @@ public class XmlParserHl7OrgDstu2Test {
String encoded = jsonParser.encodeResourceToString(obs);
ourLog.info(encoded);
String jsonString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
String jsonString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
String expected = (jsonString);
String actual = (encoded.trim());
@ -1503,7 +1503,7 @@ public class XmlParserHl7OrgDstu2Test {
@Test
public void testSimpleResourceEncodeWithCustomType() throws IOException {
String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
MyObservationWithExtensions obs = ourCtx.newXmlParser().parseResource(MyObservationWithExtensions.class, xmlString);
assertEquals(0, obs.getExtension().size());
@ -1519,7 +1519,7 @@ public class XmlParserHl7OrgDstu2Test {
String encoded = jsonParser.encodeResourceToString(obs);
ourLog.info(encoded);
String jsonString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.json"), Charset.forName("UTF-8"));
String jsonString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
JSON expected = JSONSerializer.toJSON(jsonString);
JSON actual = JSONSerializer.toJSON(encoded.trim());