Get tags working as a set instead of a list
This commit is contained in:
parent
0d6eca70a9
commit
24caec9f44
|
@ -59,12 +59,20 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
private IntegerDt myTotalResults;
|
||||
private InstantDt myUpdated;
|
||||
|
||||
/**
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addCategory(String, String, String)} should be used instead
|
||||
*/
|
||||
public Tag addCategory() {
|
||||
Tag retVal = new Tag();
|
||||
getCategories().add(retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public void addCategory(String theScheme, String theTerm, String theLabel) {
|
||||
getCategories().add(new Tag(theScheme, theTerm, theLabel));
|
||||
}
|
||||
|
||||
|
||||
public void addCategory(Tag theTag) {
|
||||
getCategories().add(theTag);
|
||||
}
|
||||
|
|
|
@ -50,12 +50,19 @@ public class BundleEntry extends BaseBundle {
|
|||
private StringDt myTitle;
|
||||
private InstantDt myUpdated;
|
||||
|
||||
/**
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addCategory(String, String, String)} should be used instead
|
||||
*/
|
||||
public Tag addCategory() {
|
||||
Tag retVal = new Tag();
|
||||
getCategories().add(retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public void addCategory(String theScheme, String theTerm, String theLabel) {
|
||||
getCategories().add(new Tag(theScheme, theTerm, theLabel));
|
||||
}
|
||||
|
||||
public void addCategory(Tag theTag) {
|
||||
getCategories().add(theTag);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,13 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* A single tag
|
||||
* <p>
|
||||
* Note on equality- When computing hashCode or equals values for this class, only the
|
||||
* {@link #getScheme() scheme} and
|
||||
* </p>
|
||||
*/
|
||||
public class Tag extends BaseElement implements IElement {
|
||||
|
||||
public static final String ATTR_LABEL = "label";
|
||||
|
@ -47,18 +54,28 @@ public class Tag extends BaseElement implements IElement {
|
|||
*/
|
||||
public static final String HL7_ORG_SECURITY_TAG = "http://hl7.org/fhir/tag/security";
|
||||
|
||||
private transient Integer myHashCode;
|
||||
private String myLabel;
|
||||
private String myScheme;
|
||||
private String myTerm;
|
||||
|
||||
/**
|
||||
* @deprecated Tags will become immutable in a future release, so this constructor should not be used.
|
||||
*/
|
||||
public Tag() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated There is no reason to create a tag with a term and not a scheme, so this constructor will be removed
|
||||
*/
|
||||
public Tag(String theTerm) {
|
||||
this((String) null, theTerm, null);
|
||||
}
|
||||
|
||||
public Tag(String theScheme, String theTerm) {
|
||||
myScheme = theScheme;
|
||||
myTerm = theTerm;
|
||||
}
|
||||
|
||||
public Tag(String theScheme, String theTerm, String theLabel) {
|
||||
myTerm = theTerm;
|
||||
myLabel = theLabel;
|
||||
|
@ -75,32 +92,6 @@ public class Tag extends BaseElement implements IElement {
|
|||
myLabel = theLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Tag other = (Tag) obj;
|
||||
if (myLabel == null) {
|
||||
if (other.myLabel != null)
|
||||
return false;
|
||||
} else if (!myLabel.equals(other.myLabel))
|
||||
return false;
|
||||
if (myScheme == null) {
|
||||
if (other.myScheme != null)
|
||||
return false;
|
||||
} else if (!myScheme.equals(other.myScheme))
|
||||
return false;
|
||||
if (myTerm == null) {
|
||||
if (other.myTerm != null)
|
||||
return false;
|
||||
} else if (!myTerm.equals(other.myTerm))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return myLabel;
|
||||
|
@ -115,18 +106,33 @@ public class Tag extends BaseElement implements IElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (myHashCode != null) {
|
||||
System.out.println("Tag alread has hashcode " + myHashCode + " - " + myScheme + " - " + myTerm + " - " + myLabel);
|
||||
return myHashCode;
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Tag other = (Tag) obj;
|
||||
if (myScheme == null) {
|
||||
if (other.myScheme != null)
|
||||
return false;
|
||||
} else if (!myScheme.equals(other.myScheme))
|
||||
return false;
|
||||
if (myTerm == null) {
|
||||
if (other.myTerm != null)
|
||||
return false;
|
||||
} else if (!myTerm.equals(other.myTerm))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((myLabel == null) ? 0 : myLabel.hashCode());
|
||||
result = prime * result + ((myScheme == null) ? 0 : myScheme.hashCode());
|
||||
result = prime * result + ((myTerm == null) ? 0 : myTerm.hashCode());
|
||||
myHashCode = result;
|
||||
System.out.println("Tag has hashcode " + myHashCode + " - " + myScheme + " - " + myTerm + " - " + myLabel);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -135,21 +141,33 @@ public class Tag extends BaseElement implements IElement {
|
|||
return StringUtils.isBlank(myLabel) && StringUtils.isBlank(myScheme) && StringUtils.isBlank(myTerm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
|
||||
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
|
||||
* tag object
|
||||
*/
|
||||
public Tag setLabel(String theLabel) {
|
||||
myLabel = theLabel;
|
||||
myHashCode = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
|
||||
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
|
||||
* tag object
|
||||
*/
|
||||
public Tag setScheme(String theScheme) {
|
||||
myScheme = theScheme;
|
||||
myHashCode = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
|
||||
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
|
||||
* tag object
|
||||
*/
|
||||
public Tag setTerm(String theTerm) {
|
||||
myTerm = theTerm;
|
||||
myHashCode = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,11 +74,41 @@ public class TagList implements Set<Tag>, Serializable {
|
|||
return myTagSet.addAll(theC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addTag(String, String, String)} should be used instead
|
||||
*/
|
||||
public Tag addTag() {
|
||||
myOrderedTags = null;
|
||||
return addTag(null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new tag instance
|
||||
*
|
||||
* @param theScheme
|
||||
* The tag scheme
|
||||
* @param theTerm
|
||||
* The tag term
|
||||
* @return Returns the newly created tag instance. Note that the tag is added to the list by this method, so you generally do not need to interact directly with the added tag.
|
||||
*/
|
||||
public Tag addTag(String theScheme, String theTerm) {
|
||||
Tag retVal = new Tag(theScheme, theTerm);
|
||||
add(retVal);
|
||||
myOrderedTags = null;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new tag instance
|
||||
*
|
||||
* @param theScheme
|
||||
* The tag scheme
|
||||
* @param theTerm
|
||||
* The tag term
|
||||
* @param theLabel
|
||||
* The tag label
|
||||
* @return Returns the newly created tag instance. Note that the tag is added to the list by this method, so you generally do not need to interact directly with the added tag.
|
||||
*/
|
||||
public Tag addTag(String theScheme, String theTerm, String theLabel) {
|
||||
Tag retVal = new Tag(theScheme, theTerm, theLabel);
|
||||
add(retVal);
|
||||
|
@ -131,81 +161,6 @@ public class TagList implements Set<Tag>, Serializable {
|
|||
}
|
||||
return myOrderedTags.get(theIndex);
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public Tag set(int theIndex, Tag theElement) {
|
||||
// throw new UnsupportedOperationException();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public void add(int theIndex, Tag theElement) {
|
||||
// myTagSet.add(theElement);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public Tag remove(int theIndex) {
|
||||
// Tag retVal = myTagSet.remove(theIndex);
|
||||
// myTagSet.remove(retVal);
|
||||
// return retVal;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public int indexOf(Object theO) {
|
||||
// myTagSet.remove(theO);
|
||||
// return myTagSet.indexOf(theO);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public int lastIndexOf(Object theO) {
|
||||
// return myTagSet.lastIndexOf(theO);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public ListIterator<Tag> listIterator() {
|
||||
// return myTagSet.listIterator();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public ListIterator<Tag> listIterator(int theIndex) {
|
||||
// return myTagSet.listIterator(theIndex);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public List<Tag> subList(int theFromIndex, int theToIndex) {
|
||||
// return myTagSet.subList(theFromIndex, theToIndex);
|
||||
// }
|
||||
|
||||
public Tag getTag(String theScheme, String theTerm) {
|
||||
for (Tag next : this) {
|
||||
|
@ -269,22 +224,6 @@ public class TagList implements Set<Tag>, Serializable {
|
|||
return myTagSet.toArray();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
// public boolean addAll(int theIndex, Collection<? extends Tag> theC) {
|
||||
// myTagSet.addAll(theC);
|
||||
// return myTagSet.addAll(theC);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @deprecated TagList will not implement the {@link List} interface in a future release, as tag order is not supposed to be meaningful
|
||||
// */
|
||||
// @Deprecated
|
||||
// @Override
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] theA) {
|
||||
return myTagSet.toArray(theA);
|
||||
|
|
|
@ -158,8 +158,7 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Invoked after any new XML event is individually processed, containing a copy of the XML event. This is basically
|
||||
* intended for embedded XHTML content
|
||||
* Invoked after any new XML event is individually processed, containing a copy of the XML event. This is basically intended for embedded XHTML content
|
||||
*/
|
||||
public void xmlEvent(XMLEvent theNextEvent) {
|
||||
myState.xmlEvent(theNextEvent);
|
||||
|
@ -222,35 +221,37 @@ class ParserState<T> {
|
|||
private static final int STATE_TERM = 1;
|
||||
|
||||
private int myCatState = STATE_NONE;
|
||||
private Tag myInstance;
|
||||
private TagList myTagList;
|
||||
private String myTerm;
|
||||
private String myLabel;
|
||||
private String myScheme;
|
||||
|
||||
public AtomCategoryState(Tag theEntry) {
|
||||
public AtomCategoryState(TagList theTagList) {
|
||||
super(null);
|
||||
myInstance = theEntry;
|
||||
myTagList = theTagList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attributeValue(String theName, String theValue) throws DataFormatException {
|
||||
if ("term".equals(theName)) {
|
||||
myInstance.setTerm(theValue);
|
||||
myTerm = theValue;
|
||||
} else if ("label".equals(theName)) {
|
||||
myInstance.setLabel(theValue);
|
||||
myLabel = theValue;
|
||||
} else if ("scheme".equals(theName)) {
|
||||
myInstance.setScheme(theValue);
|
||||
myScheme = theValue;
|
||||
} else if ("value".equals(theName)) {
|
||||
/*
|
||||
* This handles XML parsing, which is odd for this quasi-resource type, since the tag has three values
|
||||
* instead of one like everything else.
|
||||
* This handles XML parsing, which is odd for this quasi-resource type, since the tag has three values instead of one like everything else.
|
||||
*/
|
||||
switch (myCatState) {
|
||||
case STATE_LABEL:
|
||||
myInstance.setLabel(theValue);
|
||||
myLabel = theValue;
|
||||
break;
|
||||
case STATE_TERM:
|
||||
myInstance.setTerm(theValue);
|
||||
myTerm = theValue;
|
||||
break;
|
||||
case STATE_SCHEME:
|
||||
myInstance.setScheme(theValue);
|
||||
myScheme = theValue;
|
||||
break;
|
||||
default:
|
||||
super.string(theValue);
|
||||
|
@ -265,6 +266,9 @@ class ParserState<T> {
|
|||
if (myCatState != STATE_NONE) {
|
||||
myCatState = STATE_NONE;
|
||||
} else {
|
||||
if (isNotEmpty(myScheme) || isNotBlank(myTerm) || isNotBlank(myLabel)) {
|
||||
myTagList.addTag(myScheme, myTerm, myLabel);
|
||||
}
|
||||
pop();
|
||||
}
|
||||
}
|
||||
|
@ -422,7 +426,7 @@ class ParserState<T> {
|
|||
} else if ("summary".equals(theLocalPart)) {
|
||||
push(new XhtmlState(getPreResourceState(), myEntry.getSummary(), false));
|
||||
} else if ("category".equals(theLocalPart)) {
|
||||
push(new AtomCategoryState(myEntry.addCategory()));
|
||||
push(new AtomCategoryState(myEntry.getCategories()));
|
||||
} else if ("deleted".equals(theLocalPart) && myJsonMode) {
|
||||
// JSON and XML deleted entries are completely different for some reason
|
||||
myDeleted = true;
|
||||
|
@ -629,7 +633,7 @@ class ParserState<T> {
|
|||
} else if ("author".equals(theLocalPart)) {
|
||||
push(new AtomAuthorState(myInstance));
|
||||
} else if ("category".equals(theLocalPart)) {
|
||||
push(new AtomCategoryState(myInstance.getCategories().addTag()));
|
||||
push(new AtomCategoryState(myInstance.getCategories()));
|
||||
} else if ("deleted-entry".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, theNamespaceURI)) {
|
||||
push(new AtomDeletedEntryState(myInstance, myResourceType));
|
||||
} else {
|
||||
|
@ -707,7 +711,8 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param theData The string value
|
||||
* @param theData
|
||||
* The string value
|
||||
*/
|
||||
public void string(String theData) {
|
||||
// ignore by default
|
||||
|
@ -718,7 +723,8 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param theNextEvent The XML event
|
||||
* @param theNextEvent
|
||||
* The XML event
|
||||
*/
|
||||
public void xmlEvent(XMLEvent theNextEvent) {
|
||||
// ignore
|
||||
|
@ -1275,7 +1281,8 @@ class ParserState<T> {
|
|||
myContext.newTerser().visit(myInstance, new IModelVisitor() {
|
||||
|
||||
@Override
|
||||
public void acceptUndeclaredExtension(ISupportsUndeclaredExtensions theContainingElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition<?> theDefinition, ExtensionDt theNextExt) {
|
||||
public void acceptUndeclaredExtension(ISupportsUndeclaredExtensions theContainingElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition<?> theDefinition,
|
||||
ExtensionDt theNextExt) {
|
||||
acceptElement(theNextExt.getValue(), null, null);
|
||||
}
|
||||
|
||||
|
@ -1508,7 +1515,7 @@ class ParserState<T> {
|
|||
@Override
|
||||
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException {
|
||||
if (TagList.ATTR_CATEGORY.equals(theLocalPart)) {
|
||||
push(new TagState(myTagList.addTag()));
|
||||
push(new TagState(myTagList));
|
||||
} else {
|
||||
throw new DataFormatException("Unexpected element: " + theLocalPart);
|
||||
}
|
||||
|
@ -1524,11 +1531,14 @@ class ParserState<T> {
|
|||
private static final int SCHEME = 3;
|
||||
private static final int TERM = 1;
|
||||
private int mySubState = 0;
|
||||
private Tag myTag;
|
||||
private TagList myTagList;
|
||||
private String myTerm;
|
||||
private String myLabel;
|
||||
private String myScheme;
|
||||
|
||||
public TagState(Tag theTag) {
|
||||
public TagState(TagList theTagList) {
|
||||
super(null);
|
||||
myTag = theTag;
|
||||
myTagList = theTagList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1537,13 +1547,13 @@ class ParserState<T> {
|
|||
|
||||
switch (mySubState) {
|
||||
case TERM:
|
||||
myTag.setTerm(value);
|
||||
myTerm = (value);
|
||||
break;
|
||||
case LABEL:
|
||||
myTag.setLabel(value);
|
||||
myLabel = (value);
|
||||
break;
|
||||
case SCHEME:
|
||||
myTag.setScheme(value);
|
||||
myScheme = (value);
|
||||
break;
|
||||
case NONE:
|
||||
// This handles JSON encoding, which is a bit weird
|
||||
|
@ -1559,6 +1569,9 @@ class ParserState<T> {
|
|||
if (mySubState != NONE) {
|
||||
mySubState = NONE;
|
||||
} else {
|
||||
if (isNotEmpty(myScheme) || isNotBlank(myTerm) || isNotBlank(myLabel)) {
|
||||
myTagList.addTag(myScheme, myTerm, myLabel);
|
||||
}
|
||||
pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,10 +214,6 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void>
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((myVersionIdParamIndex != null) != (theRequest.getId() != null && theRequest.getId().hasVersionIdPart())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isDelete()) {
|
||||
if (Constants.PARAM_DELETE.equals(theRequest.getSecondaryOperation()) == false) {
|
||||
return false;
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.method;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
@ -66,7 +66,6 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.server.IDynamicSearchResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.SearchParameterMap;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
|
|
@ -28,6 +28,20 @@ public class TagListTest {
|
|||
assertEquals(tagList1,tagList2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsIgnoresLabel() {
|
||||
TagList tagList1 = new TagList();
|
||||
tagList1.addTag(null, "Dog", "AAAA");
|
||||
tagList1.addTag("http://foo", "Cat", "BBBB");
|
||||
|
||||
TagList tagList2 = new TagList();
|
||||
tagList2.addTag(null, "Dog", "Puppies");
|
||||
tagList2.addTag("http://foo", "Cat", "Kittens");
|
||||
|
||||
assertEquals(tagList1,tagList2);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEqualsIgnoresOrder() {
|
||||
TagList tagList1 = new TagList();
|
||||
|
|
|
@ -63,7 +63,6 @@ public class JsonParserTest {
|
|||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserTest.class);
|
||||
private static FhirContext ourCtx;
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeNarrativeBlockInBundle() {
|
||||
Patient p = new Patient();
|
||||
|
@ -87,7 +86,6 @@ public class JsonParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodingNullExtension() {
|
||||
Patient p = new Patient();
|
||||
|
@ -164,8 +162,6 @@ public class JsonParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeExtensionInResourceElement() {
|
||||
|
||||
|
@ -217,8 +213,6 @@ public class JsonParserTest {
|
|||
assertNull(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testNestedContainedResources() {
|
||||
|
||||
|
@ -254,25 +248,13 @@ public class JsonParserTest {
|
|||
Observation obsC = (Observation) obsB.getRelatedFirstRep().getTarget().getResource();
|
||||
assertEquals("C", obsC.getName().getText().getValue());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseQuery() {
|
||||
String msg = "{\n" +
|
||||
" \"resourceType\": \"Query\",\n" +
|
||||
" \"text\": {\n" +
|
||||
" \"status\": \"generated\",\n" +
|
||||
" \"div\": \"<div>[Put rendering here]</div>\"\n" +
|
||||
" },\n" +
|
||||
" \"identifier\": \"urn:uuid:42b253f5-fa17-40d0-8da5-44aeb4230376\",\n" +
|
||||
" \"parameter\": [\n" +
|
||||
" {\n" +
|
||||
" \"url\": \"http://hl7.org/fhir/query#_query\",\n" +
|
||||
" \"valueString\": \"example\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
String msg = "{\n" + " \"resourceType\": \"Query\",\n" + " \"text\": {\n" + " \"status\": \"generated\",\n" + " \"div\": \"<div>[Put rendering here]</div>\"\n" + " },\n"
|
||||
+ " \"identifier\": \"urn:uuid:42b253f5-fa17-40d0-8da5-44aeb4230376\",\n" + " \"parameter\": [\n" + " {\n" + " \"url\": \"http://hl7.org/fhir/query#_query\",\n"
|
||||
+ " \"valueString\": \"example\"\n" + " }\n" + " ]\n" + "}";
|
||||
Query query = ourCtx.newJsonParser().parseResource(Query.class, msg);
|
||||
|
||||
assertEquals("urn:uuid:42b253f5-fa17-40d0-8da5-44aeb4230376", query.getIdentifier().getValueAsString());
|
||||
|
@ -287,7 +269,6 @@ public class JsonParserTest {
|
|||
ExtensionDt parameter = q.addParameter();
|
||||
parameter.setUrl("http://hl7.org/fhir/query#_query").setValue(new StringDt("example"));
|
||||
|
||||
|
||||
String val = new FhirContext().newJsonParser().encodeResourceToString(q);
|
||||
ourLog.info(val);
|
||||
|
||||
|
@ -392,7 +373,7 @@ public class JsonParserTest {
|
|||
Bundle b = new Bundle();
|
||||
BundleEntry e = b.addEntry();
|
||||
e.setResource(new Patient());
|
||||
b.addCategory().setLabel("label").setTerm("term").setScheme("scheme");
|
||||
b.addCategory("scheme", "term", "label");
|
||||
|
||||
String val = new FhirContext().newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
|
||||
ourLog.info(val);
|
||||
|
@ -415,14 +396,14 @@ public class JsonParserTest {
|
|||
Bundle b = new Bundle();
|
||||
BundleEntry e = b.addEntry();
|
||||
e.setResource(new Patient());
|
||||
e.addCategory().setLabel("label").setTerm("term").setScheme("scheme");
|
||||
e.addCategory("scheme", "term", "label");
|
||||
|
||||
String val = new FhirContext().newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
|
||||
String val = ourCtx.newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
|
||||
ourLog.info(val);
|
||||
|
||||
assertThat(val, StringContains.containsString("\"category\":[{\"term\":\"term\",\"label\":\"label\",\"scheme\":\"scheme\"}]"));
|
||||
|
||||
b = new FhirContext().newJsonParser().parseBundle(val);
|
||||
b = ourCtx.newJsonParser().parseBundle(val);
|
||||
assertEquals(1, b.getEntries().size());
|
||||
assertEquals(1, b.getEntries().get(0).getCategories().size());
|
||||
assertEquals("term", b.getEntries().get(0).getCategories().get(0).getTerm());
|
||||
|
@ -450,7 +431,6 @@ public class JsonParserTest {
|
|||
parseAndEncode("/alert.profile.json");
|
||||
}
|
||||
|
||||
|
||||
private void parseAndEncode(String name) throws IOException {
|
||||
String msg = IOUtils.toString(XmlParser.class.getResourceAsStream(name));
|
||||
ourLog.info(msg);
|
||||
|
@ -473,8 +453,6 @@ public class JsonParserTest {
|
|||
assertEquals(exp, act);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedResourcesMore() {
|
||||
|
||||
|
@ -518,7 +496,6 @@ public class JsonParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeDeclaredExtensionWithResourceContent() {
|
||||
IParser parser = new FhirContext().newJsonParser();
|
||||
|
@ -549,8 +526,6 @@ public class JsonParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeExt() throws Exception {
|
||||
|
||||
|
@ -567,11 +542,12 @@ public class JsonParserTest {
|
|||
ourLog.info(encoded);
|
||||
|
||||
assertThat(encoded, not(containsString("123456")));
|
||||
assertEquals("{\"resourceType\":\"ValueSet\",\"define\":{\"concept\":[{\"extension\":[{\"url\":\"urn:alt\",\"valueString\":\"alt name\"}],\"code\":\"someCode\",\"display\":\"someDisplay\"}]}}", encoded);
|
||||
assertEquals(
|
||||
"{\"resourceType\":\"ValueSet\",\"define\":{\"concept\":[{\"extension\":[{\"url\":\"urn:alt\",\"valueString\":\"alt name\"}],\"code\":\"someCode\",\"display\":\"someDisplay\"}]}}",
|
||||
encoded);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeExtensionWithResourceContent() {
|
||||
IParser parser = new FhirContext().newJsonParser();
|
||||
|
@ -593,7 +569,6 @@ public class JsonParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeInvalidChildGoodException() {
|
||||
Observation obs = new Observation();
|
||||
|
@ -793,7 +768,6 @@ public class JsonParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This sample has extra elements in <searchParam> that are not actually a part of the spec any more..
|
||||
*/
|
||||
|
@ -910,7 +884,6 @@ public class JsonParserTest {
|
|||
bundleString = ourCtx.newJsonParser().setPrettyPrint(true).encodeBundleToString(b);
|
||||
assertThat(bundleString, not(containsString("deleted")));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -982,7 +955,6 @@ public class JsonParserTest {
|
|||
assertEquals("Organization/1", parsed.getManagingOrganization().getReference().getValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSimpleResourceEncodeWithCustomType() throws IOException {
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ public class XmlParserTest {
|
|||
Bundle b = new Bundle();
|
||||
BundleEntry e = b.addEntry();
|
||||
e.setResource(new Patient());
|
||||
e.addCategory().setLabel("label").setTerm("term").setScheme("scheme");
|
||||
e.addCategory("scheme", "term", "label");
|
||||
|
||||
String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeBundleToString(b);
|
||||
ourLog.info(val);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import static org.apache.commons.lang.StringUtils.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import static org.apache.commons.lang.StringUtils.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.apache.commons.lang.StringUtils.defaultString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
|
@ -33,7 +34,6 @@ import ca.uhn.fhir.rest.annotation.DeleteTags;
|
|||
import ca.uhn.fhir.rest.annotation.GetTags;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.TagListParam;
|
||||
import ca.uhn.fhir.rest.annotation.VersionIdParam;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
|
||||
/**
|
||||
|
@ -94,17 +94,6 @@ public class TagsServerTest {
|
|||
assertEquals(tagList, ourLastTagList);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
TagList list1 = ourProvider.getAllTagsPatient();
|
||||
TagList list2 = ourProvider.getAllTagsPatient();
|
||||
assertEquals(list1, list2);
|
||||
|
||||
list1 = ourProvider.getAllTagsPatient();
|
||||
list2 = ourProvider.getAllTagsPatient();
|
||||
list2.get(0).setTerm("!!!!!");
|
||||
assertNotEquals(list1, list2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllTags() throws Exception {
|
||||
|
@ -134,8 +123,10 @@ public class TagsServerTest {
|
|||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
TagList actual = ourCtx.newXmlParser().parseTagList(responseContent);
|
||||
TagList expected = ourProvider.getAllTags();
|
||||
expected.get(0).setTerm("Patient");
|
||||
|
||||
TagList expected = new TagList();
|
||||
expected.addTag(null, "Patient", "DogLabel");
|
||||
expected.addTag("http://cats", "AllCat", "CatLabel");
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -152,8 +143,10 @@ public class TagsServerTest {
|
|||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
TagList actual = ourCtx.newXmlParser().parseTagList(responseContent);
|
||||
TagList expected = ourProvider.getAllTags();
|
||||
expected.get(0).setTerm("Patient111");
|
||||
|
||||
TagList expected = new TagList();
|
||||
expected.addTag(null, "Patient111", "DogLabel");
|
||||
expected.addTag("http://cats", "AllCat", "CatLabel");
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -170,8 +163,9 @@ public class TagsServerTest {
|
|||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
TagList actual = ourCtx.newXmlParser().parseTagList(responseContent);
|
||||
TagList expected = ourProvider.getAllTags();
|
||||
expected.get(0).setTerm("Patient111222");
|
||||
TagList expected = new TagList();
|
||||
expected.addTag(null, "Patient111222", "DogLabel");
|
||||
expected.addTag("http://cats", "AllCat", "CatLabel");
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -188,8 +182,9 @@ public class TagsServerTest {
|
|||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
TagList actual = ourCtx.newXmlParser().parseTagList(responseContent);
|
||||
TagList expected = ourProvider.getAllTags();
|
||||
expected.get(0).setTerm("Patient111222");
|
||||
TagList expected = new TagList();
|
||||
expected.addTag(null, "Patient111222", "DogLabel");
|
||||
expected.addTag("http://cats", "AllCat", "CatLabel");
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -261,15 +256,9 @@ public class TagsServerTest {
|
|||
|
||||
public static class DummyProvider {
|
||||
|
||||
@AddTags(type = Patient.class)
|
||||
public void addTagsPatient(@IdParam IdDt theId, @VersionIdParam IdDt theVersion, @TagListParam TagList theTagList) {
|
||||
ourLastOutcome = "add" + theId.getIdPart() + theVersion.getVersionIdPart();
|
||||
ourLastTagList=theTagList;
|
||||
}
|
||||
|
||||
@AddTags(type = Patient.class)
|
||||
public void addTagsPatient(@IdParam IdDt theId, @TagListParam TagList theTagList) {
|
||||
ourLastOutcome = "add" + theId.getIdPart();
|
||||
ourLastOutcome = "add" + theId.getIdPart() + StringUtils.defaultString(theId.getVersionIdPart());
|
||||
ourLastTagList=theTagList;
|
||||
}
|
||||
|
||||
|
@ -297,13 +286,13 @@ public class TagsServerTest {
|
|||
return tagList;
|
||||
}
|
||||
|
||||
@GetTags(type = Patient.class)
|
||||
public TagList getAllTagsPatientIdVersion(@IdParam IdDt theId, @VersionIdParam IdDt theVersion) {
|
||||
TagList tagList = new TagList();
|
||||
tagList.add(new Tag((String) null, "Patient" + theId.getIdPart() + theVersion.getVersionIdPart(), "DogLabel"));
|
||||
tagList.add(new Tag("http://cats", "AllCat", "CatLabel"));
|
||||
return tagList;
|
||||
}
|
||||
// @GetTags(type = Patient.class)
|
||||
// public TagList getAllTagsPatientIdVersion(@IdParam IdDt theId, @VersionIdParam IdDt theVersion) {
|
||||
// TagList tagList = new TagList();
|
||||
// tagList.add(new Tag((String) null, "Patient" + theId.getIdPart() + theVersion.getVersionIdPart(), "DogLabel"));
|
||||
// tagList.add(new Tag("http://cats", "AllCat", "CatLabel"));
|
||||
// return tagList;
|
||||
// }
|
||||
|
||||
@GetTags(type = Observation.class)
|
||||
public TagList getAllTagsObservationIdVersion(@IdParam IdDt theId) {
|
||||
|
@ -313,15 +302,15 @@ public class TagsServerTest {
|
|||
return tagList;
|
||||
}
|
||||
|
||||
@DeleteTags(type = Patient.class)
|
||||
public void RemoveTagsPatient(@IdParam IdDt theId, @VersionIdParam IdDt theVersion, @TagListParam TagList theTagList) {
|
||||
ourLastOutcome = "Remove" + theId.getIdPart() + theVersion.getVersionIdPart();
|
||||
ourLastTagList=theTagList;
|
||||
}
|
||||
// @DeleteTags(type = Patient.class)
|
||||
// public void RemoveTagsPatient(@IdParam IdDt theId, @VersionIdParam IdDt theVersion, @TagListParam TagList theTagList) {
|
||||
// ourLastOutcome = "Remove" + theId.getIdPart() + theVersion.getVersionIdPart();
|
||||
// ourLastTagList=theTagList;
|
||||
// }
|
||||
|
||||
@DeleteTags(type = Patient.class)
|
||||
public void RemoveTagsPatient(@IdParam IdDt theId, @TagListParam TagList theTagList) {
|
||||
ourLastOutcome = "Remove" + theId.getIdPart();
|
||||
ourLastOutcome = "Remove" + theId.getIdPart()+StringUtils.defaultString(theId.getVersionIdPart());
|
||||
ourLastTagList=theTagList;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,23 +141,25 @@ public class UpdateTest {
|
|||
dr.addCodedDiagnosis().addCoding().setCode("AAA");
|
||||
|
||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||
httpPost.addHeader("Category", "Dog, Cat");
|
||||
httpPost.addHeader("Category", "Dog; scheme=\"urn:animals\", Cat; scheme=\"urn:animals\"");
|
||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
assertEquals(2, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag("Dog"), ourReportProvider.getLastTags().get(0));
|
||||
assertEquals(new Tag("Cat"), ourReportProvider.getLastTags().get(1));
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(2, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag("urn:animals", "Dog"), ourReportProvider.getLastTags().get(0));
|
||||
assertEquals(new Tag("urn:animals", "Cat"), ourReportProvider.getLastTags().get(1));
|
||||
|
||||
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||
httpPost.addHeader("Category", "Dog; label=\"aa\", Cat; label=\"bb\"");
|
||||
httpPost.addHeader("Category", "Dog; label=\"aa\"; scheme=\"urn:animals\", Cat; label=\"bb\"; scheme=\"urn:animals\"");
|
||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
status = ourClient.execute(httpPost);
|
||||
assertEquals(2, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag((String) null, "Dog", "aa"), ourReportProvider.getLastTags().get(0));
|
||||
assertEquals(new Tag((String) null, "Cat", "bb"), ourReportProvider.getLastTags().get(1));
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(2, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag("urn:animals", "Dog", "aa"), ourReportProvider.getLastTags().get(0));
|
||||
assertEquals(new Tag("urn:animals", "Cat", "bb"), ourReportProvider.getLastTags().get(1));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -167,13 +169,14 @@ public class UpdateTest {
|
|||
dr.addCodedDiagnosis().addCoding().setCode("AAA");
|
||||
|
||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||
httpPost.addHeader("Category", "Dog");
|
||||
httpPost.addHeader("Category", "Dog; scheme=\"animals\"");
|
||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
assertEquals(1, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag("Dog"), ourReportProvider.getLastTags().get(0));
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(1, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag("animals", "Dog"), ourReportProvider.getLastTags().get(0));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -186,17 +189,19 @@ public class UpdateTest {
|
|||
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"");
|
||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(1, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag("http://foo", "Dog", null), ourReportProvider.getLastTags().get(0));
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\";");
|
||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
ourClient.execute(httpPost);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(1, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag("http://foo", "Dog", null), ourReportProvider.getLastTags().get(0));
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
}
|
||||
|
||||
|
@ -218,9 +223,10 @@ public class UpdateTest {
|
|||
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"; label=\"aaaa\"; ");
|
||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
status=ourClient.execute(httpPost);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(1, ourReportProvider.getLastTags().size());
|
||||
assertEquals(new Tag("http://foo", "Dog", "aaaa"), ourReportProvider.getLastTags().get(0));
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
}
|
||||
|
||||
|
@ -235,6 +241,7 @@ public class UpdateTest {
|
|||
httpPut.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
HttpResponse status = ourClient.execute(httpPut);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
// String responseContent =
|
||||
// IOUtils.toString(status.getEntity().getContent());
|
||||
|
@ -242,7 +249,6 @@ public class UpdateTest {
|
|||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertEquals("http://localhost:" + ourPort + "/DiagnosticReport/001/_history/002", status.getFirstHeader("Location").getValue());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
}
|
||||
|
||||
|
@ -257,11 +263,12 @@ public class UpdateTest {
|
|||
httpPut.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
CloseableHttpResponse status = ourClient.execute(httpPut);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
ourLog.info("Response was:\n{}", responseContent);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
ourLog.info("Response was:\n{}", responseContent);
|
||||
|
||||
}
|
||||
|
||||
public void testUpdateWrongResourceType() throws Exception {
|
||||
|
@ -289,9 +296,11 @@ public class UpdateTest {
|
|||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Organization/001");
|
||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
CloseableHttpResponse response = ourClient.execute(httpPost);
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
response.close();
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
status.close();
|
||||
}
|
||||
|
||||
|
||||
|
@ -376,6 +385,7 @@ public class UpdateTest {
|
|||
return Observation.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Update()
|
||||
public MethodOutcome updateDiagnosticReportWithVersion(@IdParam IdDt theId, @ResourceParam DiagnosticOrder thePatient) {
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue