Bump up hamcrest version and force the use of the latest version
This commit is contained in:
parent
68f437177d
commit
e0b419354f
|
@ -6,7 +6,9 @@ import ca.uhn.fhir.parser.LenientErrorHandler;
|
|||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class TolerantJsonParserR4Test {
|
||||
|
||||
|
@ -42,7 +44,7 @@ public class TolerantJsonParserR4Test {
|
|||
try {
|
||||
parser.parseResource(Observation.class, input);
|
||||
} catch (DataFormatException e) {
|
||||
assertEquals("[element=\"value\"] Invalid attribute value \".\": No digits found.", e.getMessage());
|
||||
assertThat(e.getMessage(), containsString("[element=\"value\"] Invalid attribute value \".\""));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,14 +3,16 @@ package ca.uhn.fhir.rest.server;
|
|||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import java.util.List;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import org.hl7.fhir.instance.model.api.IBaseMetaType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class CommonResourceSupertypeScannerTest {
|
||||
|
||||
private final CommonResourceSupertypeScanner scanner = new CommonResourceSupertypeScanner();
|
||||
|
|
|
@ -612,8 +612,7 @@ public class XmlParserDstu2_1Test {
|
|||
String out = xmlParser.encodeResourceToString(patient);
|
||||
ourLog.info(out);
|
||||
|
||||
//@formatter:off
|
||||
assertThat(out, stringContainsInOrder("<identifier>",
|
||||
assertThat(out, stringContainsInOrder("<identifier>",
|
||||
"<type>",
|
||||
"<coding>",
|
||||
"<system value=\"http://hl7.org/fhir/v2/0203\"/>",
|
||||
|
@ -623,7 +622,6 @@ public class XmlParserDstu2_1Test {
|
|||
"<system value=\"SYS\"/>",
|
||||
"<value value=\"VAL\"/>",
|
||||
"</identifier>"));
|
||||
//@formatter:on
|
||||
|
||||
patient = ourCtx.newXmlParser().parseResource(Patient.class, out);
|
||||
assertEquals("http://hl7.org/fhir/v2/0203", patient.getIdentifier().get(0).getType().getCoding().get(0).getSystem());
|
||||
|
@ -645,120 +643,6 @@ public class XmlParserDstu2_1Test {
|
|||
assertEquals("2015-10-05", mo.getDateWrittenElement().getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeAndParseMetaProfileAndTags() {
|
||||
Patient p = new Patient();
|
||||
p.addName().addFamily("FAMILY");
|
||||
|
||||
p.getMeta().addProfile("http://foo/Profile1");
|
||||
p.getMeta().addProfile("http://foo/Profile2");
|
||||
|
||||
p.getMeta().addTag().setSystem("scheme1").setCode("term1").setDisplay("label1");
|
||||
p.getMeta().addTag().setSystem("scheme2").setCode("term2").setDisplay("label2");
|
||||
|
||||
p.getMeta().addSecurity().setSystem("sec_scheme1").setCode("sec_term1").setDisplay("sec_label1");
|
||||
p.getMeta().addSecurity().setSystem("sec_scheme2").setCode("sec_term2").setDisplay("sec_label2");
|
||||
|
||||
String enc = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p);
|
||||
ourLog.info(enc);
|
||||
|
||||
//@formatter:off
|
||||
assertThat(enc, stringContainsInOrder("<Patient xmlns=\"http://hl7.org/fhir\">",
|
||||
"<meta>",
|
||||
"<meta>",
|
||||
"<profile value=\"http://foo/Profile1\"/>",
|
||||
"<profile value=\"http://foo/Profile2\"/>",
|
||||
"<tag>",
|
||||
"<system value=\"scheme1\"/>",
|
||||
"<code value=\"term1\"/>",
|
||||
"<display value=\"label1\"/>",
|
||||
"</tag>",
|
||||
"<tag>",
|
||||
"<system value=\"scheme2\"/>",
|
||||
"<code value=\"term2\"/>",
|
||||
"<display value=\"label2\"/>",
|
||||
"</tag>",
|
||||
"</meta>",
|
||||
"</meta>",
|
||||
"<name>",
|
||||
"<family value=\"FAMILY\"/>",
|
||||
"</name>",
|
||||
"</Patient>"));
|
||||
//@formatter:on
|
||||
|
||||
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, enc);
|
||||
List<UriType> gotLabels = parsed.getMeta().getProfile();
|
||||
assertEquals(2, gotLabels.size());
|
||||
UriType label = gotLabels.get(0);
|
||||
assertEquals("http://foo/Profile1", label.getValue());
|
||||
label = gotLabels.get(1);
|
||||
assertEquals("http://foo/Profile2", label.getValue());
|
||||
|
||||
List<Coding> tagList = parsed.getMeta().getTag();
|
||||
assertEquals(2, tagList.size());
|
||||
assertEquals("scheme1", tagList.get(0).getSystem());
|
||||
assertEquals("term1", tagList.get(0).getCode());
|
||||
assertEquals("label1", tagList.get(0).getDisplay());
|
||||
assertEquals("scheme2", tagList.get(1).getSystem());
|
||||
assertEquals("term2", tagList.get(1).getCode());
|
||||
assertEquals("label2", tagList.get(1).getDisplay());
|
||||
|
||||
tagList = parsed.getMeta().getSecurity();
|
||||
assertEquals(2, tagList.size());
|
||||
assertEquals("sec_scheme1", tagList.get(0).getSystem());
|
||||
assertEquals("sec_term1", tagList.get(0).getCode());
|
||||
assertEquals("sec_label1", tagList.get(0).getDisplay());
|
||||
assertEquals("sec_scheme2", tagList.get(1).getSystem());
|
||||
assertEquals("sec_term2", tagList.get(1).getCode());
|
||||
assertEquals("sec_label2", tagList.get(1).getDisplay());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeAndParseMetaProfiles() {
|
||||
Patient p = new Patient();
|
||||
p.addName().addFamily("FAMILY");
|
||||
|
||||
p.getMeta().addTag().setSystem("scheme1").setCode("term1").setDisplay("label1");
|
||||
p.getMeta().addTag().setSystem("scheme2").setCode("term2").setDisplay("label2");
|
||||
|
||||
String enc = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p);
|
||||
ourLog.info(enc);
|
||||
|
||||
//@formatter:off
|
||||
assertThat(enc, stringContainsInOrder("<Patient xmlns=\"http://hl7.org/fhir\">",
|
||||
"<meta>",
|
||||
"<meta>",
|
||||
"<tag>",
|
||||
"<system value=\"scheme1\"/>",
|
||||
"<code value=\"term1\"/>",
|
||||
"<display value=\"label1\"/>",
|
||||
"</tag>",
|
||||
"<tag>",
|
||||
"<system value=\"scheme2\"/>",
|
||||
"<code value=\"term2\"/>",
|
||||
"<display value=\"label2\"/>",
|
||||
"</tag>",
|
||||
"</meta>",
|
||||
"</meta>",
|
||||
"<name>",
|
||||
"<family value=\"FAMILY\"/>",
|
||||
"</name>",
|
||||
"</Patient>"));
|
||||
//@formatter:on
|
||||
|
||||
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, enc);
|
||||
assertThat(parsed.getMeta().getProfile(), empty());
|
||||
|
||||
List<Coding> tagList = parsed.getMeta().getTag();
|
||||
assertEquals(2, tagList.size());
|
||||
assertEquals("scheme1", tagList.get(0).getSystem());
|
||||
assertEquals("term1", tagList.get(0).getCode());
|
||||
assertEquals("label1", tagList.get(0).getDisplay());
|
||||
assertEquals("scheme2", tagList.get(1).getSystem());
|
||||
assertEquals("term2", tagList.get(1).getCode());
|
||||
assertEquals("label2", tagList.get(1).getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #336
|
||||
*/
|
||||
|
|
|
@ -91,7 +91,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
|
||||
/**
|
||||
* We specifically include extensions on CapabilityStatment even in
|
||||
* We specifically include extensions on CapabilityStatement even in
|
||||
* summary mode, since this is behaviour that people depend on
|
||||
*/
|
||||
@Test
|
||||
|
@ -839,7 +839,6 @@ public class XmlParserDstu3Test {
|
|||
ourLog.info(enc);
|
||||
|
||||
assertThat(enc, stringContainsInOrder("<Patient xmlns=\"http://hl7.org/fhir\">",
|
||||
"<meta>",
|
||||
"<meta>",
|
||||
"<profile value=\"http://foo/Profile1\"/>",
|
||||
"<profile value=\"http://foo/Profile2\"/>",
|
||||
|
@ -854,7 +853,6 @@ public class XmlParserDstu3Test {
|
|||
"<display value=\"label2\"/>",
|
||||
"</tag>",
|
||||
"</meta>",
|
||||
"</meta>",
|
||||
"<name>",
|
||||
"<family value=\"FAMILY\"/>",
|
||||
"</name>",
|
||||
|
@ -899,7 +897,6 @@ public class XmlParserDstu3Test {
|
|||
ourLog.info(enc);
|
||||
|
||||
assertThat(enc, stringContainsInOrder("<Patient xmlns=\"http://hl7.org/fhir\">",
|
||||
"<meta>",
|
||||
"<meta>",
|
||||
"<tag>",
|
||||
"<system value=\"scheme1\"/>",
|
||||
|
@ -912,7 +909,6 @@ public class XmlParserDstu3Test {
|
|||
"<display value=\"label2\"/>",
|
||||
"</tag>",
|
||||
"</meta>",
|
||||
"</meta>",
|
||||
"<name>",
|
||||
"<family value=\"FAMILY\"/>",
|
||||
"</name>",
|
||||
|
@ -1935,7 +1931,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeUndeclaredBlock() throws Exception {
|
||||
public void testEncodeUndeclaredBlock() {
|
||||
FooMessageHeader.FooMessageSourceComponent source = new FooMessageHeader.FooMessageSourceComponent();
|
||||
source.getMessageHeaderApplicationId().setValue("APPID");
|
||||
source.setName("NAME");
|
||||
|
@ -1965,7 +1961,7 @@ public class XmlParserDstu3Test {
|
|||
Patient patient = new Patient();
|
||||
patient.addAddress().setUse(AddressUse.HOME);
|
||||
EnumFactory<AddressUse> fact = new AddressUseEnumFactory();
|
||||
PrimitiveType<AddressUse> enumeration = new Enumeration<AddressUse>(fact).setValue(AddressUse.HOME);
|
||||
PrimitiveType<AddressUse> enumeration = new Enumeration<>(fact).setValue(AddressUse.HOME);
|
||||
patient.addExtension().setUrl("urn:foo").setValue(enumeration);
|
||||
|
||||
String val = parser.encodeResourceToString(patient);
|
||||
|
@ -1981,7 +1977,7 @@ public class XmlParserDstu3Test {
|
|||
|
||||
@Test
|
||||
public void testEncodeWithContained() {
|
||||
List<Resource> contained = new ArrayList<Resource>();
|
||||
List<Resource> contained = new ArrayList<>();
|
||||
|
||||
// Will be added by reference
|
||||
Patient p = new Patient();
|
||||
|
@ -2037,7 +2033,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeWithDontEncodeElements() throws Exception {
|
||||
public void testEncodeWithDontEncodeElements() {
|
||||
Patient patient = new Patient();
|
||||
patient.setId("123");
|
||||
patient.getMeta().addProfile("http://profile");
|
||||
|
@ -2092,7 +2088,7 @@ public class XmlParserDstu3Test {
|
|||
{
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
p.setDontEncodeElements(Sets.newHashSet("Patient.meta"));
|
||||
p.setEncodeElements(new HashSet<String>(Arrays.asList("Patient.name")));
|
||||
p.setEncodeElements(new HashSet<>(Arrays.asList("Patient.name")));
|
||||
p.setPrettyPrint(true);
|
||||
String out = p.encodeResourceToString(patient);
|
||||
ourLog.info(out);
|
||||
|
@ -2106,7 +2102,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeWithEncodeElements() throws Exception {
|
||||
public void testEncodeWithEncodeElements() {
|
||||
Patient patient = new Patient();
|
||||
patient.getMeta().addProfile("http://profile");
|
||||
patient.addName().setFamily("FAMILY");
|
||||
|
@ -2129,7 +2125,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
{
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
p.setEncodeElements(new HashSet<String>(Arrays.asList("Patient.name")));
|
||||
p.setEncodeElements(new HashSet<>(Arrays.asList("Patient.name")));
|
||||
p.setPrettyPrint(true);
|
||||
String out = p.encodeResourceToString(bundle);
|
||||
ourLog.info(out);
|
||||
|
@ -2140,7 +2136,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
{
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
p.setEncodeElements(new HashSet<String>(Arrays.asList("Patient")));
|
||||
p.setEncodeElements(new HashSet<>(Arrays.asList("Patient")));
|
||||
p.setPrettyPrint(true);
|
||||
String out = p.encodeResourceToString(bundle);
|
||||
ourLog.info(out);
|
||||
|
@ -2153,7 +2149,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeWithEncodeElementsAppliesToChildResourcesOnly() throws Exception {
|
||||
public void testEncodeWithEncodeElementsAppliesToChildResourcesOnly() {
|
||||
Patient patient = new Patient();
|
||||
patient.getMeta().addProfile("http://profile");
|
||||
patient.addName().setFamily("FAMILY");
|
||||
|
@ -2208,7 +2204,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMoreExtensions() throws Exception {
|
||||
public void testMoreExtensions() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");
|
||||
|
|
|
@ -7,6 +7,7 @@ import ca.uhn.fhir.rest.annotation.Search;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.SummaryEnum;
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -18,9 +19,12 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.MedicationRequest;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -32,14 +36,13 @@ import java.util.List;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsStringIgnoringCase;
|
||||
import static org.hamcrest.CoreMatchers.containsStringIgnoringCase;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.containsStringIgnoringCase;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import ca.uhn.fhir.test.utilities.JettyUtil;
|
||||
|
||||
public class SummaryParamR4Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SummaryParamR4Test.class);
|
||||
|
@ -223,7 +226,7 @@ public class SummaryParamR4Test {
|
|||
assertThat(responseContent, (containsString("entry")));
|
||||
assertThat(responseContent, (containsString(">TEXT<")));
|
||||
assertThat(responseContent, (containsString("Medication/123")));
|
||||
assertThat(responseContent, not(CoreMatchers.containsStringIgnoringCase("note")));
|
||||
assertThat(responseContent, not(containsStringIgnoringCase("note")));
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -644,7 +644,6 @@ public class XmlParserDstu2_1Test {
|
|||
|
||||
//@formatter:off
|
||||
assertThat(enc, stringContainsInOrder("<Patient xmlns=\"http://hl7.org/fhir\">",
|
||||
"<meta>",
|
||||
"<meta>",
|
||||
"<profile value=\"http://foo/Profile1\"/>",
|
||||
"<profile value=\"http://foo/Profile2\"/>",
|
||||
|
@ -659,7 +658,6 @@ public class XmlParserDstu2_1Test {
|
|||
"<display value=\"label2\"/>",
|
||||
"</tag>",
|
||||
"</meta>",
|
||||
"</meta>",
|
||||
"<name>",
|
||||
"<family value=\"FAMILY\"/>",
|
||||
"</name>",
|
||||
|
@ -706,7 +704,6 @@ public class XmlParserDstu2_1Test {
|
|||
|
||||
//@formatter:off
|
||||
assertThat(enc, stringContainsInOrder("<Patient xmlns=\"http://hl7.org/fhir\">",
|
||||
"<meta>",
|
||||
"<meta>",
|
||||
"<tag>",
|
||||
"<system value=\"scheme1\"/>",
|
||||
|
@ -719,7 +716,6 @@ public class XmlParserDstu2_1Test {
|
|||
"<display value=\"label2\"/>",
|
||||
"</tag>",
|
||||
"</meta>",
|
||||
"</meta>",
|
||||
"<name>",
|
||||
"<family value=\"FAMILY\"/>",
|
||||
"</name>",
|
||||
|
|
|
@ -755,7 +755,6 @@ public class Dstu3XmlParserTest {
|
|||
ourLog.info(enc);
|
||||
|
||||
assertThat(enc, stringContainsInOrder("<Patient xmlns=\"http://hl7.org/fhir\">",
|
||||
"<meta>",
|
||||
"<meta>",
|
||||
"<profile value=\"http://foo/Profile1\"/>",
|
||||
"<profile value=\"http://foo/Profile2\"/>",
|
||||
|
@ -770,7 +769,6 @@ public class Dstu3XmlParserTest {
|
|||
"<display value=\"label2\"/>",
|
||||
"</tag>",
|
||||
"</meta>",
|
||||
"</meta>",
|
||||
"<name>",
|
||||
"<family value=\"FAMILY\"/>",
|
||||
"</name>",
|
||||
|
@ -815,7 +813,6 @@ public class Dstu3XmlParserTest {
|
|||
ourLog.info(enc);
|
||||
|
||||
assertThat(enc, stringContainsInOrder("<Patient xmlns=\"http://hl7.org/fhir\">",
|
||||
"<meta>",
|
||||
"<meta>",
|
||||
"<tag>",
|
||||
"<system value=\"scheme1\"/>",
|
||||
|
@ -828,7 +825,6 @@ public class Dstu3XmlParserTest {
|
|||
"<display value=\"label2\"/>",
|
||||
"</tag>",
|
||||
"</meta>",
|
||||
"</meta>",
|
||||
"<name>",
|
||||
"<family value=\"FAMILY\"/>",
|
||||
"</name>",
|
||||
|
|
10
pom.xml
10
pom.xml
|
@ -76,14 +76,14 @@
|
|||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>java-hamcrest</artifactId>
|
||||
<artifactId>hamcrest</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -1278,11 +1278,17 @@
|
|||
<artifactId>jscience</artifactId>
|
||||
<version>4.3.1</version>
|
||||
</dependency>
|
||||
<!-- TODO: remove this once we're fully switched over to hamcrest 2.2 -->
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>java-hamcrest</artifactId>
|
||||
<version>2.0.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
|
|
Loading…
Reference in New Issue