From 5b331a6efbefca1b0800e4ce02a656c6505c942d Mon Sep 17 00:00:00 2001 From: rbradley813 Date: Fri, 27 Sep 2024 16:18:11 -0400 Subject: [PATCH] Feature/ar 156 update data its part1 (#40) * update test helper and test constants * update integration tests to use new test helper and test constants * fix import * occurrences * fix bindings generation and test * fix import * occurences * formatting cleanup --- .../ikm/tinkar/integration/DataIntegrity.java | 2 +- .../ikm/tinkar/integration/TestConstants.java | 15 +- .../changeSet/EntityServiceIT.java | 12 +- .../integration/coordinate/CoordinatesIT.java | 26 +++- .../integration/coordinate/QueryByTimeIT.java | 24 +++- .../tinkar/integration/helper/DataStore.java | 28 ++++ .../tinkar/integration/helper/TestHelper.java | 67 +++------ .../integrity/DataIntegrityIT.java | 136 ++++++++++-------- .../binding/GenerateJavaBindingIT.java | 48 +++---- .../fhir/FhirCodeSystemTransformIT.java | 42 +++--- .../langext/fhir/FhirTransformAPIIT.java | 10 +- .../ephemeral/EphemeralProtobufIT.java | 30 ++-- .../ephemeral/EphemeralProviderIT.java | 18 ++- .../ephemeral/OwlToLogicalAxiomIT.java | 24 +++- .../ephemeral/ProtobufPerformanceIT.java | 61 ++++---- .../ephemeral/ProtobufRoundTripIT.java | 13 +- .../provider/mvstore/MVStoreProviderIT.java | 20 ++- .../provider/search/SearchProviderIT.java | 26 ++-- .../spinedarray/OwlTransformationTestIT.java | 33 +++-- .../spinedarray/SpinedArrayEntityCacheIT.java | 19 ++- .../spinedarray/SpinedArrayProviderIT.java | 19 ++- .../SpinedArrayPublicIdMergeIT.java | 26 ++-- .../tinkar/integration/search/SearcherIT.java | 15 +- .../snomed/core/QueryByMembershipIT.java | 49 ++----- .../SnomedToEntityDescriptionIT.java | 2 +- .../SnomedToEntityIdentifierIT.java | 2 +- ...medLanguageSemanticMultipleVersionsIT.java | 9 -- .../language/TestSnomedToEntityLanguage.java | 9 -- .../relationship/TestActiveRelationship.java | 9 -- .../ext/binding/GenerateJavaBindingTask.java | 4 +- .../ikm/tinkar/ext/binding/JavaTemplates.java | 2 +- 31 files changed, 422 insertions(+), 378 deletions(-) create mode 100644 integration/src/test/java/dev/ikm/tinkar/integration/helper/DataStore.java diff --git a/integration/src/main/java/dev/ikm/tinkar/integration/DataIntegrity.java b/integration/src/main/java/dev/ikm/tinkar/integration/DataIntegrity.java index 9c8953f6..4ab43cfe 100644 --- a/integration/src/main/java/dev/ikm/tinkar/integration/DataIntegrity.java +++ b/integration/src/main/java/dev/ikm/tinkar/integration/DataIntegrity.java @@ -75,7 +75,7 @@ public static void startup(File datastoreRootLocation){ LOG.info("Datastore location: " + datastoreRootLocation); CachingService.clearAll(); ServiceProperties.set(ServiceKeys.DATA_STORE_ROOT, datastoreRootLocation); - PrimitiveData.selectControllerByName(TestConstants.SA_STORE_OPEN_NAME); + PrimitiveData.selectControllerByName("Open SpinedArrayStore"); PrimitiveData.start(); } diff --git a/integration/src/main/java/dev/ikm/tinkar/integration/TestConstants.java b/integration/src/main/java/dev/ikm/tinkar/integration/TestConstants.java index a31f1bed..6b6708b0 100644 --- a/integration/src/main/java/dev/ikm/tinkar/integration/TestConstants.java +++ b/integration/src/main/java/dev/ikm/tinkar/integration/TestConstants.java @@ -19,23 +19,18 @@ import java.util.function.Function; public class TestConstants { - public static final Function createFilePathInTarget = (pathName) -> new File("%s/target/%s".formatted(System.getProperty("user.dir"), pathName)); + public static final Function createFilePathInTarget = (pathName) -> new File("%s/target/%s".formatted(System.getProperty("user.dir"), pathName)); - public static final Function + public static final Function createFilePathInTargetFromClassName = (clazz) -> createFilePathInTarget.apply("generated-datastores/%s".formatted(clazz.getSimpleName())); - public static final File TINK_TEST_FILE = createFilePathInTarget.apply("data/tinkar-test-dto-1.1.0.zip"); - public static final File PB_TEST_FILE = createFilePathInTarget.apply("data/tinkar-export-test.pb.zip"); + // IKM Test Data Files public static final File PB_STARTER_DATA = createFilePathInTarget.apply("data/tinkar-starter-data-1.0.0-pb.zip"); public static final File PB_STARTER_DATA_REASONED = createFilePathInTarget.apply("data/tinkar-starter-data-reasoned-1.0.0-pb.zip"); + // Other Helper Files + public static final File PB_TEST_FILE = createFilePathInTarget.apply("data/tinkar-export-test.pb.zip"); public static final File PB_ROUNDTRIP_TEST_FILE = createFilePathInTarget.apply("data/tinkar-export-test-roundtrip.pb.zip"); public static final File PB_PERFORMANCE_TEST_FILE = createFilePathInTarget.apply("data/tinkar-export-test-performance.pb.zip"); - - public static final String MV_STORE_OPEN_NAME = "Open MV Store"; - public static final String EPHEMERAL_STORE_NAME = "Load Ephemeral Store"; - public static final String SA_STORE_OPEN_NAME = "Open SpinedArrayStore"; - public static final File SNOMED_CT_DATA = createFilePathInTarget.apply("data/snomedct-2023.09.01.zip"); - } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/changeSet/EntityServiceIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/changeSet/EntityServiceIT.java index 2b7e51c0..03ffac99 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/changeSet/EntityServiceIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/changeSet/EntityServiceIT.java @@ -18,6 +18,7 @@ import dev.ikm.tinkar.entity.EntityCountSummary; import dev.ikm.tinkar.entity.EntityService; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -30,13 +31,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -class EntityServiceIT extends TestHelper { +class EntityServiceIT { + + private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(EntityServiceIT.class); - private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( - EntityServiceIT.class); @BeforeEach - public void init() { - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + void beforeEach() { + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, SAP_DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @Test diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/coordinate/CoordinatesIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/coordinate/CoordinatesIT.java index b909da77..04e47c90 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/coordinate/CoordinatesIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/coordinate/CoordinatesIT.java @@ -27,18 +27,28 @@ import dev.ikm.tinkar.coordinate.stamp.calculator.Latest; import dev.ikm.tinkar.coordinate.stamp.calculator.StampCalculatorWithCache; import dev.ikm.tinkar.coordinate.view.calculator.ViewCalculator; -import dev.ikm.tinkar.entity.*; +import dev.ikm.tinkar.entity.ConceptEntity; +import dev.ikm.tinkar.entity.ConceptEntityVersion; +import dev.ikm.tinkar.entity.Entity; +import dev.ikm.tinkar.entity.EntityService; +import dev.ikm.tinkar.entity.SemanticEntity; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.TinkarTerm; import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.set.ImmutableSet; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.IOException; import java.util.Optional; import static dev.ikm.tinkar.terms.TinkarTerm.PATH_ORIGINS_PATTERN; @@ -46,14 +56,16 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class CoordinatesIT extends TestHelper { +class CoordinatesIT { + private static final Logger LOG = LoggerFactory.getLogger(CoordinatesIT.class); - private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( CoordinatesIT.class); @BeforeAll - static void setupSuite() throws IOException { - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + static void beforeAll() { + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @Test diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/coordinate/QueryByTimeIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/coordinate/QueryByTimeIT.java index 4622f274..e372ecdb 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/coordinate/QueryByTimeIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/coordinate/QueryByTimeIT.java @@ -17,7 +17,11 @@ import dev.ikm.tinkar.common.id.IntIds; import dev.ikm.tinkar.coordinate.Coordinates; -import dev.ikm.tinkar.coordinate.stamp.*; +import dev.ikm.tinkar.coordinate.stamp.StampCoordinateRecord; +import dev.ikm.tinkar.coordinate.stamp.StampCoordinateRecordBuilder; +import dev.ikm.tinkar.coordinate.stamp.StampPositionRecord; +import dev.ikm.tinkar.coordinate.stamp.StampPositionRecordBuilder; +import dev.ikm.tinkar.coordinate.stamp.StateSet; import dev.ikm.tinkar.coordinate.stamp.calculator.Latest; import dev.ikm.tinkar.coordinate.stamp.calculator.StampCalculator; import dev.ikm.tinkar.entity.EntityService; @@ -25,9 +29,16 @@ import dev.ikm.tinkar.entity.StampEntity; import dev.ikm.tinkar.entity.StampEntityVersion; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.TinkarTerm; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,15 +52,16 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class QueryByTimeIT extends TestHelper { +public class QueryByTimeIT { private static final Logger LOG = LoggerFactory.getLogger(QueryByTimeIT.class); - private static final File SAP_COORDINATESIT_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( QueryByTimeIT.class); @BeforeAll - public void init() { - loadSpinedArrayDataBase(SAP_COORDINATESIT_DATASTORE_ROOT); + public void beforeAll() { + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @Test diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/helper/DataStore.java b/integration/src/test/java/dev/ikm/tinkar/integration/helper/DataStore.java new file mode 100644 index 00000000..39f2000d --- /dev/null +++ b/integration/src/test/java/dev/ikm/tinkar/integration/helper/DataStore.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2015 Integrated Knowledge Management (support@ikm.dev) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package dev.ikm.tinkar.integration.helper; + +public enum DataStore { + SPINED_ARRAY_STORE("Open SpinedArrayStore"), + EPHEMERAL_STORE("Load Ephemeral Store"), + MV_STORE("Open MV Store"); + + final String CONTROLLER_NAME; + + DataStore(String contollerName) { + this.CONTROLLER_NAME = contollerName; + } +} diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/helper/TestHelper.java b/integration/src/test/java/dev/ikm/tinkar/integration/helper/TestHelper.java index 4f19a940..aa4d8944 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/helper/TestHelper.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/helper/TestHelper.java @@ -21,75 +21,48 @@ import dev.ikm.tinkar.common.service.ServiceProperties; import dev.ikm.tinkar.entity.EntityCountSummary; import dev.ikm.tinkar.entity.load.LoadEntitiesFromProtobufFile; -import dev.ikm.tinkar.integration.TestConstants; -import org.junit.jupiter.api.AfterAll; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import static dev.ikm.tinkar.integration.TestConstants.PB_STARTER_DATA_REASONED; - public class TestHelper { - private static final Logger LOG = LoggerFactory.getLogger(TestHelper.class); - protected static void startEphemeralDataBase() { + public static void startDataBase(DataStore dataStore, File fileDataStore) { + if (fileDataStore.exists()) { + LOG.warn("Datastore {} already exists. Loading this datastore may impact test results.\n" + + "Consider leveraging Maven's clean lifecycle phase or `FileUtil.recursiveDelete` during test setup.", fileDataStore.getName()); + } CachingService.clearAll(); LOG.info("Cleared caches"); - LOG.info("JVM Version: " + System.getProperty("java.version")); - LOG.info("JVM Name: " + System.getProperty("java.vm.name")); - LOG.info("Setup Ephemeral Suite: " + LOG.getName()); - LOG.info(ServiceProperties.jvmUuid()); - PrimitiveData.selectControllerByName(TestConstants.EPHEMERAL_STORE_NAME); - PrimitiveData.start(); + ServiceProperties.set(ServiceKeys.DATA_STORE_ROOT, fileDataStore); + startDataController(dataStore); } - protected static void startSpinedArrayDataBase(File fileDataStore) { - LOG.info("Clear caches"); + public static void startDataBase(DataStore dataStore) { CachingService.clearAll(); - LOG.info("Setup Suite: " + LOG.getName()); - LOG.info(ServiceProperties.jvmUuid()); - ServiceProperties.set(ServiceKeys.DATA_STORE_ROOT, fileDataStore); - //FileUtil.recursiveDelete(fileDataStore); - PrimitiveData.selectControllerByName(TestConstants.SA_STORE_OPEN_NAME); - PrimitiveData.start(); + LOG.info("Cleared caches"); + startDataController(dataStore); } - protected static void startMVStoreDataBase(File fileDataStore) { - LOG.info("Clear caches"); - CachingService.clearAll(); - LOG.info("Setup suite: " + LOG.getName()); + private static void startDataController(DataStore dataStore) { + LOG.info("JVM Version: " + System.getProperty("java.version")); + LOG.info("JVM Name: " + System.getProperty("java.vm.name")); LOG.info(ServiceProperties.jvmUuid()); - ServiceProperties.set(ServiceKeys.DATA_STORE_ROOT, fileDataStore); - PrimitiveData.selectControllerByName(TestConstants.MV_STORE_OPEN_NAME); + PrimitiveData.selectControllerByName(dataStore.CONTROLLER_NAME); PrimitiveData.start(); } - protected static void loadEphemeralDataBase() { - startEphemeralDataBase(); - loadDataBase(); - } - - protected static void loadSpinedArrayDataBase(File fileDataStore) { - startSpinedArrayDataBase(fileDataStore); - loadDataBase(); + public static EntityCountSummary loadDataFile(File dataFile){ + EntityCountSummary entityCountSummary = new LoadEntitiesFromProtobufFile(dataFile).compute(); + LOG.info("Import complete for {}. Imported {} Entities.", dataFile.getName(), entityCountSummary.getTotalCount()); + return entityCountSummary; } - protected static void loadMVStoreDataBase(File fileDataStore) { - startMVStoreDataBase(fileDataStore); - loadDataBase(); - } - - protected static void loadDataBase() { - LoadEntitiesFromProtobufFile loadProto = new LoadEntitiesFromProtobufFile(PB_STARTER_DATA_REASONED); - EntityCountSummary count = loadProto.compute(); - LOG.info(count + " entitles loaded from file: " + loadProto.summarize() + "\n\n"); - } - - @AfterAll - protected static void stopDatabase() { + public static void stopDatabase() { LOG.info("Teardown Suite: " + LOG.getName()); PrimitiveData.stop(); } + } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/integrity/DataIntegrityIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/integrity/DataIntegrityIT.java index 077fe5d7..de0544ae 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/integrity/DataIntegrityIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/integrity/DataIntegrityIT.java @@ -19,13 +19,33 @@ import dev.ikm.tinkar.common.id.IntIdSet; import dev.ikm.tinkar.common.id.IntIds; import dev.ikm.tinkar.common.id.PublicId; -import dev.ikm.tinkar.common.service.*; -import dev.ikm.tinkar.entity.*; +import dev.ikm.tinkar.common.service.PrimitiveData; +import dev.ikm.tinkar.common.service.TinkExecutor; +import dev.ikm.tinkar.common.util.io.FileUtil; +import dev.ikm.tinkar.entity.Entity; +import dev.ikm.tinkar.entity.EntityService; +import dev.ikm.tinkar.entity.EntityVersion; +import dev.ikm.tinkar.entity.FieldDefinitionRecord; +import dev.ikm.tinkar.entity.FieldDefinitionRecordBuilder; +import dev.ikm.tinkar.entity.PatternRecord; +import dev.ikm.tinkar.entity.PatternRecordBuilder; +import dev.ikm.tinkar.entity.PatternVersionRecord; +import dev.ikm.tinkar.entity.PatternVersionRecordBuilder; +import dev.ikm.tinkar.entity.RecordListBuilder; +import dev.ikm.tinkar.entity.SemanticEntity; +import dev.ikm.tinkar.entity.SemanticEntityVersion; +import dev.ikm.tinkar.entity.SemanticRecord; +import dev.ikm.tinkar.entity.SemanticRecordBuilder; +import dev.ikm.tinkar.entity.SemanticVersionRecord; +import dev.ikm.tinkar.entity.SemanticVersionRecordBuilder; +import dev.ikm.tinkar.entity.StampEntity; +import dev.ikm.tinkar.entity.StampRecord; import dev.ikm.tinkar.entity.graph.DiTreeEntity; import dev.ikm.tinkar.entity.graph.EntityVertex; -import dev.ikm.tinkar.entity.load.LoadEntitiesFromProtobufFile; import dev.ikm.tinkar.integration.DataIntegrity; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; +import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.EntityProxy; import dev.ikm.tinkar.terms.State; import dev.ikm.tinkar.terms.TinkarTerm; @@ -41,43 +61,33 @@ import java.io.File; import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DataIntegrityIT { private static final Logger LOG = LoggerFactory.getLogger(DataIntegrity.class); - private static final File SAP_DATAINTEGRITYIT_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(DataIntegrityIT.class); + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(DataIntegrityIT.class); public DataIntegrity dataIntegrity; @BeforeAll public static void beforeAll() { - LOG.info("JVM Version: " + System.getProperty("java.version")); - LOG.info("JVM Name: " + System.getProperty("java.vm.name")); - LOG.info("Setup Ephemeral Protobuf Suite: " + LOG.getName()); - startDatabase(TestConstants.SA_STORE_OPEN_NAME, SAP_DATAINTEGRITYIT_DATASTORE_ROOT); - - File starterDataFile = TestConstants.PB_STARTER_DATA_REASONED; - EntityCountSummary summaryLoadStarterData = new LoadEntitiesFromProtobufFile(starterDataFile).compute(); - LOG.info("Import complete for {}. Imported {} Entities.", starterDataFile.getName(), summaryLoadStarterData.getTotalCount()); - } - - private static void startDatabase(String datastoreControllerName, File datastoreFile) { - LOG.info("Clear caches"); - CachingService.clearAll(); - LOG.info(ServiceProperties.jvmUuid()); - if (datastoreFile != null) { - ServiceProperties.set(ServiceKeys.DATA_STORE_ROOT, datastoreFile); - } - PrimitiveData.selectControllerByName(datastoreControllerName); - PrimitiveData.start(); + FileUtil.recursiveDelete(DATASTORE_ROOT); + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @AfterAll - public static void afterAll(){ - PrimitiveData.stop(); + public static void afterAll() { + TestHelper.stopDatabase(); } @Test @@ -114,7 +124,7 @@ public void incorrectDataIntegrityTest() throws InterruptedException { } @Test - public void correctDataIntegrityTest(){ + public void correctDataIntegrityTest() { List aggregatedNullNidList = new ArrayList<>(); Map> typeNameEntityMap = new HashMap<>(); typeNameEntityMap.put("Stamp", dataIntegrity.validateStampReferences(aggregatedNullNidList)); @@ -146,25 +156,25 @@ public void correctDataIntegrityTest(){ @Test public void semanticFieldSample() { ImmutableList patternFieldDefinitions = Lists.immutable.of( - TinkarTerm.COMPONENT_FIELD, - TinkarTerm.STRING - ); + TinkarTerm.COMPONENT_FIELD, + TinkarTerm.STRING + ); ImmutableList tooLongSemanticFieldValues = Lists.immutable.of( TinkarTerm.IDENTIFIER_SOURCE, "Test-UUID", "This extra field value should throw an error" - ); + ); int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); SemanticEntity semanticEntityWithTooManyFieldValues = SemanticTestHelper.createSemanticWithSupplier(referencedComponentNid, patternEntity.nid(), tooLongSemanticFieldValues, authoringStamp); - + assertFalse(DataIntegrity.validateSemanticFieldDataType(semanticEntityWithTooManyFieldValues)); } @@ -181,7 +191,7 @@ public void semanticFieldsTooShort() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -206,7 +216,7 @@ public void semanticFieldsMatchStamp() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -228,7 +238,7 @@ public void semanticFieldsMatchString() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -251,7 +261,7 @@ public void semanticFieldsMatchInt() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -273,7 +283,7 @@ public void semanticFieldsMatchFloat() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -295,7 +305,7 @@ public void semanticFieldsMatchBoolean() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -319,7 +329,7 @@ public void semanticFieldsMatchByteArray() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -366,7 +376,7 @@ public void semanticFieldsMatchConceptPatternSemanticStamp() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -419,7 +429,7 @@ public void semanticFieldsMatchDitree() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -461,7 +471,7 @@ public void semanticFieldsMismatchDigraphDiTree() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -484,7 +494,7 @@ public void semanticFieldsMatchInstant() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -507,7 +517,7 @@ public void semanticFieldsMatchComponentIdList() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -530,7 +540,7 @@ public void semanticFieldsMatchComponentIdSet() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -553,7 +563,7 @@ public void semanticFieldsMatchLong() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -576,7 +586,7 @@ public void semanticFieldsMismatchString() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -598,7 +608,7 @@ public void semanticFieldsMismatchInt() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -620,7 +630,7 @@ public void semanticFieldsMismatchFloat() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -642,7 +652,7 @@ public void semanticFieldsMismatchBoolean() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -666,7 +676,7 @@ public void semanticFieldsMismatchByteArray() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -691,7 +701,7 @@ public void semanticFieldsMismatchObjectArray() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -713,7 +723,7 @@ public void semanticFieldsMismatchConceptPatternSemanticStamp() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -747,7 +757,7 @@ public void semanticFieldsMismatchInstant() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -770,7 +780,7 @@ public void semanticFieldsMismatchComponentIdList() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -793,7 +803,7 @@ public void semanticFieldsMismatchComponentIdSet() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -816,7 +826,7 @@ public void semanticFieldsMismatchLong() { int referencedComponentNid = TinkarTerm.ANONYMOUS_CONCEPT.nid(); StampEntity authoringStamp = StampRecord.make(UUID.randomUUID(), State.ACTIVE, System.currentTimeMillis(), TinkarTerm.USER, TinkarTerm.SOLOR_OVERLAY_MODULE, TinkarTerm.DEVELOPMENT_PATH); - Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp , patternFieldDefinitions); + Entity patternEntity = PatternTestHelper.createPattern(EntityProxy.Pattern.make("Test Pattern", UUID.randomUUID()), authoringStamp, patternFieldDefinitions); EntityService.get().putEntity(authoringStamp); EntityService.get().putEntity(patternEntity); @@ -864,11 +874,12 @@ public static Entity createPattern(EntityProxy.Pattern ImmutableList fieldDefinitionConcepts) { return createPattern(pattern, TinkarTerm.MEANING, TinkarTerm.PURPOSE, authoringSTAMP, fieldDefinitionConcepts); } + public static Entity createPattern(EntityProxy.Pattern pattern, EntityProxy.Concept meaningConcept, EntityProxy.Concept purposeConcept, Entity authoringSTAMP, - ImmutableList fieldDefinitionConcepts){ + ImmutableList fieldDefinitionConcepts) { MutableList fieldDefinitions = Lists.mutable.empty(); int i = 0; @@ -897,11 +908,12 @@ public static Entity createPattern(EntityProxy.Pattern } public static FieldDefinitionRecord fieldDefinition(int patternNid, EntityProxy.Concept dataType, - Entity authoringSTAMP, int idx){ + Entity authoringSTAMP, int idx) { return fieldDefinition(patternNid, TinkarTerm.MEANING, TinkarTerm.PURPOSE, dataType, authoringSTAMP, idx); } + public static FieldDefinitionRecord fieldDefinition(int patternNid, EntityProxy.Concept meaning, EntityProxy.Concept purpose, - EntityProxy.Concept dataType, Entity authoringSTAMP, int idx){ + EntityProxy.Concept dataType, Entity authoringSTAMP, int idx) { return FieldDefinitionRecordBuilder.builder() .patternNid(patternNid) .meaningNid(meaning.nid()) diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/langext/binding/GenerateJavaBindingIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/langext/binding/GenerateJavaBindingIT.java index 4fbded22..2238cc8e 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/langext/binding/GenerateJavaBindingIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/langext/binding/GenerateJavaBindingIT.java @@ -15,57 +15,51 @@ */ package dev.ikm.tinkar.integration.langext.binding; -import dev.ikm.tinkar.common.service.CachingService; import dev.ikm.tinkar.common.service.PrimitiveData; -import dev.ikm.tinkar.common.service.ServiceKeys; -import dev.ikm.tinkar.common.service.ServiceProperties; import dev.ikm.tinkar.common.util.io.FileUtil; import dev.ikm.tinkar.coordinate.Coordinates; import dev.ikm.tinkar.coordinate.language.calculator.LanguageCalculator; import dev.ikm.tinkar.coordinate.language.calculator.LanguageCalculatorWithCache; -import dev.ikm.tinkar.coordinate.stamp.calculator.Latest; import dev.ikm.tinkar.coordinate.stamp.calculator.StampCalculator; import dev.ikm.tinkar.entity.Entity; import dev.ikm.tinkar.entity.EntityService; import dev.ikm.tinkar.entity.EntityVersion; -import dev.ikm.tinkar.entity.PatternEntityVersion; -import dev.ikm.tinkar.entity.load.LoadEntitiesFromProtobufFile; import dev.ikm.tinkar.ext.binding.BindingHelper; import dev.ikm.tinkar.ext.binding.GenerateJavaBindingTask; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; +import dev.ikm.tinkar.integration.helper.TestHelper; import org.eclipse.collections.api.factory.Lists; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.nio.file.Path; import java.util.UUID; import java.util.stream.Stream; -import static dev.ikm.tinkar.integration.TestConstants.createFilePathInTarget; import static org.junit.jupiter.api.Assertions.assertTrue; @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class GenerateJavaBindingIT { - private static final File datastore = TestConstants.createFilePathInTargetFromClassName.apply(GenerateJavaBindingIT.class); - public static final File PB_STARTER_DATA = createFilePathInTarget.apply("data/tinkar-starter-data-1.0.0-pb.zip"); + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(GenerateJavaBindingIT.class); private StampCalculator stampCalculator; private LanguageCalculator languageCalculator; private final String className = "BindingTest"; @BeforeAll - public void setup() { - CachingService.clearAll(); - ServiceProperties.set(ServiceKeys.DATA_STORE_ROOT, datastore); - FileUtil.recursiveDelete(datastore); - PrimitiveData.selectControllerByName(TestConstants.SA_STORE_OPEN_NAME); - PrimitiveData.start(); - LoadEntitiesFromProtobufFile loadEntitiesFromProtobufFile = new LoadEntitiesFromProtobufFile(PB_STARTER_DATA); - loadEntitiesFromProtobufFile.compute(); + public void beforeAll() { + FileUtil.recursiveDelete(DATASTORE_ROOT); + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA); stampCalculator = Coordinates.Stamp.DevelopmentLatest().stampCalculator(); languageCalculator = LanguageCalculatorWithCache @@ -74,8 +68,8 @@ public void setup() { } @AfterAll - public void teardown() { - PrimitiveData.stop(); + public void afterAll() { + TestHelper.stopDatabase(); } @Test @@ -100,7 +94,7 @@ public void generateConceptAndPatternBinding() { Stream.empty(), "IKM Author", "dev.ikm.tinkar.integration.langext.binding", - "BindingsTest", + "BindingTest", UUID.randomUUID(), interpolationConsumer -> { try { @@ -109,14 +103,10 @@ public void generateConceptAndPatternBinding() { throw new RuntimeException(e); } }, - new BindingHelper(languageCalculator, stampCalculator, fqn -> { - if (fqn.contains("+")){ - return fqn.replace("+", " PLUS"); - } else if (fqn.contains("/")){ - return fqn.replace("/", "_SLASH_"); - } - return fqn; - }) + new BindingHelper(languageCalculator, stampCalculator, fqn -> fqn + .replace("+", " PLUS") + .replace("/", "_SLASH_") + .replace("-", "_")) ); generateJavaBindingTask.call(); diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/langext/fhir/FhirCodeSystemTransformIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/langext/fhir/FhirCodeSystemTransformIT.java index 52595e74..4bfe1846 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/langext/fhir/FhirCodeSystemTransformIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/langext/fhir/FhirCodeSystemTransformIT.java @@ -17,22 +17,36 @@ import dev.ikm.tinkar.common.id.IntIds; import dev.ikm.tinkar.common.service.PrimitiveData; -import dev.ikm.tinkar.coordinate.stamp.*; +import dev.ikm.tinkar.coordinate.stamp.StampCoordinateRecord; +import dev.ikm.tinkar.coordinate.stamp.StampCoordinateRecordBuilder; +import dev.ikm.tinkar.coordinate.stamp.StampPositionRecord; +import dev.ikm.tinkar.coordinate.stamp.StampPositionRecordBuilder; +import dev.ikm.tinkar.coordinate.stamp.StateSet; import dev.ikm.tinkar.coordinate.stamp.calculator.StampCalculator; import dev.ikm.tinkar.coordinate.stamp.calculator.StampCalculatorWithCache; -import dev.ikm.tinkar.entity.*; +import dev.ikm.tinkar.entity.ConceptEntity; +import dev.ikm.tinkar.entity.ConceptEntityVersion; +import dev.ikm.tinkar.entity.Entity; +import dev.ikm.tinkar.entity.EntityService; +import dev.ikm.tinkar.entity.EntityVersion; +import dev.ikm.tinkar.entity.StampEntity; +import dev.ikm.tinkar.entity.StampEntityVersion; import dev.ikm.tinkar.fhir.transformers.FhirCodeSystemTransform; import dev.ikm.tinkar.fhir.transformers.FhirStatedDefinitionTransformer; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.TinkarTerm; import org.hl7.fhir.r4.model.CodeSystem; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.IOException; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -43,10 +57,10 @@ import java.util.concurrent.atomic.AtomicInteger; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class FhirCodeSystemTransformIT extends TestHelper { +public class FhirCodeSystemTransformIT { private static final Logger LOG = LoggerFactory.getLogger(FhirCodeSystemTransformIT.class); - private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( FhirCodeSystemTransformIT.class); FhirCodeSystemTransform fhirCodeSystemTransform; @@ -54,23 +68,15 @@ public class FhirCodeSystemTransformIT extends TestHelper { StampCalculator stampCalculator; final int transformSize = 1000; - @BeforeAll - public void setup() { - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + public void beforeAll() { + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } - @Test @DisplayName("Test Fhir transform for entire file" ) - public void testFhirCodeSystemTransformation() throws IOException { - -// File file = TestConstants.TINK_TEST_FILE; -// LoadEntitiesFromDtoFile loadDTO = new LoadEntitiesFromDtoFile(file); -// int count = loadDTO.compute(); -// LOG.info(count + " entitles loaded from file: " + loadDTO.report() + "\n\n"); - - + public void testFhirCodeSystemTransformation() { int patternNid = TinkarTerm.DESCRIPTION_PATTERN.nid(); Set pathNids = new HashSet<>(); EntityService.get().forEachSemanticOfPattern(patternNid,patternEntity1 -> diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/langext/fhir/FhirTransformAPIIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/langext/fhir/FhirTransformAPIIT.java index 5b098b9b..660b514d 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/langext/fhir/FhirTransformAPIIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/langext/fhir/FhirTransformAPIIT.java @@ -32,6 +32,7 @@ import dev.ikm.tinkar.entity.aggregator.TemporalEntityAggregator; import dev.ikm.tinkar.fhir.transformers.FhirCodeSystemTransform; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.TinkarTerm; import org.junit.jupiter.api.Assertions; @@ -49,14 +50,15 @@ import java.util.concurrent.atomic.AtomicInteger; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class FhirTransformAPIIT extends TestHelper { +public class FhirTransformAPIIT { private static final Logger LOG = LoggerFactory.getLogger(FhirTransformAPIIT.class); - private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(FhirTransformAPIIT.class); + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(FhirTransformAPIIT.class); @BeforeAll - public void setup() { - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + public void beforeAll() { + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @Test diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/EphemeralProtobufIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/EphemeralProtobufIT.java index 51b8aa10..1740204b 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/EphemeralProtobufIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/EphemeralProtobufIT.java @@ -23,37 +23,42 @@ import dev.ikm.tinkar.entity.util.EntityProcessor; import dev.ikm.tinkar.entity.util.EntityRealizer; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.IOException; @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class EphemeralProtobufIT extends TestHelper { +public class EphemeralProtobufIT { private static final Logger LOG = LoggerFactory.getLogger(EphemeralProtobufIT.class); @BeforeAll - public void setupSuite() { - startEphemeralDataBase(); + public static void beforeAll() { + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); } - @Test @Order(1) - public void loadProtoBufFile() throws IOException { + public void loadProtoBufFile() { File file = TestConstants.PB_STARTER_DATA_REASONED; LoadEntitiesFromProtobufFile loadProto = new LoadEntitiesFromProtobufFile(file); - EntityCountSummary count = loadProto.compute(); - LOG.info(count + " entitles loaded from file: " + loadProto.summarize() + "\n\n"); + EntityCountSummary entityCountSummary = loadProto.compute(); + LOG.info(entityCountSummary.getTotalCount() + " entities loaded from file: " + loadProto.summarize() + "\n\n"); } + @Test @Order(2) - public void countDTO(){ + public void countEntities(){ EntityProcessor processor = new EntityCounter(); PrimitiveData.get().forEach(processor); LOG.info("EPH Sequential count: \n" + processor.report() + "\n\n"); @@ -76,10 +81,11 @@ public void countDTO(){ @Test @Order(3) - public void exportEntitiesToProtobuf() throws IOException { + public void exportEntitiesToProtobuf() { File file = TestConstants.PB_TEST_FILE; ExportEntitiesToProtobufFile exportEntitiesToProtobufFile = new ExportEntitiesToProtobufFile(file); - exportEntitiesToProtobufFile.compute(); + EntityCountSummary entityCountSummary = exportEntitiesToProtobufFile.compute(); + LOG.info(entityCountSummary.getTotalCount() + " entities exported from file"); } } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/EphemeralProviderIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/EphemeralProviderIT.java index a4373b60..10bbf9c2 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/EphemeralProviderIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/EphemeralProviderIT.java @@ -22,27 +22,32 @@ import dev.ikm.tinkar.entity.util.EntityProcessor; import dev.ikm.tinkar.entity.util.EntityRealizer; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.IOException; @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class EphemeralProviderIT extends TestHelper { +class EphemeralProviderIT { private static final Logger LOG = LoggerFactory.getLogger(EphemeralProviderIT.class); @BeforeAll - static void setupSuite() { - startEphemeralDataBase(); + static void beforeAll() { + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); } @Test @Order(1) - public void loadChronologies() throws IOException { + public void loadChronologies() { File file = TestConstants.PB_STARTER_DATA_REASONED; LoadEntitiesFromProtobufFile loadProto = new LoadEntitiesFromProtobufFile(file); EntityCountSummary count = loadProto.compute(); @@ -94,4 +99,5 @@ public void countExport() { PrimitiveData.get().forEachParallel(processor); LOG.info("POST EPH Parallel realization: \n" + processor.report() + "\n\n"); } + } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/OwlToLogicalAxiomIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/OwlToLogicalAxiomIT.java index 2d582808..b5cc0881 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/OwlToLogicalAxiomIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/OwlToLogicalAxiomIT.java @@ -16,13 +16,23 @@ package dev.ikm.tinkar.integration.provider.ephemeral; import dev.ikm.tinkar.common.service.PrimitiveData; -import dev.ikm.tinkar.entity.*; +import dev.ikm.tinkar.entity.ConceptRecord; +import dev.ikm.tinkar.entity.ConceptRecordBuilder; +import dev.ikm.tinkar.entity.ConceptVersionRecord; +import dev.ikm.tinkar.entity.ConceptVersionRecordBuilder; +import dev.ikm.tinkar.entity.Entity; +import dev.ikm.tinkar.entity.EntityService; +import dev.ikm.tinkar.entity.RecordListBuilder; +import dev.ikm.tinkar.entity.StampEntityVersion; import dev.ikm.tinkar.entity.graph.DiTreeEntity; import dev.ikm.tinkar.entity.graph.EntityVertex; import dev.ikm.tinkar.entity.graph.adaptor.axiom.LogicalExpression; import dev.ikm.tinkar.ext.lang.owl.SctOwlUtilities; +import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.TinkarTerm; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -36,12 +46,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class OwlToLogicalAxiomIT extends TestHelper { +public class OwlToLogicalAxiomIT { private static final Logger LOG = LoggerFactory.getLogger(OwlToLogicalAxiomIT.class); @BeforeAll - public static void setUp() { - loadEphemeralDataBase(); + public static void beforeAll() { + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); + } + + @AfterAll + public static void afterAll() { + TestHelper.stopDatabase(); } private boolean datastoreEmpty() { diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/ProtobufPerformanceIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/ProtobufPerformanceIT.java index d1b44f08..9251c7d1 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/ProtobufPerformanceIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/ProtobufPerformanceIT.java @@ -15,10 +15,10 @@ */ package dev.ikm.tinkar.integration.provider.ephemeral; -import dev.ikm.tinkar.entity.EntityCountSummary; import dev.ikm.tinkar.entity.export.ExportEntitiesToProtobufFile; import dev.ikm.tinkar.entity.load.LoadEntitiesFromProtobufFile; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; @@ -28,53 +28,46 @@ import org.slf4j.LoggerFactory; import java.io.File; -import java.io.IOException; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class ProtobufPerformanceIT extends TestHelper { +public class ProtobufPerformanceIT { private static final Logger LOG = LoggerFactory.getLogger(ProtobufRoundTripIT.class); @BeforeAll - public void setupSuite() { - startEphemeralDataBase(); + public void beforeAll() { + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); } @Test @Order(1) - public void roundTripPerformanceTest() throws IOException { - //Printing out File size for this transformation - - long loadDTOTimeBefore = System.nanoTime(); - File file = TestConstants.PB_STARTER_DATA_REASONED; - LOG.info("[1] The size of the original DTO file is: " + file.length() + " bytes long."); - LoadEntitiesFromProtobufFile loadProto = new LoadEntitiesFromProtobufFile(file); - EntityCountSummary count = loadProto.compute(); - LOG.info(count + " entitles loaded from file: " + loadProto.summarize() + "\n\n"); - long diffLoadProto = (System.nanoTime() - loadDTOTimeBefore); - LOG.info("The time it took for the Load protobuf to Entities operation is: " + diffLoadProto/1000000 + " milliseconds."); + public void roundTripPerformanceTest() { + File starterDataFile = TestConstants.PB_STARTER_DATA_REASONED; + long loadTimeBefore = System.currentTimeMillis(); + long expectedEntityCount = new LoadEntitiesFromProtobufFile(starterDataFile).compute().getTotalCount(); + long loadElapsedMillis = System.currentTimeMillis() - loadTimeBefore; + System.out.println("[1] The size of the original Protobuf file is: " + starterDataFile.length() + " bytes long."); + System.out.println("[1] The count of Entities loaded is: " + expectedEntityCount); + System.out.println("[1] The initial Load operation took " + loadElapsedMillis + " milliseconds."); - File fileProtobuf = TestConstants.PB_PERFORMANCE_TEST_FILE; + File roundTripFile = TestConstants.PB_PERFORMANCE_TEST_FILE; + long exportTimeBefore = System.currentTimeMillis(); + long actualProtobufExportCount = new ExportEntitiesToProtobufFile(roundTripFile).compute().getTotalCount(); + long exportElapsedMillis = System.currentTimeMillis() - exportTimeBefore; //Printing out File size for this transformation - LOG.info("[2] The size of the file is: " + fileProtobuf.length() + " bytes long."); - long loadEntitiesTimeBefore = System.nanoTime(); - ExportEntitiesToProtobufFile exportEntitiesToProtobufFile = new ExportEntitiesToProtobufFile(fileProtobuf); - long actualProtobufExportCount = exportEntitiesToProtobufFile.compute().getTotalCount(); - diffLoadProto = (System.nanoTime() - loadEntitiesTimeBefore); - LOG.info("[2] The count for Entities to Protobuf is: " + actualProtobufExportCount); - LOG.info("The time it took for the Load Entities to a Protobuf file is: " + diffLoadProto/1000000 + " milliseconds."); + System.out.println("[2] The size of the file is: " + roundTripFile.length() + " bytes long."); + System.out.println("[2] The count of Entities exported is: " + actualProtobufExportCount); + System.out.println("[2] The Export operation took: " + exportElapsedMillis + " milliseconds."); //Stopping and starting the database - stopDatabase(); - startEphemeralDataBase(); + TestHelper.stopDatabase(); + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); - //Printing out File size for this transformation - LOG.info("[3] The size of the file is: " + fileProtobuf.length() + " bytes long."); - long loadProtobufTimeBefore = System.nanoTime(); - LoadEntitiesFromProtobufFile loadEntitiesFromProtobufFile = new LoadEntitiesFromProtobufFile(fileProtobuf); - long actualProtobufImportCount = loadEntitiesFromProtobufFile.compute().getTotalCount(); - long diffLoadEntities = (System.nanoTime() - loadProtobufTimeBefore); - LOG.info("[3] The count for Protobuf to Entities is: " + actualProtobufImportCount); - LOG.info("The time it took to write Entities from a Protobuf file is: " + diffLoadEntities/1000000 + " milliseconds."); + long loadRoundTripFileTimeBefore = System.currentTimeMillis(); + long actualProtobufImportCount = new LoadEntitiesFromProtobufFile(roundTripFile).compute().getTotalCount(); + long loadRoundTripFileElapsedMillis = System.currentTimeMillis() - loadRoundTripFileTimeBefore; + System.out.println("[3] The count of Entities loaded is: " + actualProtobufImportCount); + System.out.println("[3] The second Load operation took: " + loadRoundTripFileElapsedMillis + " milliseconds."); } + } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/ProtobufRoundTripIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/ProtobufRoundTripIT.java index 6030a141..d1aff081 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/ProtobufRoundTripIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/ephemeral/ProtobufRoundTripIT.java @@ -19,6 +19,7 @@ import dev.ikm.tinkar.entity.export.ExportEntitiesToProtobufFile; import dev.ikm.tinkar.entity.load.LoadEntitiesFromProtobufFile; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -35,13 +36,13 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class ProtobufRoundTripIT extends TestHelper { +public class ProtobufRoundTripIT { private static final Logger LOG = LoggerFactory.getLogger(ProtobufRoundTripIT.class); @BeforeAll - public void setupSuite() { - startEphemeralDataBase(); + public void beforeAll() { + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); } /** @@ -77,15 +78,15 @@ public void roundTripTest() throws IOException { long actualProtobufExportCount = exportEntitiesToProtobufFile.compute().getTotalCount(); LOG.info("Entities exported to protobuf: " + actualProtobufExportCount); - stopDatabase(); - startEphemeralDataBase(); + TestHelper.stopDatabase(); + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); // When we import protobuf data into entities LoadEntitiesFromProtobufFile loadEntitiesFromProtobufFile = new LoadEntitiesFromProtobufFile(fileProtobuf); long actualProtobufImportCount = loadEntitiesFromProtobufFile.compute().getTotalCount(); LOG.info("Entities loaded from protobuf: " + actualProtobufImportCount); -// Then all imported and exported entities counts should match + // Then all imported and exported entities counts should match boolean boolEntityCount = count.getTotalCount() == actualProtobufExportCount && count.getTotalCount() == actualProtobufImportCount; assertTrue(count.getTotalCount() > 0, "Imported DTO count should be greater than zero."); assertTrue(actualProtobufExportCount > 0, "Exported Protobuf count should be greater than zero."); diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/mvstore/MVStoreProviderIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/mvstore/MVStoreProviderIT.java index 5abb3244..751dd79b 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/mvstore/MVStoreProviderIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/mvstore/MVStoreProviderIT.java @@ -24,13 +24,18 @@ import dev.ikm.tinkar.entity.util.EntityProcessor; import dev.ikm.tinkar.entity.util.EntityRealizer; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.IOException; /** * Concerned that MVStore may not be "bullet proof" based on this exception. Will watch, and save for posterity. @@ -53,19 +58,19 @@ */ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class MVStoreProviderIT extends TestHelper { +class MVStoreProviderIT { private static final Logger LOG = LoggerFactory.getLogger(MVStoreProviderIT.class); - private static final File MV_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(MVStoreProviderIT.class); + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(MVStoreProviderIT.class); @BeforeAll - static void setupSuite() { - loadMVStoreDataBase(MV_DATASTORE_ROOT); + static void beforeAll() { + TestHelper.startDataBase(DataStore.MV_STORE, DATASTORE_ROOT); } @Test @Order(1) - public void loadChronologies() throws IOException { + public void loadChronologies() { File file = TestConstants.PB_STARTER_DATA_REASONED; LoadEntitiesFromProtobufFile loadProto = new LoadEntitiesFromProtobufFile(file); EntityCountSummary count = loadProto.compute(); @@ -133,4 +138,5 @@ public void openAndClose() { PrimitiveData.get().forEachParallel(processor); LOG.info("MVS Parallel realization: \n" + processor.report() + "\n\n"); } + } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/search/SearchProviderIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/search/SearchProviderIT.java index b6534c2b..ee3f96b9 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/search/SearchProviderIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/search/SearchProviderIT.java @@ -17,11 +17,8 @@ import dev.ikm.tinkar.common.id.PublicId; import dev.ikm.tinkar.common.id.PublicIds; -import dev.ikm.tinkar.common.service.CachingService; -import dev.ikm.tinkar.common.service.PrimitiveData; -import dev.ikm.tinkar.common.service.ServiceKeys; -import dev.ikm.tinkar.common.service.ServiceProperties; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.provider.search.Searcher; import dev.ikm.tinkar.terms.TinkarTerm; @@ -33,18 +30,23 @@ import org.slf4j.LoggerFactory; import java.io.File; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class SearchProviderIT extends TestHelper { +public class SearchProviderIT { private static final Logger LOG = LoggerFactory.getLogger(SearchProviderIT.class); @BeforeAll - public void setUp() { - loadEphemeralDataBase(); + public void beforeAll() { + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @Test @@ -122,12 +124,9 @@ public void getDescriptionsIT() { } private void setupSnomedLoincLidrData() { - PrimitiveData.stop(); - CachingService.clearAll(); File dataStore = new File(System.getProperty("user.home") + "/Solor/snomedLidrLoinc-data-5-6-2024-withCollabData-dev"); - ServiceProperties.set(ServiceKeys.DATA_STORE_ROOT, dataStore); - PrimitiveData.selectControllerByName(TestConstants.SA_STORE_OPEN_NAME); - PrimitiveData.start(); + TestHelper.stopDatabase(); + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, dataStore); } @Test @@ -144,7 +143,6 @@ public void getResultConformancesFromLidrRecordIT() { assertEquals(expectedResultConformances, actualResultConformances, "LIDR Record Result Conformances do not match"); } - @Test @Disabled public void getAllowedResultsFromResultConformanceIT() { diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/OwlTransformationTestIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/OwlTransformationTestIT.java index 034fe045..10391399 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/OwlTransformationTestIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/OwlTransformationTestIT.java @@ -15,13 +15,28 @@ */ package dev.ikm.tinkar.integration.provider.spinedarray; -import dev.ikm.tinkar.common.service.PrimitiveData; -import dev.ikm.tinkar.entity.*; +import dev.ikm.tinkar.entity.ConceptRecord; +import dev.ikm.tinkar.entity.ConceptRecordBuilder; +import dev.ikm.tinkar.entity.ConceptVersionRecord; +import dev.ikm.tinkar.entity.ConceptVersionRecordBuilder; +import dev.ikm.tinkar.entity.Entity; +import dev.ikm.tinkar.entity.EntityService; +import dev.ikm.tinkar.entity.EntityVersion; +import dev.ikm.tinkar.entity.RecordListBuilder; +import dev.ikm.tinkar.entity.SemanticRecord; +import dev.ikm.tinkar.entity.SemanticRecordBuilder; +import dev.ikm.tinkar.entity.SemanticVersionRecord; +import dev.ikm.tinkar.entity.SemanticVersionRecordBuilder; +import dev.ikm.tinkar.entity.StampRecord; +import dev.ikm.tinkar.entity.StampRecordBuilder; +import dev.ikm.tinkar.entity.StampVersionRecord; +import dev.ikm.tinkar.entity.StampVersionRecordBuilder; import dev.ikm.tinkar.entity.graph.adaptor.axiom.LogicalExpression; import dev.ikm.tinkar.entity.transaction.Transaction; import dev.ikm.tinkar.ext.lang.owl.Rf2OwlToLogicAxiomTransformer; import dev.ikm.tinkar.ext.lang.owl.SctOwlUtilities; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.EntityProxy; import dev.ikm.tinkar.terms.TinkarTerm; @@ -45,25 +60,26 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class OwlTransformationTestIT extends TestHelper { +public class OwlTransformationTestIT { private static final Logger LOG = LoggerFactory.getLogger(OwlTransformationTestIT.class); public static final EntityProxy.Pattern IDENTIFIER_PATTERN = EntityProxy.Pattern.make("Identifier Pattern", UUID.fromString("5d60e14b-c410-5172-9559-3c4253278ae2")); public static final EntityProxy.Pattern AXIOM_SYNTAX_PATTERN = EntityProxy.Pattern.make("Axiom Syntax Pattern", UUID.fromString("c0ca180b-aae2-5fa1-9ab7-4a24f2dfe16b")); - private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(OwlTransformationTestIT.class); + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply(OwlTransformationTestIT.class); private static final List testConceptList = Arrays.asList( EntityProxy.Concept.make("TESTCONCEPTONE", UUID.randomUUID()), EntityProxy.Concept.make("TESTCONCEPTTWO", UUID.randomUUID()), EntityProxy.Concept.make("TESTCONCEPTTHREE", UUID.randomUUID())); @BeforeEach - public void startup(){ - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + public void beforeEach(){ + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); generateTestAxiomData(); // Write minimal axiom test data } @AfterEach - public void breakdown(){ - PrimitiveData.stop(); + public void afterEach(){ + TestHelper.stopDatabase(); } @Test @@ -309,4 +325,5 @@ private static Entity createAxiomSyntaxSemanticTestHelp EntityService.get().putEntity(entity); return entity; } + } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayEntityCacheIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayEntityCacheIT.java index ccf2ac42..0a916d37 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayEntityCacheIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayEntityCacheIT.java @@ -18,9 +18,17 @@ import dev.ikm.tinkar.common.id.PublicId; import dev.ikm.tinkar.common.id.PublicIds; import dev.ikm.tinkar.common.service.PrimitiveData; -import dev.ikm.tinkar.entity.*; +import dev.ikm.tinkar.entity.ConceptEntity; +import dev.ikm.tinkar.entity.ConceptRecord; +import dev.ikm.tinkar.entity.ConceptRecordBuilder; +import dev.ikm.tinkar.entity.ConceptVersionRecord; +import dev.ikm.tinkar.entity.ConceptVersionRecordBuilder; +import dev.ikm.tinkar.entity.EntityService; +import dev.ikm.tinkar.entity.RecordListBuilder; +import dev.ikm.tinkar.entity.StampEntity; import dev.ikm.tinkar.entity.transaction.Transaction; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.EntityProxy; import dev.ikm.tinkar.terms.State; @@ -37,19 +45,20 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -class SpinedArrayEntityCacheIT extends TestHelper { +class SpinedArrayEntityCacheIT { private static final Logger LOG = LoggerFactory.getLogger(SpinedArrayEntityCacheIT.class); - private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( SpinedArrayEntityCacheIT.class); @BeforeAll static void beforeAll() { - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @AfterAll static void afterAll() { - PrimitiveData.stop(); + TestHelper.stopDatabase();; } // Entity Cache Refresh Cases: diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayProviderIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayProviderIT.java index 2e8ea44d..3d6d224d 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayProviderIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayProviderIT.java @@ -24,30 +24,35 @@ import dev.ikm.tinkar.entity.util.EntityProcessor; import dev.ikm.tinkar.entity.util.EntityRealizer; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.IOException; import java.util.Arrays; @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class SpinedArrayProviderIT extends TestHelper { +class SpinedArrayProviderIT { private static final Logger LOG = LoggerFactory.getLogger(SpinedArrayProviderIT.class); - private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( SpinedArrayProviderIT.class); @BeforeAll - static void setupSuite() { - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + static void beforeAll() { + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); } @Test @Order(1) - public void loadChronologies() throws IOException { + public void loadChronologies() { File file = TestConstants.PB_STARTER_DATA_REASONED; LoadEntitiesFromProtobufFile loadProto = new LoadEntitiesFromProtobufFile(file); EntityCountSummary count = loadProto.compute(); diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayPublicIdMergeIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayPublicIdMergeIT.java index f1a94b5d..6b878fab 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayPublicIdMergeIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/provider/spinedarray/SpinedArrayPublicIdMergeIT.java @@ -18,39 +18,47 @@ import dev.ikm.tinkar.common.id.PublicId; import dev.ikm.tinkar.common.id.PublicIds; import dev.ikm.tinkar.common.service.PrimitiveData; -import dev.ikm.tinkar.common.service.TinkExecutor; -import dev.ikm.tinkar.entity.*; +import dev.ikm.tinkar.entity.ConceptEntity; +import dev.ikm.tinkar.entity.ConceptRecord; +import dev.ikm.tinkar.entity.ConceptRecordBuilder; +import dev.ikm.tinkar.entity.ConceptVersionRecord; +import dev.ikm.tinkar.entity.ConceptVersionRecordBuilder; +import dev.ikm.tinkar.entity.EntityService; +import dev.ikm.tinkar.entity.RecordListBuilder; +import dev.ikm.tinkar.entity.StampEntity; import dev.ikm.tinkar.entity.transaction.Transaction; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.terms.EntityProxy; import dev.ikm.tinkar.terms.State; import dev.ikm.tinkar.terms.TinkarTerm; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.util.HashSet; -import java.util.Set; import java.util.UUID; -import java.util.concurrent.TimeUnit; import static org.junit.jupiter.api.Assertions.assertEquals; -class SpinedArrayPublicIdMergeIT extends TestHelper { +class SpinedArrayPublicIdMergeIT { private static final Logger LOG = LoggerFactory.getLogger(SpinedArrayPublicIdMergeIT.class); private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( SpinedArrayPublicIdMergeIT.class); @BeforeAll static void beforeAll() { - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + TestHelper.startDataBase(DataStore.EPHEMERAL_STORE); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @AfterAll static void afterAll() { - PrimitiveData.stop(); + TestHelper.stopDatabase();; } // Merging PublicId Cases: diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/search/SearcherIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/search/SearcherIT.java index 9fb4e650..2964a95a 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/search/SearcherIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/search/SearcherIT.java @@ -17,10 +17,10 @@ import dev.ikm.tinkar.common.id.PublicId; import dev.ikm.tinkar.common.id.PublicIds; -import dev.ikm.tinkar.common.service.PrimitiveData; import dev.ikm.tinkar.coordinate.Coordinates; import dev.ikm.tinkar.coordinate.navigation.calculator.NavigationCalculatorWithCache; import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.provider.search.Searcher; import dev.ikm.tinkar.terms.EntityProxy; @@ -38,19 +38,20 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class SearcherIT extends TestHelper { +public class SearcherIT { - private static final File SAP_DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( + private static final File DATASTORE_ROOT = TestConstants.createFilePathInTargetFromClassName.apply( SearcherIT.class); @BeforeAll - public void setup() { - loadSpinedArrayDataBase(SAP_DATASTORE_ROOT); + public void beforeAll() { + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); + TestHelper.loadDataFile(TestConstants.PB_STARTER_DATA_REASONED); } @AfterAll - public void teardown() { - PrimitiveData.stop(); + public void afterAll() { + TestHelper.stopDatabase(); } @Test diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/core/QueryByMembershipIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/core/QueryByMembershipIT.java index 1894a0a1..f3cc4a63 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/core/QueryByMembershipIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/core/QueryByMembershipIT.java @@ -15,27 +15,14 @@ */ package dev.ikm.tinkar.integration.snomed.core; -import dev.ikm.tinkar.common.service.CachingService; import dev.ikm.tinkar.common.service.PrimitiveData; -import dev.ikm.tinkar.common.service.ServiceKeys; -import dev.ikm.tinkar.common.service.ServiceProperties; -import dev.ikm.tinkar.entity.ConceptEntity; -import dev.ikm.tinkar.entity.Entity; -import dev.ikm.tinkar.entity.EntityService; -import dev.ikm.tinkar.entity.EntityVersion; -import dev.ikm.tinkar.entity.PatternEntity; -import dev.ikm.tinkar.entity.SemanticEntity; -import dev.ikm.tinkar.entity.StampEntity; -import dev.ikm.tinkar.entity.StampEntityVersion; +import dev.ikm.tinkar.entity.*; import dev.ikm.tinkar.entity.transform.EntityToTinkarSchemaTransformer; -import dev.ikm.tinkar.integration.TestConstants; +import dev.ikm.tinkar.integration.helper.DataStore; +import dev.ikm.tinkar.integration.helper.TestHelper; import dev.ikm.tinkar.schema.TinkarMsg; import dev.ikm.tinkar.terms.TinkarTerm; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,44 +38,30 @@ public class QueryByMembershipIT { - private static final Logger LOG = LoggerFactory.getLogger( QueryByMembershipIT.class); - - private static final String CONTROLLER_NAME = TestConstants.SA_STORE_OPEN_NAME; - - private static final File DATA_STORE_FILE = new File(System.getProperty("user.home") + "/Solor/snomed-starter-data"); - - private static final File DATA_STORE_FILE2 = new File(System.getProperty("user.home") + "/Solor/membership-filter"); + private static final File DATASTORE_ROOT = new File(System.getProperty("user.home") + "/Solor/snomed-starter-data"); private final EntityToTinkarSchemaTransformer entityTransformer = EntityToTinkarSchemaTransformer.getInstance(); final AtomicInteger exportPatternCount = new AtomicInteger(); - final AtomicInteger exportConceptCount = new AtomicInteger(); final AtomicInteger exportSemanticCount = new AtomicInteger(); - final AtomicInteger exportStampCount = new AtomicInteger(); final AtomicInteger nullEntities = new AtomicInteger(0); static final int VERBOSE_ERROR_COUNT = 10; - public void initialize(File datastore) throws IOException { - LOG.info("Starting database"); - LOG.info("Loading data from " + DATA_STORE_FILE.getAbsolutePath()); - CachingService.clearAll(); - ServiceProperties.set(ServiceKeys.DATA_STORE_ROOT, datastore); - PrimitiveData.selectControllerByName(CONTROLLER_NAME); - PrimitiveData.start(); + @BeforeAll + public static void beforeAll() { + TestHelper.startDataBase(DataStore.SPINED_ARRAY_STORE, DATASTORE_ROOT); } @Test @DisplayName("Exporting filtered entities to protobuf file") @Disabled("Enable the tests after figuring out the way to load the DataStores in Jenkins. or test directory") - @Order(1) - public void exportProtobufTest() throws IOException { - initialize(DATA_STORE_FILE); + public void exportProtobufTest() { AtomicInteger verboseErrors = new AtomicInteger(0); int patternNidMembership = TinkarTerm.PATHS_PATTERN.nid(); Set> entitiesFromMembership = filterbyMembership(patternNidMembership); //input pattern nid @@ -144,7 +117,7 @@ public void exportProtobufTest() throws IOException { Assertions.assertTrue(exportSemanticCount.get()>0); Assertions.assertTrue(exportConceptCount.get()>0); - } + } public Set> filterbyMembership(int patternNid){ Set> entitySet = new HashSet<>(); @@ -157,7 +130,6 @@ public Set> filterbyMembership(int patternNid){ LOG.info("Stamps for concept: " + EntityService.get().getStampFast(stampNid)); }); - System.out.println ("Print patterns: " + semanticEntity.pattern()); entitySet.add(semanticEntity.pattern()); //Adds patterns to the Hashset. Duplicates are avoided @@ -174,7 +146,6 @@ public Set> filterbyMembership(int patternNid){ }); }); - return entitySet; } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/description/SnomedToEntityDescriptionIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/description/SnomedToEntityDescriptionIT.java index 6a85352f..bae74a7c 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/description/SnomedToEntityDescriptionIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/description/SnomedToEntityDescriptionIT.java @@ -43,7 +43,7 @@ public class SnomedToEntityDescriptionIT { public static final long EXPECTED_DATE = LocalDate.parse("20020131", DateTimeFormatter.ofPattern("yyyyMMdd")).atTime(12,0,0).toInstant(ZoneOffset.UTC).toEpochMilli(); @BeforeEach - public void setup() { + public void beforeEach() { transformer = new SnomedToEntityDescription(); } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/description/SnomedToEntityIdentifierIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/description/SnomedToEntityIdentifierIT.java index 2c4b798a..7074124c 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/description/SnomedToEntityIdentifierIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/description/SnomedToEntityIdentifierIT.java @@ -41,7 +41,7 @@ public class SnomedToEntityIdentifierIT { SnomedToEntityIdentifier transformer; @BeforeEach - public void setup() { + public void beforeEach() { transformer = new SnomedToEntityIdentifier(); } diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/language/SnomedLanguageSemanticMultipleVersionsIT.java b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/language/SnomedLanguageSemanticMultipleVersionsIT.java index a4accc03..77969990 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/language/SnomedLanguageSemanticMultipleVersionsIT.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/language/SnomedLanguageSemanticMultipleVersionsIT.java @@ -34,15 +34,6 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class SnomedLanguageSemanticMultipleVersionsIT { - @BeforeEach - void setUp() { - } - - @AfterEach - void tearDown() { - } - - @Test @DisplayName("Language Acceptability Semantic with multiple versions") @Order(1) diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/language/TestSnomedToEntityLanguage.java b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/language/TestSnomedToEntityLanguage.java index 3c52a83b..9292eab7 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/language/TestSnomedToEntityLanguage.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/language/TestSnomedToEntityLanguage.java @@ -30,15 +30,6 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestSnomedToEntityLanguage { - @BeforeAll - public void setupSuite() throws IOException { - - } - - @AfterAll - public void teardownSuite() throws IOException{ - - } @Test @DisplayName("Test Snomed to Entity Language.") public void testSnomedToEntityLanguage(){ diff --git a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/relationship/TestActiveRelationship.java b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/relationship/TestActiveRelationship.java index 753bca2c..874a013e 100644 --- a/integration/src/test/java/dev/ikm/tinkar/integration/snomed/relationship/TestActiveRelationship.java +++ b/integration/src/test/java/dev/ikm/tinkar/integration/snomed/relationship/TestActiveRelationship.java @@ -30,15 +30,6 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestActiveRelationship { - @BeforeAll - public void setupSuite() throws IOException { - - } - - @AfterAll - public void teardownSuite() throws IOException{ - - } @Test @DisplayName("Test Snomed to Entity Relationship Version. - One record.") public void testSnomedToEntityRelationShipOneRecord(){ diff --git a/language-extensions/binding-extension/src/main/java/dev/ikm/tinkar/ext/binding/GenerateJavaBindingTask.java b/language-extensions/binding-extension/src/main/java/dev/ikm/tinkar/ext/binding/GenerateJavaBindingTask.java index 41aba962..286bf074 100644 --- a/language-extensions/binding-extension/src/main/java/dev/ikm/tinkar/ext/binding/GenerateJavaBindingTask.java +++ b/language-extensions/binding-extension/src/main/java/dev/ikm/tinkar/ext/binding/GenerateJavaBindingTask.java @@ -70,8 +70,10 @@ protected Void compute() throws Exception { .empty("imports", outputConsumer -> outputConsumer.accept(""" import java.util.UUID; + import dev.ikm.tinkar.common.id.PublicIds; import dev.ikm.tinkar.terms.EntityProxy.Concept; - import dev.ikm.tinkar.terms.EntityProxy.Pattern;""")) + import dev.ikm.tinkar.terms.EntityProxy.Pattern;""" + )) .empty("className", outputConsumer -> outputConsumer.accept(className)) .empty("namespaceUUID", outputConsumer -> outputConsumer.accept(namespace.toString())) .stream("concepts", conceptEntities, diff --git a/language-extensions/binding-extension/src/main/java/dev/ikm/tinkar/ext/binding/JavaTemplates.java b/language-extensions/binding-extension/src/main/java/dev/ikm/tinkar/ext/binding/JavaTemplates.java index c2a05386..01a4400c 100644 --- a/language-extensions/binding-extension/src/main/java/dev/ikm/tinkar/ext/binding/JavaTemplates.java +++ b/language-extensions/binding-extension/src/main/java/dev/ikm/tinkar/ext/binding/JavaTemplates.java @@ -76,7 +76,7 @@ public class ${className} { ${patternFieldDefinitions} *
    */ - public static final Pattern ${patternVariable} = Concept.make("${patternDescription}", PublicIds.of(${patternPublicId})); + public static final Pattern ${patternVariable} = Pattern.make("${patternDescription}", PublicIds.of(${patternPublicId})); """; public static final String JAVA_PATTERN_FIELD_DEFINITION_TEMPLATE =