Merge pull request #2575 from hapifhir/kh_2526_Add_Operation_Section_to_Conformance_Statements_resource_section
Kh 2526 add operation section to conformance statements resource section
This commit is contained in:
commit
dd61a8aa2c
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 2526
|
||||
title: "Added Operation section to Conformance Statement."
|
|
@ -284,7 +284,6 @@
|
|||
<artifactId>spring-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.jena</groupId>
|
||||
<artifactId>jena-core</artifactId>
|
||||
|
@ -295,6 +294,12 @@
|
|||
<artifactId>jena-arq</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-jpaserver-model</artifactId>
|
||||
<version>5.4.0-PRE8-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.rest.server;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
@ -46,7 +47,6 @@ import ca.uhn.fhir.rest.server.provider.HashMapResourceProvider;
|
|||
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
||||
import ca.uhn.fhir.rest.server.provider.ServerCapabilityStatementProvider;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.test.utilities.server.MockServletUtil;
|
||||
import ca.uhn.fhir.util.HapiExtensions;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
|
@ -71,6 +71,7 @@ import org.hl7.fhir.r4.model.DiagnosticReport;
|
|||
import org.hl7.fhir.r4.model.Encounter;
|
||||
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
|
||||
import org.hl7.fhir.r4.model.Extension;
|
||||
import org.hl7.fhir.r4.model.Group;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.OperationDefinition;
|
||||
|
@ -85,14 +86,17 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ca.uhn.fhir.test.utilities.server.MockServletUtil.createServletConfig;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -118,6 +122,19 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4);
|
||||
private FhirValidator myValidator;
|
||||
|
||||
private static Set<String> toStrings(Collection<? extends IPrimitiveType> theType) {
|
||||
HashSet<String> retVal = new HashSet<String>();
|
||||
for (IPrimitiveType next : theType) {
|
||||
retVal.add(next.getValueAsString());
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
myValidator = myCtx.newValidator();
|
||||
|
@ -154,7 +171,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement cs = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
List<String> formats = cs
|
||||
|
@ -172,7 +189,6 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConditionalOperations() throws Exception {
|
||||
|
||||
|
@ -182,7 +198,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
||||
|
@ -214,7 +230,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
validate(conformance);
|
||||
|
@ -243,7 +259,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
};
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
OperationDefinition opDef = (OperationDefinition) sc.readOperationDefinition(new IdType("OperationDefinition/Patient-i-everything"), createRequestDetails(rs));
|
||||
validate(opDef);
|
||||
|
@ -264,7 +280,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
String conf = validate(conformance);
|
||||
|
@ -282,7 +298,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
boolean found = false;
|
||||
Collection<ResourceBinding> resourceBindings = rs.getResourceBindings();
|
||||
|
@ -314,7 +330,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
validate(conformance);
|
||||
|
@ -327,7 +343,6 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
assertNull(res.getConditionalUpdateElement().getValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOperationParameterDocumentation() throws Exception {
|
||||
RestfulServer rs = new RestfulServer(myCtx);
|
||||
|
@ -337,7 +352,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
validate(conformance);
|
||||
|
@ -362,7 +377,6 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
assertEquals("2002", exampleExtensions.get(1).getValueAsPrimitive().getValueAsString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* See #379
|
||||
*/
|
||||
|
@ -375,7 +389,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
|
@ -431,7 +445,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
|
@ -451,7 +465,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
validate(conformance);
|
||||
|
@ -480,7 +494,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
String conf = validate(conformance);
|
||||
|
@ -498,7 +512,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
||||
|
@ -518,7 +532,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
boolean found = false;
|
||||
Collection<ResourceBinding> resourceBindings = rs.getResourceBindings();
|
||||
|
@ -545,7 +559,6 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFormatIncludesSpecialNonMediaTypeFormats() throws ServletException {
|
||||
RestfulServer rs = new RestfulServer(myCtx);
|
||||
|
@ -554,7 +567,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
CapabilityStatement serverConformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
List<String> formatCodes = serverConformance.getFormat().stream().map(c -> c.getCode()).collect(Collectors.toList());
|
||||
|
@ -577,7 +590,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
boolean found = false;
|
||||
Collection<ResourceBinding> resourceBindings = rs.getResourceBindings();
|
||||
|
@ -609,7 +622,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
boolean found = false;
|
||||
Collection<ResourceBinding> resourceBindings = rs.getResourceBindings();
|
||||
|
@ -649,7 +662,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
rsNoType.registerProvider(new SearchProviderWithListNoType());
|
||||
ServerCapabilityStatementProvider scNoType = new ServerCapabilityStatementProvider(rsNoType);
|
||||
rsNoType.setServerConformanceProvider(scNoType);
|
||||
rsNoType.init(MockServletUtil.createServletConfig());
|
||||
rsNoType.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) scNoType.getServerConformance(createHttpServletRequest(), createRequestDetails(rsNoType));
|
||||
conformance.setId("");
|
||||
|
@ -666,7 +679,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
rsWithType.registerProvider(new SearchProviderWithListWithType());
|
||||
ServerCapabilityStatementProvider scWithType = new ServerCapabilityStatementProvider(rsWithType);
|
||||
rsWithType.setServerConformanceProvider(scWithType);
|
||||
rsWithType.init(MockServletUtil.createServletConfig());
|
||||
rsWithType.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformanceWithType = (CapabilityStatement) scWithType.getServerConformance(createHttpServletRequest(), createRequestDetails(rsWithType));
|
||||
conformanceWithType.setId("");
|
||||
|
@ -685,7 +698,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
String conf = validate(conformance);
|
||||
|
@ -702,7 +715,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
String conf = validate(conformance);
|
||||
|
@ -737,7 +750,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
};
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement opDef = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
|
@ -778,7 +791,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
};
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement opDef = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
|
@ -818,7 +831,6 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
assertTrue(operationDefinition.getInstance());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPlainProviderGlobalSystemAndInstanceOperations() throws Exception {
|
||||
|
||||
|
@ -871,7 +883,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
};
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement opDef = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
|
@ -949,7 +961,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
};
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement opDef = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
|
@ -1013,7 +1025,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
};
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement opDef = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
|
@ -1034,7 +1046,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
validate(conformance);
|
||||
|
@ -1079,7 +1091,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
validate(conformance);
|
||||
|
@ -1121,7 +1133,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
|
||||
|
@ -1148,7 +1160,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
ourLog.info(myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance));
|
||||
|
@ -1198,7 +1210,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
sc.setRestResourceRevIncludesEnabled(true);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
ourLog.info(myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance));
|
||||
|
@ -1235,7 +1247,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
}
|
||||
|
||||
@Search
|
||||
public List<Observation> search(@OptionalParam(name = "subject") ReferenceParam theSubject) {
|
||||
public List<Observation> search(@OptionalParam(name = "subject") ReferenceParam theSubject) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1248,7 +1260,7 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
sc.setRestResourceRevIncludesEnabled(true);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
|
||||
rs.init(MockServletUtil.createServletConfig());
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
ourLog.info(myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance));
|
||||
|
@ -1260,6 +1272,27 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
assertThat(toStrings(patientResource.getSearchRevInclude()), containsInAnyOrder("Observation:subject"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBulkDataExport() throws ServletException {
|
||||
RestfulServer rs = new RestfulServer(myCtx);
|
||||
rs.setResourceProviders(new BulkDataExportProvider());
|
||||
rs.setServerAddressStrategy(new HardcodedServerAddressStrategy("http://localhost/baseR4"));
|
||||
|
||||
ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
|
||||
rs.setServerConformanceProvider(sc);
|
||||
rs.init(createServletConfig());
|
||||
|
||||
CapabilityStatement conformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs));
|
||||
ourLog.info(myCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conformance));
|
||||
|
||||
List<CapabilityStatementRestResourceComponent> resources = conformance.getRestFirstRep().getResource();
|
||||
CapabilityStatementRestResourceComponent groupResource = resources.stream()
|
||||
.filter(resource -> "Group".equals(resource.getType()))
|
||||
.findFirst().get();
|
||||
|
||||
assertThat(toOperationNames(groupResource.getOperation()),containsInAnyOrder("export", "export-poll-status"));
|
||||
}
|
||||
|
||||
private List<String> toOperationIdParts(List<CapabilityStatementRestResourceOperationComponent> theOperation) {
|
||||
ArrayList<String> retVal = Lists.newArrayList();
|
||||
for (CapabilityStatementRestResourceOperationComponent next : theOperation) {
|
||||
|
@ -1304,6 +1337,52 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
return myCtx.newXmlParser().setPrettyPrint(false).encodeResourceToString(theResource);
|
||||
}
|
||||
|
||||
public static class BulkDataExportProvider implements IResourceProvider {
|
||||
@Operation(name = JpaConstants.OPERATION_EXPORT, global = false /* set to true once we can handle this */, manualResponse = true, idempotent = true)
|
||||
public void export(
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_OUTPUT_FORMAT, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theOutputFormat,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_TYPE, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theType,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_SINCE, min = 0, max = 1, typeName = "instant") IPrimitiveType<Date> theSince,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_TYPE_FILTER, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theTypeFilter,
|
||||
ServletRequestDetails theRequestDetails
|
||||
) {
|
||||
}
|
||||
|
||||
@Operation(name = JpaConstants.OPERATION_EXPORT, manualResponse = true, idempotent = true, typeName = "Group")
|
||||
public void groupExport(
|
||||
@IdParam IIdType theIdParam,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_OUTPUT_FORMAT, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theOutputFormat,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_TYPE, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theType,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_SINCE, min = 0, max = 1, typeName = "instant") IPrimitiveType<Date> theSince,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_TYPE_FILTER, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theTypeFilter,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_MDM, min = 0, max = 1, typeName = "boolean") IPrimitiveType<Boolean> theMdm,
|
||||
ServletRequestDetails theRequestDetails
|
||||
) {
|
||||
}
|
||||
|
||||
@Operation(name = JpaConstants.OPERATION_EXPORT, manualResponse = true, idempotent = true, typeName = "Patient")
|
||||
public void patientExport(
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_OUTPUT_FORMAT, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theOutputFormat,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_TYPE, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theType,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_SINCE, min = 0, max = 1, typeName = "instant") IPrimitiveType<Date> theSince,
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_TYPE_FILTER, min = 0, max = 1, typeName = "string") IPrimitiveType<String> theTypeFilter,
|
||||
ServletRequestDetails theRequestDetails
|
||||
) {
|
||||
}
|
||||
|
||||
@Operation(name = JpaConstants.OPERATION_EXPORT_POLL_STATUS, manualResponse = true, idempotent = true)
|
||||
public void exportPollStatus(
|
||||
@OperationParam(name = JpaConstants.PARAM_EXPORT_POLL_STATUS_JOB_ID, typeName = "string", min = 0, max = 1) IPrimitiveType<String> theJobId,
|
||||
ServletRequestDetails theRequestDetails
|
||||
) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IBaseResource> getResourceType() {
|
||||
return Group.class;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static class ConditionalProvider implements IResourceProvider {
|
||||
|
||||
|
@ -1400,7 +1479,6 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
public IBundleProvider validate(HttpServletRequest theServletRequest, @IdParam IdType theId, @ResourceParam Patient thePatient) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -1658,17 +1736,4 @@ public class ServerCapabilityStatementProviderR4Test {
|
|||
public static class PatientTripleSub extends PatientSubSub {
|
||||
}
|
||||
|
||||
private static Set<String> toStrings(Collection<? extends IPrimitiveType> theType) {
|
||||
HashSet<String> retVal = new HashSet<String>();
|
||||
for (IPrimitiveType next : theType) {
|
||||
retVal.add(next.getValueAsString());
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue