Skip to content

Commit

Permalink
issue #3855 - update path references in source files
Browse files Browse the repository at this point in the history
Signed-off-by: Lee Surprenant <lmsurpre@merative.com>
  • Loading branch information
lmsurpre committed Aug 9, 2022
1 parent ac0a5fe commit 93f4bd2
Show file tree
Hide file tree
Showing 31 changed files with 126 additions and 117 deletions.
2 changes: 1 addition & 1 deletion docs/src/pages/guides/BringYourOwnPersistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ The LinuxForHealth FHIR Server supports [extended operations](https://hl7.org/fh
In addition to defining the interfaces, the `fhir-persistence` module includes a set of tests that you can extend to test your implementation.

Most of the tests defined in this module relate to search, but they also exercise the create, update, and delete interactions in the process.
The tests in the `org.linuxforhealth.fhir.persistence.search.test` package are organized by search parameter type and they utilize tenant-specific search parameter definitions from the `fhir-persistence/src/test/resources/config` directory and search for fields on the generated example resources at `fhir-examples/src/main/resources/json/ibm/basic`. The `fhir-examples` module is available on Maven Central [link](https://repo1.maven.org/maven2/com/ibm/fhir/fhir-examples/).
The tests in the `org.linuxforhealth.fhir.persistence.search.test` package are organized by search parameter type and they utilize tenant-specific search parameter definitions from the `fhir-persistence/src/test/resources/config` directory and search for fields on the generated example resources at `fhir-examples/src/main/resources/json/basic`. The `fhir-examples` module is available on Maven Central [link](https://repo1.maven.org/maven2/org/linuxforhealth/fhir/fhir-examples/).

For an example of how to extend these tests, see the `org.linuxforhealth.fhir.persistence.jdbc.search.test` package under `fhir-persistence-jdbc/src/test/java`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
public class FHIRValueSetBenchmarks {
@Benchmark
public ValueSet readJsonResource() throws Exception {
Reader reader = ExamplesUtil.resourceReader("json/ibm/valueset/ValueSet-large.json");
Reader reader = ExamplesUtil.resourceReader("json/valueset/ValueSet-large.json");
return FHIRParser.parser(Format.JSON).parse(reader);
}

@Benchmark
public ValueSet readXmlResource() throws Exception {
Reader reader = ExamplesUtil.resourceReader("xml/ibm/valueset/ValueSet-large.xml");
Reader reader = ExamplesUtil.resourceReader("xml/valueset/ValueSet-large.xml");
return FHIRParser.parser(Format.XML).parse(reader);
}

Expand Down Expand Up @@ -83,7 +83,7 @@ public static class FHIRValueSetState {

@Setup
public void setUp() throws Exception {
Reader reader = ExamplesUtil.resourceReader("json/ibm/valueset/ValueSet-large.json");
Reader reader = ExamplesUtil.resourceReader("json/valueset/ValueSet-large.json");
valueSet = FHIRParser.parser(Format.JSON).parse(reader);

List<Contains> concepts = valueSet.getExpansion().getContains();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CheckReferenceTypeTest {
public void testCheckReferenceType() throws Exception {
boolean originalSetting = FHIRModelConfig.getCheckReferenceTypes();

try (Reader reader = ExamplesUtil.resourceReader("json/ibm/minimal/Observation-1.json")) {
try (Reader reader = ExamplesUtil.resourceReader("json/minimal/Observation-1.json")) {
FHIRModelConfig.setCheckReferenceTypes(true);
Observation observation = FHIRParser.parser(Format.JSON).parse(reader);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class CodeableConceptRequiredBindingTest {
@Test
public void testCodeableConceptRequiredBinding() throws Exception {
try (Reader reader = ExamplesUtil.resourceReader("json/ibm/minimal/AllergyIntolerance-1.json")) {
try (Reader reader = ExamplesUtil.resourceReader("json/minimal/AllergyIntolerance-1.json")) {
AllergyIntolerance allergyIntolerance = FHIRParser.parser(Format.JSON).parse(reader);

// valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static Extension buildMoneyQuantity() {
public void testResources() throws Exception {
for (Class<?> resourceType : ModelSupport.getResourceTypes(false)) {
Resource resource =
TestUtil.readExampleResource("json/ibm/complete-mock/" + resourceType.getSimpleName() + "-1.json");
TestUtil.readExampleResource("json/complete-mock/" + resourceType.getSimpleName() + "-1.json");
Method[] methods = resource.getClass().getMethods();
runMethods(resource, methods);
Class<?>[] clzs = resource.getClass().getClasses();
Expand All @@ -125,7 +125,7 @@ public void testResources() throws Exception {
public void testResourcesWithXml() throws Exception {
for (Class<?> resourceType : ModelSupport.getResourceTypes(false)) {
Resource resource =
TestUtil.readExampleResource("xml/ibm/complete-mock/" + resourceType.getSimpleName() + "-1.xml");
TestUtil.readExampleResource("xml/complete-mock/" + resourceType.getSimpleName() + "-1.xml");

Resource.Builder builder = resource.toBuilder();
Method[] methods = builder.getClass().getMethods();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020
* (C) Copyright IBM Corp. 2020, 2022
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -9,9 +9,6 @@
import static org.testng.Assert.fail;

import java.io.Reader;
import java.util.Collections;

import org.testng.annotations.Test;

import org.linuxforhealth.fhir.examples.ExamplesUtil;
import org.linuxforhealth.fhir.model.format.Format;
Expand All @@ -23,61 +20,73 @@
import org.linuxforhealth.fhir.model.type.Coding;
import org.linuxforhealth.fhir.model.type.Uri;
import org.linuxforhealth.fhir.model.util.ValidationSupport;
import org.testng.annotations.Test;

/**
* Tests for validation against Code/Coding/CodeableConcept required (or maxValueSet) binding to syntax-based value sets.
*/
public class SyntaxBasedValueSetBindingTest {

// Currently no resource types have a Code with a required binding to a syntax-based value set. If that changes, add tests here.
// Currently no resource types have a Code with a required binding to a syntax-based value set. If that changes, add tests here.

@Test
public void testMaxValueSetCodeValid() throws Exception {
try (Reader reader = ExamplesUtil.resourceReader("json/ibm/minimal/Account-1.json")) {
Account account = FHIRParser.parser(Format.JSON).parse(reader);

account.toBuilder().language(Code.of("en-AU")).build();
}
Account account = TestUtil.getMinimalResource(Account.class);
account.toBuilder().language(Code.of("en-AU")).build();
}
@Test

@Test
public void testMaxValueSetCodeNotValid() throws Exception {
try (Reader reader = ExamplesUtil.resourceReader("json/ibm/minimal/Account-1.json")) {
Account account = FHIRParser.parser(Format.JSON).parse(reader);
Account account = TestUtil.getMinimalResource(Account.class);

try {
account.toBuilder().language(Code.of("invalidLanguageCode")).build();
fail();
} catch (IllegalStateException e) {
}
try {
account.toBuilder().language(Code.of("invalidLanguageCode")).build();
fail();
} catch (IllegalStateException e) {
// expected
}
}

// Currently no resource types have a Coding with a required binding to a syntax-based value set. If that changes, add tests here.

// Currently no resource types have a Coding with a maxValueSet binding to a syntax-based value set. If that changes, add tests here.
// Currently no resource types have a Coding with a required binding to a syntax-based value set. If that changes, add tests here.

// Currently no resource types have a Coding with a maxValueSet binding to a syntax-based value set. If that changes, add tests here.

@Test
@Test
public void testMaxValueSetCodeableConceptValid() throws Exception {
try (Reader reader = ExamplesUtil.resourceReader("json/ibm/minimal/Practitioner-1.json")) {
Practitioner practitioner = FHIRParser.parser(Format.JSON).parse(reader);

practitioner.toBuilder().communication(Collections.singletonList(CodeableConcept.builder().coding(
Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("ar")).build()).build())).build();
}
Practitioner practitioner = TestUtil.getMinimalResource(Practitioner.class);

practitioner.toBuilder()
.communication(CodeableConcept.builder()
.coding(Coding.builder()
.system(Uri.of(ValidationSupport.BCP_47_URN))
.code(Code.of("ar"))
.build())
.build())
.build();
}
@Test

@Test
public void testMaxValueSetCodeableConceptNotValid() throws Exception {
try (Reader reader = ExamplesUtil.resourceReader("json/ibm/minimal/Practitioner-1.json")) {
Practitioner practitioner = FHIRParser.parser(Format.JSON).parse(reader);
try (Reader reader = ExamplesUtil.resourceReader("json/minimal/Practitioner-1.json")) {
Practitioner practitioner = FHIRParser.parser(Format.JSON).parse(reader);

try {
practitioner.toBuilder().communication(Collections.singletonList(CodeableConcept.builder().coding(
Coding.builder().system(Uri.of("invalidSystem")).code(Code.of("ar")).build(),
Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("invalidLanguageCode")).build()).build())).build();
fail();
practitioner.toBuilder()
.communication(CodeableConcept.builder()
.coding(Coding.builder()
.system(Uri.of("invalidSystem"))
.code(Code.of("ar"))
.build())
.coding(Coding.builder()
.system(Uri.of(ValidationSupport.BCP_47_URN))
.code(Code.of("invalidLanguageCode"))
.build())
.build())
.build();

fail();
} catch (IllegalStateException e) {
// expected
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static <T extends Resource> T readLocalResource(String fileName) throws E
* This function reads the contents of an example resource from the specified path in fhir-examples into a Resource.
*
* @param fileName
* the name of the file containing the example resource (e.g. "json/ibm/minimal/Patient-1.json")
* the name of the file containing the example resource (e.g. "json/minimal/Patient-1.json")
* @return the de-serialized resource
* @throws Exception
*/
Expand Down Expand Up @@ -337,7 +337,7 @@ public static <T extends Resource> T getMinimalResource(Class<T> type, Format fo

// Build filename
String formatString = format.toString().toLowerCase();
String fileName = formatString + "/ibm/minimal/" + type.getSimpleName() + "-1." + formatString;
String fileName = formatString + "/minimal/" + type.getSimpleName() + "-1." + formatString;

// Deserialize the file contents.
try (Reader reader = ExamplesUtil.resourceReader(fileName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public static void main(java.lang.String[] args) throws Exception {
.family(String.of("Doe"))
.build();

Resource patient1 = TestUtil.readExampleResource("json/ibm/minimal/Patient-1.json").toBuilder().id("1").build();
Resource patient2 = TestUtil.readExampleResource("json/ibm/minimal/Patient-2.json").toBuilder().id("2").build();
Resource patient1 = TestUtil.getMinimalResource(Patient.class).toBuilder().id("1").build();
Resource patient2 = patient1.toBuilder().id("2").build();

Patient patient = Patient.builder()
.id(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
* --expectation PARSE
* --file-name file:/path/to/bad.json
* --expectation VALIDATION
* --file-name json/ibm/minimal/Patient-1.json
* --file-name json/minimal/Patient-1.json
*
* java org.linuxforhealth.fhir.persistence.jdbc.test.spec.Main
* --parse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public abstract class AbstractSearchCompartmentTest extends AbstractPLSearchTest

@Override
protected Basic getBasicResource() throws Exception {
Basic basic = TestUtil.readExampleResource("json/ibm/basic/BasicWithAllTypes.json");
Basic basic = TestUtil.readExampleResource("json/basic/BasicWithAllTypes.json");
// Add a references to a patient and a practitioner so we can exercise those compartments
return basic.toBuilder()
.subject(Reference.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class AbstractSearchCompositeTest extends AbstractPLSearchTest {

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicComposite.json");
return TestUtil.readExampleResource("json/basic/BasicComposite.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class AbstractSearchDateTest extends AbstractPLSearchTest {

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicDate.json");
return TestUtil.readExampleResource("json/basic/BasicDate.json");
}
@Override
protected void setTenant() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public abstract class AbstractSearchIdAndLastUpdatedTest extends AbstractPLSearc

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicDate.json");
return TestUtil.readExampleResource("json/basic/BasicDate.json");
}

private Reference buildReference(Resource resource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class AbstractSearchNumberTest extends AbstractPLSearchTest {

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicNumber.json");
return TestUtil.readExampleResource("json/basic/BasicNumber.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class AbstractSearchQuantityTest extends AbstractPLSearchTest {

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicQuantity.json");
return TestUtil.readExampleResource("json/basic/BasicQuantity.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class AbstractSearchReferenceTest extends AbstractPLSearchTest {

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicReference.json");
return TestUtil.readExampleResource("json/basic/BasicReference.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class AbstractSearchStringTest extends AbstractPLSearchTest {

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicString.json");
return TestUtil.readExampleResource("json/basic/BasicString.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class AbstractSearchTokenTest extends AbstractPLSearchTest {

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicToken.json");
return TestUtil.readExampleResource("json/basic/BasicToken.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class AbstractSearchURITest extends AbstractPLSearchTest {

@Override
protected Basic getBasicResource() throws Exception {
return TestUtil.readExampleResource("json/ibm/basic/BasicURI.json");
return TestUtil.readExampleResource("json/basic/BasicURI.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GroupSearchCompilerTest {
@Test(expectedExceptions= {GroupSearchCompilerException.class})
public void testDisabledGroup() throws Exception {
GroupSearchCompiler compiler = GroupSearchCompilerFactory.getInstance();
Group group = (Group) TestUtil.readExampleResource("json/ibm/bulk-data/group/age-simple-disabled-group.json");
Group group = (Group) TestUtil.readExampleResource("json/bulk-data/group/age-simple-disabled-group.json");
compiler.groupToSearch(group, "Patient");
}

Expand All @@ -37,7 +37,7 @@ public void testGroupNull() throws Exception {
@Test
public void testAgeRangeGroup() throws Exception {
GroupSearchCompiler compiler = GroupSearchCompilerFactory.getInstance();
Group group = (Group) TestUtil.readExampleResource("json/ibm/bulk-data/group/age-range-group.json");
Group group = (Group) TestUtil.readExampleResource("json/bulk-data/group/age-range-group.json");
MultivaluedMap<String,String> queryParams = compiler.groupToSearch(group, "Patient");
assertNotNull(queryParams);
assertEquals(queryParams.size(),1);
Expand All @@ -47,7 +47,7 @@ public void testAgeRangeGroup() throws Exception {
@Test
public void testAgeSimpleGroup() throws Exception {
GroupSearchCompiler compiler = GroupSearchCompilerFactory.getInstance();
Group group = (Group) TestUtil.readExampleResource("json/ibm/bulk-data/group/age-simple-group.json");
Group group = (Group) TestUtil.readExampleResource("json/bulk-data/group/age-simple-group.json");
MultivaluedMap<String,String> queryParams = compiler.groupToSearch(group, "Patient");
assertNotNull(queryParams);
assertEquals(queryParams.size(),1);
Expand All @@ -57,7 +57,7 @@ public void testAgeSimpleGroup() throws Exception {
@Test
public void testAgeRangeBloodPressureGroup() throws Exception {
GroupSearchCompiler compiler = GroupSearchCompilerFactory.getInstance();
Group group = (Group) TestUtil.readExampleResource("json/ibm/bulk-data/group/age-range-blood-pressure-group.json");
Group group = (Group) TestUtil.readExampleResource("json/bulk-data/group/age-range-blood-pressure-group.json");
MultivaluedMap<String,String> queryParams = compiler.groupToSearch(group, "Patient");
assertNotNull(queryParams);
assertEquals(queryParams.size(),1);
Expand All @@ -67,7 +67,7 @@ public void testAgeRangeBloodPressureGroup() throws Exception {
@Test
public void testAgeRangeGenderGroup() throws Exception {
GroupSearchCompiler compiler = GroupSearchCompilerFactory.getInstance();
Group group = (Group) TestUtil.readExampleResource("json/ibm/bulk-data/group/age-range-with-gender-group.json");
Group group = (Group) TestUtil.readExampleResource("json/bulk-data/group/age-range-with-gender-group.json");
MultivaluedMap<String,String> queryParams = compiler.groupToSearch(group, "Patient");
assertNotNull(queryParams);
assertEquals(queryParams.size(),2);
Expand All @@ -79,7 +79,7 @@ public void testAgeRangeGenderGroup() throws Exception {
@Test
public void testAgeRangeGenderAndExcludeGroup() throws Exception {
GroupSearchCompiler compiler = GroupSearchCompilerFactory.getInstance();
Group group = (Group) TestUtil.readExampleResource("json/ibm/bulk-data/group/age-range-with-gender-and-exclude-group.json");
Group group = (Group) TestUtil.readExampleResource("json/bulk-data/group/age-range-with-gender-and-exclude-group.json");
MultivaluedMap<String,String> queryParams = compiler.groupToSearch(group, "Patient");
assertNotNull(queryParams);
assertEquals(queryParams.size(),2);
Expand Down
Loading

0 comments on commit 93f4bd2

Please sign in to comment.