fixing tests
This commit is contained in:
parent
368a45a150
commit
5893249747
|
@ -20,21 +20,15 @@ import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices;
|
||||||
import org.hl7.fhir.utilities.graphql.NameValue;
|
import org.hl7.fhir.utilities.graphql.NameValue;
|
||||||
import org.hl7.fhir.utilities.graphql.Parser;
|
import org.hl7.fhir.utilities.graphql.Parser;
|
||||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -42,8 +36,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class GraphQLEngineTests implements IGraphQLStorageServices {
|
public class GraphQLEngineTests implements IGraphQLStorageServices {
|
||||||
|
|
||||||
public static Stream<Arguments> data() throws IOException, ParserConfigurationException, SAXException {
|
public static Stream<Arguments> data() throws IOException, ParserConfigurationException, SAXException {
|
||||||
|
@ -91,7 +83,7 @@ public class GraphQLEngineTests implements IGraphQLStorageServices {
|
||||||
msg = e.getMessage();
|
msg = e.getMessage();
|
||||||
}
|
}
|
||||||
if (ok) {
|
if (ok) {
|
||||||
assertTrue("Expected to fail, but didn't", !output.equals("$error"));
|
Assertions.assertTrue(!output.equals("$error"), "Expected to fail, but didn't");
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
gql.getOutput().setWriteWrapper(false);
|
gql.getOutput().setWriteWrapper(false);
|
||||||
gql.getOutput().write(str, 0);
|
gql.getOutput().write(str, 0);
|
||||||
|
@ -99,10 +91,10 @@ public class GraphQLEngineTests implements IGraphQLStorageServices {
|
||||||
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "graphql", output), new FileOutputStream(TestingUtilities.tempFile("graphql", output)));
|
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "graphql", output), new FileOutputStream(TestingUtilities.tempFile("graphql", output)));
|
||||||
TextFile.stringToFile(str.toString(), TestingUtilities.tempFile("graphql", output+".out"));
|
TextFile.stringToFile(str.toString(), TestingUtilities.tempFile("graphql", output+".out"));
|
||||||
msg = TestingUtilities.checkJsonIsSame(TestingUtilities.tempFile("graphql", output+".out"), TestingUtilities.tempFile("graphql", output));
|
msg = TestingUtilities.checkJsonIsSame(TestingUtilities.tempFile("graphql", output+".out"), TestingUtilities.tempFile("graphql", output));
|
||||||
assertTrue(msg, Utilities.noString(msg));
|
Assertions.assertTrue(Utilities.noString(msg), msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assertTrue("Error, but proper output was expected ("+msg+")", output.equals("$error"));
|
Assertions.assertTrue(output.equals("$error"), "Error, but proper output was expected ("+msg+")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
package org.hl7.fhir.r5.test;
|
package org.hl7.fhir.r5.test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||||
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
import org.hl7.fhir.utilities.graphql.EGraphEngine;
|
||||||
|
import org.hl7.fhir.utilities.graphql.EGraphQLException;
|
||||||
|
import org.hl7.fhir.utilities.graphql.Package;
|
||||||
|
import org.hl7.fhir.utilities.graphql.Parser;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -8,31 +16,18 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.hl7.fhir.utilities.TextFile;
|
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
|
||||||
import org.hl7.fhir.utilities.graphql.EGraphEngine;
|
|
||||||
import org.hl7.fhir.utilities.graphql.EGraphQLException;
|
|
||||||
import org.hl7.fhir.utilities.graphql.Package;
|
|
||||||
import org.hl7.fhir.utilities.graphql.Parser;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
public class GraphQLParserTests {
|
public class GraphQLParserTests {
|
||||||
|
|
||||||
public static Stream<Arguments> data() throws FileNotFoundException, IOException {
|
public static Stream<Arguments> data() throws IOException {
|
||||||
String src = TestingUtilities.loadTestResource("r5", "graphql", "parser-tests.gql");
|
String src = TestingUtilities.loadTestResource("r5", "graphql", "parser-tests.gql");
|
||||||
String[] tests = src.split("###");
|
String[] tests = src.split("###");
|
||||||
List<Arguments> objects = new ArrayList<>();
|
List<Arguments> objects = new ArrayList<>();
|
||||||
for (String s : tests) {
|
for (String s : tests) {
|
||||||
if (!Utilities.noString(s.trim())) {
|
if (!Utilities.noString(s.trim())) {
|
||||||
int l = s.indexOf('\r');
|
int l = s.indexOf('\r');
|
||||||
objects.add(Arguments.of(s.substring(0, l), s.substring(l+2).trim()));
|
objects.add(Arguments.of(s.substring(0, l), s.substring(l + 2).trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return objects.stream();
|
return objects.stream();
|
||||||
|
|
|
@ -2,11 +2,9 @@ package org.hl7.fhir.r5.test;
|
||||||
|
|
||||||
import org.hl7.fhir.r5.model.Coding;
|
import org.hl7.fhir.r5.model.Coding;
|
||||||
import org.hl7.fhir.r5.model.Meta;
|
import org.hl7.fhir.r5.model.Meta;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class MetaTest {
|
public class MetaTest {
|
||||||
public static String TEST_SYSTEM = "TEST_SYSTEM";
|
public static String TEST_SYSTEM = "TEST_SYSTEM";
|
||||||
public static String TEST_CODE = "TEST_CODE";
|
public static String TEST_CODE = "TEST_CODE";
|
||||||
|
@ -15,12 +13,12 @@ public class MetaTest {
|
||||||
public void testMetaSecurity() {
|
public void testMetaSecurity() {
|
||||||
Meta meta = new Meta();
|
Meta meta = new Meta();
|
||||||
Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
|
Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
|
||||||
assertTrue(meta.hasSecurity());
|
Assertions.assertTrue(meta.hasSecurity());
|
||||||
assertNotNull(meta.getSecurity());
|
Assertions.assertNotNull(meta.getSecurity());
|
||||||
assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
|
Assertions.assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
|
||||||
assertEquals(1, meta.getSecurity().size());
|
Assertions.assertEquals(1, meta.getSecurity().size());
|
||||||
assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
|
Assertions.assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
|
||||||
assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
|
Assertions.assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
|
||||||
assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
|
Assertions.assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.hl7.fhir.r5.test;
|
package org.hl7.fhir.r5.test;
|
||||||
|
|
||||||
import org.fhir.ucum.UcumException;
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.r5.formats.XmlParser;
|
import org.hl7.fhir.r5.formats.XmlParser;
|
||||||
import org.hl7.fhir.r5.model.DomainResource;
|
import org.hl7.fhir.r5.model.DomainResource;
|
||||||
|
@ -23,7 +22,7 @@ public class NarrativeGeneratorTests {
|
||||||
private NarrativeGenerator gen;
|
private NarrativeGenerator gen;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public void setUp() throws FileNotFoundException, IOException, FHIRException, UcumException {
|
public void setUp() throws FHIRException {
|
||||||
gen = new NarrativeGenerator("", null, TestingUtilities.context());
|
gen = new NarrativeGenerator("", null, TestingUtilities.context());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.hl7.fhir.r5.test;
|
package org.hl7.fhir.r5.test;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.fhir.ucum.UcumException;
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.r5.formats.IParser;
|
import org.hl7.fhir.r5.formats.IParser;
|
||||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||||
|
@ -20,7 +19,7 @@ import java.io.*;
|
||||||
public class ResourceRoundTripTests {
|
public class ResourceRoundTripTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws FileNotFoundException, IOException, FHIRException, EOperationOutcome, UcumException {
|
public void test() throws IOException, FHIRException, EOperationOutcome {
|
||||||
Resource res = new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"));
|
Resource res = new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"));
|
||||||
new NarrativeGenerator("", "", TestingUtilities.context()).generate((DomainResource) res, null);
|
new NarrativeGenerator("", "", TestingUtilities.context()).generate((DomainResource) res, null);
|
||||||
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.xml")));
|
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.xml")));
|
||||||
|
|
|
@ -2,10 +2,9 @@ package org.hl7.fhir.r5.test;
|
||||||
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.r5.utils.SnomedExpressions;
|
import org.hl7.fhir.r5.utils.SnomedExpressions;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
public class SnomedExpressionsTests {
|
public class SnomedExpressionsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -47,7 +46,7 @@ public class SnomedExpressionsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void p(String expression) throws FHIRException {
|
private void p(String expression) throws FHIRException {
|
||||||
assertNotNull("must be present", SnomedExpressions.parse(expression));
|
Assertions.assertNotNull(SnomedExpressions.parse(expression), "must be present");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.hl7.fhir.r5.utils.StructureMapUtilities;
|
||||||
import org.hl7.fhir.r5.utils.StructureMapUtilities.ITransformerServices;
|
import org.hl7.fhir.r5.utils.StructureMapUtilities.ITransformerServices;
|
||||||
import org.hl7.fhir.utilities.cache.PackageCacheManager;
|
import org.hl7.fhir.utilities.cache.PackageCacheManager;
|
||||||
import org.hl7.fhir.utilities.cache.ToolsVersion;
|
import org.hl7.fhir.utilities.cache.ToolsVersion;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -24,7 +23,7 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
|
||||||
|
|
||||||
static private SimpleWorkerContext context;
|
static private SimpleWorkerContext context;
|
||||||
|
|
||||||
@BeforeAll
|
// @BeforeAll
|
||||||
static public void setUp() throws Exception {
|
static public void setUp() throws Exception {
|
||||||
PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||||
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.0"));
|
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.0"));
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,6 @@
|
||||||
package org.hl7.fhir.r5.test;
|
package org.hl7.fhir.r5.test;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
import org.apache.commons.lang3.SystemUtils;
|
||||||
|
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
||||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||||
|
@ -14,6 +9,9 @@ import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class UtilitiesTests {
|
public class UtilitiesTests {
|
||||||
|
|
||||||
private static final String XHTML_SIMPLE = "<div>Some Text</div>";
|
private static final String XHTML_SIMPLE = "<div>Some Text</div>";
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
package org.hl7.fhir.r5.test;
|
package org.hl7.fhir.r5.test;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||||
import org.hl7.fhir.r5.elementmodel.Element;
|
import org.hl7.fhir.r5.elementmodel.Element;
|
||||||
|
@ -14,6 +8,12 @@ import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
||||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ValidationTestConvertor {
|
public class ValidationTestConvertor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,12 +29,12 @@ public class ValidationTestConvertor {
|
||||||
File t = new File(Utilities.changeFileExt(f.getAbsolutePath(), ".ttl"));
|
File t = new File(Utilities.changeFileExt(f.getAbsolutePath(), ".ttl"));
|
||||||
if (!t.exists()) {
|
if (!t.exists()) {
|
||||||
try {
|
try {
|
||||||
System.out.print("Process "+f.getAbsolutePath());
|
System.out.print("Process " + f.getAbsolutePath());
|
||||||
Element e = Manager.parse(context, new FileInputStream(f), FhirFormat.XML);
|
Element e = Manager.parse(context, new FileInputStream(f), FhirFormat.XML);
|
||||||
Manager.compose(context, e, new FileOutputStream(t), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
|
Manager.compose(context, e, new FileOutputStream(t), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
|
||||||
System.out.println(" .... success");
|
System.out.println(" .... success");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(" .... fail: "+e.getMessage());
|
System.out.println(" .... fail: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,17 +43,16 @@ public class ValidationTestConvertor {
|
||||||
File t = new File(Utilities.changeFileExt(f.getAbsolutePath(), ".ttl"));
|
File t = new File(Utilities.changeFileExt(f.getAbsolutePath(), ".ttl"));
|
||||||
if (!t.exists()) {
|
if (!t.exists()) {
|
||||||
try {
|
try {
|
||||||
System.out.print("Process "+f.getAbsolutePath());
|
System.out.print("Process " + f.getAbsolutePath());
|
||||||
Element e = Manager.parse(context, new FileInputStream(f), FhirFormat.JSON);
|
Element e = Manager.parse(context, new FileInputStream(f), FhirFormat.JSON);
|
||||||
Manager.compose(context, e, new FileOutputStream(t), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
|
Manager.compose(context, e, new FileOutputStream(t), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
|
||||||
System.out.println(" .... success");
|
System.out.println(" .... success");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(" .... fail: "+e.getMessage());
|
System.out.println(" .... fail: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue