Hopefully fix #983
This commit is contained in:
parent
e7804b881c
commit
6feb23896f
|
@ -16,6 +16,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.r4.model.Bundle;
|
import org.hl7.fhir.r4.model.Bundle;
|
||||||
|
@ -35,6 +36,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
@ -174,12 +176,6 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
||||||
ResourceProviderInterceptorR4Test.verifyDaoInterceptor(myDaoInterceptor);
|
ResourceProviderInterceptorR4Test.verifyDaoInterceptor(myDaoInterceptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a weird way of verifying, but because this class
|
|
||||||
* is a child of a superclass that has other test children
|
|
||||||
* it's possible that other tests are hitting the server
|
|
||||||
* at the same time
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateResourceInTransaction() throws IOException {
|
public void testCreateResourceInTransaction() throws IOException {
|
||||||
String methodName = "testCreateResourceInTransaction";
|
String methodName = "testCreateResourceInTransaction";
|
||||||
|
@ -220,15 +216,17 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
||||||
* DAO Interceptor
|
* DAO Interceptor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sometimes we get more than 2 hits of the incomingRequestPreHandled
|
||||||
|
* method. My working theory is that it's a scheduled background job,
|
||||||
|
* such as the subscription interceptor or the search parameter cache
|
||||||
|
* updating.
|
||||||
|
*/
|
||||||
ardCaptor = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
ardCaptor = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
||||||
opTypeCaptor = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
opTypeCaptor = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
||||||
verify(myDaoInterceptor, times(2)).incomingRequestPreHandled(opTypeCaptor.capture(), ardCaptor.capture());
|
verify(myDaoInterceptor, atLeast(2)).incomingRequestPreHandled(opTypeCaptor.capture(), ardCaptor.capture());
|
||||||
assertEquals(RestOperationTypeEnum.TRANSACTION, opTypeCaptor.getAllValues().get(0));
|
assertThat(ardCaptor.getAllValues().stream().map(ActionRequestDetails::getResourceType).collect(Collectors.toList()), Matchers.contains("Bundle", "Patient"));
|
||||||
assertEquals("Bundle", ardCaptor.getAllValues().get(0).getResourceType());
|
assertThat(opTypeCaptor.getAllValues(), Matchers.contains(RestOperationTypeEnum.TRANSACTION, RestOperationTypeEnum.CREATE));
|
||||||
assertNotNull(ardCaptor.getAllValues().get(0).getResource());
|
|
||||||
assertEquals(RestOperationTypeEnum.CREATE, opTypeCaptor.getAllValues().get(1));
|
|
||||||
assertEquals("Patient", ardCaptor.getAllValues().get(1).getResourceType());
|
|
||||||
assertNotNull(ardCaptor.getAllValues().get(1).getResource());
|
|
||||||
|
|
||||||
rdCaptor = ArgumentCaptor.forClass(RequestDetails.class);
|
rdCaptor = ArgumentCaptor.forClass(RequestDetails.class);
|
||||||
srCaptor = ArgumentCaptor.forClass(HttpServletRequest.class);
|
srCaptor = ArgumentCaptor.forClass(HttpServletRequest.class);
|
||||||
|
|
|
@ -49,6 +49,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.fhir.rest.server.method.*;
|
import ca.uhn.fhir.rest.server.method.*;
|
||||||
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
||||||
import ca.uhn.fhir.rest.server.method.SearchParameter;
|
import ca.uhn.fhir.rest.server.method.SearchParameter;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
|
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
|
||||||
|
@ -132,10 +133,10 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTimeType conformanceDate() {
|
private DateTimeType conformanceDate() {
|
||||||
String buildDate = getServerConfiguration().getConformanceDate();
|
IPrimitiveType<Date> buildDate = getServerConfiguration().getConformanceDate();
|
||||||
if (buildDate != null) {
|
if (buildDate != null && buildDate.getValue() != null) {
|
||||||
try {
|
try {
|
||||||
return new DateTimeType(buildDate);
|
return new DateTimeType(buildDate.getValueAsString());
|
||||||
} catch (DataFormatException e) {
|
} catch (DataFormatException e) {
|
||||||
// fall through
|
// fall through
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import ca.uhn.fhir.rest.server.method.*;
|
||||||
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -136,10 +137,10 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTimeDt conformanceDate() {
|
private DateTimeDt conformanceDate() {
|
||||||
String buildDate = getServerConfiguration().getConformanceDate();
|
IPrimitiveType<Date> buildDate = getServerConfiguration().getConformanceDate();
|
||||||
if (buildDate != null) {
|
if (buildDate != null && buildDate.getValue() != null) {
|
||||||
try {
|
try {
|
||||||
return new DateTimeDt(buildDate);
|
return new DateTimeDt(buildDate.getValueAsString());
|
||||||
} catch (DataFormatException e) {
|
} catch (DataFormatException e) {
|
||||||
// fall through
|
// fall through
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.fhir.rest.server.method.*;
|
import ca.uhn.fhir.rest.server.method.*;
|
||||||
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
||||||
import ca.uhn.fhir.rest.server.method.SearchParameter;
|
import ca.uhn.fhir.rest.server.method.SearchParameter;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server FHIR Provider which serves the conformance statement for a RESTful
|
* Server FHIR Provider which serves the conformance statement for a RESTful
|
||||||
|
@ -314,10 +315,10 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTimeType conformanceDate() {
|
private DateTimeType conformanceDate() {
|
||||||
String buildDate = getServerConfiguration().getConformanceDate();
|
IPrimitiveType<Date> buildDate = getServerConfiguration().getConformanceDate();
|
||||||
if (buildDate != null) {
|
if (buildDate != null && buildDate.getValue() != null) {
|
||||||
try {
|
try {
|
||||||
return new DateTimeType(buildDate);
|
return new DateTimeType(buildDate.getValueAsString());
|
||||||
} catch (DataFormatException e) {
|
} catch (DataFormatException e) {
|
||||||
// fall through
|
// fall through
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import ca.uhn.fhir.rest.server.method.SearchParameter;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
import org.hl7.fhir.r4.model.*;
|
import org.hl7.fhir.r4.model.*;
|
||||||
import org.hl7.fhir.r4.model.CapabilityStatement.*;
|
import org.hl7.fhir.r4.model.CapabilityStatement.*;
|
||||||
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
|
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
|
||||||
|
@ -139,10 +140,10 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTimeType conformanceDate() {
|
private DateTimeType conformanceDate() {
|
||||||
String buildDate = getServerConfiguration().getConformanceDate();
|
IPrimitiveType<Date> buildDate = getServerConfiguration().getConformanceDate();
|
||||||
if (buildDate != null) {
|
if (buildDate != null && buildDate.getValue() != null) {
|
||||||
try {
|
try {
|
||||||
return new DateTimeType(buildDate);
|
return new DateTimeType(buildDate.getValueAsString());
|
||||||
} catch (DataFormatException e) {
|
} catch (DataFormatException e) {
|
||||||
// fall through
|
// fall through
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue