Skip to content

Commit

Permalink
Addressing the windows issue for the test cases to run.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalma Maadaadi committed Oct 3, 2023
1 parent 6048cf9 commit f67195a
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package org.opencds.cqf.tooling.operation;

import ca.uhn.fhir.context.FhirContext;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.r4.model.Library;
import org.opencds.cqf.tooling.Operation;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class StripGeneratedContentOperationTest {
import static org.testng.Assert.*;

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

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

assertEquals(libraryAfterStrip.getContent().size(), 1);
assertFalse(libraryAfterStrip.hasText());
Expand All @@ -50,4 +50,18 @@ public void test_strip_generated_content() throws URISyntaxException, FileNotFou
assertEquals(libraryAfterStrip.getRelatedArtifact().size(), 1);

}

private Path getPath() {
String location = getClass().getProtectionDomain().getCodeSource().getLocation().getPath() +
"/../test-output/strip-generated-content";
String[] st = location.split("/");
StringBuilder sb = new StringBuilder();
for(String item: st){
if(!StringUtils.isBlank(item)) {
sb.append(item);
sb.append(separator);
}
}
return Paths.get(sb.toString());
}
}

0 comments on commit f67195a

Please sign in to comment.