Skip to content

Commit

Permalink
Fixed pom entry for wiremock, abandoning multhreading on LibraryProce…
Browse files Browse the repository at this point in the history
…ssor as it's too unstable at the server during ci checks, and added conditional path processing to tooling/src/test/java/org/opencds/cqf/tooling/operation/StripGeneratedContentOperationTest.java
  • Loading branch information
Evan Chicoine committed Oct 25, 2023
1 parent 7fa132b commit 365eaef
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 43 deletions.
3 changes: 2 additions & 1 deletion tooling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,9 @@
<version>4.1.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>3.0.1</version>
<scope>test</scope>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,54 +93,25 @@ public List<String> refreshIgLibraryContent(BaseProcessor parentContext, Encodin

public Boolean bundleLibraryDependencies(String path, FhirContext fhirContext, Map<String, IBaseResource> resources,
Encoding encoding, boolean versioned) {
return ThreadUtils.executeTasks(bundleLibraryDependenciesTasks(path, fhirContext, resources, encoding, versioned));
}

public List<Callable<Void>> bundleLibraryDependenciesTasks(String path, FhirContext fhirContext, Map<String, IBaseResource> resources,
Encoding encoding, boolean versioned) {
List<Callable<Void>> returnTasks = new ArrayList<>();

String fileName = FilenameUtils.getName(path);
boolean prefixed = fileName.toLowerCase().startsWith("library-");
Boolean shouldPersist = true;
try {
Map<String, IBaseResource> dependencies = ResourceUtils.getDepLibraryResources(path, fhirContext, encoding, versioned, logger);
// String currentResourceID = IOUtils.getTypeQualifiedResourceId(path, fhirContext);
for (IBaseResource resource : dependencies.values()) {
returnTasks.add(() -> {
resources.putIfAbsent(resource.getIdElement().getIdPart(), resource);
resources.putIfAbsent(resource.getIdElement().getIdPart(), resource);

// NOTE: Assuming dependency library will be in directory of dependent.
String dependencyPath = IOUtils.getResourceFileName(IOUtils.getResourceDirectory(path), resource, encoding, fhirContext, versioned, prefixed);
returnTasks.addAll(bundleLibraryDependenciesTasks(dependencyPath, fhirContext, resources, encoding, versioned));
return null;
});
// NOTE: Assuming dependency library will be in directory of dependent.
String dependencyPath = IOUtils.getResourceFileName(IOUtils.getResourceDirectory(path), resource, encoding, fhirContext, versioned, prefixed);
bundleLibraryDependencies(dependencyPath, fhirContext, resources, encoding, versioned);
}
} catch (Exception e) {
shouldPersist = false;
LogUtils.putException(path, e);
}
return returnTasks;
return shouldPersist;
}
//public Boolean bundleLibraryDependencies(String path, FhirContext fhirContext, Map<String, IBaseResource> resources,
// Encoding encoding, boolean versioned) {
// String fileName = FilenameUtils.getName(path);
// boolean prefixed = fileName.toLowerCase().startsWith("library-");
// Boolean shouldPersist = true;
// try {
// Map<String, IBaseResource> dependencies = ResourceUtils.getDepLibraryResources(path, fhirContext, encoding, versioned, logger);
// // String currentResourceID = IOUtils.getTypeQualifiedResourceId(path, fhirContext);
// for (IBaseResource resource : dependencies.values()) {
// resources.putIfAbsent(resource.getIdElement().getIdPart(), resource);
//
// // NOTE: Assuming dependency library will be in directory of dependent.
// String dependencyPath = IOUtils.getResourceFileName(IOUtils.getResourceDirectory(path), resource, encoding, fhirContext, versioned, prefixed);
// bundleLibraryDependencies(dependencyPath, fhirContext, resources, encoding, versioned);
// }
// } catch (Exception e) {
// shouldPersist = false;
// LogUtils.putException(path, e);
// }
// return shouldPersist;
//}

protected boolean versioned;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.nio.file.Paths;

public class StripGeneratedContentOperationTest {

private static final String separator = System.getProperty("file.separator");
@Test
public void test_strip_generated_content() throws URISyntaxException, FileNotFoundException {
String dataInputPath = "strip-resources";
Expand All @@ -39,12 +39,23 @@ public void test_strip_generated_content() throws URISyntaxException, FileNotFou
Operation stripGeneratedContentOperation = new StripGeneratedContentOperation();
stripGeneratedContentOperation.execute(args);

File classLocation = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
File parentDir = classLocation.getParentFile(); // Get the parent directory of the class location
File outputDir = new File(parentDir, "test-output/");
File jsonFile = new File(outputDir, "strip-generated-contentLibraryBreastCancerScreeningFHIR.json");
Library libraryAfterStrip = null;
if (separator.equalsIgnoreCase("/")) {

Path path = Paths.get(getClass().getProtectionDomain().getCodeSource().getLocation().getPath() +
"/../test-output/strip-generated-content");
libraryAfterStrip = (Library)FhirContext.forR4Cached().newJsonParser().parseResource(
new FileReader(path + "/LibraryBreastCancerScreeningFHIR.json"));

}else{

File classLocation = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
File parentDir = classLocation.getParentFile(); // Get the parent directory of the class location
File outputDir = new File(parentDir, "test-output/");
File jsonFile = new File(outputDir, "strip-generated-contentLibraryBreastCancerScreeningFHIR.json");

Library libraryAfterStrip = (Library) FhirContext.forR4Cached().newJsonParser().parseResource(new FileReader(jsonFile));
libraryAfterStrip = (Library) FhirContext.forR4Cached().newJsonParser().parseResource(new FileReader(jsonFile));
}


assertEquals(libraryAfterStrip.getContent().size(), 1);
Expand Down

0 comments on commit 365eaef

Please sign in to comment.