Fix build
This commit is contained in:
parent
8edc325f54
commit
fc36dabc68
|
@ -155,6 +155,11 @@
|
||||||
<artifactId>xmlunit</artifactId>
|
<artifactId>xmlunit</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Hibernate -->
|
<!-- Hibernate -->
|
||||||
|
|
|
@ -59,15 +59,22 @@ public class FhirInstanceValidatorTest {
|
||||||
boolean retVal = myDefaultValidationSupport.isCodeSystemSupported((String) theInvocation.getArguments()[0]);
|
boolean retVal = myDefaultValidationSupport.isCodeSystemSupported((String) theInvocation.getArguments()[0]);
|
||||||
ourLog.info("isCodeSystemSupported({}) : {}", theInvocation.getArguments()[0], retVal);
|
ourLog.info("isCodeSystemSupported({}) : {}", theInvocation.getArguments()[0], retVal);
|
||||||
return retVal;
|
return retVal;
|
||||||
}});
|
}
|
||||||
when(myMockSupport.fetchResource(any(FhirContext.class), any(Class.class), any(String.class))).thenAnswer(new Answer<IBaseResource>() {
|
});
|
||||||
|
when(myMockSupport.fetchResource(any(FhirContext.class), any(Class.class), any(String.class)))
|
||||||
|
.thenAnswer(new Answer<IBaseResource>() {
|
||||||
@Override
|
@Override
|
||||||
public IBaseResource answer(InvocationOnMock theInvocation) throws Throwable {
|
public IBaseResource answer(InvocationOnMock theInvocation) throws Throwable {
|
||||||
IBaseResource retVal = myDefaultValidationSupport.fetchResource((FhirContext)theInvocation.getArguments()[0], (Class<IBaseResource>) theInvocation.getArguments()[1],(String)theInvocation.getArguments()[2]);
|
IBaseResource retVal = myDefaultValidationSupport.fetchResource(
|
||||||
ourLog.info("fetchResource({}, {}) : {}", theInvocation.getArguments()[1], theInvocation.getArguments()[2], retVal);
|
(FhirContext) theInvocation.getArguments()[0], (Class<IBaseResource>) theInvocation.getArguments()[1],
|
||||||
|
(String) theInvocation.getArguments()[2]);
|
||||||
|
ourLog.info("fetchResource({}, {}) : {}", theInvocation.getArguments()[1], theInvocation.getArguments()[2],
|
||||||
|
retVal);
|
||||||
return retVal;
|
return retVal;
|
||||||
}});
|
}
|
||||||
when(myMockSupport.validateCode(any(String.class), any(String.class),any(String.class))).thenAnswer(new Answer<org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult>() {
|
});
|
||||||
|
when(myMockSupport.validateCode(any(String.class), any(String.class), any(String.class)))
|
||||||
|
.thenAnswer(new Answer<org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult>() {
|
||||||
@Override
|
@Override
|
||||||
public org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult answer(InvocationOnMock theInvocation)
|
public org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult answer(InvocationOnMock theInvocation)
|
||||||
throws Throwable {
|
throws Throwable {
|
||||||
|
@ -75,21 +82,24 @@ public class FhirInstanceValidatorTest {
|
||||||
String code = (String) theInvocation.getArguments()[1];
|
String code = (String) theInvocation.getArguments()[1];
|
||||||
org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult retVal;
|
org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult retVal;
|
||||||
if (myValidConcepts.contains(system + "___" + code)) {
|
if (myValidConcepts.contains(system + "___" + code)) {
|
||||||
retVal = new org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult(new ConceptDefinitionComponent(new CodeType(code)));
|
retVal = new org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult(
|
||||||
|
new ConceptDefinitionComponent(new CodeType(code)));
|
||||||
} else {
|
} else {
|
||||||
retVal = myDefaultValidationSupport.validateCode(system, code, (String) theInvocation.getArguments()[2]);
|
retVal = myDefaultValidationSupport.validateCode(system, code, (String) theInvocation.getArguments()[2]);
|
||||||
}
|
}
|
||||||
ourLog.info("validateCode({}, {}, {}) : {}", new Object[] {system,code, (String)theInvocation.getArguments()[2], retVal});
|
ourLog.info("validateCode({}, {}, {}) : {}",
|
||||||
|
new Object[] { system, code, (String) theInvocation.getArguments()[2], retVal });
|
||||||
return retVal;
|
return retVal;
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
when(myMockSupport.fetchCodeSystem(any(String.class))).thenAnswer(new Answer<ValueSet>() {
|
when(myMockSupport.fetchCodeSystem(any(String.class))).thenAnswer(new Answer<ValueSet>() {
|
||||||
@Override
|
@Override
|
||||||
public ValueSet answer(InvocationOnMock theInvocation)
|
public ValueSet answer(InvocationOnMock theInvocation) throws Throwable {
|
||||||
throws Throwable {
|
|
||||||
ValueSet retVal = myDefaultValidationSupport.fetchCodeSystem((String) theInvocation.getArguments()[0]);
|
ValueSet retVal = myDefaultValidationSupport.fetchCodeSystem((String) theInvocation.getArguments()[0]);
|
||||||
ourLog.info("fetchCodeSystem({}) : {}", new Object[] { (String) theInvocation.getArguments()[0], retVal });
|
ourLog.info("fetchCodeSystem({}) : {}", new Object[] { (String) theInvocation.getArguments()[0], retVal });
|
||||||
return retVal;
|
return retVal;
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +108,8 @@ public class FhirInstanceValidatorTest {
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (SingleValidationMessage next : theOutput.getMessages()) {
|
for (SingleValidationMessage next : theOutput.getMessages()) {
|
||||||
ourLog.info("Result {}: {} - {} - {}", index, next.getSeverity(), next.getLocationString(), next.getMessage());
|
ourLog.info("Result {}: {} - {} - {}",
|
||||||
|
new Object[] { index, next.getSeverity(), next.getLocationString(), next.getMessage() });
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (next.getSeverity() != ResultSeverityEnum.INFORMATION) {
|
if (next.getSeverity() != ResultSeverityEnum.INFORMATION) {
|
||||||
|
@ -112,10 +123,7 @@ public class FhirInstanceValidatorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testValidateJsonResource() {
|
public void testValidateJsonResource() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
String input = "{"
|
String input = "{" + "\"resourceType\":\"Patient\"," + "\"id\":\"123\"" + "}";
|
||||||
+ "\"resourceType\":\"Patient\","
|
|
||||||
+ "\"id\":\"123\""
|
|
||||||
+ "}";
|
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
ValidationResult output = myVal.validateWithResult(input);
|
ValidationResult output = myVal.validateWithResult(input);
|
||||||
|
@ -125,11 +133,7 @@ public class FhirInstanceValidatorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testValidateJsonResourceBadAttributes() {
|
public void testValidateJsonResourceBadAttributes() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
String input = "{"
|
String input = "{" + "\"resourceType\":\"Patient\"," + "\"id\":\"123\"," + "\"foo\":\"123\"" + "}";
|
||||||
+ "\"resourceType\":\"Patient\","
|
|
||||||
+ "\"id\":\"123\","
|
|
||||||
+ "\"foo\":\"123\""
|
|
||||||
+ "}";
|
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
ValidationResult output = myVal.validateWithResult(input);
|
ValidationResult output = myVal.validateWithResult(input);
|
||||||
|
@ -140,7 +144,6 @@ public class FhirInstanceValidatorTest {
|
||||||
assertEquals("Element is unknown or does not match any slice", output.getMessages().get(0).getMessage());
|
assertEquals("Element is unknown or does not match any slice", output.getMessages().get(0).getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateResourceFailingInvariant() {
|
public void testValidateResourceFailingInvariant() {
|
||||||
Observation input = new Observation();
|
Observation input = new Observation();
|
||||||
|
@ -151,12 +154,11 @@ public class FhirInstanceValidatorTest {
|
||||||
|
|
||||||
ValidationResult output = myVal.validateWithResult(input);
|
ValidationResult output = myVal.validateWithResult(input);
|
||||||
assertThat(output.getMessages().size(), greaterThan(0));
|
assertThat(output.getMessages().size(), greaterThan(0));
|
||||||
assertEquals("Element '/f:Observation.status': minimum required = 1, but only found 0", output.getMessages().get(0).getMessage());
|
assertEquals("Element '/f:Observation.status': minimum required = 1, but only found 0",
|
||||||
|
output.getMessages().get(0).getMessage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateResourceWithExampleBindingCodeValidationFailing() {
|
public void testValidateResourceWithExampleBindingCodeValidationFailing() {
|
||||||
Observation input = new Observation();
|
Observation input = new Observation();
|
||||||
|
@ -203,23 +205,18 @@ public class FhirInstanceValidatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateResourceWithDefaultValuesetBadCode() {
|
public void testValidateResourceWithDefaultValuesetBadCode() {
|
||||||
String input = "<Observation xmlns=\"http://hl7.org/fhir\">\n" +
|
String input = "<Observation xmlns=\"http://hl7.org/fhir\">\n" + " <status value=\"notvalidcode\"/>\n"
|
||||||
" <status value=\"notvalidcode\"/>\n" +
|
+ " <code>\n" + " <text value=\"No code here!\"/>\n" + " </code>\n" + "</Observation>";
|
||||||
" <code>\n" +
|
|
||||||
" <text value=\"No code here!\"/>\n" +
|
|
||||||
" </code>\n" +
|
|
||||||
"</Observation>";
|
|
||||||
ValidationResult output = myVal.validateWithResult(input);
|
ValidationResult output = myVal.validateWithResult(input);
|
||||||
assertEquals("Coded value notvalidcode is not in value set http://hl7.org/fhir/ValueSet/observation-status (http://hl7.org/fhir/ValueSet/observation-status)", output.getMessages().get(0).getMessage());
|
assertEquals(
|
||||||
|
"Coded value notvalidcode is not in value set http://hl7.org/fhir/ValueSet/observation-status (http://hl7.org/fhir/ValueSet/observation-status)",
|
||||||
|
output.getMessages().get(0).getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateXmlResource() {
|
public void testValidateXmlResource() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
String input = "<Patient xmlns=\"http://hl7.org/fhir\">"
|
String input = "<Patient xmlns=\"http://hl7.org/fhir\">" + "<id value=\"123\"/>" + "</Patient>";
|
||||||
+ "<id value=\"123\"/>"
|
|
||||||
+ "</Patient>";
|
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
ValidationResult output = myVal.validateWithResult(input);
|
ValidationResult output = myVal.validateWithResult(input);
|
||||||
|
@ -229,9 +226,7 @@ public class FhirInstanceValidatorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testValidateXmlResourceBadAttributes() {
|
public void testValidateXmlResourceBadAttributes() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
String input = "<Patient xmlns=\"http://hl7.org/fhir\">"
|
String input = "<Patient xmlns=\"http://hl7.org/fhir\">" + "<id value=\"123\"/>" + "<foo value=\"222\"/>"
|
||||||
+ "<id value=\"123\"/>"
|
|
||||||
+ "<foo value=\"222\"/>"
|
|
||||||
+ "</Patient>";
|
+ "</Patient>";
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue