Fix unit tests
This commit is contained in:
parent
1fddb04fb3
commit
80826b62fd
|
@ -168,6 +168,13 @@
|
|||
<version>0.8</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
<version>${hamcrest_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<reporting>
|
||||
|
|
|
@ -1,25 +1,32 @@
|
|||
package ca.uhn.fhir.model.primitive;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
/**
|
||||
* Represents the FHIR ID type. This is the actual resource ID, meaning the ID that
|
||||
* will be used in RESTful URLs, Resource References, etc. to represent a specific
|
||||
* instance of a resource.
|
||||
*
|
||||
* <p>
|
||||
* <b>Description</b>: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length
|
||||
* limit of 36 characters.
|
||||
* </p>
|
||||
* <p>
|
||||
* regex: [a-z0-9\-\.]{1,36}
|
||||
* </p>
|
||||
*/
|
||||
@DatatypeDef(name = "id")
|
||||
public class IdDt extends BasePrimitive<String> {
|
||||
|
||||
private String myValue;
|
||||
|
||||
/**
|
||||
* Create a new ID.
|
||||
*
|
||||
* <p>
|
||||
* <b>Description</b>:
|
||||
* A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
|
||||
* </p>
|
||||
* <p>
|
||||
* regex: [a-z0-9\-\.]{1,36}
|
||||
* </p>
|
||||
* Create a new empty ID
|
||||
*/
|
||||
public IdDt() {
|
||||
super();
|
||||
|
@ -33,21 +40,32 @@ public class IdDt extends BasePrimitive<String> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new ID
|
||||
* Create a new ID using a string
|
||||
*
|
||||
* <p>
|
||||
* <b>Description</b>:
|
||||
* A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
|
||||
* <b>Description</b>: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length
|
||||
* limit of 36 characters.
|
||||
* </p>
|
||||
* <p>
|
||||
* regex: [a-z0-9\-\.]{1,36}
|
||||
* </p>
|
||||
* regex: [a-z0-9\-\.]{1,36}
|
||||
* </p>
|
||||
*/
|
||||
@SimpleSetter
|
||||
public IdDt(@SimpleSetter.Parameter(name="theId") String theValue) {
|
||||
public IdDt(@SimpleSetter.Parameter(name = "theId") String theValue) {
|
||||
setValue(theValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ID, using a BigDecimal input. Uses {@link BigDecimal#toPlainString()} to generate the string representation.
|
||||
*/
|
||||
public IdDt(BigDecimal thePid) {
|
||||
if (thePid != null) {
|
||||
setValue(thePid.toPlainString());
|
||||
} else {
|
||||
setValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return myValue;
|
||||
|
@ -62,12 +80,12 @@ public class IdDt extends BasePrimitive<String> {
|
|||
* Set the value
|
||||
*
|
||||
* <p>
|
||||
* <b>Description</b>:
|
||||
* A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
|
||||
* <b>Description</b>: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length
|
||||
* limit of 36 characters.
|
||||
* </p>
|
||||
* <p>
|
||||
* regex: [a-z0-9\-\.]{1,36}
|
||||
* </p>
|
||||
* regex: [a-z0-9\-\.]{1,36}
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void setValue(String theValue) throws DataFormatException {
|
||||
|
@ -79,12 +97,12 @@ public class IdDt extends BasePrimitive<String> {
|
|||
* Set the value
|
||||
*
|
||||
* <p>
|
||||
* <b>Description</b>:
|
||||
* A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
|
||||
* <b>Description</b>: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length
|
||||
* limit of 36 characters.
|
||||
* </p>
|
||||
* <p>
|
||||
* regex: [a-z0-9\-\.]{1,36}
|
||||
* </p>
|
||||
* regex: [a-z0-9\-\.]{1,36}
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void setValueAsString(String theValue) throws DataFormatException {
|
||||
|
|
|
@ -16,6 +16,7 @@ import javax.xml.stream.events.XMLEvent;
|
|||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
@DatatypeDef(name = "xhtml")
|
||||
|
@ -23,13 +24,43 @@ public class XhtmlDt extends BasePrimitive<List<XMLEvent>> {
|
|||
|
||||
private List<XMLEvent> myValue;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public XhtmlDt() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor which accepts a string code
|
||||
*
|
||||
* @see #setValueAsString(String) for a description of how this value is applied
|
||||
*/
|
||||
@SimpleSetter()
|
||||
public XhtmlDt(@SimpleSetter.Parameter(name = "theTextDiv") String theTextDiv) {
|
||||
setValueAsString(theTextDiv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a textual DIV and parses it into XHTML events which are stored internally.
|
||||
* <p>
|
||||
* <b>Formatting note:</b> The text will be trimmed {@link String#trim()}. If the text does not start with
|
||||
* an HTML tag (generally this would be a div tag), a div tag will be automatically
|
||||
* placed surrounding the text.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void setValueAsString(String theValue) throws DataFormatException {
|
||||
if (theValue == null) {
|
||||
myValue = null;
|
||||
return;
|
||||
}
|
||||
String val = "<a>" + theValue + "</a>";
|
||||
|
||||
String val = theValue.trim();
|
||||
if (!val.startsWith("<")) {
|
||||
val = "<div>" + val + "</div>";
|
||||
}
|
||||
|
||||
try {
|
||||
ArrayList<XMLEvent> value = new ArrayList<XMLEvent>();
|
||||
XMLEventReader er = XMLInputFactory.newInstance().createXMLEventReader(new StringReader(val));
|
||||
|
|
|
@ -462,7 +462,8 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
}
|
||||
|
||||
if (!haveContent) {
|
||||
theEventWriter.writeEnd();
|
||||
// theEventWriter.writeEnd();
|
||||
theEventWriter.flush(); // TODO: remove
|
||||
theEventWriter.writeNull();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.lang.reflect.Modifier;
|
|||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
@ -19,7 +18,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hamcrest.core.IsNot;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
|
@ -37,8 +35,8 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.MethodNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.provider.ServerProfileProvider;
|
||||
import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.provider.ServerProfileProvider;
|
||||
|
||||
public abstract class RestfulServer extends HttpServlet {
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package ca.uhn.fhir.parser;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -34,6 +35,8 @@ public class JsonParserTest {
|
|||
UndeclaredExtension undeclaredExtension = undeclaredExtensions.get(0);
|
||||
assertEquals("http://hl7.org/fhir/Profile/iso-21090#qualifier", undeclaredExtension.getUrl());
|
||||
|
||||
ctx.newJsonParser().setPrettyPrint(true).encodeResourceToWriter(obs, new OutputStreamWriter(System.out));
|
||||
|
||||
String encoded = ctx.newJsonParser().encodeResourceToString(obs);
|
||||
ourLog.info(encoded);
|
||||
|
||||
|
|
Loading…
Reference in New Issue