Add tests
This commit is contained in:
parent
578f2b7aef
commit
e6d3897700
|
@ -25,6 +25,7 @@ import java.util.zip.ZipEntry;
|
|||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.*;
|
||||
import static org.apache.commons.lang3.StringUtils.leftPad;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -252,6 +253,66 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyDeltaAdd_UsingCodeSystemWithVeryLongDescription() {
|
||||
|
||||
// Create initial codesystem
|
||||
{
|
||||
CodeSystem codeSystem = new CodeSystem();
|
||||
codeSystem.setUrl("http://foo/cs");
|
||||
CodeSystem.ConceptDefinitionComponent chem = codeSystem.addConcept().setCode("CHEM").setDisplay("Chemistry");
|
||||
chem.addConcept().setCode("HB").setDisplay("Hemoglobin");
|
||||
|
||||
LoggingInterceptor interceptor = new LoggingInterceptor(true);
|
||||
ourClient.registerInterceptor(interceptor);
|
||||
Parameters outcome = ourClient
|
||||
.operation()
|
||||
.onType(CodeSystem.class)
|
||||
.named(JpaConstants.OPERATION_APPLY_CODESYSTEM_DELTA_ADD)
|
||||
.withParameter(Parameters.class, TerminologyUploaderProvider.PARAM_SYSTEM, new UriType("http://foo/cs"))
|
||||
.andParameter(TerminologyUploaderProvider.PARAM_CODESYSTEM, codeSystem)
|
||||
.prettyPrint()
|
||||
.execute();
|
||||
ourClient.unregisterInterceptor(interceptor);
|
||||
}
|
||||
|
||||
// Add a child with a really long description
|
||||
Parameters outcome;
|
||||
{
|
||||
CodeSystem codeSystem = new CodeSystem();
|
||||
codeSystem.setUrl("http://foo/cs");
|
||||
CodeSystem.ConceptDefinitionComponent chem = codeSystem.addConcept().setCode("HB").setDisplay("Hemoglobin")
|
||||
.addConcept().setCode("HBA").setDisplay(leftPad("", 500, 'Z'));
|
||||
|
||||
LoggingInterceptor interceptor = new LoggingInterceptor(true);
|
||||
ourClient.registerInterceptor(interceptor);
|
||||
outcome = ourClient
|
||||
.operation()
|
||||
.onType(CodeSystem.class)
|
||||
.named(JpaConstants.OPERATION_APPLY_CODESYSTEM_DELTA_ADD)
|
||||
.withParameter(Parameters.class, TerminologyUploaderProvider.PARAM_SYSTEM, new UriType("http://foo/cs"))
|
||||
.andParameter(TerminologyUploaderProvider.PARAM_CODESYSTEM, codeSystem)
|
||||
.prettyPrint()
|
||||
.execute();
|
||||
ourClient.unregisterInterceptor(interceptor);
|
||||
}
|
||||
|
||||
String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome);
|
||||
ourLog.info(encoded);
|
||||
assertThat(encoded, stringContainsInOrder(
|
||||
"\"name\": \"conceptCount\"",
|
||||
"\"valueInteger\": 2",
|
||||
"\"name\": \"target\"",
|
||||
"\"reference\": \"CodeSystem/"
|
||||
));
|
||||
|
||||
assertHierarchyContains(
|
||||
"CHEM seq=0",
|
||||
" HB seq=0",
|
||||
" HBA seq=0"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyDeltaAdd_MissingSystem() throws IOException {
|
||||
String conceptsCsv = loadResource("/custom_term/concepts.csv");
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.leftPad;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -219,6 +220,44 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddChildWithVeryLongDescription() {
|
||||
CustomTerminologySet set;
|
||||
|
||||
// Create not-present
|
||||
CodeSystem cs = new CodeSystem();
|
||||
cs.setUrl("http://foo");
|
||||
cs.setContent(CodeSystem.CodeSystemContentMode.NOTPRESENT);
|
||||
myCodeSystemDao.create(cs);
|
||||
|
||||
// Add parent with 1 child
|
||||
set = new CustomTerminologySet();
|
||||
set.addRootConcept("ParentA", "Parent A")
|
||||
.addChild(TermConceptParentChildLink.RelationshipTypeEnum.ISA).setCode("ChildA").setDisplay("Child A");
|
||||
myTermCodeSystemStorageSvc.applyDeltaCodeSystemsAdd("http://foo", set);
|
||||
|
||||
// Check so far
|
||||
assertHierarchyContains(
|
||||
"ParentA seq=0",
|
||||
" ChildA seq=0"
|
||||
);
|
||||
|
||||
// Add sub-child to existing child
|
||||
ourLog.info("*** Adding child to existing child");
|
||||
set = new CustomTerminologySet();
|
||||
set.addRootConcept("ChildA", "Child A")
|
||||
.addChild(TermConceptParentChildLink.RelationshipTypeEnum.ISA).setCode("ChildAA").setDisplay(leftPad("", 10000, 'Z'));
|
||||
myTermCodeSystemStorageSvc.applyDeltaCodeSystemsAdd("http://foo", set);
|
||||
|
||||
// Check so far
|
||||
assertHierarchyContains(
|
||||
"ParentA seq=0",
|
||||
" ChildA seq=0",
|
||||
" ChildAA seq=0"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddWithoutPreExistingCodeSystem() {
|
||||
|
||||
|
|
|
@ -546,11 +546,13 @@ public class JsonParserR4Test extends BaseTest {
|
|||
* 18:25:00.463 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:483] - Encoded 500 passes - 44ms / pass - 22.6 / second
|
||||
*
|
||||
* 2019-09-19 - Post #1489
|
||||
* 20:43:21.434 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:470] - Encoded 2300 passes - 29ms / pass - 33.5 / second
|
||||
* 20:43:24.228 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:470] - Encoded 2400 passes - 29ms / pass - 33.6 / second
|
||||
* 20:43:27.029 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:470] - Encoded 2500 passes - 29ms / pass - 33.7 / second
|
||||
* 20:43:29.825 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:470] - Encoded 2600 passes - 29ms / pass - 33.8 / second
|
||||
* 20:43:32.779 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:470] - Encoded 2700 passes - 29ms / pass - 33.8 / second
|
||||
* 15:20:30.134 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:574] - Encoded 800 passes - 28ms / pass - 34.5 / second
|
||||
* 15:20:32.986 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:574] - Encoded 900 passes - 28ms / pass - 34.6 / second
|
||||
* 15:20:35.865 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:574] - Encoded 1000 passes - 28ms / pass - 34.6 / second
|
||||
* 15:20:38.797 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:574] - Encoded 1100 passes - 28ms / pass - 34.6 / second
|
||||
* 15:20:41.708 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:574] - Encoded 1200 passes - 28ms / pass - 34.5 / second
|
||||
* 15:20:44.722 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:574] - Encoded 1300 passes - 29ms / pass - 34.4 / second
|
||||
* 15:20:47.716 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:574] - Encoded 1400 passes - 29ms / pass - 34.4 / second
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
|
@ -559,6 +561,14 @@ public class JsonParserR4Test extends BaseTest {
|
|||
Bundle b = createBigBundle();
|
||||
|
||||
IParser parser = ourCtx.newJsonParser();
|
||||
|
||||
for (int i = 0; i < 500; i++) {
|
||||
parser.encodeResourceToWriter(b, new NullWriter());
|
||||
if (i % 100 == 0) {
|
||||
ourLog.info("Warm-up Encoded {} passes", i);
|
||||
}
|
||||
}
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
for (int i = 0; ; i++) {
|
||||
parser.encodeResourceToWriter(b, new NullWriter());
|
||||
|
@ -601,18 +611,34 @@ public class JsonParserR4Test extends BaseTest {
|
|||
|
||||
/**
|
||||
* 2019-09-19
|
||||
* 18:31:01.513 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:486] - Parsed 600 passes - 37ms / pass - 27.0 / second
|
||||
* 18:31:04.454 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:486] - Parsed 700 passes - 35ms / pass - 27.8 / second
|
||||
* 18:31:07.451 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:486] - Parsed 800 passes - 35ms / pass - 28.4 / second
|
||||
* 18:31:10.457 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:486] - Parsed 900 passes - 34ms / pass - 28.9 / second
|
||||
* 15:22:30.758 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 1700 passes - 12ms / pass - 79.3 / second
|
||||
* 15:22:31.968 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 1800 passes - 12ms / pass - 79.5 / second
|
||||
* 15:22:33.223 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 1900 passes - 12ms / pass - 79.5 / second
|
||||
* 15:22:34.459 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 2000 passes - 12ms / pass - 79.6 / second
|
||||
* 15:22:35.696 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 2100 passes - 12ms / pass - 79.7 / second
|
||||
* 15:22:36.983 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 2200 passes - 12ms / pass - 79.6 / second
|
||||
* 15:22:38.203 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 2300 passes - 12ms / pass - 79.7 / second
|
||||
* 15:22:39.456 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 2400 passes - 12ms / pass - 79.7 / second
|
||||
* 15:22:40.699 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 2500 passes - 12ms / pass - 79.7 / second
|
||||
* 15:22:42.135 [main] INFO ca.uhn.fhir.parser.JsonParserR4Test [JsonParserR4Test.java:638] - Parsed 2600 passes - 12ms / pass - 79.3 / second
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void testTimingsInput() throws IOException {
|
||||
public void testTimingsInput() {
|
||||
Bundle b = createBigBundle();
|
||||
IParser parser = ourCtx.newJsonParser();
|
||||
String input = parser.encodeResourceToString(b);
|
||||
|
||||
for (int i = 0; i < 500; i++) {
|
||||
parser.parseResource(input);
|
||||
if (i % 100 == 0) {
|
||||
ourLog.info("Warm up parsed {} passes", i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
for (int i = 0; ; i++) {
|
||||
parser.parseResource(input);
|
||||
|
|
Loading…
Reference in New Issue