Work on getting java9 building
This commit is contained in:
parent
f66e6d055e
commit
7688be1231
|
@ -80,23 +80,13 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-jetty-http</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -88,6 +88,11 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Unit test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
|
@ -109,6 +114,20 @@
|
|||
<artifactId>jetty-servlet</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
|
@ -129,6 +148,8 @@
|
|||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
|
|
|
@ -69,6 +69,7 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
|||
private org.hl7.fhir.dstu2016may.model.Conformance myDstu2_1Conformance;
|
||||
private org.hl7.fhir.instance.model.Conformance myDstu2Hl7OrgConformance;
|
||||
private ca.uhn.fhir.model.dstu2.resource.Conformance myDstu2Conformance;
|
||||
private boolean myInitialized;
|
||||
|
||||
/**
|
||||
* Constructor allowing the description, servername and server to be set
|
||||
|
@ -112,7 +113,11 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
|||
* conformance
|
||||
*/
|
||||
@PostConstruct
|
||||
protected void setUpPostConstruct() {
|
||||
protected synchronized void setUpPostConstruct() {
|
||||
if (myInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entry<Class<? extends IResourceProvider>, IResourceProvider> provider : getProviders().entrySet()) {
|
||||
addProvider(provider.getValue(), provider.getKey());
|
||||
}
|
||||
|
@ -155,6 +160,8 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
|||
default:
|
||||
throw new ConfigurationException("Unsupported Fhir version: " + fhirContextVersion);
|
||||
}
|
||||
|
||||
myInitialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,6 +191,8 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
|||
@GET
|
||||
@Path("/metadata")
|
||||
public Response conformance() throws IOException {
|
||||
setUpPostConstruct();
|
||||
|
||||
Builder request = getRequest(RequestTypeEnum.OPTIONS, RestOperationTypeEnum.METADATA);
|
||||
IRestfulResponse response = request.build().getResponse();
|
||||
response.addHeader(Constants.HEADER_CORS_ALLOW_ORIGIN, "*");
|
||||
|
|
|
@ -47,8 +47,8 @@ import ca.uhn.fhir.rest.server.method.BaseMethodBinding;
|
|||
* a large amount of the fhir api functionality using JAXRS
|
||||
* @author Peter Van Houte | peter.vanhoute@agfa.com | Agfa Healthcare
|
||||
*/
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML, Constants.CT_FHIR_JSON_NEW, Constants.CT_FHIR_XML_NEW })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML })
|
||||
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML, Constants.CT_FHIR_JSON_NEW, Constants.CT_FHIR_XML_NEW, "application/octet-stream" })
|
||||
@Interceptors(JaxRsExceptionInterceptor.class)
|
||||
public abstract class AbstractJaxRsResourceProvider<R extends IBaseResource> extends AbstractJaxRsProvider
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class JaxRsMethodBindings {
|
|||
*/
|
||||
public BaseMethodBinding<?> getBinding(RestOperationTypeEnum operationType, String theBindingKey) {
|
||||
String bindingKey = StringUtils.defaultIfBlank(theBindingKey, DEFAULT_METHOD_KEY);
|
||||
ConcurrentHashMap<String, BaseMethodBinding<?>> map = operationBindings.get(operationType);
|
||||
ConcurrentHashMap<String, BaseMethodBinding<?>> map = getMapForOperation(operationType);
|
||||
if(map == null || !map.containsKey(bindingKey)) {
|
||||
throw new NotImplementedOperationException("Operation not implemented");
|
||||
} else {
|
||||
|
|
|
@ -6,6 +6,7 @@ import static org.junit.Assert.*;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Priority;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -81,7 +82,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderFetchConformance() throws Exception {
|
||||
public void testAcceptHeaderFetchConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Conformance conf = new Conformance();
|
||||
|
@ -115,7 +116,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformance() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformance() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final Conformance conf = new Conformance();
|
||||
|
@ -145,7 +146,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final Conformance conf = new Conformance();
|
||||
|
@ -175,7 +176,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testConformance() throws Exception {
|
||||
public void testConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Conformance conf = new Conformance();
|
||||
|
@ -198,7 +199,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testProviderWhereWeForgotToSetTheContext() throws Exception {
|
||||
public void testProviderWhereWeForgotToSetTheContext() {
|
||||
JaxRsRestfulClientFactory clientFactory = new JaxRsRestfulClientFactory(); // no ctx
|
||||
clientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
|
||||
|
@ -214,7 +215,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
public void testCreate() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
|
@ -246,7 +247,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateConditional() throws Exception {
|
||||
public void testCreateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -290,7 +291,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
@Test
|
||||
public void testCreatePrefer() throws Exception {
|
||||
public void testCreatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -315,7 +316,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateReturningResourceBody() throws Exception {
|
||||
public void testCreateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
@ -338,7 +339,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteConditional() throws Exception {
|
||||
public void testDeleteConditional() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -363,7 +364,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() throws Exception {
|
||||
public void testDelete() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -377,7 +378,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHistory() throws Exception {
|
||||
public void testHistory() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -474,7 +475,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetaAdd() throws Exception {
|
||||
public void testMetaAdd() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
MetaDt inMeta = new MetaDt().addProfile("urn:profile:in");
|
||||
|
@ -507,7 +508,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetaGet() throws Exception {
|
||||
public void testMetaGet() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -563,7 +564,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithInParameters() throws Exception {
|
||||
public void testOperationAsGetWithInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -642,7 +643,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithNoInParameters() throws Exception {
|
||||
public void testOperationAsGetWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -713,7 +714,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseJson() throws Exception {
|
||||
public void testOperationWithBundleResponseJson() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_JSON;
|
||||
final String respString = "{\n" + " \"resourceType\":\"Bundle\",\n" + " \"id\":\"8cef5f2a-0ba9-43a5-be26-c8dde9ff0e19\",\n" + " \"base\":\"http://localhost:" + ourPort + "/fhir\"\n" + "}";
|
||||
|
@ -743,7 +744,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseXml() throws Exception {
|
||||
public void testOperationWithBundleResponseXml() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -780,7 +781,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithInlineParams() throws Exception {
|
||||
public void testOperationWithInlineParams() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -899,7 +900,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithProfiledDatatypeParam() throws IOException, Exception {
|
||||
public void testOperationWithProfiledDatatypeParam() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -948,7 +949,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithListOfParameterResponse() throws Exception {
|
||||
public void testOperationWithListOfParameterResponse() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -1023,7 +1024,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithNoInParameters() throws Exception {
|
||||
public void testOperationWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -1102,7 +1103,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPageNext() throws Exception {
|
||||
public void testPageNext() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
|
||||
ourResponseBody = getPatientFeedWithOneResult();
|
||||
|
@ -1129,7 +1130,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPageNextNoLink() throws Exception {
|
||||
public void testPageNextNoLink() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle sourceBundle = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
|
@ -1141,7 +1142,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPagePrev() throws Exception {
|
||||
public void testPagePrev() {
|
||||
|
||||
|
||||
|
||||
|
@ -1187,7 +1188,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadByUri() throws Exception {
|
||||
public void testReadByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().addFamily("FAM");
|
||||
|
@ -1207,7 +1208,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadFluentByUri() throws Exception {
|
||||
public void testReadFluentByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().addFamily("FAM");
|
||||
|
@ -1220,13 +1221,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
Patient response;
|
||||
|
||||
response = (Patient) client.read().resource(Patient.class).withUrl(new IdDt("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
response = client.read().resource(Patient.class).withUrl(new IdDt("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
assertEquals("http://localhost:" + ourPort + "/AAA/Patient/123", ourRequestUri);
|
||||
assertEquals("FAM", response.getName().get(0).getFamily().get(0).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() throws Exception {
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() {
|
||||
|
||||
|
||||
final String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
|
@ -1264,7 +1265,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithElementsParam() throws Exception {
|
||||
public void testReadWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";
|
||||
|
||||
|
||||
|
@ -1287,7 +1288,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryInvalid() throws Exception {
|
||||
public void testReadWithSummaryInvalid() {
|
||||
String msg = "<>>>><<<<>";
|
||||
|
||||
|
||||
|
@ -1313,7 +1314,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryParamHtml() throws Exception {
|
||||
public void testReadWithSummaryParamHtml() {
|
||||
String msg = "<div>HELP IM A DIV</div>";
|
||||
|
||||
|
||||
|
@ -1338,7 +1339,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByString() throws Exception {
|
||||
public void testSearchByString() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1362,7 +1363,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByUrl() throws Exception {
|
||||
public void testSearchByUrl() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -1469,7 +1470,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithElementsParam() throws Exception {
|
||||
public void testSearchWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1496,7 +1497,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPost() throws Exception {
|
||||
public void testSearchByPost() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1533,7 +1534,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPostUseJson() throws Exception {
|
||||
public void testSearchByPostUseJson() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1571,7 +1572,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithLastUpdated() throws Exception {
|
||||
public void testSearchWithLastUpdated() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1598,7 +1599,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithProfileAndSecurity() throws Exception {
|
||||
public void testSearchWithProfileAndSecurity() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1628,7 +1629,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchWithReverseInclude() throws Exception {
|
||||
public void testSearchWithReverseInclude() {
|
||||
|
||||
String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -1655,7 +1656,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithSummaryParam() throws Exception {
|
||||
public void testSearchWithSummaryParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1682,7 +1683,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithListOfResources() throws Exception {
|
||||
public void testTransactionWithListOfResources() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
|
@ -1735,7 +1736,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithString() throws Exception {
|
||||
public void testTransactionWithString() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle req = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
Patient patient = new Patient();
|
||||
|
@ -1781,7 +1782,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithTransactionResource() throws Exception {
|
||||
public void testTransactionWithTransactionResource() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
|
@ -1822,7 +1823,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateConditional() throws Exception {
|
||||
public void testUpdateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1877,7 +1878,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNonFluent() throws Exception {
|
||||
public void testUpdateNonFluent() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1907,7 +1908,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePrefer() throws Exception {
|
||||
public void testUpdatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1933,7 +1934,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateReturningResourceBody() throws Exception {
|
||||
public void testUpdateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
@ -1956,7 +1957,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateFluent() throws Exception {
|
||||
public void testValidateFluent() {
|
||||
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
|
@ -2010,7 +2011,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateNonFluent() throws Exception {
|
||||
public void testValidateNonFluent() {
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
final String msg = ourCtx.newXmlParser().encodeResourceToString(oo);
|
||||
|
@ -2080,7 +2081,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
ourServer.setHandler(new AbstractHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException, ServletException {
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException {
|
||||
theRequest.setHandled(true);
|
||||
ourRequestUri = "http:" + theRequest.getHttpURI().toString();
|
||||
ourRequestUriAll.add(ourRequestUri);
|
||||
|
|
|
@ -79,7 +79,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderFetchConformance() throws Exception {
|
||||
public void testAcceptHeaderFetchConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
CapabilityStatement conf = new CapabilityStatement();
|
||||
|
@ -113,7 +113,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformance() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformance() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final CapabilityStatement conf = new CapabilityStatement();
|
||||
|
@ -143,7 +143,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final CapabilityStatement conf = new CapabilityStatement();
|
||||
|
@ -172,7 +172,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConformance() throws Exception {
|
||||
public void testConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
CapabilityStatement conf = new CapabilityStatement();
|
||||
|
@ -188,7 +188,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
|
||||
//@formatter:off
|
||||
CapabilityStatement resp = (CapabilityStatement)client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
CapabilityStatement resp = client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
|
||||
//@formatter:on
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/metadata", ourRequestUri);
|
||||
|
@ -199,7 +199,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testProviderWhereWeForgotToSetTheContext() throws Exception {
|
||||
public void testProviderWhereWeForgotToSetTheContext() {
|
||||
JaxRsRestfulClientFactory clientFactory = new JaxRsRestfulClientFactory(); // no ctx
|
||||
clientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
public void testCreate() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
|
@ -247,7 +247,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateConditional() throws Exception {
|
||||
public void testCreateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -289,7 +289,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreate2() throws Exception {
|
||||
public void testCreate2() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -310,7 +310,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreatePrefer() throws Exception {
|
||||
public void testCreatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -335,7 +335,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateReturningResourceBody() throws Exception {
|
||||
public void testCreateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
@ -358,7 +358,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteConditional() throws Exception {
|
||||
public void testDeleteConditional() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -384,7 +384,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testDeleteNonFluent() throws Exception {
|
||||
public void testDeleteNonFluent() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -398,7 +398,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHistory() throws Exception {
|
||||
public void testHistory() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -494,7 +494,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetaAdd() throws Exception {
|
||||
public void testMetaAdd() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Meta inMeta = new Meta().addProfile("urn:profile:in");
|
||||
|
@ -527,7 +527,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetaGet() throws Exception {
|
||||
public void testMetaGet() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -583,7 +583,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithInParameters() throws Exception {
|
||||
public void testOperationAsGetWithInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -662,7 +662,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithNoInParameters() throws Exception {
|
||||
public void testOperationAsGetWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -733,7 +733,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseJson() throws Exception {
|
||||
public void testOperationWithBundleResponseJson() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_JSON;
|
||||
final String respString = "{\n" + " \"resourceType\":\"Bundle\",\n" + " \"id\":\"8cef5f2a-0ba9-43a5-be26-c8dde9ff0e19\",\n" + " \"base\":\"http://localhost:" + ourPort + "/fhir\"\n" + "}";
|
||||
|
@ -763,7 +763,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseXml() throws Exception {
|
||||
public void testOperationWithBundleResponseXml() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -800,7 +800,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithInlineParams() throws Exception {
|
||||
public void testOperationWithInlineParams() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -919,7 +919,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithProfiledDatatypeParam() throws IOException, Exception {
|
||||
public void testOperationWithProfiledDatatypeParam() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -968,7 +968,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithListOfParameterResponse() throws Exception {
|
||||
public void testOperationWithListOfParameterResponse() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -1043,7 +1043,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithNoInParameters() throws Exception {
|
||||
public void testOperationWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -1122,7 +1122,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPageNext() throws Exception {
|
||||
public void testPageNext() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
|
||||
ourResponseBody = getPatientFeedWithOneResult();
|
||||
|
@ -1149,7 +1149,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPageNextNoLink() throws Exception {
|
||||
public void testPageNextNoLink() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle sourceBundle = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
|
@ -1161,7 +1161,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPagePrev() throws Exception {
|
||||
public void testPagePrev() {
|
||||
|
||||
|
||||
|
||||
|
@ -1207,7 +1207,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadByUri() throws Exception {
|
||||
public void testReadByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().setFamily("FAM");
|
||||
|
@ -1227,7 +1227,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadFluentByUri() throws Exception {
|
||||
public void testReadFluentByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().setFamily("FAM");
|
||||
|
@ -1240,13 +1240,13 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
Patient response;
|
||||
|
||||
response = (Patient) client.read().resource(Patient.class).withUrl(new IdType("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
response = client.read().resource(Patient.class).withUrl(new IdType("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
assertEquals("http://localhost:" + ourPort + "/AAA/Patient/123", ourRequestUri);
|
||||
assertEquals("FAM", response.getName().get(0).getFamily());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() throws Exception {
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() {
|
||||
|
||||
//@formatter:off
|
||||
final String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
|
@ -1286,7 +1286,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithElementsParam() throws Exception {
|
||||
public void testReadWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";
|
||||
|
||||
|
||||
|
@ -1311,7 +1311,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryInvalid() throws Exception {
|
||||
public void testReadWithSummaryInvalid() {
|
||||
String msg = "<>>>><<<<>";
|
||||
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryParamHtml() throws Exception {
|
||||
public void testReadWithSummaryParamHtml() {
|
||||
String msg = "<div>HELP IM A DIV</div>";
|
||||
|
||||
|
||||
|
@ -1365,7 +1365,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByString() throws Exception {
|
||||
public void testSearchByString() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1391,7 +1391,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByUrl() throws Exception {
|
||||
public void testSearchByUrl() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -1498,7 +1498,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithElementsParam() throws Exception {
|
||||
public void testSearchWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1525,7 +1525,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPost() throws Exception {
|
||||
public void testSearchByPost() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1562,7 +1562,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPostUseJson() throws Exception {
|
||||
public void testSearchByPostUseJson() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1600,7 +1600,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithLastUpdated() throws Exception {
|
||||
public void testSearchWithLastUpdated() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1627,7 +1627,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithProfileAndSecurity() throws Exception {
|
||||
public void testSearchWithProfileAndSecurity() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1657,7 +1657,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchWithReverseInclude() throws Exception {
|
||||
public void testSearchWithReverseInclude() {
|
||||
|
||||
String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -1684,7 +1684,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithSummaryParam() throws Exception {
|
||||
public void testSearchWithSummaryParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1711,7 +1711,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithListOfResources() throws Exception {
|
||||
public void testTransactionWithListOfResources() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle resp = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
|
@ -1764,7 +1764,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithString() throws Exception {
|
||||
public void testTransactionWithString() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle req = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
Patient patient = new Patient();
|
||||
|
@ -1810,7 +1810,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithTransactionResource() throws Exception {
|
||||
public void testTransactionWithTransactionResource() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle resp = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
|
@ -1851,7 +1851,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateConditional() throws Exception {
|
||||
public void testUpdateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1906,7 +1906,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNonFluent() throws Exception {
|
||||
public void testUpdateNonFluent() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1936,7 +1936,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePrefer() throws Exception {
|
||||
public void testUpdatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1962,7 +1962,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateReturningResourceBody() throws Exception {
|
||||
public void testUpdateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
@ -1985,7 +1985,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateFluent() throws Exception {
|
||||
public void testValidateFluent() {
|
||||
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
|
@ -2039,7 +2039,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateNonFluent() throws Exception {
|
||||
public void testValidateNonFluent() {
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
final String msg = ourCtx.newXmlParser().encodeResourceToString(oo);
|
||||
|
@ -2109,7 +2109,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
ourServer.setHandler(new AbstractHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException, ServletException {
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException {
|
||||
theRequest.setHandled(true);
|
||||
ourRequestUri = "http:" + theRequest.getHttpURI().toString();
|
||||
ourRequestUriAll.add(ourRequestUri);
|
||||
|
|
|
@ -3,51 +3,56 @@ package ca.uhn.fhir.jaxrs.client;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Sebastien Riviere on 31/07/2017.
|
||||
*/
|
||||
public class JaxRsRestfulClientFactoryTest {
|
||||
|
||||
private final FhirContext context = FhirContext.forDstu2();
|
||||
private JaxRsRestfulClientFactory factory;
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(JaxRsRestfulClientFactoryTest.class);
|
||||
private final FhirContext context = FhirContext.forDstu2();
|
||||
private JaxRsRestfulClientFactory factory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
factory = new JaxRsRestfulClientFactory(context);
|
||||
}
|
||||
@Test
|
||||
public void emptyConstructorTest() {
|
||||
assertNotNull(new JaxRsRestfulClientFactory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyConstructorTest() {
|
||||
assertNotNull(new JaxRsRestfulClientFactory());
|
||||
}
|
||||
@Test
|
||||
public void getDefaultNativeClientTest() {
|
||||
assertNotNull(factory.getNativeClientClient());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultNativeClientTest() {
|
||||
assertNotNull(factory.getNativeClientClient());
|
||||
}
|
||||
@Test
|
||||
public void getNativeClientEmptyRegisteredComponentListTest() {
|
||||
factory.register(new ArrayList<>());
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
ourLog.info("Classes: {}", result.getConfiguration().getClasses());
|
||||
assertThat(result.getConfiguration().getClasses(), not(hasItem(ca.uhn.fhir.jaxrs.client.MyFilter.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNativeClientEmptyRegisteredComponentListTest() {
|
||||
factory.register(new ArrayList<Class<?>>());
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
assertTrue(result.getConfiguration().getClasses().isEmpty());
|
||||
}
|
||||
@Test
|
||||
public void getNativeClientRegisteredComponentListTest() {
|
||||
factory.register(Arrays.asList(MyFilter.class, String.class));
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
ourLog.info("Classes: {}", result.getConfiguration().getClasses());
|
||||
assertThat(result.getConfiguration().getClasses(), hasItem(ca.uhn.fhir.jaxrs.client.MyFilter.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNativeClientRegisteredComponentListTest() {
|
||||
factory.register(Arrays.asList(MyFilter.class, String.class));
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.getConfiguration().getClasses().size());
|
||||
}
|
||||
}
|
||||
@Before
|
||||
public void setUp() {
|
||||
factory = new JaxRsRestfulClientFactory(context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2Hl7Org;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu2Hl7OrgTest {
|
||||
|
||||
|
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderDstu2Hl7OrgTest {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2_1;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2_1;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2_1;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2_1;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu2_1Test {
|
||||
|
||||
|
@ -29,19 +26,20 @@ public class AbstractJaxRsConformanceProviderDstu2_1Test {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
providers = new ConcurrentHashMap<>();
|
||||
provider = createConformanceProvider(providers);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu3Test {
|
||||
|
||||
|
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderDstu3Test {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderR4;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderR4;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderR4;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderR4;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderR4Test {
|
||||
|
||||
|
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderR4Test {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
|
|
@ -1,26 +1,23 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProvider;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderTest {
|
||||
|
||||
|
@ -28,16 +25,17 @@ public class AbstractJaxRsConformanceProviderTest {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
|
|
@ -135,7 +135,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
@Test
|
||||
public void testConformance() {
|
||||
final CapabilityStatement conf = client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType().toString(), "Patient");
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType(), "Patient");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -149,7 +149,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome response = client.create().resource(toCreate).prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.execute();
|
||||
IBaseResource resource = (IBaseResource) response.getResource();
|
||||
IBaseResource resource = response.getResource();
|
||||
compareResultId(1, resource);
|
||||
assertEquals("myIdentifier", patientCaptor.getValue().getIdentifier().get(0).getValue());
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalDelete() throws Exception {
|
||||
public void testConditionalDelete() {
|
||||
when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome());
|
||||
client.delete().resourceConditionalByType("Patient").where(Patient.IDENTIFIER.exactly().identifier("2")).execute();
|
||||
assertEquals("Patient?identifier=2&_format=json", conditionalCaptor.getValue());
|
||||
|
@ -187,7 +187,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
assertEquals("outputValue", ((StringType)outParams.getParameter().get(0).getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
class StringTypeMatcher extends ArgumentMatcher<StringType> {
|
||||
class StringTypeMatcher implements ArgumentMatcher<StringType> {
|
||||
private StringType myStringType;
|
||||
|
||||
public StringTypeMatcher(StringType stringType) {
|
||||
|
@ -195,8 +195,8 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object argument) {
|
||||
return myStringType.getValue().equals(((StringType)argument).getValue());
|
||||
public boolean matches(StringType argument) {
|
||||
return myStringType.getValue().equals(argument.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -214,8 +214,14 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
inParams.addParameter().setName("dummy").setValue(new StringType("myAwesomeDummyValue"));
|
||||
|
||||
// invoke
|
||||
Parameters outParams = client.operation().onInstance(new IdType("Patient", "1")).named("$someCustomOperation")
|
||||
.withParameters(inParams).useHttpGet().execute();
|
||||
Parameters outParams = client
|
||||
.operation()
|
||||
.onInstance(new IdType("Patient", "1"))
|
||||
.named("$someCustomOperation")
|
||||
.withParameters(inParams)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
|
||||
// verify
|
||||
assertEquals("outputValue", ((StringType)outParams.getParameter().get(0).getValue()).getValueAsString());
|
||||
}
|
||||
|
@ -248,7 +254,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(ArgumentMatchers.isNull(), ArgumentMatchers.isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
org.hl7.fhir.dstu3.model.Bundle result = client.search().forResource("Patient").usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(org.hl7.fhir.dstu3.model.Bundle.class).execute();
|
||||
|
@ -275,12 +281,12 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
/** Search - Multi-valued Parameters (ANY/OR) */
|
||||
@Test
|
||||
public void testSearchUsingGenericClientBySearchWithMultiValues() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNotNull(StringAndListParam.class)))
|
||||
when(mock.search(any(StringParam.class), ArgumentMatchers.notNull()))
|
||||
.thenReturn(Arrays.asList(createPatient(1)));
|
||||
final Bundle results = client.search().forResource(Patient.class)
|
||||
.where(Patient.ADDRESS.matches().values("Toronto")).and(Patient.ADDRESS.matches().values("Ontario"))
|
||||
.and(Patient.ADDRESS.matches().values("Canada"))
|
||||
.where(Patient.IDENTIFIER.exactly().systemAndIdentifier("SHORTNAME", "TOYS")).returnBundle(Bundle.class).execute();
|
||||
.where(Patient.NAME.matches().value("SHORTNAME")).returnBundle(Bundle.class).execute();
|
||||
IBaseResource resource = results.getEntry().get(0).getResource();
|
||||
|
||||
compareResultId(1, resource);
|
||||
|
@ -291,7 +297,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
@Test
|
||||
public void testSearchWithPaging() {
|
||||
// Perform a search
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(ArgumentMatchers.isNull(), ArgumentMatchers.isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
final org.hl7.fhir.dstu3.model.Bundle results = client.search().forResource(Patient.class).count(8).returnBundle(org.hl7.fhir.dstu3.model.Bundle.class)
|
||||
.execute();
|
||||
|
@ -416,17 +422,17 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
TestJaxRsMockPatientRestProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
// JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
TestJaxRsConformanceRestProviderDstu3.class.getCanonicalName(),
|
||||
TestJaxRsMockPageProviderDstu3.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
|
||||
jettyServer.start();
|
||||
|
@ -441,7 +447,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
public static void tearDownClass() {
|
||||
try {
|
||||
jettyServer.destroy();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.junit.*;
|
|||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -127,7 +128,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
@Test
|
||||
public void testConformance() {
|
||||
final Conformance conf = client.fetchConformance().ofType(Conformance.class).execute();
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType().toString(), "Patient");
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType(), "Patient");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -154,7 +155,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalDelete() throws Exception {
|
||||
public void testConditionalDelete() {
|
||||
when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome());
|
||||
client.delete().resourceConditionalByType("Patient").where(Patient.IDENTIFIER.exactly().identifier("2")).execute();
|
||||
assertEquals("Patient?identifier=2&_format=json", conditionalCaptor.getValue());
|
||||
|
@ -226,9 +227,12 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(isNull(), isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
Bundle result = client.search().forResource("Patient").usingStyle(SearchStyleEnum.POST)
|
||||
Bundle result = client
|
||||
.search()
|
||||
.forResource("Patient")
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(Bundle.class).execute();
|
||||
IResource resource = result.getEntry().get(0).getResource();
|
||||
compareResultId(1, resource);
|
||||
|
@ -253,12 +257,12 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
/** Search - Multi-valued Parameters (ANY/OR) */
|
||||
@Test
|
||||
public void testSearchUsingGenericClientBySearchWithMultiValues() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNotNull(StringAndListParam.class)))
|
||||
when(mock.search(any(StringParam.class), any(StringAndListParam.class)))
|
||||
.thenReturn(Arrays.asList(createPatient(1)));
|
||||
Bundle results = client.search().forResource(Patient.class)
|
||||
.where(Patient.ADDRESS.matches().values("Toronto")).and(Patient.ADDRESS.matches().values("Ontario"))
|
||||
.and(Patient.ADDRESS.matches().values("Canada"))
|
||||
.where(Patient.IDENTIFIER.exactly().systemAndIdentifier("SHORTNAME", "TOYS")).returnBundle(Bundle.class).execute();
|
||||
.where(Patient.NAME.matches().value("SHORTNAME")).returnBundle(Bundle.class).execute();
|
||||
IResource resource = results.getEntry().get(0).getResource();
|
||||
|
||||
compareResultId(1, resource);
|
||||
|
@ -269,7 +273,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
@Test
|
||||
public void testSearchWithPaging() {
|
||||
// Perform a search
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(isNull(), isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
final Bundle results = client.search().forResource(Patient.class).limitTo(8).returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
@ -370,24 +374,17 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
}
|
||||
|
||||
private <T> T withId(final T id) {
|
||||
return argThat(new BaseMatcher<T>() {
|
||||
@Override
|
||||
public void describeTo(Description arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object other) {
|
||||
IdDt thisId;
|
||||
IdDt otherId;
|
||||
if (id instanceof IdDt) {
|
||||
thisId = (IdDt) id;
|
||||
otherId = (IdDt) other;
|
||||
} else {
|
||||
thisId = ((IResource) id).getId();
|
||||
otherId = ((IResource) other).getId();
|
||||
}
|
||||
return thisId.getIdPartAsLong().equals(otherId.getIdPartAsLong());
|
||||
return argThat(other -> {
|
||||
IdDt thisId;
|
||||
IdDt otherId;
|
||||
if (id instanceof IdDt) {
|
||||
thisId = (IdDt) id;
|
||||
otherId = (IdDt) other;
|
||||
} else {
|
||||
thisId = ((IResource) id).getId();
|
||||
otherId = ((IResource) other).getId();
|
||||
}
|
||||
return thisId.getIdPartAsLong().equals(otherId.getIdPartAsLong());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -399,17 +396,16 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
TestJaxRsMockPatientRestProvider.class.getCanonicalName(),
|
||||
JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
TestJaxRsConformanceRestProvider.class.getCanonicalName(),
|
||||
TestJaxRsMockPageProvider.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
|
||||
jettyServer.start();
|
||||
|
@ -424,7 +420,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
public static void tearDownClass() {
|
||||
try {
|
||||
jettyServer.destroy();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -1,34 +1,22 @@
|
|||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsRequest;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsResponse;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class JaxRsRequestDstu3Test {
|
||||
|
||||
|
@ -38,7 +26,7 @@ public class JaxRsRequestDstu3Test {
|
|||
|
||||
private JaxRsRequest details;
|
||||
private MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>();
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private TestJaxRsDummyPatientProviderDstu3 provider;
|
||||
|
||||
@Before
|
||||
|
@ -52,11 +40,11 @@ public class JaxRsRequestDstu3Test {
|
|||
String headerValue = "location_value";
|
||||
String headerValue2 = "location_value_2";
|
||||
assertTrue(StringUtils.isBlank(details.getHeader(headerKey)));
|
||||
headers.header(headerKey, headerValue);
|
||||
queryParameters.add(headerKey, headerValue);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue), details.getHeaders(headerKey));
|
||||
|
||||
headers.header(headerKey, headerValue2);
|
||||
queryParameters.add(headerKey, headerValue2);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue, headerValue2), details.getHeaders(headerKey));
|
||||
}
|
||||
|
@ -98,9 +86,9 @@ public class JaxRsRequestDstu3Test {
|
|||
assertEquals(this.provider, details.getServer());
|
||||
}
|
||||
|
||||
public JaxRsRequest createRequestDetails() throws URISyntaxException {
|
||||
//headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null, new MapPropertiesDelegate());
|
||||
public JaxRsRequest createRequestDetails() {
|
||||
// headers
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
//uri info
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
|
|
|
@ -1,31 +1,22 @@
|
|||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class JaxRsRequestTest {
|
||||
|
||||
|
@ -35,7 +26,7 @@ public class JaxRsRequestTest {
|
|||
|
||||
private JaxRsRequest details;
|
||||
private MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>();
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private TestJaxRsDummyPatientProvider provider;
|
||||
|
||||
@Before
|
||||
|
@ -49,11 +40,11 @@ public class JaxRsRequestTest {
|
|||
String headerValue = "location_value";
|
||||
String headerValue2 = "location_value_2";
|
||||
assertTrue(StringUtils.isBlank(details.getHeader(headerKey)));
|
||||
headers.header(headerKey, headerValue);
|
||||
queryParameters.add(headerKey, headerValue);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue), details.getHeaders(headerKey));
|
||||
|
||||
headers.header(headerKey, headerValue2);
|
||||
queryParameters.add(headerKey, headerValue2);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue, headerValue2), details.getHeaders(headerKey));
|
||||
}
|
||||
|
@ -96,8 +87,10 @@ public class JaxRsRequestTest {
|
|||
}
|
||||
|
||||
public JaxRsRequest createRequestDetails() throws URISyntaxException {
|
||||
//headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null, new MapPropertiesDelegate());
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
//uri info
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
|
|
|
@ -58,24 +58,12 @@
|
|||
<version>${jetty_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet-core</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-jetty-http</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
|
|
|
@ -43,15 +43,15 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
JaxRsConformanceProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsPatientRestProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsPageProviderDstu3.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
jettyServer.start();
|
||||
|
||||
|
|
|
@ -47,15 +47,15 @@ public class JaxRsPatientProviderTest {
|
|||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
JaxRsConformanceProvider.class.getCanonicalName(),
|
||||
JaxRsPatientRestProvider.class.getCanonicalName(),
|
||||
JaxRsPageProvider.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
jettyServer.start();
|
||||
|
||||
|
|
|
@ -210,7 +210,17 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--
|
||||
Dependencies that need to be added since JDK9
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test Database -->
|
||||
<dependency>
|
||||
|
|
|
@ -1,21 +1,31 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Link;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.Create;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
@ -26,21 +36,18 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.*;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Link;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SearchDstu2Test {
|
||||
|
||||
|
@ -142,14 +149,14 @@ public class SearchDstu2Test {
|
|||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(responseContent, PatternMatcher.pattern("id value..[0-9a-f-]+\\\""));
|
||||
assertThat(responseContent, matchesPattern("id value..[0-9a-f-]+\\\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchBlacklist01Failing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchBlacklist01&ref.black1=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
@ -159,7 +166,7 @@ public class SearchDstu2Test {
|
|||
public void testSearchBlacklist01Passing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchBlacklist01&ref.white1=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
/**
|
||||
* Tests if the argument is a {@link CharSequence} that matches a regular expression.
|
||||
*/
|
||||
public class PatternMatcher extends TypeSafeMatcher<CharSequence> {
|
||||
|
||||
/**
|
||||
* Creates a matcher that matches if the examined {@link CharSequence} matches the specified regular expression.
|
||||
* <p/>
|
||||
* For example:
|
||||
*
|
||||
* <pre>
|
||||
* assertThat("myStringOfNote", pattern("[0-9]+"))
|
||||
* </pre>
|
||||
*
|
||||
* @param regex
|
||||
* the regular expression that the returned matcher will use to match any examined {@link CharSequence}
|
||||
*/
|
||||
@Factory
|
||||
public static Matcher<CharSequence> pattern(String regex) {
|
||||
return pattern(Pattern.compile(regex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a matcher that matches if the examined {@link CharSequence} matches the specified {@link Pattern}.
|
||||
* <p/>
|
||||
* For example:
|
||||
*
|
||||
* <pre>
|
||||
* assertThat("myStringOfNote", Pattern.compile("[0-9]+"))
|
||||
* </pre>
|
||||
*
|
||||
* @param pattern
|
||||
* the pattern that the returned matcher will use to match any examined {@link CharSequence}
|
||||
*/
|
||||
@Factory
|
||||
public static Matcher<CharSequence> pattern(Pattern pattern) {
|
||||
return new PatternMatcher(pattern);
|
||||
}
|
||||
|
||||
private final Pattern pattern;
|
||||
|
||||
public PatternMatcher(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(CharSequence item) {
|
||||
return pattern.matcher(item).find();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeMismatchSafely(CharSequence item, org.hamcrest.Description mismatchDescription) {
|
||||
mismatchDescription.appendText("was \"").appendText(String.valueOf(item)).appendText("\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(org.hamcrest.Description description) {
|
||||
description.appendText("a string with pattern \"").appendText(String.valueOf(pattern)).appendText("\"");
|
||||
}
|
||||
}
|
|
@ -1,15 +1,11 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
@ -22,15 +18,15 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
import org.hl7.fhir.instance.model.Bundle;
|
||||
import org.hl7.fhir.instance.model.Patient;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.*;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.util.PatternMatcherB;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SearchHl7OrgDstu2Test {
|
||||
|
||||
|
@ -86,7 +82,7 @@ public class SearchHl7OrgDstu2Test {
|
|||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(responseContent, PatternMatcherB.pattern("id value..[0-9a-f-]+\\\""));
|
||||
assertThat(responseContent, matchesPattern("id value..[0-9a-f-]+\\\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
/**
|
||||
* Tests if the argument is a {@link CharSequence} that matches a regular expression.
|
||||
*/
|
||||
public class PatternMatcherB extends TypeSafeMatcher<CharSequence> {
|
||||
|
||||
/**
|
||||
* Creates a matcher that matches if the examined {@link CharSequence} matches the specified regular expression.
|
||||
* <p/>
|
||||
* For example:
|
||||
*
|
||||
* <pre>
|
||||
* assertThat("myStringOfNote", pattern("[0-9]+"))
|
||||
* </pre>
|
||||
*
|
||||
* @param regex
|
||||
* the regular expression that the returned matcher will use to match any examined {@link CharSequence}
|
||||
*/
|
||||
@Factory
|
||||
public static Matcher<CharSequence> pattern(String regex) {
|
||||
return pattern(Pattern.compile(regex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a matcher that matches if the examined {@link CharSequence} matches the specified {@link Pattern}.
|
||||
* <p/>
|
||||
* For example:
|
||||
*
|
||||
* <pre>
|
||||
* assertThat("myStringOfNote", Pattern.compile("[0-9]+"))
|
||||
* </pre>
|
||||
*
|
||||
* @param pattern
|
||||
* the pattern that the returned matcher will use to match any examined {@link CharSequence}
|
||||
*/
|
||||
@Factory
|
||||
public static Matcher<CharSequence> pattern(Pattern pattern) {
|
||||
return new PatternMatcherB(pattern);
|
||||
}
|
||||
|
||||
private final Pattern pattern;
|
||||
|
||||
public PatternMatcherB(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(CharSequence item) {
|
||||
return pattern.matcher(item).find();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeMismatchSafely(CharSequence item, org.hamcrest.Description mismatchDescription) {
|
||||
mismatchDescription.appendText("was \"").appendText(String.valueOf(item)).appendText("\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(org.hamcrest.Description description) {
|
||||
description.appendText("a string with pattern \"").appendText(String.valueOf(pattern)).appendText("\"");
|
||||
}
|
||||
}
|
|
@ -1,24 +1,5 @@
|
|||
package ca.uhn.fhir.rest.client;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.*;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
|
@ -35,6 +16,20 @@ import ch.qos.logback.classic.joran.JoranConfigurator;
|
|||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.classic.spi.LoggingEvent;
|
||||
import ch.qos.logback.core.Appender;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.*;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class LoggingInterceptorTest {
|
||||
|
||||
|
@ -78,8 +73,8 @@ public class LoggingInterceptorTest {
|
|||
|
||||
verify(myMockAppender, times(2)).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() {
|
||||
@Override
|
||||
public boolean matches(final Object argument) {
|
||||
String formattedMessage = ((LoggingEvent) argument).getFormattedMessage();
|
||||
public boolean matches(final ILoggingEvent argument) {
|
||||
String formattedMessage = argument.getFormattedMessage();
|
||||
System.out.flush();
|
||||
System.out.println("** Got Message: " + formattedMessage);
|
||||
System.out.flush();
|
||||
|
@ -103,8 +98,8 @@ public class LoggingInterceptorTest {
|
|||
|
||||
verify(myMockAppender, times(1)).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() {
|
||||
@Override
|
||||
public boolean matches(final Object argument) {
|
||||
String formattedMessage = ((LoggingEvent) argument).getFormattedMessage();
|
||||
public boolean matches(final ILoggingEvent argument) {
|
||||
String formattedMessage = argument.getFormattedMessage();
|
||||
System.out.println("Verifying: " + formattedMessage);
|
||||
return formattedMessage.replace("; ", ";").toLowerCase().contains("Content-Type: application/fhir+xml;charset=utf-8".toLowerCase());
|
||||
}
|
||||
|
@ -118,8 +113,8 @@ public class LoggingInterceptorTest {
|
|||
|
||||
verify(myMockAppender, times(1)).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() {
|
||||
@Override
|
||||
public boolean matches(final Object argument) {
|
||||
String formattedMessage = ((LoggingEvent) argument).getFormattedMessage();
|
||||
public boolean matches(final ILoggingEvent argument) {
|
||||
String formattedMessage = argument.getFormattedMessage();
|
||||
System.out.println("Verifying: " + formattedMessage);
|
||||
return formattedMessage.replace("; ", ";").toLowerCase().contains("Content-Type: application/fhir+xml;charset=utf-8".toLowerCase());
|
||||
}
|
||||
|
|
29
pom.xml
29
pom.xml
|
@ -79,7 +79,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -442,7 +442,7 @@
|
|||
<commons_lang3_version>3.6</commons_lang3_version>
|
||||
<derby_version>10.14.1.0</derby_version>
|
||||
<error_prone_annotations_version>2.0.18</error_prone_annotations_version>
|
||||
<guava_version>23.0</guava_version>
|
||||
<guava_version>25.0-jre</guava_version>
|
||||
<gson_version>2.8.1</gson_version>
|
||||
<jaxb_api_version>2.3.0</jaxb_api_version>
|
||||
<jaxb_core_version>2.3.0</jaxb_core_version>
|
||||
|
@ -461,6 +461,7 @@
|
|||
<maven_license_plugin_version>1.8</maven_license_plugin_version>
|
||||
<phloc_schematron_version>2.7.1</phloc_schematron_version>
|
||||
<phloc_commons_version>4.4.11</phloc_commons_version>
|
||||
<resteasy_version>4.0.0.Beta3</resteasy_version>
|
||||
<servicemix_saxon_version>9.5.1-5_1</servicemix_saxon_version>
|
||||
<servicemix_xmlresolver_version>1.2_5</servicemix_xmlresolver_version>
|
||||
<spring_version>5.0.3.RELEASE</spring_version>
|
||||
|
@ -620,6 +621,11 @@
|
|||
<artifactId>txtmark</artifactId>
|
||||
<version>0.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ejb</groupId>
|
||||
<artifactId>ejb-api</artifactId>
|
||||
|
@ -944,7 +950,7 @@
|
|||
<artifactId>javax.json</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
|
@ -963,6 +969,16 @@
|
|||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<version>${resteasy_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<version>${resteasy_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jscience</groupId>
|
||||
|
@ -1011,8 +1027,8 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.10.19</version>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.18.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -1270,7 +1286,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20.1</version>
|
||||
<version>2.21.0</version>
|
||||
<configuration>
|
||||
<redirectTestOutputToFile>true</redirectTestOutputToFile>
|
||||
<runOrder>random</runOrder>
|
||||
|
@ -1501,6 +1517,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-java</id>
|
||||
|
|
Loading…
Reference in New Issue