Sort methods

This commit is contained in:
James 2017-10-31 20:55:36 -04:00
parent dea9cdde58
commit a1ffe0d1c3
1 changed files with 34 additions and 34 deletions

View File

@ -24,10 +24,36 @@ public class GraphQLEngineTest {
private static FhirContext ourCtx; private static FhirContext ourCtx;
private org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(GraphQLEngineTest.class); private org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(GraphQLEngineTest.class);
@BeforeClass private Observation createObservation() {
public static void beforeClass() { Observation obs = new Observation();
ourCtx = FhirContext.forR4(); obs.setId("http://foo.com/Patient/PATA");
ourWorkerCtx = new HapiWorkerContext(ourCtx, new DefaultProfileValidationSupport()); obs.setValue(new Quantity().setValue(123).setUnit("cm"));
obs.setSubject(new Reference("Patient/123"));
return obs;
}
private IGraphQLStorageServices<Resource, Reference, Bundle> createStorageServices() throws FHIRException {
IGraphQLStorageServices<Resource, Reference, Bundle> retVal = mock(IGraphQLStorageServices.class);
when(retVal.lookup(any(Object.class), any(Resource.class), any(Reference.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object appInfo = invocation.getArguments()[0];
Resource context = (Resource) invocation.getArguments()[1];
Reference reference = (Reference) invocation.getArguments()[2];
ourLog.info("AppInfo: {} / Context: {} / Reference: {}", appInfo, context.getId(), reference.getReference());
if (reference.getReference().equalsIgnoreCase("Patient/123")) {
Patient p = new Patient();
p.getBirthDateElement().setValueAsString("2011-02-22");
return new ReferenceResolution<>(context, p);
}
ourLog.info("Not found!");
return null;
}
});
return retVal;
} }
@Test @Test
@ -54,14 +80,6 @@ public class GraphQLEngineTest {
} }
private Observation createObservation() {
Observation obs = new Observation();
obs.setId("http://foo.com/Patient/PATA");
obs.setValue(new Quantity().setValue(123).setUnit("cm"));
obs.setSubject(new Reference("Patient/123"));
return obs;
}
@Test @Test
public void testReferences() throws EGraphQLException, EGraphEngine, IOException, FHIRException { public void testReferences() throws EGraphQLException, EGraphEngine, IOException, FHIRException {
@ -99,28 +117,10 @@ public class GraphQLEngineTest {
} }
private IGraphQLStorageServices<Resource, Reference, Bundle> createStorageServices() throws FHIRException { @BeforeClass
IGraphQLStorageServices<Resource, Reference, Bundle> retVal = mock(IGraphQLStorageServices.class); public static void beforeClass() {
when(retVal.lookup(any(Object.class), any(Resource.class), any(Reference.class))).thenAnswer(new Answer<Object>() { ourCtx = FhirContext.forR4();
@Override ourWorkerCtx = new HapiWorkerContext(ourCtx, new DefaultProfileValidationSupport());
public Object answer(InvocationOnMock invocation) throws Throwable {
Object appInfo = invocation.getArguments()[0];
Resource context = (Resource) invocation.getArguments()[1];
Reference reference = (Reference) invocation.getArguments()[2];
ourLog.info("AppInfo: {} / Context: {} / Reference: {}", appInfo, context.getId(), reference.getReference());
if (reference.getReference().equalsIgnoreCase("Patient/123")) {
Patient p = new Patient();
p.getBirthDateElement().setValueAsString("2011-02-22");
return new ReferenceResolution<>(context, p);
}
ourLog.info("Not found!");
return null;
}
});
return retVal;
} }
} }