use of au.csiro.pathling.io.Database in project pathling by aehrc.
the class ManifestConverterTest method convertsManifest.
@Test
void convertsManifest() {
database = new Database(configuration, spark, fhirEncoders, executor);
final PassportScope passportScope = new PassportScope();
final VisaManifest manifest = new VisaManifest();
manifest.setPatientIds(Arrays.asList(PATIENT_ID_1, PATIENT_ID_2, PATIENT_ID_3, PATIENT_ID_4));
final ManifestConverter manifestConverter = new ManifestConverter(configuration, fhirContext);
manifestConverter.populateScope(passportScope, manifest);
// Convert the scope to JSON and compare it to a test fixture.
final Gson gson = new GsonBuilder().create();
final String json = gson.toJson(passportScope);
assertJson("responses/ManifestConverterTest/convertsManifest.json", json);
// our test patients.
for (final ResourceType resourceType : passportScope.keySet()) {
if (AVAILABLE_RESOURCE_TYPES.contains(resourceType)) {
boolean found = false;
for (final String filter : passportScope.get(resourceType)) {
final Dataset<Row> dataset = assertThatResultOf(resourceType, filter).isElementPath(BooleanPath.class).selectResult().apply(result -> result.filter(result.columns()[1])).getDataset();
if (dataset.count() > 0) {
found = true;
}
}
assertTrue(found, "No results found for " + resourceType.toCode());
}
}
}
use of au.csiro.pathling.io.Database in project pathling by aehrc.
the class EntityTagInterceptorTest method setUp.
@BeforeEach
void setUp() {
database = mock(Database.class);
conformanceProvider = mock(ConformanceProvider.class);
request = mock(HttpServletRequest.class);
requestDetails = mock(RequestDetails.class);
response = mock(HttpServletResponse.class);
final Configuration configuration = mock(Configuration.class);
final HttpCaching httpCaching = mock(HttpCaching.class);
when(httpCaching.getVary()).thenReturn(List.of("Accept", "Accept-Encoding", "Prefer", "Authorization"));
when(httpCaching.getCacheableControl()).thenReturn(List.of("must-revalidate", "max-age=1"));
when(configuration.getHttpCaching()).thenReturn(httpCaching);
interceptor = new EntityTagInterceptor(configuration, database, conformanceProvider);
}
use of au.csiro.pathling.io.Database in project pathling by aehrc.
the class CodingLiteralPathTest method setUp.
@BeforeEach
void setUp() {
final Database database = mock(Database.class);
final Dataset<Row> inputContextDataset = new ResourceDatasetBuilder(spark).withIdColumn().withRow("observation-1").withRow("observation-2").withRow("observation-3").withRow("observation-4").withRow("observation-5").build();
when(database.read(ResourceType.OBSERVATION)).thenReturn(inputContextDataset);
inputContext = new ResourcePathBuilder(spark).expression("Observation").resourceType(ResourceType.OBSERVATION).database(database).singular(true).build();
}
use of au.csiro.pathling.io.Database in project pathling by aehrc.
the class ExtractQueryTest method setUp.
@BeforeEach
void setUp() {
SharedMocks.resetAll();
database = mock(Database.class);
final ResultWriter resultWriter = mock(ResultWriter.class);
final ResultRegistry resultRegistry = mock(ResultRegistry.class);
executor = new ExtractExecutor(configuration, fhirContext, spark, database, Optional.ofNullable(terminologyServiceFactory), resultWriter, resultRegistry);
}
use of au.csiro.pathling.io.Database in project pathling by aehrc.
the class AggregateExecutorTest method runFirstGroupingThroughSearch.
/**
* Test that the drill-down expression from the first grouping from each aggregate result can be
* successfully executed using the FHIRPath search.
*/
@AfterEach
void runFirstGroupingThroughSearch() {
if (response != null) {
final Optional<Grouping> firstGroupingOptional = response.getGroupings().stream().filter(grouping -> grouping.getDrillDown().isPresent()).findFirst();
if (firstGroupingOptional.isPresent()) {
final Grouping firstGrouping = firstGroupingOptional.get();
assertTrue(firstGrouping.getDrillDown().isPresent());
final String drillDown = firstGrouping.getDrillDown().get();
final StringAndListParam filters = new StringAndListParam();
filters.addAnd(new StringParam(drillDown));
final IBundleProvider searchExecutor = new SearchExecutor(configuration, fhirContext, spark, database, Optional.of(terminologyServiceFactory), fhirEncoders, subjectResource, Optional.of(filters));
final List<IBaseResource> resources = searchExecutor.getResources(0, 100);
assertTrue(resources.size() > 0);
}
}
}
Aggregations