Merge pull request #858 from patrick-werner/master
added Test for #11 to Dstu3 and R4, fixed #853
This commit is contained in:
commit
29c09e40f0
|
@ -51,6 +51,8 @@ import java.util.*;
|
|||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.hamcrest.text.StringContainsInOrder.stringContainsInOrder;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
@ -3242,6 +3244,26 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See #11
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateContainedResources() {
|
||||
|
||||
Observation resA = new Observation();
|
||||
resA.setComment("A");
|
||||
|
||||
Observation resB = new Observation();
|
||||
resB.setComment("B");
|
||||
resB.addBasedOn(new Reference(resA));
|
||||
resB.addBasedOn(new Reference(resA));
|
||||
|
||||
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resB);
|
||||
ourLog.info(encoded);
|
||||
|
||||
assertThat(encoded, stringContainsInOrder(Arrays.asList("<contained>", "<Observation", "</Observation>", "</contained>")));
|
||||
assertThat(encoded, not(stringContainsInOrder(Arrays.asList("<contained>", "<Observation", "</Observation>", "<Observation", "</contained>"))));
|
||||
}
|
||||
/**
|
||||
* See #551
|
||||
*/
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package z;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class TestTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testId() throws InterruptedException {
|
||||
Thread.sleep(1000000);
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,17 +4,21 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.hamcrest.text.StringContainsInOrder.stringContainsInOrder;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class XmlParserR4Test {
|
||||
|
@ -161,6 +165,26 @@ public class XmlParserR4Test {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* See #11
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateContainedResources() {
|
||||
|
||||
Observation resA = new Observation();
|
||||
resA.setComment("A");
|
||||
|
||||
Observation resB = new Observation();
|
||||
resB.setComment("B");
|
||||
resB.addHasMember(new Reference(resA));
|
||||
resB.addHasMember(new Reference(resA));
|
||||
|
||||
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resB);
|
||||
ourLog.info(encoded);
|
||||
|
||||
assertThat(encoded, stringContainsInOrder(Arrays.asList("<contained>", "<Observation", "</Observation>", "</contained>")));
|
||||
assertThat(encoded, not(stringContainsInOrder(Arrays.asList("<contained>", "<Observation", "</Observation>", "<Observation", "</contained>"))));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
|
|
|
@ -3601,7 +3601,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
// all observations should have a subject, a performer, and a time
|
||||
|
||||
bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("subject") != null, "All observations should have a subject");
|
||||
bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("performer") != null, "All observations should have a performer");
|
||||
List<Element> performer = new ArrayList();
|
||||
element.getNamedChildren("performer", performer);
|
||||
bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), !performer.isEmpty(), "All observations should have a performer");
|
||||
bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("effectiveDateTime") != null || element.getNamedChild("effectivePeriod") != null,
|
||||
"All observations should have an effectiveDateTime or an effectivePeriod");
|
||||
}
|
||||
|
|
18
pom.xml
18
pom.xml
|
@ -323,9 +323,6 @@
|
|||
<id>joelsch</id>
|
||||
<name>Joel Schneider</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>elnin0815</id>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>dangerousben</id>
|
||||
<name>Ben Spencer</name>
|
||||
|
@ -1801,6 +1798,21 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-maven</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<failBuildOnCVSS>8</failBuildOnCVSS>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
Loading…
Reference in New Issue