diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Child.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Child.java index 25bb24df6e6..b0370b6c625 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Child.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Child.java @@ -111,15 +111,18 @@ public @interface Child { @CoverageIgnore public static class NoEnumFactory implements IBaseEnumFactory> { + @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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java index 37972bb1a0a..f32023ec0e4 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java @@ -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 iter = elem.getAttributes(); iter.hasNext();) { + @SuppressWarnings("unchecked") + Iterator attributes = elem.getAttributes(); + for (Iterator 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 children, - boolean theIncludedResource) throws XMLStreamException, DataFormatException { + private void encodeCompositeElementChildrenToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, List 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 to java.util.List> seems to be - * rejected by the compiler some of the time. + * This is just to work around the fact that casting java.util.List to + * java.util.List> seems to be rejected by the + * compiler some of the time. */ private > List> toBaseExtensionList(final List theList) { List> retVal = new ArrayList>(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 preExtensionChildren = new ArrayList(); @@ -885,8 +883,7 @@ public class XmlParser extends BaseParser implements IParser { } } - private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theWriter, List> theExtensions, String tagName, boolean theIncludedResource) - throws XMLStreamException, DataFormatException { + private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theWriter, List> theExtensions, String tagName, boolean theIncludedResource) throws XMLStreamException, DataFormatException { for (IBaseExtension next : theExtensions) { if (next == null || (ElementUtil.isEmpty(next.getValue()) && next.getExtension().isEmpty())) { continue; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientConnectionException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientConnectionException.java index afb18fd43f2..573749d554f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientConnectionException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientConnectionException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientInappropriateForServerException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientInappropriateForServerException.java index c3bbd991acb..b8c5e69ce58 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientInappropriateForServerException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientInappropriateForServerException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/InvalidResponseException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/InvalidResponseException.java index 59dd892a84d..5b4ac7070fc 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/InvalidResponseException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/InvalidResponseException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/NonFhirResponseException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/NonFhirResponseException.java index 0836d473dd7..a4142968e84 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/NonFhirResponseException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/NonFhirResponseException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java index 9b74f843e37..57005048353 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java @@ -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 HTTP 401 Client Unauthorized 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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ForbiddenOperationException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ForbiddenOperationException.java index 6696e8bbde2..dd6fc5b5b16 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ForbiddenOperationException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ForbiddenOperationException.java @@ -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. *

*/ +@CoverageIgnore public class ForbiddenOperationException extends BaseServerResponseException { public static final int STATUS_CODE = Constants.STATUS_HTTP_403_FORBIDDEN; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InternalErrorException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InternalErrorException.java index 197d2f5cf9d..aca46166774 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InternalErrorException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InternalErrorException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.java index 1f60ebe24e4..960d1b290c9 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/MethodNotAllowedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/MethodNotAllowedException.java index 9321b73c1bc..434276e57db 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/MethodNotAllowedException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/MethodNotAllowedException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotImplementedOperationException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotImplementedOperationException.java index 13b63936a68..3bda91cfe5a 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotImplementedOperationException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotImplementedOperationException.java @@ -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. *

*/ +@CoverageIgnore public class NotImplementedOperationException extends BaseServerResponseException { public static final int STATUS_CODE = Constants.STATUS_HTTP_501_NOT_IMPLEMENTED; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotModifiedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotModifiedException.java index 82ffd9fdbda..bd77f74f2c6 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotModifiedException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotModifiedException.java @@ -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. *

*/ +@CoverageIgnore public class NotModifiedException extends BaseServerResponseException { public static final int STATUS_CODE = Constants.STATUS_HTTP_304_NOT_MODIFIED; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/PreconditionFailedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/PreconditionFailedException.java index 4161c7ccd5e..e931cd719d8 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/PreconditionFailedException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/PreconditionFailedException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceGoneException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceGoneException.java index be728be8408..285d29f5716 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceGoneException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceGoneException.java @@ -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 HTTP 410 Resource Gone 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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java index 2d89461d86d..56b8f84672c 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java @@ -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 HTTP 404 Resource Not Found 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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionConflictException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionConflictException.java index 9924f72a7f4..8f4ff824414 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionConflictException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionConflictException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java index 7758c4611a6..07e343214ac 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java @@ -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; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnclassifiedServerFailureException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnclassifiedServerFailureException.java index 46bf595df95..557b6e3cea8 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnclassifiedServerFailureException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnclassifiedServerFailureException.java @@ -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 { /** diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.java index 000b0aca59e..67c6d2e0d82 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.java @@ -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 HTTP 400 Bad Request failure */ +@CoverageIgnore public class UnprocessableEntityException extends BaseServerResponseException { private static final String DEFAULT_MESSAGE = "Unprocessable Entity"; diff --git a/hapi-fhir-cobertura/pom.xml b/hapi-fhir-cobertura/pom.xml index 0ae80227bb5..11d49becab3 100644 --- a/hapi-fhir-cobertura/pom.xml +++ b/hapi-fhir-cobertura/pom.xml @@ -62,11 +62,13 @@ jcl-over-slf4j ${slf4j_version} - - org.slf4j - slf4j-nop - ${slf4j_version} - + + + ch.qos.logback + logback-classic + ${logback_version} + org.hamcrest @@ -215,7 +217,10 @@ ${maven_cobertura_plugin_version} false - xml + + html + xml + 256m @@ -225,6 +230,11 @@ **/valueset/*.class **/exceptions/*.class + @@ -289,8 +299,9 @@ ../hapi-fhir-structures-dstu/src/test/java - ../hapi-fhir-structures-dstu2/src/test/java - ../hapi-fhir-structures-hl7org-dstu2/src/test/java ../hapi-fhir-jpaserver-base/src/test/java + ../hapi-fhir-structures-dstu2/src/test/java + ../hapi-fhir-structures-hl7org-dstu2/src/test/java + ../hapi-fhir-jpaserver-base/src/test/java diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java index 948141d4f52..89b264637ec 100644 --- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java +++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java @@ -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); diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java index a4272882475..8e94cfa56bc 100644 --- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java +++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java @@ -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 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()); diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general.json b/hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general-hl7orgdstu2.json similarity index 100% rename from hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general.json rename to hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general-hl7orgdstu2.json diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general.xml b/hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general-hl7orgdstu2.xml similarity index 100% rename from hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general.xml rename to hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general-hl7orgdstu2.xml