Fix build

This commit is contained in:
James Agnew 2015-08-31 09:23:21 -04:00
parent 8edc325f54
commit fc36dabc68
3 changed files with 189 additions and 188 deletions

View File

@ -155,6 +155,11 @@
<artifactId>xmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -178,6 +178,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Hibernate -->

View File

@ -59,15 +59,22 @@ public class FhirInstanceValidatorTest {
boolean retVal = myDefaultValidationSupport.isCodeSystemSupported((String) theInvocation.getArguments()[0]);
ourLog.info("isCodeSystemSupported({}) : {}", theInvocation.getArguments()[0], 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
public IBaseResource answer(InvocationOnMock theInvocation) throws Throwable {
IBaseResource retVal = myDefaultValidationSupport.fetchResource((FhirContext)theInvocation.getArguments()[0], (Class<IBaseResource>) theInvocation.getArguments()[1],(String)theInvocation.getArguments()[2]);
ourLog.info("fetchResource({}, {}) : {}", theInvocation.getArguments()[1], theInvocation.getArguments()[2], retVal);
IBaseResource retVal = myDefaultValidationSupport.fetchResource(
(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;
}});
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
public org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult answer(InvocationOnMock theInvocation)
throws Throwable {
@ -75,21 +82,24 @@ public class FhirInstanceValidatorTest {
String code = (String) theInvocation.getArguments()[1];
org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult retVal;
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 {
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;
}});
}
});
when(myMockSupport.fetchCodeSystem(any(String.class))).thenAnswer(new Answer<ValueSet>() {
@Override
public ValueSet answer(InvocationOnMock theInvocation)
throws Throwable {
public ValueSet answer(InvocationOnMock theInvocation) throws Throwable {
ValueSet retVal = myDefaultValidationSupport.fetchCodeSystem((String) theInvocation.getArguments()[0]);
ourLog.info("fetchCodeSystem({}) : {}", new Object[] { (String) theInvocation.getArguments()[0], retVal });
return retVal;
}});
}
});
}
@ -98,7 +108,8 @@ public class FhirInstanceValidatorTest {
int index = 0;
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++;
if (next.getSeverity() != ResultSeverityEnum.INFORMATION) {
@ -112,10 +123,7 @@ public class FhirInstanceValidatorTest {
@Test
public void testValidateJsonResource() {
// @formatter:off
String input = "{"
+ "\"resourceType\":\"Patient\","
+ "\"id\":\"123\""
+ "}";
String input = "{" + "\"resourceType\":\"Patient\"," + "\"id\":\"123\"" + "}";
// @formatter:on
ValidationResult output = myVal.validateWithResult(input);
@ -125,11 +133,7 @@ public class FhirInstanceValidatorTest {
@Test
public void testValidateJsonResourceBadAttributes() {
// @formatter:off
String input = "{"
+ "\"resourceType\":\"Patient\","
+ "\"id\":\"123\","
+ "\"foo\":\"123\""
+ "}";
String input = "{" + "\"resourceType\":\"Patient\"," + "\"id\":\"123\"," + "\"foo\":\"123\"" + "}";
// @formatter:on
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());
}
@Test
public void testValidateResourceFailingInvariant() {
Observation input = new Observation();
@ -151,12 +154,11 @@ public class FhirInstanceValidatorTest {
ValidationResult output = myVal.validateWithResult(input);
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
public void testValidateResourceWithExampleBindingCodeValidationFailing() {
Observation input = new Observation();
@ -203,23 +205,18 @@ public class FhirInstanceValidatorTest {
@Test
public void testValidateResourceWithDefaultValuesetBadCode() {
String input = "<Observation xmlns=\"http://hl7.org/fhir\">\n" +
" <status value=\"notvalidcode\"/>\n" +
" <code>\n" +
" <text value=\"No code here!\"/>\n" +
" </code>\n" +
"</Observation>";
String input = "<Observation xmlns=\"http://hl7.org/fhir\">\n" + " <status value=\"notvalidcode\"/>\n"
+ " <code>\n" + " <text value=\"No code here!\"/>\n" + " </code>\n" + "</Observation>";
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
public void testValidateXmlResource() {
// @formatter:off
String input = "<Patient xmlns=\"http://hl7.org/fhir\">"
+ "<id value=\"123\"/>"
+ "</Patient>";
String input = "<Patient xmlns=\"http://hl7.org/fhir\">" + "<id value=\"123\"/>" + "</Patient>";
// @formatter:on
ValidationResult output = myVal.validateWithResult(input);
@ -229,9 +226,7 @@ public class FhirInstanceValidatorTest {
@Test
public void testValidateXmlResourceBadAttributes() {
// @formatter:off
String input = "<Patient xmlns=\"http://hl7.org/fhir\">"
+ "<id value=\"123\"/>"
+ "<foo value=\"222\"/>"
String input = "<Patient xmlns=\"http://hl7.org/fhir\">" + "<id value=\"123\"/>" + "<foo value=\"222\"/>"
+ "</Patient>";
// @formatter:on