From ba5845c86ae4d89c0c4e65c95ec13905ed9ca12d Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 29 Jan 2023 17:11:13 +0000 Subject: [PATCH] Add new tests to CTS Signed-off-by: Mandy Chessell --- ...enMetadataConformanceWorkbenchWorkPad.java | 14 +- .../beans/OpenMetadataTestCase.java | 98 +- .../RepositoryConformanceTestCase.java | 21 +- .../connector/TestMetadataCollectionId.java | 23 +- ...estClassificationHasSupportedEntities.java | 11 +- .../instances/TestGraphQueries.java | 615 ++++---- .../TestSupportedClassificationLifecycle.java | 84 +- .../TestSupportedEntityLifecycle.java | 1318 +++++++++++++---- .../TestSupportedEntityProxyLifecycle.java | 354 +++-- ...SupportedEntityReferenceCopyLifecycle.java | 422 +++--- .../TestSupportedEntityReidentify.java | 87 +- .../instances/TestSupportedEntityRetype.java | 116 +- .../instances/TestSupportedEntitySearch.java | 1056 +++++++------ ...dReferenceCopyClassificationLifecycle.java | 122 +- .../TestSupportedRelationshipLifecycle.java | 1063 +++++++++---- ...tedRelationshipReferenceCopyLifecycle.java | 461 +++--- .../TestSupportedRelationshipReidentify.java | 68 +- .../TestSupportedRelationshipSearch.java | 13 +- .../types/TestSupportedTypeDef.java | 6 +- .../RepositoryConformanceProfile.java | 20 +- ...positoryConformanceProfileRequirement.java | 22 +- .../RepositoryConformanceWorkPad.java | 45 +- .../RepositoryConformanceWorkbench.java | 68 +- .../ConformanceSuiteOMRSTopicListener.java | 2 +- .../spring/ConformanceSuiteResource.java | 2 +- .../properties/EndpointProperties.java | 44 +- .../converters/EndpointConverter.java | 4 +- .../server/ConnectionRESTServices.java | 8 +- .../properties/EndpointProperties.java | 50 +- .../converters/EndpointConverter.java | 4 +- .../server/ConnectionRESTServices.java | 8 +- .../properties/AssetProperties.java | 44 +- .../converters/AssetConverter.java | 4 +- .../properties/AssetProperties.java | 48 +- .../GraphOMRSEntityMapper.java | 2 +- .../GraphOMRSMetadataStore.java | 31 +- .../InMemoryOMRSMetadataCollection.java | 8 +- .../InMemoryOMRSMetadataStore.java | 174 ++- .../OpenMetadataServerSecurityVerifier.java | 30 +- .../properties/TestAssetDetail.java | 16 +- .../properties/TestAssetSummary.java | 28 +- .../properties/beans/TestAsset.java | 5 +- .../OMRSMetadataCollection.java | 6 +- .../OpenMetadataRepositorySecurity.java | 32 +- .../properties/RepositoryElementHeader.java | 21 +- .../instances/InstanceElementHeader.java | 3 +- .../typedefs/TypeDefElementHeader.java | 7 - .../typedefs/TypeDefElementHeaderTest.java | 6 +- .../OMRSRepositoryContentHelper.java | 1 - .../fvt/connections/CreateConnectionTest.java | 12 +- .../fvt/connections/CreateConnectionTest.java | 12 +- 51 files changed, 4327 insertions(+), 2392 deletions(-) diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceWorkbenchWorkPad.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceWorkbenchWorkPad.java index 0918d1d6af2..932e8670935 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceWorkbenchWorkPad.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceWorkbenchWorkPad.java @@ -33,7 +33,7 @@ public abstract class OpenMetadataConformanceWorkbenchWorkPad * Add time of last received event - this is to help with determining whether workbench has completed */ protected Date lastActive = new Date(); - private static final long DELAY_TIME = 10000l; // 10 seconds - time to wait after activity has quiesced before reporting completion + private static final long DELAY_TIME = 10000L; // 10 seconds - time to wait after activity has quiesced before reporting completion /** * Constructor takes properties that are common to all work pads. @@ -150,7 +150,6 @@ public OpenMetadataConformanceWorkbenchStatus getWorkbenchStatus() * Set the completion state of the workbench to true. * This signifies that the synchronous portion of the tests have completed. * The workbench may still be processing asynchronous events which trigger further tests. - * */ public void setWorkbenchComplete() { @@ -356,24 +355,19 @@ protected OpenMetadataConformanceStatus processEvidence(Listobject1=" + object1 + "; ===>object2=" + object2); + workPad.addUnsuccessfulCondition(profileId, requirementId, testCaseId, testCaseName, testCaseDescriptionURL, assertionId, methodName, elapsedTime); + throw new AssertionFailureException(assertionId, assertionMessage); + } + + /** * Throw an exception if the condition is not true; else return * @@ -302,6 +338,39 @@ protected void verifyCondition(boolean condition, } + /** + * Log if the condition is not true; else return + * + * @param object1 object to test + * @param object2 object to test + * @param assertionId identifier for the assertion + * @param assertionMessage descriptive message of the assertion + * @param profileId identifier of profile for this assertion + * @param requirementId identifier of requirement for this assertion + * @param methodName method that this condition tests + * @param elapsedTime of the test executing (in milliseconds) + */ + protected void verifyObjectsAreEqual(Object object1, + Object object2, + String assertionId, + String assertionMessage, + Integer profileId, + Integer requirementId, + String methodName, + Long elapsedTime) + { + if (object1.equals(object2)) + { + successfulAssertions.add(assertionId + ": " + assertionMessage); + workPad.addSuccessfulCondition(profileId, requirementId, testCaseId, testCaseName, testCaseDescriptionURL, assertionId, methodName, elapsedTime); + return; + } + + unsuccessfulAssertions.add(assertionId + ": " + assertionMessage + "==>object1=" + object1 + "; ===>object2=" + object2); + workPad.addUnsuccessfulCondition(profileId, requirementId, testCaseId, testCaseName, testCaseDescriptionURL, assertionId, methodName, elapsedTime); + } + + /** * Log if the condition is not true; else return * @@ -421,6 +490,9 @@ public void executeTest() } catch (AssertionFailureException exception) { + /* + * This exception has already been logged + */ } catch (Exception exception) { @@ -461,6 +533,9 @@ public void executeTest(TestPhase phase) } catch (AssertionFailureException exception) { + /* + * This is already handled. + */ } catch (Exception exception) { @@ -480,11 +555,14 @@ public void executeTest(TestPhase phase) } - public void cleanTest() { - try { + public void cleanTest() + { + try + { this.cleanup(); } - catch (Exception exception) { + catch (Exception exception) + { /* No action taken - the cleanup should be a belt and braces clearing of instances */ } } @@ -514,7 +592,7 @@ protected void cleanup() throws Exception protected void run(TestPhase phase) throws Exception { /* - * Method is overloaded by any multi-phase test case + * Method is overloaded by any multiphase test case */ } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/RepositoryConformanceTestCase.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/RepositoryConformanceTestCase.java index 141d4748773..4f331f1e015 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/RepositoryConformanceTestCase.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/RepositoryConformanceTestCase.java @@ -63,11 +63,8 @@ protected RepositoryConformanceTestCase(RepositoryConformanceWorkPad workPad, this.repositoryConformanceWorkPad = workPad; - if (workPad != null) - { - cohortRepositoryConnector = workPad.getTutRepositoryConnector(); - maxSearchResults = workPad.getMaxSearchResults(); - } + cohortRepositoryConnector = workPad.getTutRepositoryConnector(); + maxSearchResults = workPad.getMaxSearchResults(); } /** @@ -226,6 +223,7 @@ protected int getMaxSearchResults() { return maxSearchResults; } + /** * Return the repository connector generated from the cohort registration event. * @@ -481,14 +479,14 @@ protected InstanceProperties getAllPropertiesForInstance(String userId, TypeDef { Map propertyMap = new HashMap<>(); - for (TypeDefAttribute typeDefAttribute : allTypeDefAttributes) { String attributeName = typeDefAttribute.getAttributeName(); AttributeTypeDef attributeType = typeDefAttribute.getAttributeType(); AttributeTypeDefCategory category = attributeType.getCategory(); - if (category == AttributeTypeDefCategory.PRIMITIVE) { + if (category == AttributeTypeDefCategory.PRIMITIVE) + { PrimitiveDef primitiveDef = (PrimitiveDef) attributeType; propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef)); } @@ -529,7 +527,8 @@ protected InstanceProperties generatePropertiesForInstance(String userId, List< AttributeTypeDefCategory category = attributeType.getCategory(); boolean attrUnique = typeDefAttribute.isUnique(); - if (category == AttributeTypeDefCategory.PRIMITIVE) { + if (category == AttributeTypeDefCategory.PRIMITIVE) + { PrimitiveDef primitiveDef = (PrimitiveDef) attributeType; propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef, attrUnique, instanceCount)); } @@ -573,8 +572,10 @@ protected InstanceProperties getAllUniquePropertiesForInstance(String userId, T AttributeTypeDef attributeType = typeDefAttribute.getAttributeType(); AttributeTypeDefCategory category = attributeType.getCategory(); - if (typeDefAttribute.isUnique()) { - if (category == AttributeTypeDefCategory.PRIMITIVE) { + if (typeDefAttribute.isUnique()) + { + if (category == AttributeTypeDefCategory.PRIMITIVE) + { PrimitiveDef primitiveDef = (PrimitiveDef) attributeType; propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef)); } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/connector/TestMetadataCollectionId.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/connector/TestMetadataCollectionId.java index 4f9b9587ea0..d369050b19c 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/connector/TestMetadataCollectionId.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/connector/TestMetadataCollectionId.java @@ -7,6 +7,7 @@ import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryConnector; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException; public class TestMetadataCollectionId extends RepositoryConformanceTestCase { @@ -77,7 +78,26 @@ protected void run() throws Exception defaultRequirementId); OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - String mcMetadataCollectionId = metadataCollection.getMetadataCollectionId(workPad.getLocalServerUserId()); + String mcMetadataCollectionId = null; + + /* + * This is the first attempt to make a remote call to the technology under test. + */ + int retryCount = 0; + do + { + try + { + mcMetadataCollectionId = metadataCollection.getMetadataCollectionId(workPad.getLocalServerUserId()); + } + catch (RepositoryErrorException serverNotRunningException) + { + Thread.sleep(1000); + } + + retryCount++; + + } while ((retryCount < 20) && (mcMetadataCollectionId == null)); verifyCondition((mcMetadataCollectionId != null), assertion3, @@ -91,7 +111,6 @@ protected void run() throws Exception defaultProfileId, defaultRequirementId); - addDiscoveredProperty(metadataCollectionIdPropertyName, mcMetadataCollectionId, defaultProfileId, diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestClassificationHasSupportedEntities.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestClassificationHasSupportedEntities.java index aa912994194..2ab3ea9173c 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestClassificationHasSupportedEntities.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestClassificationHasSupportedEntities.java @@ -30,10 +30,10 @@ public class TestClassificationHasSupportedEntities extends RepositoryConformanc private static final String successMessage = " has at least one supported entity"; - private Map entityDefs; - private ClassificationDef classificationDef; + private final Map entityDefs; + private final ClassificationDef classificationDef; - private List supportedEntityDefsForClassification = new ArrayList<>(); + private final List supportedEntityDefsForClassification = new ArrayList<>(); /** * Typical constructor sets up superclass and discovered information needed for tests @@ -62,7 +62,6 @@ public TestClassificationHasSupportedEntities(RepositoryConformanceWorkPad workP */ protected void run() throws Exception { - /* * Verify that the supplied TypeDef is valid and update the testId */ @@ -98,7 +97,6 @@ protected void run() throws Exception } else { - super.addNotSupportedAssertion(assertion2, testTypeName + assertionMsg2 + classificationDef.getName(), RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), @@ -108,10 +106,9 @@ protected void run() throws Exception } } - /* * Verify that there are entities to connect this classification to. - * It the repository does not support any of the valid entity types for this classification. + * If the repository does not support any of the valid entity types for this classification. * it should not be supporting this classification. */ assertCondition((! supportedEntityDefsForClassification.isEmpty()), diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestGraphQueries.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestGraphQueries.java index 86d95c696f8..8d42692ccfc 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestGraphQueries.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestGraphQueries.java @@ -81,8 +81,8 @@ public class TestGraphQueries extends RepositoryConformanceTestCase { private static final String assertionMsg16 = " repository supports getLinkingEntities "; - private String testTypeName; - private RepositoryConformanceWorkPad workPad; + private final String testTypeName; + private final RepositoryConformanceWorkPad workPad; private OMRSMetadataCollection metadataCollection; private Map entityDefs = null; private Map relationshipDefs = null; @@ -91,8 +91,8 @@ public class TestGraphQueries extends RepositoryConformanceTestCase { private int edgeCount = 0; private int nodeCount = 0; - private int maxDepth = 3; - private int maxFanout = 3; + private final int maxDepth = 3; + private final int maxFanout = 3; /* * The edgeToNodeMap is a map of relationshipGUID to a pair of entityGUIDs, ordered as end1 then end2 @@ -123,13 +123,13 @@ public TestGraphQueries(RepositoryConformanceWorkPad workPad, List(); - for (RelationshipDef relDef : relationshipDefs) { + for (RelationshipDef relDef : relationshipDefs) + { this.relationshipDefs.put(relDef.getName(),relDef); } @@ -137,7 +137,6 @@ public TestGraphQueries(RepositoryConformanceWorkPad workPad, List curP, List routes = connMap.get(curE); Set routeKeys = routes.keySet(); - for (String routeKey : routeKeys) { - if (curP == null || !curP.contains(routeKey)) { + for (String routeKey : routeKeys) + { + if (curP == null || !curP.contains(routeKey)) + { String remoteEntity = routes.get(routeKey); List curPex = new ArrayList<>(); - if (curP != null) { + if (curP != null) + { curPex.addAll(curP); } curPex.add(routeKey); - if (remoteEntity.equals(tgtE)) { + if (remoteEntity.equals(tgtE)) + { /* Arrived! - record path and pop */ discoveredPaths.add(curPex); return; - } else { + } + else + { traverse(remoteEntity, tgtE, curPex, discoveredPaths); } } @@ -240,19 +232,25 @@ private List> exploreFromEntity(String entityGUID, String arrivalEd List discoveredEntityGUIDs = new ArrayList<>(); List discoveredRelationshipGUIDs = new ArrayList<>(); - if (remainingDepth != 0) { + if (remainingDepth != 0) + { List> inOutEdges = nodeToEdgesMap.get(entityGUID); List bothEdges = new ArrayList<>(); bothEdges.addAll(inOutEdges.get(0)); bothEdges.addAll(inOutEdges.get(1)); - if (!(bothEdges.isEmpty())) { - for (String edgeGUID : bothEdges) { - if (!edgeGUID.equals(arrivalEdgeGUID)) { + if (!(bothEdges.isEmpty())) + { + for (String edgeGUID : bothEdges) + { + if (!edgeGUID.equals(arrivalEdgeGUID)) + { /* For each untraversed edge from this entity, explore */ List end1end2 = this.edgeToNodesMap.get(edgeGUID); - for (String entGUID : end1end2) { - if (!(entGUID.equals(entityGUID))) { + for (String entGUID : end1end2) + { + if (!(entGUID.equals(entityGUID))) + { /* Explore from the other entity */ List> newGUIDs = this.exploreFromEntity(entGUID, edgeGUID, remainingDepth>0?(remainingDepth - 1):remainingDepth); discoveredEntityGUIDs.addAll(newGUIDs.get(0)); @@ -275,7 +273,8 @@ private List> exploreFromEntity(String entityGUID, String arrivalEd - private void constructGraph() throws Exception { + private void constructGraph() throws Exception + { /* * Clear the usage maps and counts @@ -296,7 +295,8 @@ private void constructGraph() throws Exception { Iterator relationshipTypeNameIterator = relationshipTypeNames.iterator(); - if (relationshipTypeNameIterator.hasNext()) { + if (relationshipTypeNameIterator.hasNext()) + { String relationshipTypeName = relationshipTypeNameIterator.next(); @@ -324,7 +324,8 @@ private void constructGraph() throws Exception { * Update end1's outbound and inbound edge lists */ List> end1pairedEdgeLists = this.nodeToEdgesMap.get(end1GUID); - if (end1pairedEdgeLists == null) { + if (end1pairedEdgeLists == null) + { /* * First time for this node, so create the pair of lists */ @@ -365,10 +366,10 @@ private void constructGraph() throws Exception { * Create a relationship and far end (only) and hook the relationship onto the current (end2) entity. */ - if (this.maxDepth > 1) { + if (this.maxDepth > 1) + { this.extendGraph(workPad.getLocalServerUserId(), end2GUID, 1); } - } } @@ -377,35 +378,41 @@ private void destroyGraph() throws Exception /* * Clean up the instances created for the graph query tests. - * This is easiest if we use the keys from the ndoeToEdgesMap to delete the nodes (entities). This will clean up the relationships. + * This is easiest if we use the keys from the nodeToEdgesMap to delete the nodes (entities). This will clean up the relationships. */ Set nodeKeys = nodeToEdgesMap.keySet(); - for (String nodeKey : nodeKeys) { + for (String nodeKey : nodeKeys) + { /* - * Need to get the entitiy so that we can note its type, needed for delete. + * Need to get the entity so that we can note its type, needed for delete. */ - try { - + try + { EntityDetail entityToDelete = metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), nodeKey); - try { + try + { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), - entityToDelete.getType().getTypeDefGUID(), - entityToDelete.getType().getTypeDefName(), - nodeKey); + entityToDelete.getType().getTypeDefGUID(), + entityToDelete.getType().getTypeDefName(), + nodeKey); - } catch (FunctionNotSupportedException exc) { + } + catch (FunctionNotSupportedException exc) + { /* NO OP - continue with purge */ } metadataCollection.purgeEntity(workPad.getLocalServerUserId(), - entityToDelete.getType().getTypeDefGUID(), - entityToDelete.getType().getTypeDefName(), - nodeKey); - } catch (Exception exception) { + entityToDelete.getType().getTypeDefGUID(), + entityToDelete.getType().getTypeDefName(), + nodeKey); + } + catch (Exception exception) + { /* * Rethrow the exception - this will cause a failure of the testcase, which is desirable. */ @@ -428,15 +435,15 @@ private void extendGraph(String userId, String entityGUID, int currentDepth) thr int fanout = 0; int endChoice = 1; - while (fanout < maxFanout) { - + while (fanout < maxFanout) + { /* * Find an available relationship type if possible, if not reuse types. * Alternate between using this entity as end1 or end2 of the relationship to be created. */ - if (endChoice == 1) { - + if (endChoice == 1) + { /* Use as end1 */ List end1PossibleTypeNames = possibleRelTypeNames.get(0); int end1Index = fanout % 2; @@ -462,7 +469,8 @@ private void extendGraph(String userId, String entityGUID, int currentDepth) thr * Update end1's outbound and inbound edge lists */ List> end1pairedEdgeLists = this.nodeToEdgesMap.get(end1GUID); - if (end1pairedEdgeLists == null) { + if (end1pairedEdgeLists == null) + { /* * First time for this node, so create the pair of lists */ @@ -480,7 +488,8 @@ private void extendGraph(String userId, String entityGUID, int currentDepth) thr * Update end2's outbound and inbound edge lists */ List> end2pairedEdgeLists = this.nodeToEdgesMap.get(end2GUID); - if (end2pairedEdgeLists == null) { + if (end2pairedEdgeLists == null) + { /* * First time for this node, so create the pair of lists */ @@ -500,12 +509,13 @@ private void extendGraph(String userId, String entityGUID, int currentDepth) thr currentDepth++; - if (this.maxDepth > currentDepth) { + if (this.maxDepth > currentDepth) + { this.extendGraph(userId, end2GUID, currentDepth); } - - } else { - + } + else + { /* Use as end2 */ List end2PossibleTypeNames = possibleRelTypeNames.get(1); @@ -531,7 +541,8 @@ private void extendGraph(String userId, String entityGUID, int currentDepth) thr * Update end1's outbound and inbound edge lists */ List> end1pairedEdgeLists = this.nodeToEdgesMap.get(end1GUID); - if (end1pairedEdgeLists == null) { + if (end1pairedEdgeLists == null) + { /* * First time for this node, so create the pair of lists */ @@ -549,7 +560,8 @@ private void extendGraph(String userId, String entityGUID, int currentDepth) thr * Update end2's outbound and inbound edge lists */ List> end2pairedEdgeLists = this.nodeToEdgesMap.get(end2GUID); - if (end2pairedEdgeLists == null) { + if (end2pairedEdgeLists == null) + { /* * First time for this node, so create the pair of lists */ @@ -566,10 +578,10 @@ private void extendGraph(String userId, String entityGUID, int currentDepth) thr this.edgeCount++; this.nodeCount++; - currentDepth++; - if (this.maxDepth > currentDepth) { + if (this.maxDepth > currentDepth) + { this.extendGraph(userId, end1GUID, currentDepth); } } @@ -602,25 +614,27 @@ private List addFullEdgeToGraph(String relationshipTypeName) throws Exce */ OMRSRepositoryConnector cohortRepositoryConnector = null; OMRSRepositoryHelper repositoryHelper = null; - if (workPad != null) { + if (workPad != null) + { cohortRepositoryConnector = workPad.getTutRepositoryConnector(); repositoryHelper = cohortRepositoryConnector.getRepositoryHelper(); } RelationshipDef knownRelationshipDef = null; - if (repositoryHelper != null) { + if (repositoryHelper != null) + { knownRelationshipDef = (RelationshipDef) repositoryHelper.getTypeDefByName(workPad.getLocalServerUserId(), relationshipTypeName); } RelationshipDef repositoryRelationshipDef = relationshipDefs.get(relationshipTypeName); verifyCondition((repositoryRelationshipDef.equals(knownRelationshipDef)), - assertion0, - testTypeName + assertionMsg0, - RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getProfileId(), - RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getRequirementId()); + assertion0, + testTypeName + assertionMsg0, + RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getProfileId(), + RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getRequirementId()); /* * In this testcase the repository is believed to support the relationship type defined by - * relationshipDef - but may not support all of the entity inheritance hierarchy - it may only + * relationshipDef - but may not support all the entity inheritance hierarchy - it may only * support a subset of entity types. So although the relationship type may have end definitions * each specifying a given entity type - the repository may only support certain sub-types of the * specified type. This is OK, and the testcase needs to only try to use entity types that are @@ -637,7 +651,8 @@ private List addFullEdgeToGraph(String relationshipTypeName) throws Exce } List end1DefTypeNames = new ArrayList<>(); end1DefTypeNames.add(end1DefName); - if (this.workPad.getEntitySubTypes(end1DefName) != null) { + if (this.workPad.getEntitySubTypes(end1DefName) != null) + { end1DefTypeNames.addAll(this.workPad.getEntitySubTypes(end1DefName)); } @@ -645,7 +660,8 @@ private List addFullEdgeToGraph(String relationshipTypeName) throws Exce String end2DefName = knownRelationshipDef.getEndDef2().getEntityType().getName(); List end2DefTypeNames = new ArrayList<>(); end2DefTypeNames.add(end2DefName); - if (this.workPad.getEntitySubTypes(end2DefName) != null) { + if (this.workPad.getEntitySubTypes(end2DefName) != null) + { end2DefTypeNames.addAll(this.workPad.getEntitySubTypes(end2DefName)); } @@ -654,13 +670,15 @@ private List addFullEdgeToGraph(String relationshipTypeName) throws Exce */ List end1SupportedTypeNames = new ArrayList<>(); - for (String end1TypeName : end1DefTypeNames) { + for (String end1TypeName : end1DefTypeNames) + { if (entityDefs.get(end1TypeName) != null) end1SupportedTypeNames.add(end1TypeName); } List end2SupportedTypeNames = new ArrayList<>(); - for (String end2TypeName : end2DefTypeNames) { + for (String end2TypeName : end2DefTypeNames) + { if (entityDefs.get(end2TypeName) != null) end2SupportedTypeNames.add(end2TypeName); } @@ -668,16 +686,16 @@ private List addFullEdgeToGraph(String relationshipTypeName) throws Exce /* * Check that neither list is empty */ - if (end1SupportedTypeNames.isEmpty() || end2SupportedTypeNames.isEmpty()) { - + if (end1SupportedTypeNames.isEmpty() || end2SupportedTypeNames.isEmpty()) + { /* * There are no supported types for at least one of the ends - the repository cannot test this relationship type. */ assertCondition((false), - assertion12, - testTypeName + assertionMsg12, - RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId()); + assertion12, + testTypeName + assertionMsg12, + RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), + RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId()); } @@ -699,14 +717,13 @@ private List addFullEdgeToGraph(String relationshipTypeName) throws Exce super.getPropertiesForInstance(knownRelationshipDef.getPropertiesDefinition()), end1.getGUID(), end2.getGUID(), - null); + null); List guids = new ArrayList<>(); guids.add(newRelationship.getGUID()); guids.add(end1.getGUID()); guids.add(end2.getGUID()); return guids; - } @@ -726,27 +743,29 @@ private List addPartialEdgeToGraph(String relationshipTypeName, String e */ OMRSRepositoryConnector cohortRepositoryConnector = null; OMRSRepositoryHelper repositoryHelper = null; - if (workPad != null) { + if (workPad != null) + { cohortRepositoryConnector = workPad.getTutRepositoryConnector(); repositoryHelper = cohortRepositoryConnector.getRepositoryHelper(); } RelationshipDef knownRelationshipDef = null; - if (repositoryHelper != null) { + if (repositoryHelper != null) + { knownRelationshipDef = (RelationshipDef) repositoryHelper.getTypeDefByName(workPad.getLocalServerUserId(), relationshipTypeName); } RelationshipDef repositoryRelationshipDef = relationshipDefs.get(relationshipTypeName); verifyCondition((repositoryRelationshipDef.equals(knownRelationshipDef)), - assertion0, - testTypeName + assertionMsg0, - RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getProfileId(), - RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getRequirementId()); + assertion0, + testTypeName + assertionMsg0, + RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getProfileId(), + RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getRequirementId()); RelationshipDef relationshipDef = knownRelationshipDef; /* * In this testcase the repository is believed to support the relationship type defined by - * relationshipDef - but may not support all of the entity inheritance hierarchy - it may only + * relationshipDef - but may not support all the entity inheritance hierarchy - it may only * support a subset of entity types. So although the relationship type may have end definitions * each specifying a given entity type - the repository may only support certain sub-types of the * specified type. This is OK, and the testcase needs to only try to use entity types that are @@ -760,7 +779,8 @@ private List addPartialEdgeToGraph(String relationshipTypeName, String e String end1DefName = relationshipDef.getEndDef1().getEntityType().getName(); List end1DefTypeNames = new ArrayList<>(); end1DefTypeNames.add(end1DefName); - if (this.workPad.getEntitySubTypes(end1DefName) != null) { + if (this.workPad.getEntitySubTypes(end1DefName) != null) + { end1DefTypeNames.addAll(this.workPad.getEntitySubTypes(end1DefName)); } @@ -768,7 +788,8 @@ private List addPartialEdgeToGraph(String relationshipTypeName, String e String end2DefName = relationshipDef.getEndDef2().getEntityType().getName(); List end2DefTypeNames = new ArrayList<>(); end2DefTypeNames.add(end2DefName); - if (this.workPad.getEntitySubTypes(end2DefName) != null) { + if (this.workPad.getEntitySubTypes(end2DefName) != null) + { end2DefTypeNames.addAll(this.workPad.getEntitySubTypes(end2DefName)); } /* @@ -776,15 +797,21 @@ private List addPartialEdgeToGraph(String relationshipTypeName, String e */ List end1SupportedTypeNames = new ArrayList<>(); - for (String end1TypeName : end1DefTypeNames) { + for (String end1TypeName : end1DefTypeNames) + { if (entityDefs.get(end1TypeName) != null) + { end1SupportedTypeNames.add(end1TypeName); + } } List end2SupportedTypeNames = new ArrayList<>(); - for (String end2TypeName : end2DefTypeNames) { + for (String end2TypeName : end2DefTypeNames) + { if (entityDefs.get(end2TypeName) != null) + { end2SupportedTypeNames.add(end2TypeName); + } } /* @@ -796,10 +823,10 @@ private List addPartialEdgeToGraph(String relationshipTypeName, String e * There are no supported types for at least one of the ends - the repository cannot test this relationship type. */ assertCondition((false), - assertion12, - testTypeName + assertionMsg12, - RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId()); + assertion12, + testTypeName + assertionMsg12, + RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), + RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId()); } /* @@ -813,14 +840,16 @@ private List addPartialEdgeToGraph(String relationshipTypeName, String e String end1GUID; String end2GUID; - if (existingEntityEnd ==1) { + if (existingEntityEnd == 1) + { /* Add an entity to end2 */ EntityDef end2Type = entityDefs.get(end2TypeName); EntityDetail end2 = this.addEntityToRepository(workPad.getLocalServerUserId(), metadataCollection, end2Type); end1GUID = existingEntityGUID; end2GUID = end2.getGUID(); } - else { + else + { /* existing entity is end 2 */ /* Add an entity to end1 */ EntityDef end1Type = entityDefs.get(end1TypeName); @@ -831,18 +860,18 @@ private List addPartialEdgeToGraph(String relationshipTypeName, String e Relationship newRelationship = metadataCollection.addRelationship(workPad.getLocalServerUserId(), - relationshipDef.getGUID(), - super.getPropertiesForInstance(relationshipDef.getPropertiesDefinition()), - end1GUID, - end2GUID, - null); + relationshipDef.getGUID(), + super.getPropertiesForInstance(relationshipDef.getPropertiesDefinition()), + end1GUID, + end2GUID, + null); List guids= new ArrayList<>(); guids.add(newRelationship.getGUID()); guids.add(end1GUID); guids.add(end2GUID); - return guids; + return guids; } private void getEntityNeighborhood() throws Exception @@ -854,37 +883,39 @@ private void getEntityNeighborhood() throws Exception * There is no type filtering on these queries. */ Set entityGUIDs = this.nodeToEdgesMap.keySet(); - for (String entityGUID : entityGUIDs) { - - for (int level = 0; level < 4; level++) { + for (String entityGUID : entityGUIDs) + { + for (int level = 0; level < 4; level++) + { InstanceGraph instGraph = null; long start; long elapsedTime; - try { + try + { start = System.currentTimeMillis(); instGraph = metadataCollection.getEntityNeighborhood(workPad.getLocalServerUserId(), - entityGUID, - null, - null, - null, - null, - null, - level); + entityGUID, + null, + null, + null, + null, + null, + level); elapsedTime = System.currentTimeMillis() - start; - - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion14, - assertionMsg14, - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); - + assertionMsg14, + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); return; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -906,12 +937,12 @@ private void getEntityNeighborhood() throws Exception assertCondition((true), - assertion14, - testTypeName + assertionMsg14, - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId(), - "getEntityNeighborhood", - elapsedTime); + assertion14, + testTypeName + assertionMsg14, + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId(), + "getEntityNeighborhood", + elapsedTime); /* @@ -927,74 +958,84 @@ private void getEntityNeighborhood() throws Exception assertCondition((instGraph != null), - assertion1, - testTypeName + assertionMsg1, - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); + assertion1, + testTypeName + assertionMsg1, + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); /* Check entities */ /* Always expect to get at least one entity - the root of the query */ - if (instGraph != null) { + if (instGraph != null) + { assertCondition((instGraph.getEntities() != null && !(instGraph.getEntities().isEmpty()) && instGraph.getEntities().size() == expectedEntityGUIDs.size()), - assertion2, - testTypeName + assertionMsg2, - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); + assertion2, + testTypeName + assertionMsg2, + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); } List returnedEntityGUIDs = new ArrayList<>(); - if (instGraph != null && instGraph.getEntities() != null) { - for (EntityDetail entity : instGraph.getEntities()) { - if (entity != null) { + if (instGraph != null && instGraph.getEntities() != null) + { + for (EntityDetail entity : instGraph.getEntities()) + { + if (entity != null) + { returnedEntityGUIDs.add(entity.getGUID()); } } } + assertCondition((returnedEntityGUIDs.containsAll(expectedEntityGUIDs)), - assertion3, - testTypeName + assertionMsg3, - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); + assertion3, + testTypeName + assertionMsg3, + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); /* Check relationships */ /* Don't always expect to get at least one relationship */ - if (expectedRelationshipGUIDs.isEmpty()) { + if (expectedRelationshipGUIDs.isEmpty()) + { - if (instGraph != null) { + if (instGraph != null) + { assertCondition((instGraph.getRelationships() == null), - assertion4, - testTypeName + assertionMsg4, - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); + assertion4, + testTypeName + assertionMsg4, + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); } - } else { - + } + else + { if (instGraph != null) { assertCondition((instGraph.getRelationships().size() == expectedRelationshipGUIDs.size()), - assertion4, - testTypeName + assertionMsg4, - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); + assertion4, + testTypeName + assertionMsg4, + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); } - List returnedRelationshipGUIDs = new ArrayList<>(); - if (instGraph.getRelationships() != null) { + if (instGraph.getRelationships() != null) + { for (Relationship relationship : instGraph.getRelationships()) { - if (relationship != null) { + if (relationship != null) + { returnedRelationshipGUIDs.add(relationship.getGUID()); } } } + assertCondition((returnedRelationshipGUIDs.containsAll(expectedRelationshipGUIDs)), - assertion5, - testTypeName + assertionMsg5, - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); + assertion5, + testTypeName + assertionMsg5, + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_NEIGHBORHOOD.getRequirementId()); } } } @@ -1014,37 +1055,41 @@ private void getRelatedEntities() throws Exception Set entityGUIDs = this.nodeToEdgesMap.keySet(); - for (String entityGUID : entityGUIDs) { - + for (String entityGUID : entityGUIDs) + { List relatedEntities = null; long start; long elapsedTime; - try { + try + { start = System.currentTimeMillis(); relatedEntities = metadataCollection.getRelatedEntities(workPad.getLocalServerUserId(), - entityGUID, - null, - 0, - null, - null, - null, - null, - null, - 0); + entityGUID, + null, + 0, + null, + null, + null, + null, + null, + 0); elapsedTime = System.currentTimeMillis() - start; - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion15, - assertionMsg15, - RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getRequirementId()); + assertionMsg15, + RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getRequirementId()); return; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1063,17 +1108,16 @@ private void getRelatedEntities() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((true), - assertion15, - testTypeName + assertionMsg15, - RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getRequirementId(), - "getRelatedEntities", - elapsedTime); + assertion15, + testTypeName + assertionMsg15, + RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getRequirementId(), + "getRelatedEntities", + elapsedTime); /* @@ -1094,10 +1138,10 @@ private void getRelatedEntities() throws Exception /* Always expect to get at least one entity - the root of the query */ assertCondition((relatedEntities != null && !(relatedEntities.isEmpty()) && relatedEntities.size() == expectedEntityGUIDs.size()), - assertion6, - testTypeName + assertionMsg6, - RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getRequirementId()); + assertion6, + testTypeName + assertionMsg6, + RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getRequirementId()); List returnedEntityGUIDs = new ArrayList<>(); if (relatedEntities != null) { @@ -1108,16 +1152,16 @@ private void getRelatedEntities() throws Exception } } assertCondition((returnedEntityGUIDs.containsAll(expectedEntityGUIDs)), - assertion7, - testTypeName + assertionMsg7, - RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getRequirementId()); + assertion7, + testTypeName + assertionMsg7, + RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.CONNECTED_ENTITIES.getRequirementId()); } } - private void getlinkingEntities() throws Exception + private void getLinkingEntities() throws Exception { /* @@ -1137,7 +1181,8 @@ private void getlinkingEntities() throws Exception /* Form Map from entityGUID to Map of edgeGUID to remote entity GUID */ this.connMap = new HashMap<>(); - while (entityGUIDIterator.hasNext()) { + while (entityGUIDIterator.hasNext()) + { String entityGUID = entityGUIDIterator.next(); List> edgeGUIDs = this.nodeToEdgesMap.get(entityGUID); @@ -1145,15 +1190,20 @@ private void getlinkingEntities() throws Exception this.connMap.put(entityGUID, routeMap); /* process the end1 ends */ - if (edgeGUIDs.get(0) != null) { - for (String edgeGUID : edgeGUIDs.get(0)) { + if (edgeGUIDs.get(0) != null) + { + for (String edgeGUID : edgeGUIDs.get(0)) + { String otherEntityGUID = this.edgeToNodesMap.get(edgeGUID).get(1); routeMap.put(edgeGUID, otherEntityGUID); } } + /* process the end2 ends */ - if (edgeGUIDs.get(1) != null) { - for (String edgeGUID : edgeGUIDs.get(1)) { + if (edgeGUIDs.get(1) != null) + { + for (String edgeGUID : edgeGUIDs.get(1)) + { String otherEntityGUID = this.edgeToNodesMap.get(edgeGUID).get(0); routeMap.put(edgeGUID, otherEntityGUID); } @@ -1164,9 +1214,11 @@ private void getlinkingEntities() throws Exception * Traverse the connMap to find the available paths, from A to B */ - for (String entityAGUID : entityGUIDs) { + for (String entityAGUID : entityGUIDs) + { - for (String entityBGUID : entityGUIDs) { + for (String entityBGUID : entityGUIDs) + { /* * Calculate the expected result @@ -1175,14 +1227,15 @@ private void getlinkingEntities() throws Exception List expectedEntityGUIDs = new ArrayList<>(); List expectedRelationshipGUIDs = new ArrayList<>(); - if (entityBGUID.equals(entityAGUID)) { + if (entityBGUID.equals(entityAGUID)) + { /* * There will be no paths - but we expect to get the (one) entity back. */ expectedEntityGUIDs.add(entityAGUID); - - } else { - + } + else + { /* * For the pair of entities A & B find all paths through the test graph (if any exist) */ @@ -1191,14 +1244,18 @@ private void getlinkingEntities() throws Exception traverse(entityAGUID, entityBGUID, null, pathsAB); - if (!pathsAB.isEmpty()) { + if (!pathsAB.isEmpty()) + { /* There is at least one path */ - for (List thisPath : pathsAB) { + for (List thisPath : pathsAB) + { - for (String thisEdge : thisPath) { + for (String thisEdge : thisPath) + { - if (!expectedRelationshipGUIDs.contains(thisEdge)) { + if (!expectedRelationshipGUIDs.contains(thisEdge)) + { expectedRelationshipGUIDs.add(thisEdge); String entity1GUID = this.edgeToNodesMap.get(thisEdge).get(0); if (!expectedEntityGUIDs.contains(entity1GUID)) @@ -1217,26 +1274,29 @@ private void getlinkingEntities() throws Exception long start; long elapsedTime; - try { + try + { start = System.currentTimeMillis(); instanceGraph = metadataCollection.getLinkingEntities(workPad.getLocalServerUserId(), - entityAGUID, - entityBGUID, - null, - null); + entityAGUID, + entityBGUID, + null, + null); elapsedTime = System.currentTimeMillis() - start; - - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion16, - assertionMsg16, - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); + assertionMsg16, + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); return; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1254,12 +1314,12 @@ private void getlinkingEntities() throws Exception assertCondition((true), - assertion16, - testTypeName + assertionMsg16, - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId(), - "getLinkingEntities", - elapsedTime); + assertion16, + testTypeName + assertionMsg16, + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId(), + "getLinkingEntities", + elapsedTime); /* Check results */ @@ -1283,63 +1343,70 @@ private void getlinkingEntities() throws Exception String assertionMessage = MessageFormat.format(assertionMsg8, resultCount, expectedEntityCount, parameters); assertCondition(((!expectedEntityGUIDs.isEmpty() && returnedEntities != null - && !(returnedEntities.isEmpty()) - && returnedEntities.size() == expectedEntityGUIDs.size()) - || expectedEntityGUIDs.isEmpty() && returnedEntities == null), - assertion8, - assertionMessage, - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); + && !(returnedEntities.isEmpty()) + && returnedEntities.size() == expectedEntityGUIDs.size()) + || expectedEntityGUIDs.isEmpty() && returnedEntities == null), + assertion8, + assertionMessage, + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); /* Extract the GUIDs so they are easier to check */ List returnedEntityGUIDs = new ArrayList<>(); - if (returnedEntities != null) { - for (EntityDetail entity : returnedEntities) { - if (entity != null) { + if (returnedEntities != null) + { + for (EntityDetail entity : returnedEntities) + { + if (entity != null) + { returnedEntityGUIDs.add(entity.getGUID()); } } } assertCondition((returnedEntityGUIDs.containsAll(expectedEntityGUIDs)), - assertion9, - testTypeName + assertionMsg9, - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); + assertion9, + testTypeName + assertionMsg9, + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); /* Check relationships */ assertCondition(((!expectedRelationshipGUIDs.isEmpty() && returnedRelationships != null - && !(returnedRelationships.isEmpty()) - && returnedRelationships.size() == expectedRelationshipGUIDs.size()) - || expectedRelationshipGUIDs.isEmpty() && returnedRelationships == null), - assertion10, - testTypeName + assertionMsg10, - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); + && !(returnedRelationships.isEmpty()) + && returnedRelationships.size() == expectedRelationshipGUIDs.size()) + || expectedRelationshipGUIDs.isEmpty() && returnedRelationships == null), + assertion10, + testTypeName + assertionMsg10, + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); /* Extract the GUIDs so they are easier to check */ List returnedRelationshipGUIDs = new ArrayList<>(); - if (returnedRelationships != null) { - for (Relationship relationship : returnedRelationships) { - if (relationship != null) { + if (returnedRelationships != null) + { + for (Relationship relationship : returnedRelationships) + { + if (relationship != null) + { returnedRelationshipGUIDs.add(relationship.getGUID()); } } } assertCondition((returnedRelationshipGUIDs.containsAll(expectedRelationshipGUIDs)), - assertion11, - testTypeName + assertionMsg11, - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), - RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); + assertion11, + testTypeName + assertionMsg11, + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getProfileId(), + RepositoryConformanceProfileRequirement.LINKED_ENTITIES.getRequirementId()); } } } - private Map getParameters(String startEntityGUID, String endEntityGUID) { + private Map getParameters(String startEntityGUID, String endEntityGUID) + { Map parameters = new TreeMap<>(); parameters.put("startEntityGUID", startEntityGUID); parameters.put("endEntityGUID", endEntityGUID); diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedClassificationLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedClassificationLifecycle.java index 373b17008b2..db0177441ec 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedClassificationLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedClassificationLifecycle.java @@ -2,6 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; @@ -41,11 +42,11 @@ public class TestSupportedClassificationLifecycle extends RepositoryConformanceT private static final String assertionMsg6 = " repository supports creation of instances "; - private EntityDef testEntityDef; - private ClassificationDef classificationDef; - private String testTypeName; + private final EntityDef testEntityDef; + private final ClassificationDef classificationDef; + private final String testTypeName; - private List createdEntities = new ArrayList<>(); + private final List createdEntities = new ArrayList<>(); @@ -82,20 +83,18 @@ protected void run() throws Exception { OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - /* * To accommodate repositories that do not support the creation of instances, wrap the creation of the entity * in a try..catch to check for FunctionNotSupportedException. If the connector throws this, then give up * on the test by setting the discovered property to disabled and returning. */ - EntityDetail testEntity; - + EntityDetail testEntity; InstanceProperties instProps = null; long elapsedTime; - try { - + try + { /* * Generate property values for all the type's defined properties, including inherited properties * This ensures that any properties defined as mandatory by Egeria property cardinality are provided @@ -123,9 +122,16 @@ protected void run() throws Exception // Record the created instance for later clean up. createdEntities.add(testEntity); - - - } catch (FunctionNotSupportedException exception) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (FunctionNotSupportedException exception) + { /* * If running against a read-only repository/connector that cannot add @@ -141,25 +147,24 @@ protected void run() throws Exception return; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "addEntity"; String operationDescription = "add an entity of type " + testEntityDef.getName(); Map parameters = new HashMap<>(); parameters.put("typeGUID", testEntityDef.getGUID()); parameters.put("initialProperties", instProps != null ? instProps.toString() : "null"); - parameters.put("initialClasiifications", "null"); + parameters.put("initialClassifications", "null"); parameters.put("initialStatus", "null"); String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - assertCondition((testEntity.getClassifications() == null), assertion1, assertionMsg1 + testEntityDef.getName(), @@ -169,8 +174,8 @@ protected void run() throws Exception EntityDetail classifiedEntity = null; - try { - + try + { long start = System.currentTimeMillis(); classifiedEntity = metadataCollection.classifyEntity(workPad.getLocalServerUserId(), testEntity.getGUID(), @@ -179,7 +184,8 @@ protected void run() throws Exception elapsedTime = System.currentTimeMillis() - start; } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -193,10 +199,8 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - assertCondition((classifiedEntity != null), assertion2, testEntityDef.getName() + assertionMsg2, @@ -226,20 +230,19 @@ protected void run() throws Exception InstanceProperties classificationProperties = this.getPropertiesForInstance(classificationDef.getPropertiesDefinition()); if (classificationProperties != null) { - EntityDetail reclassifiedEntity = null; - try { - + try + { long start = System.currentTimeMillis(); reclassifiedEntity = metadataCollection.updateEntityClassification(workPad.getLocalServerUserId(), - testEntity.getGUID(), - classificationDef.getName(), - classificationProperties); + testEntity.getGUID(), + classificationDef.getName(), + classificationProperties); elapsedTime = System.currentTimeMillis() - start; - } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -253,10 +256,8 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - Classification updatedClassification = null; classifications = reclassifiedEntity.getClassifications(); @@ -276,10 +277,10 @@ protected void run() throws Exception elapsedTime); } - EntityDetail declassifiedEntity = null; - try { + try + { long start = System.currentTimeMillis(); declassifiedEntity = metadataCollection.declassifyEntity(workPad.getLocalServerUserId(), @@ -287,7 +288,8 @@ protected void run() throws Exception classificationDef.getName()); elapsedTime = System.currentTimeMillis() - start; } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -300,10 +302,8 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - assertCondition(((declassifiedEntity != null) && (declassifiedEntity.getClassifications() == null)), assertion5, testTypeName + assertionMsg5 + testEntityDef.getName(), @@ -316,7 +316,6 @@ protected void run() throws Exception } - /** * Method to clean any instance created by the test case that has not already been cleaned by the running of the test. * @@ -324,17 +323,16 @@ protected void run() throws Exception */ public void cleanup() throws Exception { - OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - if (createdEntities != null && !createdEntities.isEmpty()) { - + if (createdEntities != null && !createdEntities.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntities) { - + for (EntityDetail entity : createdEntities) + { try { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityLifecycle.java index 44d51060e08..edbdeba955f 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityLifecycle.java @@ -2,10 +2,12 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.HistorySequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.*; import org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException; @@ -15,7 +17,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -83,19 +84,36 @@ public class TestSupportedEntityLifecycle extends RepositoryConformanceTestCase private static final String assertionMsg26 = " entity purged."; private static final String assertion27 = testCaseId + "-27"; private static final String assertionMsg27 = " historical retrieval returned correct version of entity "; - private static final String assertion28 = testCaseId + "-28"; private static final String assertionMsg28 = " repository supports creation of instances "; - private static final String assertion29 = testCaseId + "-29"; private static final String assertionMsg29 = " repository supports undo of operations "; - private static final String assertion30 = testCaseId + "-30"; private static final String assertionMsg30 = " repository supports soft delete "; - private static final String assertion31 = testCaseId + "-31"; private static final String assertionMsg31 = " repository supports historic retrieval "; - + private static final String assertion32 = testCaseId + "-32"; + private static final String assertionMsg32 = " entity versions NOT returned before create time "; + private static final String assertion33 = testCaseId + "-33"; + private static final String assertionMsg33 = " entity versions returned after create "; + private static final String assertion34 = testCaseId + "-34"; + private static final String assertionMsg34 = " entity versions returned after update "; + private static final String assertion35 = testCaseId + "-35"; + private static final String assertionMsg35 = " entity version is returned while deleted "; + private static final String assertion36 = testCaseId + "-36"; + private static final String assertionMsg36 = " entity versions returned after restore "; + private static final String assertion37 = testCaseId + "-37"; + private static final String assertionMsg37 = " entity versions returned after update "; + private static final String assertion38 = testCaseId + "-38"; + private static final String assertionMsg38 = " entity versions NOT returned after purge "; + private static final String assertion39 = testCaseId + "-39"; + private static final String assertionMsg39 = " entity is not known after purge "; + private static final String assertion40 = testCaseId + "-40"; + private static final String assertionMsg40 = " entity versions are ordered BACKWARDS as requested "; + private static final String assertion41 = testCaseId + "-41"; + private static final String assertionMsg41 = " entity versions are ordered FORWARDS as requested "; + private static final String assertion43 = testCaseId + "-43"; + private static final String assertionMsg43 = " entity is known when deleted "; private final String metadataCollectionId; @@ -139,27 +157,29 @@ protected void run() throws Exception /* * To accommodate repositories that do not support the creation of instances, wrap the creation of the entity - * in a try..catch to check for FunctionNotSupportedException. If the connector throws this, then give up + * in a try...catch to check for FunctionNotSupportedException. If the connector throws this, then give up * on the test by setting the discovered property to disabled and returning. */ EntityDetail newEntity; + Date beforeEntityCreateTime = new Date(); InstanceProperties instProps = null; long elapsedTime; - try { - + long start; + try + { /* * Generate property values for all the type's defined properties, including inherited properties * This ensures that any properties defined as mandatory by Egeria property cardinality are provided * thereby getting into the connector-logic beyond the property validation. It also creates an * entity that is logically complete - versus an instance with just the locally-defined properties. */ + start = System.currentTimeMillis(); instProps = super.getAllPropertiesForInstance(workPad.getLocalServerUserId(), entityDef); - long start = System.currentTimeMillis(); newEntity = metadataCollection.addEntity(workPad.getLocalServerUserId(), entityDef.getGUID(), super.getAllPropertiesForInstance(workPad.getLocalServerUserId(), entityDef), @@ -177,9 +197,16 @@ protected void run() throws Exception // Record the created instance for later clean up. createdEntities.add(newEntity); - - - } catch (FunctionNotSupportedException exception) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (FunctionNotSupportedException exception) + { /* * If running against a read-only repository/connector that cannot add * entities or relationships catch FunctionNotSupportedException and give up the test. @@ -193,8 +220,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); return; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -204,12 +232,11 @@ protected void run() throws Exception Map parameters = new HashMap<>(); parameters.put("typeGUID", entityDef.getGUID()); parameters.put("initialProperties", instProps != null ? instProps.toString() : "null"); - parameters.put("initialClasiifications", "null"); + parameters.put("initialClassifications", "null"); parameters.put("initialStatus", "null"); String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((newEntity != null), @@ -244,15 +271,17 @@ protected void run() throws Exception InstanceType instanceType = newEntity.getType(); - if (instanceType != null) { + if (instanceType != null) + { verifyCondition(((instanceType.getTypeDefGUID().equals(entityDef.getGUID())) && (instanceType.getTypeDefName().equals(testTypeName))), assertion6, testTypeName + assertionMsg6, RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); - - } else { + } + else + { verifyCondition(false, assertion6, testTypeName + assertionMsg6, @@ -269,32 +298,102 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); + /* + * The version should be set up and greater than zero + */ verifyCondition((newEntity.getVersion() > 0), assertion8, testTypeName + assertionMsg8, RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getProfileId(), RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getRequirementId()); - /* - * Validate that the entity can be consistently retrieved. + String retrievalOperationName = "getEntityDetailHistory"; + + /*=============== + * Validate that the entity version can not be retrieved for a time before the entity is created */ + start = System.currentTimeMillis(); + try + { + metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + newEntity.getGUID(), + null, + beforeEntityCreateTime, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.FORWARDS); + elapsedTime = System.currentTimeMillis() - start; - String retrievalOperationName = ""; + /* + * This is a fail because EntityNotKnownException should be thrown. + */ + verifyCondition(false, + assertion32, + testTypeName + assertionMsg32, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + retrievalOperationName, + elapsedTime); + } + catch (EntityNotKnownException exception) + { + elapsedTime = System.currentTimeMillis() - start; + + verifyCondition(true, + assertion32, + testTypeName + assertionMsg32, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + retrievalOperationName, + elapsedTime); + } + catch (FunctionNotSupportedException exception) + { + /* + * If running against a repository/connector that does not support history catch FunctionNotSupportedException and give up the test. + * Report the inability to create instances and give up on the testcase.... + */ + super.addNotSupportedAssertion(assertion32, + assertionMsg32, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId()); + + return; + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String operationDescription = " retrieve version history before creation of an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("typeGUID", entityDef.getGUID()); + parameters.put("initialProperties", instProps != null ? instProps.toString() : "null"); + parameters.put("initialStatus", "null"); + String msg = this.buildExceptionMessage(testCaseId, retrievalOperationName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } - try { - long start = System.currentTimeMillis(); + /*================ + * Validate that the entity can be consistently retrieved. + */ + try + { + start = System.currentTimeMillis(); EntityDetail knownEntity = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), newEntity.getGUID()); elapsedTime = System.currentTimeMillis() - start; retrievalOperationName = "isEntityKnown"; - verifyCondition((newEntity.equals(knownEntity)), - assertion9, - testTypeName + assertionMsg9, - RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), - RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), - "isEntityKnown", - elapsedTime); + verifyObjectsAreEqual(newEntity, + knownEntity, + assertion9, + testTypeName + assertionMsg9, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + retrievalOperationName, + elapsedTime); start = System.currentTimeMillis(); @@ -307,7 +406,7 @@ protected void run() throws Exception testTypeName + assertionMsg10, RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), - "getEntitySummary", + retrievalOperationName, elapsedTime); start = System.currentTimeMillis(); @@ -315,45 +414,130 @@ protected void run() throws Exception elapsedTime = System.currentTimeMillis() - start; retrievalOperationName = "getEntityDetail"; - verifyCondition((newEntity.equals(entityDetail)), - assertion11, - testTypeName + assertionMsg11, - RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), - RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), - "getEntityDetail", - elapsedTime); - - } catch (Exception exc) { + verifyObjectsAreEqual(newEntity, + entityDetail, + assertion11, + testTypeName + assertionMsg11, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + retrievalOperationName, + elapsedTime); + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - - String methodName = retrievalOperationName; String operationDescription = "retrieve an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); parameters.put("entityGUID", newEntity.getGUID()); - String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, retrievalOperationName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - /* - * No relationships have been created so none should be returned. + + /*=============== + * Validate that the entity version can be retrieved after the entity is created */ + start = System.currentTimeMillis(); + try + { + List entityDetails = metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + newEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.FORWARDS); + elapsedTime = System.currentTimeMillis() - start; + + assertCondition(entityDetails != null, + assertion33, + testTypeName + assertionMsg33, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + retrievalOperationName, + elapsedTime); + + assertCondition(entityDetails.size() == 1, + assertion33, + testTypeName + assertionMsg33, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + retrievalOperationName, + elapsedTime); + + verifyObjectsAreEqual(newEntity, + entityDetails.get(0), + assertion33, + testTypeName + assertionMsg33, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + retrievalOperationName, + elapsedTime); + } + catch (EntityNotKnownException exception) + { + elapsedTime = System.currentTimeMillis() - start; + + assertCondition(false, + assertion33, + testTypeName + assertionMsg33, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + retrievalOperationName, + elapsedTime); + } + catch (AssertionFailureException exception) + { + /* + * Keep going + */ + } + catch (FunctionNotSupportedException exception) + { + /* + * If running against a repository/connector that does not support history catch FunctionNotSupportedException and give up the test. + * Report the inability to create instances and give up on the testcase.... + */ + super.addNotSupportedAssertion(assertion33, + assertionMsg33, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId()); + + return; + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String operationDescription = " retrieve version history of an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("typeGUID", entityDef.getGUID()); + parameters.put("initialProperties", instProps != null ? instProps.toString() : "null"); + parameters.put("initialStatus", "null"); + String msg = this.buildExceptionMessage(testCaseId, retrievalOperationName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - try { + throw new Exception(msg, exc); + } - long start = System.currentTimeMillis(); + /*============= + * No relationships have been created so none should be returned for this entity. + */ + try + { + start = System.currentTimeMillis(); List relationships = metadataCollection.getRelationshipsForEntity(workPad.getLocalServerUserId(), - newEntity.getGUID(), - null, - 0, - null, - null, - null, - null, - 0); + newEntity.getGUID(), + null, + 0, + null, + null, + null, + null, + 0); elapsedTime = System.currentTimeMillis() - start; verifyCondition((relationships == null), assertion12, @@ -362,7 +546,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), "getRelationshipsForEntity-negative", elapsedTime); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -381,29 +567,29 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - /* * Update entity status */ long nextVersion = newEntity.getVersion() + 1; - for (InstanceStatus validInstanceStatus : entityDef.getValidInstanceStatusList()) { - if (validInstanceStatus != InstanceStatus.DELETED) { - EntityDetail updatedEntity = null; - try { - - long start = System.currentTimeMillis(); + for (InstanceStatus validInstanceStatus : entityDef.getValidInstanceStatusList()) + { + if (validInstanceStatus != InstanceStatus.DELETED) + { + EntityDetail updatedEntity; + try + { + start = System.currentTimeMillis(); updatedEntity = metadataCollection.updateEntityStatus(workPad.getLocalServerUserId(), newEntity.getGUID(), validInstanceStatus); elapsedTime = System.currentTimeMillis() - start; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "updateEntityStatus"; String operationDescription = "update the status of an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); @@ -412,7 +598,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((updatedEntity != null), @@ -439,8 +624,9 @@ protected void run() throws Exception } } - long start = System.currentTimeMillis(); - try { + start = System.currentTimeMillis(); + try + { metadataCollection.updateEntityStatus(workPad.getLocalServerUserId(), newEntity.getGUID(), InstanceStatus.DELETED); elapsedTime = System.currentTimeMillis() - start; verifyCondition((false), @@ -450,7 +636,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), "updateEntityStatus-negative", elapsedTime); - } catch (StatusNotSupportedException exception) { + } + catch (StatusNotSupportedException exception) + { elapsedTime = System.currentTimeMillis() - start; verifyCondition((true), assertion16, @@ -459,7 +647,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), "updateEntityStatus-negative", elapsedTime); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -472,11 +662,10 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - /* + /*============ * Modify the entity such that it has the minimum set of properties possible. If any properties are defined as * mandatory (based on their cardinality) then provide them - in order to exercise the connector more fully. * All optional properties are removed. @@ -484,18 +673,21 @@ protected void run() throws Exception if ((newEntity.getProperties() != null) && (newEntity.getProperties().getInstanceProperties() != null) && - (!newEntity.getProperties().getInstanceProperties().isEmpty())) { + (!newEntity.getProperties().getInstanceProperties().isEmpty())) + { InstanceProperties minEntityProps = super.getMinPropertiesForInstance(workPad.getLocalServerUserId(), entityDef); + EntityDetail minPropertiesEntity; - EntityDetail minPropertiesEntity = null; - try { - + try + { start = System.currentTimeMillis(); minPropertiesEntity = metadataCollection.updateEntityProperties(workPad.getLocalServerUserId(), newEntity.getGUID(), minEntityProps); elapsedTime = System.currentTimeMillis() - start; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -508,7 +700,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } /* @@ -536,20 +727,118 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getProfileId(), RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getRequirementId()); - nextVersion = minPropertiesEntity.getVersion() + 1; - /* - * Test the ability (or not) to undo the changes just made + * Verify that entity versions can be retrieved following an update */ + try + { + start = System.currentTimeMillis(); + List entityDetailHistory = metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + newEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + elapsedTime = System.currentTimeMillis() - start; + assertCondition(entityDetailHistory != null, + assertion34, + testTypeName + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - EntityDetail undoneEntity = null; + verifyCondition(entityDetailHistory.size() == nextVersion, + assertion34, + testTypeName + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - try { + verifyObjectsAreEqual(entityDetailHistory.get(0), + minPropertiesEntity, + assertion34, + testTypeName + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); start = System.currentTimeMillis(); - undoneEntity = metadataCollection.undoEntityUpdate(workPad.getLocalServerUserId(), newEntity.getGUID()); + entityDetailHistory = metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + newEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.FORWARDS); elapsedTime = System.currentTimeMillis() - start; + assertCondition(entityDetailHistory != null, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + verifyCondition(entityDetailHistory.size() == nextVersion, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + verifyObjectsAreEqual(entityDetailHistory.get(0), + newEntity, + assertion41, + testTypeName + assertionMsg41, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + } + catch (AssertionFailureException exception) + { + /* + * Keep going + */ + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion34, + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId()); + + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getEntityDetailHistory"; + String operationDescription = "retrieve an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } + /*============ + * Test the ability (or not) to undo the changes just made + */ + nextVersion = minPropertiesEntity.getVersion() + 1; + EntityDetail undoneEntity; + + try + { + start = System.currentTimeMillis(); + undoneEntity = metadataCollection.undoEntityUpdate(workPad.getLocalServerUserId(), newEntity.getGUID()); + elapsedTime = System.currentTimeMillis() - start; assertCondition(true, assertion29, @@ -559,7 +848,6 @@ protected void run() throws Exception "undoEntityUpdate", elapsedTime); - assertCondition(((undoneEntity != null) && (undoneEntity.getProperties() != null)), assertion19, testTypeName + assertionMsg19, @@ -572,18 +860,117 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_UNDO.getProfileId(), RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_UNDO.getRequirementId()); - nextVersion = undoneEntity.getVersion() + 1; + /* + * Verify that entity versions can be retrieved following undo + */ + try + { + start = System.currentTimeMillis(); + List entityDetailHistory = metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + newEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + elapsedTime = System.currentTimeMillis() - start; + assertCondition(entityDetailHistory != null, + assertion37, + testTypeName + assertionMsg37, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + verifyCondition(entityDetailHistory.size() == nextVersion, + assertion37, + testTypeName + assertionMsg37, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + verifyObjectsAreEqual(entityDetailHistory.get(0), + undoneEntity, + assertion40, + testTypeName + assertionMsg40, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + start = System.currentTimeMillis(); + entityDetailHistory = metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + newEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.FORWARDS); + elapsedTime = System.currentTimeMillis() - start; + assertCondition(entityDetailHistory != null, + assertion37, + testTypeName + assertionMsg37, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + verifyCondition(entityDetailHistory.size() == nextVersion, + assertion37, + testTypeName + assertionMsg37, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + verifyObjectsAreEqual(entityDetailHistory.get(0), + newEntity, + assertion41, + testTypeName + assertionMsg41, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + } + catch (AssertionFailureException exception) + { + throw exception; + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion34, + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId()); + + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getEntityDetailHistory"; + String operationDescription = "retrieve an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - } catch (FunctionNotSupportedException exception) { + throw new Exception(msg, exc); + } + nextVersion = undoneEntity.getVersion() + 1; + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion29, assertionMsg29, RepositoryConformanceProfileRequirement.RETURN_PREVIOUS_VERSION.getProfileId(), RepositoryConformanceProfileRequirement.RETURN_PREVIOUS_VERSION.getRequirementId()); - - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -595,49 +982,27 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - } + /* - * Catch the current time for a later historic query test, then sleep for a second so we are sure that time has moved on + * Catch the current time for a later historic query test, then sleep for a second, so we are sure that time has moved on */ Date preDeleteDate = new Date(); - EntityDetail preDeleteEntity; - - try { - - preDeleteEntity = metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID()); - - } catch (Exception exc) { - /* - * We are not expecting any exceptions from this method call. Log and fail the test. - */ - - String methodName = "getEntityDetail"; - String operationDescription = "retrieve an entity of type " + entityDef.getName(); - Map parameters = new HashMap<>(); - parameters.put("entityGUID", newEntity.getGUID()); - String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - - throw new Exception(msg, exc); - - } - - /* - * Test that the entity can be soft deleted, that the soft deleted entity has a higher version. - * Verify that the soft deleted entity cannot be retrieved, but can be restored and thatthe restored entity has + /*========================================================= + * Test that the entity can be soft-deleted, that the soft-deleted entity has a higher version. + * Verify that the soft deleted entity cannot be retrieved, but can be restored and that the restored entity has * a valid version (higher than when it was deleted). * Check that the restored entity can be retrieved. */ - EntityDetail deletedEntity = null; - - try { + EntityDetail deletedEntity; + try + { start = System.currentTimeMillis(); deletedEntity = metadataCollection.deleteEntity(workPad.getLocalServerUserId(), newEntity.getType().getTypeDefGUID(), @@ -659,171 +1024,427 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getProfileId(), RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getRequirementId()); - } catch (FunctionNotSupportedException exception) { + Date preRestoreDate = new Date(); - super.addNotSupportedAssertion(assertion30, - assertionMsg30, - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId()); - } catch (Exception exc) { /* - * We are not expecting any other exceptions from this method call. Log and fail the test. + * Verify that an entity cannot be retrieved when deleted */ + try + { + start = System.currentTimeMillis(); + metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID()); + elapsedTime = System.currentTimeMillis() - start; - String methodName = "deleteEntity"; - String operationDescription = "delete an entity of type " + entityDef.getName(); - Map parameters = new HashMap<>(); - parameters.put("typeDefGUID", newEntity.getType().getTypeDefGUID()); - parameters.put("typeDefName", newEntity.getType().getTypeDefName()); - parameters.put("obsoleteEntityGUID", newEntity.getGUID()); - String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - - throw new Exception(msg, exc); - - } + assertCondition((false), + assertion22, + testTypeName + assertionMsg22, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + "getEntityDetail-negative", + elapsedTime); + } + catch (EntityNotKnownException exception) + { + elapsedTime = System.currentTimeMillis() - start; + assertCondition((true), + assertion22, + testTypeName + assertionMsg22, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + "getEntityDetail-negative", + elapsedTime); + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getEntityDetail"; + String operationDescription = "retrieve an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + throw new Exception(msg, exc); + } + /* + * Verify that the entity is known following delete + */ + try + { + start = System.currentTimeMillis(); + EntityDetail knownEntity = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), deletedEntity.getGUID()); + elapsedTime = System.currentTimeMillis() - start; + verifyObjectsAreEqual(deletedEntity, + knownEntity, + assertion43, + testTypeName + assertionMsg43, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + "isEntityKnown", + elapsedTime); + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "isEntityKnown"; + String operationDescription = " known a deleted entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", deletedEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + throw new Exception(msg, exc); + } - try { + /* + * Verify that the deleted version of the entity can be retrieved. + */ + try + { + start = System.currentTimeMillis(); + List entityVersions = metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + newEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + elapsedTime = System.currentTimeMillis() - start; - start = System.currentTimeMillis(); - metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID()); - elapsedTime = System.currentTimeMillis() - start; + assertCondition(entityVersions != null, + assertion35, + testTypeName + assertionMsg35, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - assertCondition((false), - assertion22, - testTypeName + assertionMsg22, - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId(), - "getEntityDetail-negative", - elapsedTime); + verifyCondition(! entityVersions.isEmpty(), + assertion35, + testTypeName + assertionMsg35, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - } catch (EntityNotKnownException exception) { + verifyCondition((entityVersions.get(0).getStatus() == InstanceStatus.DELETED), + assertion35, + testTypeName + assertionMsg35, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + } + catch (AssertionFailureException exception) + { + /* + * Keep going + */ + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ - elapsedTime = System.currentTimeMillis() - start; - assertCondition((true), - assertion22, - testTypeName + assertionMsg22, - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId(), - "getEntityDetail-negative", - elapsedTime); + String methodName = "getEntityDetailHistory"; + String operationDescription = "retrieve an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - } - catch (Exception exc) { - /* - * We are not expecting any other exceptions from this method call. Log and fail the test. - */ + throw new Exception(msg, exc); + } - String methodName = "getEntityDetail"; - String operationDescription = "retrieve an entity of type " + entityDef.getName(); - Map parameters = new HashMap<>(); - parameters.put("entityGUID", newEntity.getGUID()); - String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + /*========================================= + * Verify that an entity can be restored + */ - throw new Exception(msg, exc); + /* + * Performing the restore should advance the version number again + */ + nextVersion = deletedEntity.getVersion() + 1; - } + EntityDetail restoredEntity; + try + { + start = System.currentTimeMillis(); + restoredEntity = metadataCollection.restoreEntity(workPad.getLocalServerUserId(), newEntity.getGUID()); + elapsedTime = System.currentTimeMillis() - start; + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "restoreEntity"; + String operationDescription = "restore a soft-deleted entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + throw new Exception(msg, exc); + } + assertCondition((restoredEntity != null), + assertion23, + testTypeName + assertionMsg23, + RepositoryConformanceProfileRequirement.UNDELETE_INSTANCE.getProfileId(), + RepositoryConformanceProfileRequirement.UNDELETE_INSTANCE.getRequirementId(), + "restoreEntity", + elapsedTime); + assertCondition((restoredEntity.getVersion() >= nextVersion), + assertion24, + testTypeName + assertionMsg24 + nextVersion, + RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_RESTORE.getProfileId(), + RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_RESTORE.getRequirementId()); - /* - * Performing the restore should advance the version number again - */ - nextVersion = deletedEntity.getVersion() + 1; + /* + * Verify that entity can be retrieved following restore + */ + try + { + start = System.currentTimeMillis(); + EntityDetail entityDetail = metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), restoredEntity.getGUID()); + elapsedTime = System.currentTimeMillis() - start; + verifyObjectsAreEqual(restoredEntity, + entityDetail, + assertion25, + testTypeName + assertionMsg25, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + "getEntityDetail", + elapsedTime); + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getEntityDetail"; + String operationDescription = "retrieve an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", restoredEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - EntityDetail restoredEntity = null; - try { + throw new Exception(msg, exc); + } - start = System.currentTimeMillis(); - restoredEntity = metadataCollection.restoreEntity(workPad.getLocalServerUserId(), - newEntity.getGUID()); - elapsedTime = System.currentTimeMillis() - start; - } - catch (Exception exc) { /* - * We are not expecting any other exceptions from this method call. Log and fail the test. + * Verify that entity versions can be retrieved following restore */ + try + { + start = System.currentTimeMillis(); + List entityDetailHistory = metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + restoredEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + elapsedTime = System.currentTimeMillis() - start; + assertCondition(entityDetailHistory != null, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - String methodName = "restoreEntity"; - String operationDescription = "restore a soft-deleted entity of type " + entityDef.getName(); - Map parameters = new HashMap<>(); - parameters.put("entityGUID", newEntity.getGUID()); - String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + verifyCondition(entityDetailHistory.size() == nextVersion, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - throw new Exception(msg, exc); + verifyObjectsAreEqual(entityDetailHistory.get(0), + restoredEntity, + assertion40, + testTypeName + assertionMsg40, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - } + start = System.currentTimeMillis(); + entityDetailHistory = metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + restoredEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.FORWARDS); + elapsedTime = System.currentTimeMillis() - start; + assertCondition(entityDetailHistory != null, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - assertCondition((restoredEntity != null), - assertion23, - testTypeName + assertionMsg23, - RepositoryConformanceProfileRequirement.UNDELETE_INSTANCE.getProfileId(), - RepositoryConformanceProfileRequirement.UNDELETE_INSTANCE.getRequirementId(), - "restoreEntity", - elapsedTime); + verifyCondition(entityDetailHistory.size() == nextVersion, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); - assertCondition((restoredEntity.getVersion() >= nextVersion), - assertion24, - testTypeName + assertionMsg24 + nextVersion, - RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_RESTORE.getProfileId(), - RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_RESTORE.getRequirementId()); + verifyObjectsAreEqual(entityDetailHistory.get(0), + newEntity, + assertion41, + testTypeName + assertionMsg41, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + } + catch (AssertionFailureException exception) + { + /* + * Keep going + */ + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion31, + assertionMsg31, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId()); + + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getEntityDetailHistory"; + String operationDescription = "retrieve an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", restoredEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } - /* - * Verify that entity can be retrieved following restore - */ - try { - start = System.currentTimeMillis(); - EntityDetail knownEntity = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), restoredEntity.getGUID()); - elapsedTime = System.currentTimeMillis() - start; - verifyCondition((restoredEntity.equals(knownEntity)), - assertion25, - testTypeName + assertionMsg25, - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), - "isEntityKnown", - elapsedTime); - } - catch (Exception exc) { /* - * We are not expecting any other exceptions from this method call. Log and fail the test. + * Verify that historical query for the time when it was deleted does not return the entity */ + try + { + start = System.currentTimeMillis(); + metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID(), deletedEntity.getUpdateTime()); - String methodName = "isEntityKnown"; - String operationDescription = "retrieve an entity of type " + entityDef.getName(); - Map parameters = new HashMap<>(); - parameters.put("entityGUID", restoredEntity.getGUID()); - String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + assertCondition(false, + assertion31, + testTypeName + assertionMsg31, + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId()); + } + catch (EntityNotKnownException exception) + { + /* + * Even if it supports historical retrieval, the repository should not return the entity at this time. + */ + elapsedTime = System.currentTimeMillis() - start; + assertCondition((true), + assertion27, + testTypeName + assertionMsg27, + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId(), + "getEntityDetail-when deleted", + elapsedTime); - throw new Exception(msg, exc); + } + catch (AssertionFailureException exception) + { + /* + * Keep going + */ + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion31, + assertionMsg31, + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId()); - } + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getEntityDetail"; + String operationDescription = "retrieve a historical copy of a purged entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID" , newEntity.getGUID()); + parameters.put("asOfTime" , deletedEntity.getUpdateTime().toString()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - /* - * Now get rid of the entity - this time for real - */ + throw new Exception(msg, exc); + } - try { + /*===================================== + * Now soft-delete the entity - this time for real + */ + try + { + deletedEntity = metadataCollection.deleteEntity(workPad.getLocalServerUserId(), + newEntity.getType().getTypeDefGUID(), + newEntity.getType().getTypeDefName(), + newEntity.getGUID()); + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion30, + assertionMsg30, + RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), + RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId()); - metadataCollection.deleteEntity(workPad.getLocalServerUserId(), - newEntity.getType().getTypeDefGUID(), - newEntity.getType().getTypeDefName(), - newEntity.getGUID()); + /* OK to continue - soft delete is optional */ - } - catch (FunctionNotSupportedException exception) { + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + final String methodName = "deleteEntity"; + String operationDescription = "delete an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("typeDefGUID", newEntity.getType().getTypeDefGUID()); + parameters.put("typeDefName", newEntity.getType().getTypeDefName()); + parameters.put("obsoleteEntityGUID", newEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + throw new Exception(msg, exc); + } + } + catch (AssertionFailureException exception) + { + /* + * Keep going. + */ + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion30, assertionMsg30, RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId()); - - /* OK to continue - soft delete is optional */ - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -840,21 +1461,23 @@ protected void run() throws Exception } - try { - + /*======================================= + * Test that an entity can be purged. + */ + try + { start = System.currentTimeMillis(); metadataCollection.purgeEntity(workPad.getLocalServerUserId(), newEntity.getType().getTypeDefGUID(), newEntity.getType().getTypeDefName(), newEntity.getGUID()); elapsedTime = System.currentTimeMillis() - start; - } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "purgeEntity"; String operationDescription = "purge an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); @@ -864,33 +1487,41 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - - try { + /* + * Check an entity can not be retrieved after purge + */ + try + { metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID()); assertCondition((false), assertion26, testTypeName + assertionMsg26, - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), - "purgeEntity", + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + "getEntityDetail", elapsedTime); } - catch (EntityNotKnownException exception) { - + catch (EntityNotKnownException exception) + { assertCondition((true), assertion26, testTypeName + assertionMsg26, RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), - "purgeEntity", - elapsedTime); + "getEntityDetail", + null); + } + catch (AssertionFailureException exception) + { + /* + * Keep going. + */ } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -902,42 +1533,64 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); + } + /* + * Check that an entity is no longer known after the purge. + */ + try + { + EntityDetail entityDetail = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), newEntity.getGUID()); + + assertCondition((entityDetail == null), + assertion39, + testTypeName + assertionMsg39, + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), + "isEntityKnown", + null); + } + catch (AssertionFailureException exception) + { + /* + * Keep going. + */ } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "isEntityKnown"; + String operationDescription = "retrieve an entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } /* * Perform a historic get of the entity - this should not return the entity since it has now been [deleted and] purged * The time for the query is the time set just before the delete operation above. */ - try { + try + { start = System.currentTimeMillis(); - EntityDetail earlierEntity = metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID(), preDeleteDate); - elapsedTime = System.currentTimeMillis() - start; + metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID(), preDeleteDate); - assertCondition(true, + assertCondition(false, assertion31, testTypeName + assertionMsg31, RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId()); - - /* - * Check that the earlierEntity is null (really it should be the EntityNotKnownException below that handles) - */ - assertCondition((earlierEntity == null), - assertion27, - testTypeName + assertionMsg27, - RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), - RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId(), - "getEntityDetail-negative", - elapsedTime); - - - } catch (EntityNotKnownException exception) { - + } + catch (EntityNotKnownException exception) + { /* * Even if it supports historical retrieval, the repository should not return any version of a purged entity, - * as the entity and all of its history should have been purged. Therefore this exception being thrown + * as the entity and all of its history should have been purged. Therefore, this exception being thrown * indicates success -- so we do not need to handle it any further. */ elapsedTime = System.currentTimeMillis() - start; @@ -946,37 +1599,107 @@ protected void run() throws Exception testTypeName + assertionMsg27, RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId(), - "getEntityDetail-negative", + "getEntityDetail-purged", elapsedTime); - } catch (FunctionNotSupportedException exception) { - + } + catch (AssertionFailureException exception) + { + /* + * Keep going. + */ + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion31, assertionMsg31, RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId()); } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "getEntityDetail"; - String operationDescription = "retrieve a historical copy of an entity of type " + entityDef.getName(); + String operationDescription = "retrieve a historical copy of a purged entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); parameters.put("entityGUID" , newEntity.getGUID()); parameters.put("asOfTime" , preDeleteDate.toString()); String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); + } + /* + * Perform a get entity history - this should not return any of the versions because the entity has now been purged + */ + try + { + start = System.currentTimeMillis(); + metadataCollection.getEntityDetailHistory(workPad.getLocalServerUserId(), + newEntity.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + + assertCondition(false, + assertion38, + testTypeName + assertionMsg38, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId()); } + catch (EntityNotKnownException exception) + { + /* + * Even if it supports historical retrieval, the repository should not return any version of a purged entity, + * as the entity and all of its history should have been purged. Therefore, this exception being thrown + * indicates success -- so we do not need to handle it any further. + */ + elapsedTime = System.currentTimeMillis() - start; + assertCondition((true), + assertion38, + testTypeName + assertionMsg38, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId(), + "getEntityDetailHistory-purged", + elapsedTime); - super.setSuccessMessage("Entities can be managed through their lifecycle"); - } + } + catch (AssertionFailureException exception) + { + /* + * Keep going. + */ + throw exception; + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion38, + assertionMsg38, + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_ENTITY_VERSIONS.getRequirementId()); + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getEntityDetailHistory"; + String operationDescription = "retrieve a historical versions of a purged entity of type " + entityDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newEntity.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + throw new Exception(msg, exc); + } + + super.setSuccessMessage("Entities can be managed through their lifecycle"); + } /** @@ -986,19 +1709,18 @@ protected void run() throws Exception */ public void cleanup() throws Exception { - OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - if (createdEntities != null && !createdEntities.isEmpty()) { - + if (createdEntities != null && !createdEntities.isEmpty()) + { /* * Instances were created - clean them up. * They may have already been cleaned up so be prepared to catch everything from * FunctionNotSupportedException to EntityNotKnownException and maybe others. */ - for (EntityDetail entity : createdEntities) { - + for (EntityDetail entity : createdEntities) + { try { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), @@ -1075,11 +1797,9 @@ private boolean doPropertiesMatch(InstanceProperties firstInstanceProps, Instanc // Assume the values match and prove it if they don't... boolean matchValues = true; - Iterator secondPropertiesKeyIterator = secondPropertiesKeySet.iterator(); - while (secondPropertiesKeyIterator.hasNext()) + for (String key : secondPropertiesKeySet) { - String key = secondPropertiesKeyIterator.next(); - if (!(secondPropertiesMap.get(key).equals(firstPropertiesMap.get(key)))) + if (! (secondPropertiesMap.get(key).equals(firstPropertiesMap.get(key)))) { matchValues = false; } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityProxyLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityProxyLifecycle.java index b8702d57a4d..bb47abcf61d 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityProxyLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityProxyLifecycle.java @@ -3,6 +3,7 @@ package org.odpi.openmetadata.conformance.tests.repository.instances; import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; @@ -35,7 +36,7 @@ */ public class TestSupportedEntityProxyLifecycle extends RepositoryConformanceTestCase { - private static final String testCaseId = "repository-entity-proxy-lifecycle"; + private static final String testCaseId = "repository-entity-proxy-lifecycle"; private static final String testCaseName = "Repository entity proxy lifecycle test case"; private static final String assertion1 = testCaseId + "-01"; @@ -92,7 +93,7 @@ public class TestSupportedEntityProxyLifecycle extends RepositoryConformanceTest * 1. Creates an entity E1 in the CTS server * 1a. The master instance of E1 is created in the CTS server's repository * 1b. A NEW_ENTITY_EVENT is flowed to the TUT for E1 - * 1c. The TUT should create a reference copy of E1 - we are not interested in the ref copy but we need to be aware of it and purge it. + * 1c. The TUT should create a reference copy of E1 - we are not interested in the ref copy, but we need to be aware of it and purge it. * * 2. The E1ref copy is purged from the TUT * @@ -102,7 +103,7 @@ public class TestSupportedEntityProxyLifecycle extends RepositoryConformanceTest * 3c. The proxy E1' is installed in the TUT by a REST call to the TUT's metadataCollection addEntityProxy method * 3d. The TUT creates an E1' proxy. * - * 4. All of the above is repeated for a second entity. This avoids requiring that the TUT supports creation of locally mastered entities or reference copies. + * 4. All the above is repeated for a second entity. This avoids requiring that the TUT supports creation of locally mastered entities or reference copies. * It would be sufficient to support the ENTITY_PROXIES profile if the TUT only supports the creation of proxies of entities mastered elsewhere (in this test at the CTS) * * 5. Perform retrieval tests on the E1' proxy: @@ -452,7 +453,8 @@ protected void run() throws Exception */ long elapsedTime; - try { + try + { long start = System.currentTimeMillis(); metadataCollection.addEntityProxy(workPad.getLocalServerUserId(), entity1Proxy); elapsedTime = System.currentTimeMillis() - start; @@ -467,7 +469,9 @@ protected void run() throws Exception createdEntityProxiesTUT.add(entity1Proxy); - } catch (FunctionNotSupportedException excpetion) { + } + catch (FunctionNotSupportedException exception) + { /* * Report that the TUT does not support the creation of proxies - and do not pursue the test any further @@ -478,7 +482,16 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.STORE_ENTITY_PROXIES.getRequirementId()); return; - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -490,19 +503,14 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - /* * Create E2 at the CTS */ - EntityDef end2Type = entityDefs.get(end2TypeName); - /* * Generate property values for all the type's defined properties, including inherited properties * This ensures that any properties defined as mandatory by Egeria property cardinality are provided @@ -535,16 +543,19 @@ protected void run() throws Exception * Retrieve the ref copy from the TUT - if it does not exist, assert that ref copies are not a discovered property * Have to be prepared to wait until event has propagated and TUT has created a reference copy of the entity. */ - try { + try + { Integer remainingCount = this.pollCount; - while (entity2Ref == null && remainingCount > 0) { - + while (entity2Ref == null && remainingCount > 0) + { entity2Ref = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), entity2.getGUID()); Thread.sleep(this.pollPeriod); remainingCount--; } - if (entity2Ref == null && remainingCount == 0) { + + if (entity2Ref == null && remainingCount == 0) + { ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() .logRecord(assertion2, @@ -555,11 +566,12 @@ protected void run() throws Exception overflow.getSystemAction(), overflow.getUserAction()); } - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "isEntityKnown"; String operationDescription = "retrieve an entity of type " + end2Type.getName(); Map parameters = new HashMap<>(); @@ -567,7 +579,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } createdEntityRefCopiesTUT.add(entity2Ref); @@ -576,7 +587,8 @@ protected void run() throws Exception * This test needs to eliminate the reference copy - so that a proxy of E2 can be created at the TUT. */ - if (entity2Ref != null) { + if (entity2Ref != null) + { /* * If we retrieved the reference copy of the entity - we must purge it. @@ -584,11 +596,12 @@ protected void run() throws Exception * If there is no reference copy it may be because the TUT does not support ref copies - that's OK, we can continue with the test of proxy support */ - try { - + try + { metadataCollection.purgeEntityReferenceCopy(workPad.getLocalServerUserId(), entity2Ref); - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -602,7 +615,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } } @@ -690,17 +702,18 @@ protected void run() throws Exception */ EntitySummary retrievedEntity1Summary = null; - try { + try + { long start = System.currentTimeMillis(); retrievedEntity1Summary = metadataCollection.getEntitySummary(workPad.getLocalServerUserId(), entity1.getGUID()); elapsedTime = System.currentTimeMillis() - start; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "getEntitySummary"; String operationDescription = "retrieve an entity of type " + end1Type.getName(); Map parameters = new HashMap<>(); @@ -708,7 +721,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((retrievedEntity1Summary != null), @@ -725,8 +737,8 @@ protected void run() throws Exception */ long start = System.currentTimeMillis(); - try { - + try + { EntityDetail retrievedEntity1Detail = metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), entity1.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -737,7 +749,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.RETRIEVE_ENTITY_PROXIES.getRequirementId(), "getEntityDetail-negative", elapsedTime); - } catch (EntityProxyOnlyException exception) { + } + catch (EntityProxyOnlyException exception) + { elapsedTime = System.currentTimeMillis() - start; assertCondition((true), assertion4, @@ -746,7 +760,16 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.RETRIEVE_ENTITY_PROXIES.getRequirementId(), "getEntityDetail-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -765,8 +788,8 @@ protected void run() throws Exception * It SHOULD NOT be possible to retrieve the proxy using isEntityKnown - this should return null */ - try { - + try + { start = System.currentTimeMillis(); EntityDetail retrievedEntity1Detail = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), entity1.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -779,7 +802,16 @@ protected void run() throws Exception "isEntityKnown-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -791,10 +823,8 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - /* * Verify that operations that should not be valid on a proxy are correctly disallowed. * These tests are all performed on the E1 proxy. @@ -807,10 +837,10 @@ protected void run() throws Exception * to modify the status of the entity proxy - this should fail */ - for (InstanceStatus validInstanceStatus : end1Type.getValidInstanceStatusList()) { - - try { - + for (InstanceStatus validInstanceStatus : end1Type.getValidInstanceStatusList()) + { + try + { start = System.currentTimeMillis(); EntityDetail updatedEntity = metadataCollection.updateEntityStatus(workPad.getLocalServerUserId(), entity1.getGUID(), validInstanceStatus); elapsedTime = System.currentTimeMillis() - start; @@ -823,7 +853,9 @@ protected void run() throws Exception "updateEntityStatus-negative", elapsedTime); - } catch (InvalidParameterException e) { + } + catch (InvalidParameterException e) + { /* * We are not expecting the status update to work - it should have thrown an InvalidParameterException */ @@ -836,7 +868,16 @@ protected void run() throws Exception "updateEntityStatus-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -851,7 +892,6 @@ protected void run() throws Exception throw new Exception(msg, exc); } - } /* @@ -864,8 +904,8 @@ protected void run() throws Exception (!entity1.getProperties().getInstanceProperties().isEmpty())) { InstanceProperties minEntityProps = super.getMinPropertiesForInstance(workPad.getLocalServerUserId(), end1Type); - try { - + try + { start = System.currentTimeMillis(); EntityDetail minPropertiesEntity = metadataCollection.updateEntityProperties(workPad.getLocalServerUserId(), entity1.getGUID(), minEntityProps); elapsedTime = System.currentTimeMillis() - start; @@ -878,7 +918,9 @@ protected void run() throws Exception "updateEntityProperties-negative", elapsedTime); - } catch (InvalidParameterException e) { + } + catch (InvalidParameterException e) + { /* * We are not expecting the status update to work - it should have thrown an InvalidParameterException */ @@ -890,7 +932,16 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_PROXY_LOCKING.getRequirementId(), "updateEntityProperties-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -903,9 +954,7 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - } @@ -917,8 +966,8 @@ protected void run() throws Exception * This test is performed against the TUT. */ - try { - + try + { start = System.currentTimeMillis(); EntityDetail reTypedEntity = metadataCollection.reTypeEntity(workPad.getLocalServerUserId(), entity1.getGUID(), @@ -934,7 +983,9 @@ protected void run() throws Exception "reTypeEntity-negative", elapsedTime); - } catch (InvalidParameterException e) { + } + catch (InvalidParameterException e) + { /* * We are not expecting the type update to work - it should have thrown an InvalidParameterException @@ -948,7 +999,16 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_PROXY_LOCKING.getRequirementId(), "reTypeEntity-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -962,11 +1022,8 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - /* * Verify that it is not possible to re-identify the entity proxy. * This test is performed using a different GUID to the original. The actual value should not be looked at @@ -976,7 +1033,8 @@ protected void run() throws Exception String newGUID = UUID.randomUUID().toString(); - try { + try + { start = System.currentTimeMillis(); EntityDetail reIdentifiedEntity = metadataCollection.reIdentifyEntity(workPad.getLocalServerUserId(), @@ -987,7 +1045,9 @@ protected void run() throws Exception elapsedTime = System.currentTimeMillis() - start; if (reIdentifiedEntity != null) + { createdEntitiesTUT.add(reIdentifiedEntity); + } assertCondition((false), assertion12, @@ -997,8 +1057,9 @@ protected void run() throws Exception "reIdentifyEntity-negative", elapsedTime); - } catch (InvalidParameterException e) { - + } + catch (InvalidParameterException e) + { /* * We are not expecting the identity update to work - it should have thrown an InvalidParameterException */ @@ -1011,7 +1072,16 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_PROXY_LOCKING.getRequirementId(), "reIdentifyEntity-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1025,14 +1095,9 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - - - /* * Create a relationship between the proxy and the local entity, entity2 */ @@ -1040,8 +1105,8 @@ protected void run() throws Exception Relationship newRelationship = null; InstanceProperties instanceProps = null; - try { - + try + { instanceProps = super.getPropertiesForInstance(relationshipDef.getPropertiesDefinition()); start = System.currentTimeMillis(); @@ -1063,7 +1128,16 @@ protected void run() throws Exception createdRelationshipsTUT.add(newRelationship); - } catch (FunctionNotSupportedException exception) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (FunctionNotSupportedException exception) + { /* * If running against a read-only repository/connector that cannot add @@ -1079,7 +1153,9 @@ protected void run() throws Exception /* Worth carrying on with whatever else in the test we can achieve - so don't return here */ - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -1095,16 +1171,16 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - if (newRelationship != null) { + if (newRelationship != null) + { /* * We have no further use for the relationship - so delete it and purge it. */ - try { - + try + { start = System.currentTimeMillis(); Relationship deletedRelationship = metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), newRelationship.getType().getTypeDefGUID(), @@ -1121,7 +1197,9 @@ protected void run() throws Exception elapsedTime); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion7, assertionMsg7 + testTypeName, @@ -1130,11 +1208,19 @@ protected void run() throws Exception /* Soft delete is optional so carry on */ - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "deleteRelationship"; String operationDescription = "delete a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -1144,18 +1230,18 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - try { - - + try + { metadataCollection.purgeRelationship(workPad.getLocalServerUserId(), newRelationship.getType().getTypeDefGUID(), newRelationship.getType().getTypeDefName(), newRelationship.getGUID()); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1169,14 +1255,9 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - } - - /* * Delete (soft then hard) each of the CTS local entities - these operations are performed on the local (CTS) repo. * They should cause an OMRS instance event to flow to the TUT and for each entity proxy to be purged @@ -1187,14 +1268,15 @@ protected void run() throws Exception * lifecycle - that is tested elsewhere. This is just to trigger clean up of the proxy at the TUT. */ - try { - + try + { EntityDetail deletedEntity = ctsMetadataCollection.deleteEntity(workPad.getLocalServerUserId(), entity1.getType().getTypeDefGUID(), entity1.getType().getTypeDefName(), entity1.getGUID()); - - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * This would admittedly be surprising as the CTS is most likely using the in-memory repo, but in case @@ -1214,9 +1296,6 @@ protected void run() throws Exception entity1.getGUID()); - - - /* * Test that the entity proxy has been removed from the TUT repository */ @@ -1227,20 +1306,27 @@ protected void run() throws Exception * Retry the whole try catch up to pollCount times. */ - try { + try + { EntitySummary survivingEnt1Proxy; Integer remainingCount = this.pollCount; - do { - try { + do + { + try + { survivingEnt1Proxy = metadataCollection.getEntitySummary(workPad.getLocalServerUserId(), entity1.getGUID()); - } catch (EntityNotKnownException exception) { + } + catch (EntityNotKnownException exception) + { survivingEnt1Proxy = null; } Thread.sleep(this.pollPeriod); remainingCount--; } while (survivingEnt1Proxy != null && remainingCount > 0); - if (entity1Ref == null && remainingCount == 0) { + + if (entity1Ref == null && remainingCount == 0) + { ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() .logRecord(assertion8, @@ -1252,7 +1338,8 @@ protected void run() throws Exception overflow.getUserAction()); } } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -1264,14 +1351,14 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } /* * By now we have given this enough retries that it is either gone or is deemed to have failed....make one or other assertion */ - try { + try + { start = System.currentTimeMillis(); metadataCollection.getEntitySummary(workPad.getLocalServerUserId(), entity1.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -1285,7 +1372,8 @@ protected void run() throws Exception elapsedTime); } - catch (EntityNotKnownException exception) { + catch (EntityNotKnownException exception) + { elapsedTime = System.currentTimeMillis() - start; assertCondition((true), assertion8, @@ -1295,11 +1383,18 @@ protected void run() throws Exception "getEntitySummary-negative", elapsedTime); } - catch (Exception exc) { + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "getEntitySummary"; String operationDescription = "retrieve an entity of type " + end1Type.getName(); Map parameters = new HashMap<>(); @@ -1307,25 +1402,22 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - /* * Delete and purge E2 */ - - try { - + try + { EntityDetail deletedEntity = ctsMetadataCollection.deleteEntity(workPad.getLocalServerUserId(), entity2.getType().getTypeDefGUID(), entity2.getType().getTypeDefName(), entity2.getGUID()); - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { /* * This would admittedly be surprising as the CTS is most likely using the in-memory repo, but in case * it is ever used with a repository that does not support soft deletes, then this is OK - we can NO OP and @@ -1333,21 +1425,15 @@ protected void run() throws Exception */ } - /* * Purge the master instance of E1 */ - ctsMetadataCollection.purgeEntity(workPad.getLocalServerUserId(), entity2.getType().getTypeDefGUID(), entity2.getType().getTypeDefName(), entity2.getGUID()); - - super.setSuccessMessage("Entity proxies can be managed through their lifecycle"); - - } @@ -1372,14 +1458,15 @@ public void cleanup() throws Exception * createdRelationshipsTUT */ - if (createdRelationshipsTUT != null && !createdRelationshipsTUT.isEmpty()) { + if (createdRelationshipsTUT != null && !createdRelationshipsTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (Relationship relationship : createdRelationshipsTUT) { - + for (Relationship relationship : createdRelationshipsTUT) + { try { metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), @@ -1405,13 +1492,13 @@ public void cleanup() throws Exception } } - if (createdEntitiesCTS != null && !createdEntitiesCTS.isEmpty()) { - + if (createdEntitiesCTS != null && !createdEntitiesCTS.isEmpty()) + { /* * Instances were created - clean them up. */ - - for (EntityDetail entity : createdEntitiesCTS) { + for (EntityDetail entity : createdEntitiesCTS) + { try { @@ -1438,14 +1525,15 @@ public void cleanup() throws Exception } } - if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) { + if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntitiesTUT) { - + for (EntityDetail entity : createdEntitiesTUT) + { try { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), @@ -1471,13 +1559,15 @@ public void cleanup() throws Exception } } - if (createdEntityRefCopiesTUT != null && !createdEntityRefCopiesTUT.isEmpty()) { + if (createdEntityRefCopiesTUT != null && !createdEntityRefCopiesTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntityRefCopiesTUT) { + for (EntityDetail entity : createdEntityRefCopiesTUT) + { try { diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReferenceCopyLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReferenceCopyLifecycle.java index 7fb8959d735..fb0a203f13b 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReferenceCopyLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReferenceCopyLifecycle.java @@ -3,6 +3,7 @@ package org.odpi.openmetadata.conformance.tests.repository.instances; import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; @@ -133,7 +134,6 @@ public TestSupportedEntityReferenceCopyLifecycle(RepositoryConformanceWorkPad wo */ this.pollPeriod = Math.max(this.pollPeriod, 100); this.pollCount = Math.max(this.pollCount, 1); - } @@ -151,15 +151,18 @@ protected void run() throws Exception */ OMRSRepositoryConnector cohortRepositoryConnector = null; OMRSRepositoryHelper repositoryHelper = null; - if (workPad != null) { + if (workPad != null) + { cohortRepositoryConnector = workPad.getTutRepositoryConnector(); repositoryHelper = cohortRepositoryConnector.getRepositoryHelper(); } EntityDef knownEntityDef = null; - if (repositoryHelper != null) { + if (repositoryHelper != null) + { knownEntityDef = (EntityDef) repositoryHelper.getTypeDefByName(workPad.getLocalServerUserId(), entityDef.getName()); } + verifyCondition((entityDef.equals(knownEntityDef)), assertion0, testTypeName + assertionMsg0, @@ -221,15 +224,11 @@ protected void run() throws Exception * thereby getting into the connector-logic beyond the property validation. It also creates an * entity that is logically complete - versus an instance with just the locally-defined properties. */ - - EntityDetail newEntity = null; - if (workPad != null) { - newEntity = ctsMetadataCollection.addEntity(workPad.getLocalServerUserId(), - entityDef.getGUID(), - super.getAllPropertiesForInstance(workPad.getLocalServerUserId(), entityDef), - null, - null); - } + EntityDetail newEntity = ctsMetadataCollection.addEntity(workPad.getLocalServerUserId(), + entityDef.getGUID(), + super.getAllPropertiesForInstance(workPad.getLocalServerUserId(), entityDef), + null, + null); createdEntitiesCTS.add(newEntity); @@ -252,23 +251,23 @@ protected void run() throws Exception * Have to be prepared to wait until event has propagated and TUT has created a reference copy of the entity. */ long elapsedTime = 0; - try { + try + { Integer remainingCount = this.pollCount; - while (refEntity == null && remainingCount > 0) { + while (refEntity == null && remainingCount > 0) + { + long start = System.currentTimeMillis(); + refEntity = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), newEntity.getGUID()); + elapsedTime = System.currentTimeMillis() - start; - if (workPad != null) { - long start = System.currentTimeMillis(); - refEntity = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), newEntity.getGUID()); - elapsedTime = System.currentTimeMillis() - start; - } Thread.sleep(this.pollPeriod); remainingCount--; } - if (refEntity == null && remainingCount == 0) { - if (workPad != null) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; - workPad.getAuditLog() + if (refEntity == null && remainingCount == 0) + { + ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; + workPad.getAuditLog() .logRecord(assertion1, overflow.getLogMessageId(), overflow.getSeverity(), @@ -276,9 +275,10 @@ protected void run() throws Exception null, overflow.getSystemAction(), overflow.getUserAction()); - } } - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -286,27 +286,25 @@ protected void run() throws Exception String methodName = "isEntityKnown"; String operationDescription = "retrieve an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); - if (newEntity != null) { + if (newEntity != null) + { parameters.put("entityGUID", newEntity.getGUID()); } String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - /* * If this proves to be a performance problem it might be preferable to refactor the testcase to create all local * instances and batch the GUIDs. On completion of the batch, look for the reference copies. */ - - if (refEntity != null) { + if (refEntity != null) + { /* * If we retrieved the reference copy of the entity - we can assert that the TUT supports reference copies. */ - assertCondition((true), assertion1, testTypeName + assertionMsg1, @@ -317,10 +315,9 @@ protected void run() throws Exception createdEntityRefCopiesTUT.add(refEntity); - - - } else { - + } + else + { /* * Report that reference storage requirement is not supported. */ @@ -333,7 +330,6 @@ protected void run() throws Exception * Terminate the test */ return; - } @@ -341,23 +337,22 @@ protected void run() throws Exception * Validate that the reference copy can be consistently retrieved from the TUT and that the retrieved reference copy 'matches' what was saved. */ - String retrievalOperationName = ""; + String retrievalOperationName = "getEntitySummary"; EntityDetail retrievedReferenceCopy = null; - try { - + try + { long start = System.currentTimeMillis(); EntitySummary entitySummary = metadataCollection.getEntitySummary(workPad.getLocalServerUserId(), newEntity.getGUID()); elapsedTime = System.currentTimeMillis() - start; - retrievalOperationName = "getEntitySummary"; verifyCondition((entitySummary != null), assertion2, testTypeName + assertionMsg2, RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), - "getEntitySummary", + retrievalOperationName, elapsedTime); retrievalOperationName = "getEntityDetail"; @@ -370,51 +365,59 @@ protected void run() throws Exception testTypeName + assertionMsg3, RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), - "getEntityDetail", + retrievalOperationName, elapsedTime); - - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Keep going. + */ + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String operationDescription = "retrieve an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); parameters.put("entityGUID", newEntity.getGUID()); String msg = this.buildExceptionMessage(testCaseId, retrievalOperationName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } /* * Verify that the retrieved reference copy matches the original entity */ - - verifyCondition((newEntity.equals(retrievedReferenceCopy)), - assertion4, - testTypeName + assertionMsg4, - RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), - RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId()); - - + verifyObjectsAreEqual(newEntity, + retrievedReferenceCopy, + assertion4, + testTypeName + assertionMsg4, + RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), + RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId(), + retrievalOperationName, + null); /* * No relationships have been created so none should be returned. */ - try { - if (retrievedReferenceCopy != null) { + try + { + if (retrievedReferenceCopy != null) + { long start = System.currentTimeMillis(); List relationships = metadataCollection.getRelationshipsForEntity(workPad.getLocalServerUserId(), - retrievedReferenceCopy.getGUID(), - null, - 0, - null, - null, - null, - null, - 0); + retrievedReferenceCopy.getGUID(), + null, + 0, + null, + null, + null, + null, + 0); elapsedTime = System.currentTimeMillis() - start; + verifyCondition((relationships == null), assertion5, testTypeName + assertionMsg5, @@ -423,11 +426,12 @@ protected void run() throws Exception "getRelationshipsForEntity-negative", elapsedTime); } - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "getRelationshipsForEntity"; String operationDescription = "retrieve the relationships for an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); @@ -442,7 +446,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -454,8 +457,8 @@ protected void run() throws Exception for (InstanceStatus validInstanceStatus : entityDef.getValidInstanceStatusList()) { long start = System.currentTimeMillis(); - try { - + try + { EntityDetail updatedEntity = metadataCollection.updateEntityStatus(workPad.getLocalServerUserId(), retrievedReferenceCopy.getGUID(), validInstanceStatus); elapsedTime = System.currentTimeMillis() - start; @@ -467,7 +470,9 @@ protected void run() throws Exception "updateEntityStatus-negative", elapsedTime); - } catch (InvalidParameterException e) { + } + catch (InvalidParameterException e) + { /* * We are not expecting the status update to work - it should have thrown an InvalidParameterException */ @@ -479,11 +484,19 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), "updateEntityStatus-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "updateEntityStatus"; String operationDescription = "update the status of an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); @@ -494,7 +507,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } } @@ -507,36 +519,49 @@ protected void run() throws Exception if (retrievedReferenceCopy != null && (retrievedReferenceCopy.getProperties() != null) && (retrievedReferenceCopy.getProperties().getInstanceProperties() != null) && - (!retrievedReferenceCopy.getProperties().getInstanceProperties().isEmpty())) { + (!retrievedReferenceCopy.getProperties().getInstanceProperties().isEmpty())) + { InstanceProperties minEntityProps = super.getMinPropertiesForInstance(workPad.getLocalServerUserId(), entityDef); long start = System.currentTimeMillis(); - try { + try + { EntityDetail minPropertiesEntity = metadataCollection.updateEntityProperties(workPad.getLocalServerUserId(), retrievedReferenceCopy.getGUID(), minEntityProps); elapsedTime = System.currentTimeMillis() - start; assertCondition((false), - assertion7, - testTypeName + assertionMsg7, - RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getProfileId(), - RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), - "updateEntityProperties-negative", - elapsedTime); + assertion7, + testTypeName + assertionMsg7, + RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getProfileId(), + RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), + "updateEntityProperties-negative", + elapsedTime); - } catch (InvalidParameterException e) { + } + catch (InvalidParameterException e) + { /* * We are not expecting the status update to work - it should have thrown an InvalidParameterException */ elapsedTime = System.currentTimeMillis() - start; assertCondition((true), - assertion7, - testTypeName + assertionMsg7, - RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getProfileId(), - RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), - "updateEntityProperties-negative", - elapsedTime); - } catch (Exception exc) { + assertion7, + testTypeName + assertionMsg7, + RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getProfileId(), + RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), + "updateEntityProperties-negative", + elapsedTime); + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -549,9 +574,7 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - } @@ -564,7 +587,8 @@ protected void run() throws Exception */ long start = System.currentTimeMillis(); - try { + try + { EntityDetail reTypedEntity = metadataCollection.reTypeEntity(workPad.getLocalServerUserId(), newEntity.getGUID(), @@ -580,8 +604,9 @@ protected void run() throws Exception "reTypeEntity-negative", elapsedTime); - } catch (InvalidParameterException e) { - + } + catch (InvalidParameterException e) + { /* * We are not expecting the type update to work - it should have thrown an InvalidParameterException */ @@ -593,7 +618,16 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), "reTypeEntity-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -607,7 +641,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -622,8 +655,8 @@ protected void run() throws Exception String newGUID = UUID.randomUUID().toString(); start = System.currentTimeMillis(); - try { - + try + { EntityDetail reIdentifiedEntity = metadataCollection.reIdentifyEntity(workPad.getLocalServerUserId(), entityDef.getGUID(), entityDef.getName(), @@ -632,8 +665,9 @@ protected void run() throws Exception elapsedTime = System.currentTimeMillis() - start; if (reIdentifiedEntity != null) + { createdEntityRefCopiesTUT.add(reIdentifiedEntity); - + } assertCondition((false), assertion9, @@ -642,8 +676,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), "reIdentifyEntity-negative", elapsedTime); - - } catch (InvalidParameterException e) { + } + catch (InvalidParameterException e) + { /* * We are not expecting the identity update to work - it should have thrown an InvalidParameterException @@ -656,11 +691,19 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), "reIdentifyEntity-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "reIdentifyEntity"; String operationDescription = "reidentify an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); @@ -670,7 +713,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -679,7 +721,8 @@ protected void run() throws Exception * This test is performed against the TUT. */ - try { + try + { start = System.currentTimeMillis(); metadataCollection.purgeEntityReferenceCopy(workPad.getLocalServerUserId(), refEntity); @@ -696,11 +739,19 @@ protected void run() throws Exception "purgeEntityReferenceCopy", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "purgeEntityReferenceCopy"; String operationDescription = "purge a reference copy of an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); @@ -708,11 +759,11 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - try { + try + { start = System.currentTimeMillis(); metadataCollection.refreshEntityReferenceCopy(workPad.getLocalServerUserId(), refEntity.getGUID(), @@ -731,11 +782,19 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId(), "refreshEntityReferenceCopy", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "refreshEntityReferenceCopy"; String operationDescription = "request a refresh of a reference copy of an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); @@ -746,7 +805,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -803,13 +861,16 @@ protected void run() throws Exception * Verify that the reference copy can be retrieved form the TUT and matches the original... */ - try { + try + { start = System.currentTimeMillis(); refreshedEntityRefCopy = metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID()); elapsedTime = System.currentTimeMillis() - start; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -850,13 +911,15 @@ protected void run() throws Exception * They should cause an OMRS instance event to flow to the TUT and for the ref copy to be purged */ - try { - + try + { EntityDetail deletedEntity = ctsMetadataCollection.deleteEntity(workPad.getLocalServerUserId(), newEntity.getType().getTypeDefGUID(), newEntity.getType().getTypeDefName(), newEntity.getGUID()); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity @@ -878,10 +941,12 @@ protected void run() throws Exception * Since it may take time to propagate the purge event, retry until the entity is no longer known at the TUT. */ - try { + try + { EntityDetail survivingEntRefCopy; Integer remainingCount = this.pollCount; - do { + do + { survivingEntRefCopy = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), newEntity.getGUID()); Thread.sleep(this.pollPeriod); remainingCount--; @@ -897,7 +962,9 @@ protected void run() throws Exception overflow.getSystemAction(), overflow.getUserAction()); } - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -913,7 +980,8 @@ protected void run() throws Exception } - try { + try + { start = System.currentTimeMillis(); metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -926,7 +994,9 @@ protected void run() throws Exception "getEntityDetail-negative", elapsedTime); - } catch (EntityNotKnownException exception) { + } + catch (EntityNotKnownException exception) + { elapsedTime = System.currentTimeMillis() - start; assertCondition((true), assertion14, @@ -935,7 +1005,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_DELETE.getRequirementId(), "getEntityDetail-negative", elapsedTime); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -965,14 +1037,15 @@ protected void run() throws Exception /* * To accommodate repositories that do not support the creation of instances, wrap the creation of the entity - * in a try..catch to check for FunctionNotSupportedException. If the connector throws this, then give up + * in a try...catch to check for FunctionNotSupportedException. If the connector throws this, then give up * on the test by setting the discovered property to disabled and returning. */ EntityDetail entityWithMappingProperties; InstanceProperties instanceProperties = null; - try { + try + { /* * Create an entity reference copy of the entity type. * To do this, a local entity is created, copied and deleted/purged. The copy is modified (so that it @@ -1005,7 +1078,9 @@ protected void run() throws Exception createdEntitiesTUT.add(entityWithMappingProperties); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * If running against a read-only repository/connector that cannot add @@ -1021,7 +1096,9 @@ protected void run() throws Exception return; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -1031,7 +1108,7 @@ protected void run() throws Exception Map parameters = new HashMap<>(); parameters.put("typeGUID", entityDef.getGUID()); parameters.put("initialProperties", instanceProperties != null ? instanceProperties.toString() : "null"); - parameters.put("initialClasiifications", "null"); + parameters.put("initialClassifications", "null"); parameters.put("initialStatus", "null"); String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); @@ -1056,17 +1133,21 @@ protected void run() throws Exception * If the repository under test supports soft delete, the entity must be deleted before being purged */ - try { + try + { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), entityWithMappingProperties.getType().getTypeDefGUID(), entityWithMappingProperties.getType().getTypeDefName(), entityWithMappingProperties.getGUID()); - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity */ - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1084,12 +1165,15 @@ protected void run() throws Exception } - try { + try + { metadataCollection.purgeEntity(workPad.getLocalServerUserId(), entityWithMappingProperties.getType().getTypeDefGUID(), entityWithMappingProperties.getType().getTypeDefName(), entityWithMappingProperties.getGUID()); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1140,8 +1224,8 @@ protected void run() throws Exception * Save a reference copy of the 'remote' entity */ - try { - + try + { start = System.currentTimeMillis(); metadataCollection.saveEntityReferenceCopy(workPad.getLocalServerUserId(), remoteEntityWithMappingProperties); elapsedTime = System.currentTimeMillis() - start; @@ -1164,14 +1248,14 @@ protected void run() throws Exception EntityDetail retrievedReferenceCopyWithMappingProperties = null; - try { - + try + { start = System.currentTimeMillis(); retrievedReferenceCopyWithMappingProperties = metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), remoteEntityGUID); elapsedTime = System.currentTimeMillis() - start; - } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1183,21 +1267,16 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - assertCondition((retrievedReferenceCopyWithMappingProperties.equals(remoteEntityWithMappingProperties)), - assertion17, - assertionMsg17 + entityDef.getName(), - RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), - RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId(), - "getEntityDetail", - elapsedTime); - - - - + assertObjectsAreEqual(retrievedReferenceCopyWithMappingProperties, + remoteEntityWithMappingProperties, + assertion17, + assertionMsg17 + entityDef.getName(), + RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), + RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId(), + "getEntityDetail", + elapsedTime); /* * Continuing with the tests based on a locally synthesized entity used as a reference copy, emulating @@ -1207,10 +1286,10 @@ protected void run() throws Exception * The next test verifies whether it is possible to re-home a reference copy. The rehome operation is * effectively a pull of the master-ship of the reference copy - i.e. it is a request made by the TUT. * This should not be performed on a reference copy of an entity whose master is on the CTS server - the - * CTS server is not defunct and we also cannot delete the master instance without also triggering an event + * CTS server is not defunct, and we also cannot delete the master instance without also triggering an event * that would trigger clean up of the TUT's reference copy. The bottom line is that performing a rehome on - * the CTS's instance woudld place the cohort into an invalid state - and taht is not what we are aiming to - * test. Therefore the rehome is performed on the locally synthesized instance used above for the + * the CTS's instance would place the cohort into an invalid state - and that is not what we are aiming to + * test. Therefore, the rehome function is performed on the locally synthesized instance used above for the * mappingProperties test. */ @@ -1221,8 +1300,8 @@ protected void run() throws Exception */ EntityDetail newMasterEntity = null; - try { - + try + { start = System.currentTimeMillis(); newMasterEntity = metadataCollection.reHomeEntity(workPad.getLocalServerUserId(), remoteEntityGUID, @@ -1331,8 +1410,9 @@ protected void run() throws Exception } - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { /* * Because rehome is an optional method, this is not fatal - just record that the connector does not support rehome */ @@ -1341,8 +1421,9 @@ protected void run() throws Exception assertionMsg18, RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_HOME.getProfileId(), RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_HOME.getRequirementId()); - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1359,20 +1440,26 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - } - catch (FunctionNotSupportedException e) { - + catch (AssertionFailureException e) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw e; + } + catch (FunctionNotSupportedException e) + { super.addNotSupportedAssertion(assertion16, assertionMsg16, RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId()); } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1384,7 +1471,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReidentify.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReidentify.java index af6ec498344..2c8b9d36eae 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReidentify.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReidentify.java @@ -2,6 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; @@ -100,9 +101,8 @@ protected void run() throws Exception InstanceProperties instProps = null; - try { - - + try + { /* * Generate property values for all the type's defined properties, including inherited properties * This ensures that any properties defined as mandatory by Egeria property cardinality are provided @@ -130,7 +130,16 @@ protected void run() throws Exception createdEntitiesTUT.add(newEntity); - } catch (FunctionNotSupportedException exception) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (FunctionNotSupportedException exception) + { /* * If running against a read-only repository/connector that cannot add * entities or relationships catch FunctionNotSupportedException and give up the test. @@ -144,7 +153,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); return; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -200,8 +211,8 @@ protected void run() throws Exception EntityDetail reIdentifiedEntity = null; long elapsedTime; - try { - + try + { long start = System.currentTimeMillis(); reIdentifiedEntity = metadataCollection.reIdentifyEntity(workPad.getLocalServerUserId(), entityDef.getGUID(), @@ -209,9 +220,9 @@ protected void run() throws Exception newEntity.getGUID(), newGUID); elapsedTime = System.currentTimeMillis() - start; - - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion8, assertionMsg8, RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getProfileId(), @@ -219,8 +230,9 @@ protected void run() throws Exception /* Give up the testcase */ return; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -234,7 +246,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition(true, @@ -265,7 +276,9 @@ protected void run() throws Exception */ long start = System.currentTimeMillis(); - try { + + try + { metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -277,7 +290,9 @@ protected void run() throws Exception "getEntityDetail-negative", elapsedTime); - } catch (EntityNotKnownException exception) { + } + catch (EntityNotKnownException exception) + { elapsedTime = System.currentTimeMillis() - start; assertCondition((true), assertion5, @@ -293,15 +308,19 @@ protected void run() throws Exception * Validate that the relationship can be retrieved under its new GUID. */ - try { - assertCondition((reIdentifiedEntity.equals(metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newGUID))), - assertion6, - testTypeName + assertionMsg6, - RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getProfileId(), - RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getRequirementId()); - - } catch (EntityNotKnownException exception) { - + try + { + assertObjectsAreEqual(reIdentifiedEntity, + metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newGUID), + assertion6, + testTypeName + assertionMsg6, + RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getProfileId(), + RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getRequirementId(), + "getEntityDetail", + null); + } + catch (EntityNotKnownException exception) + { assertCondition((false), assertion6, testTypeName + assertionMsg6, @@ -321,14 +340,15 @@ protected void run() throws Exception * not work this will fail but that's OK. */ - try { - + try + { EntityDetail deletedEntity = metadataCollection.deleteEntity(workPad.getLocalServerUserId(), newEntity.getType().getTypeDefGUID(), newEntity.getType().getTypeDefName(), newGUID); - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity */ @@ -341,13 +361,9 @@ protected void run() throws Exception super.setSuccessMessage("Entities can be reidentified"); - } - - - /** * Method to clean any instance created by the test case that has not already been cleaned by the running of the test. * @@ -358,7 +374,8 @@ public void cleanup() throws Exception OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) { + if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) + { /* * Instances were created - clean them up. @@ -366,8 +383,8 @@ public void cleanup() throws Exception * FunctionNotSupportedException to EntityNotKnownException and maybe others. */ - for (EntityDetail entity : createdEntitiesTUT) { - + for (EntityDetail entity : createdEntitiesTUT) + { try { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityRetype.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityRetype.java index 84fe9ff53f6..647f39d3059 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityRetype.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityRetype.java @@ -2,6 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; @@ -136,8 +137,8 @@ protected void run() throws Exception long start; long elapsedTime; - try { - + try + { /* * Generate property values for all the type's defined properties, including inherited properties * This ensures that any properties defined as mandatory by Egeria property cardinality are provided @@ -156,18 +157,18 @@ protected void run() throws Exception elapsedTime = System.currentTimeMillis() - start; assertCondition((true), - assertion17, - testTypeName + assertionMsg17, - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), - "addEntity", - elapsedTime); + assertion17, + testTypeName + assertionMsg17, + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), + "addEntity", + elapsedTime); createdEntities.add(newEntity); - } - catch (FunctionNotSupportedException exception) { + catch (FunctionNotSupportedException exception) + { /* * If running against a read-only repository/connector that cannot add @@ -177,13 +178,21 @@ protected void run() throws Exception */ super.addNotSupportedAssertion(assertion17, - assertionMsg17, - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); + assertionMsg17, + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); return; } - catch(Exception exc) { + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch(Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -193,19 +202,18 @@ protected void run() throws Exception Map parameters = new HashMap<>(); parameters.put("typeGUID" , entityDef.getGUID()); parameters.put("initialProperties" , instanceProperties!=null?instanceProperties.toString():"null"); - parameters.put("initialClasiifications" , "null"); + parameters.put("initialClassifications" , "null"); parameters.put("initialStatus" , "null"); String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception( msg , exc ); - } assertCondition((newEntity != null), - assertion1, - testTypeName + assertionMsg1, - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); + assertion1, + testTypeName + assertionMsg1, + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); /* * Other conditions - such as content of InstanceAuditHeader fields - are tested by Entity Lifecycle tests; so not tested here. @@ -218,10 +226,10 @@ protected void run() throws Exception */ verifyCondition((newEntity.equals(metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), newEntity.getGUID()))), - assertion2, - testTypeName + assertionMsg2, - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); + assertion2, + testTypeName + assertionMsg2, + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), + RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); @@ -244,19 +252,21 @@ protected void run() throws Exception */ List subTypeNames = repositoryConformanceWorkPad.getEntitySubTypes(entityDef.getName()); - if (subTypeNames == null) { + if (subTypeNames == null) + { /* * No subtypes - ignore this type */ return; } - else { - + else + { /* * This type has subtypes - retype the entity instance to each subtype and back again. */ - for (String subTypeName : subTypeNames) { + for (String subTypeName : subTypeNames) + { /* * Re-type the entity instance to this subtype. @@ -268,7 +278,8 @@ protected void run() throws Exception TypeDef subTypeDef = metadataCollection.getTypeDefByName(workPad.getLocalServerUserId(), subTypeName); - try { + try + { start = System.currentTimeMillis(); subTypedEntity = metadataCollection.reTypeEntity(workPad.getLocalServerUserId(), @@ -276,8 +287,9 @@ protected void run() throws Exception entityDef, subTypeDef); elapsedTime = System.currentTimeMillis() - start; - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion18, testTypeName + assertionMsg18 + subTypeName, RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_TYPE.getProfileId(), @@ -286,7 +298,9 @@ protected void run() throws Exception /* Give up the rest of the testcase */ return; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -299,7 +313,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition(true, @@ -392,7 +405,8 @@ protected void run() throws Exception EntityDetail superTypedEntity = null; - try { + try + { start = System.currentTimeMillis(); superTypedEntity = metadataCollection.reTypeEntity(workPad.getLocalServerUserId(), @@ -400,9 +414,9 @@ protected void run() throws Exception subTypeDef, entityDef); elapsedTime = System.currentTimeMillis() - start; - - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion18, subTypeName + assertionMsg18 + testTypeName, RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_TYPE.getProfileId(), @@ -410,11 +424,12 @@ protected void run() throws Exception return; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "reTypeEntity"; String operationDescription = "retype an entity of type " + entityDef.getName(); Map parameters = new HashMap<>(); @@ -423,7 +438,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } /* @@ -500,8 +514,6 @@ protected void run() throws Exception testTypeName + assertionMsg16, RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_TYPE.getProfileId(), RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_TYPE.getRequirementId()); - - } } @@ -515,12 +527,15 @@ protected void run() throws Exception * not work this will fail but that's OK. */ - try { + try + { EntityDetail deletedEntity = metadataCollection.deleteEntity(workPad.getLocalServerUserId(), - newEntity.getType().getTypeDefGUID(), - newEntity.getType().getTypeDefName(), - newEntity.getGUID()); - } catch (FunctionNotSupportedException exception) { + newEntity.getType().getTypeDefGUID(), + newEntity.getType().getTypeDefName(), + newEntity.getGUID()); + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity @@ -528,10 +543,9 @@ protected void run() throws Exception } metadataCollection.purgeEntity(workPad.getLocalServerUserId(), - newEntity.getType().getTypeDefGUID(), - newEntity.getType().getTypeDefName(), - newEntity.getGUID()); - + newEntity.getType().getTypeDefGUID(), + newEntity.getType().getTypeDefName(), + newEntity.getGUID()); super.setSuccessMessage("Entities can be retyped"); } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntitySearch.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntitySearch.java index c86223db496..6c1bf24f082 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntitySearch.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntitySearch.java @@ -2,22 +2,20 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyCategory; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceType; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.PrimitivePropertyValue; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.search.PropertyComparisonOperator; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.search.PropertyCondition; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.search.SearchClassifications; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.search.SearchProperties; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.AttributeTypeDefCategory; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EntityDef; @@ -49,84 +47,84 @@ */ public class TestSupportedEntitySearch extends RepositoryConformanceTestCase { - private static final String TEST_CASE_ID = "repository-entity-property-search"; - private static final String TEST_CASE_NAME = "Repository entity property search test case"; + private static final String testCaseId = "repository-entity-property-search"; + private static final String testCaseName = "Repository entity property search test case"; - private static final String ASSERTION_101FEBP = TEST_CASE_ID + "-101FEBP"; - private static final String ASSERTION_MSG_101FEBP = "findEntitiesByProperty is supported: "; + private static final String assertion101FEBP = testCaseId + "-101FEBP"; + private static final String assertionMsg_101FEBP = "findEntitiesByProperty is supported: "; - private static final String ASSERTION_101FEBPV = TEST_CASE_ID + "-101FEBPV"; - private static final String ASSERTION_MSG_101FEBPV = "findEntitiesByPropertyValue is supported: "; + private static final String assertion101FEBPV = testCaseId + "-101FEBPV"; + private static final String assertionMsg_101FEBPV = "findEntitiesByPropertyValue is supported: "; - private static final String ASSERTION_101FE = TEST_CASE_ID + "-101FE"; - private static final String ASSERTION_MSG_101FE = "findEntities using SearchProperties is supported: "; + private static final String assertion101FE = testCaseId + "-101FE"; + private static final String assertionMsg_101FE = "findEntities using SearchProperties is supported: "; - private static final String ASSERTION_101FEBPGEN = TEST_CASE_ID + "-101FEBPGEN"; - private static final String ASSERTION_MSG_101FEBPGEN = "findEntitiesByProperty supports general regular expressions: "; + private static final String assertion101FEBPGEN = testCaseId + "-101FEBPGEN"; + private static final String assertionMsg_101FEBPGEN = "findEntitiesByProperty supports general regular expressions: "; - private static final String ASSERTION_101FEBPVGEN = TEST_CASE_ID + "-101FEBPVGEN"; - private static final String ASSERTION_MSG_101FEBPVGEN = "findEntitiesByPropertyValue supports general regular expressions: "; + private static final String assertion101FEBPVGEN = testCaseId + "-101FEBPVGEN"; + private static final String assertionMsg_101FEBPVGEN = "findEntitiesByPropertyValue supports general regular expressions: "; - private static final String ASSERTION_1 = TEST_CASE_ID + "-01"; - private static final String ASSERTION_MSG_1 = " entity type matches the known type from the repository helper."; + private static final String assertion1 = testCaseId + "-01"; + private static final String assertionMsg_1 = " entity type matches the known type from the repository helper."; - private static final String ASSERTION_2 = TEST_CASE_ID + "-2"; - private static final String ASSERTION_MSG_2 = "repository supports creation of instances of type "; + private static final String assertion2 = testCaseId + "-2"; + private static final String assertionMsg_2 = "repository supports creation of instances of type "; - private static final String ASSERTION_3 = TEST_CASE_ID + "-03"; - private static final String ASSERTION_MSG_3 = "findEntitiesByProperty found {0}/{1} expected results using parameters: {2}"; + private static final String assertion3 = testCaseId + "-03"; + private static final String assertionMsg_3 = "findEntitiesByProperty found {0}/{1} expected results using parameters: {2}"; - private static final String ASSERTION_4 = TEST_CASE_ID + "-04"; - private static final String ASSERTION_MSG_4 = "findEntitiesByProperty returned {0} unexpected results using parameters: {1}"; + private static final String assertion4 = testCaseId + "-04"; + private static final String assertionMsg_4 = "findEntitiesByProperty returned {0} unexpected results using parameters: {1}"; - private static final String ASSERTION_5 = TEST_CASE_ID + "-05"; - private static final String ASSERTION_MSG_5 = ASSERTION_MSG_3; + private static final String assertion5 = testCaseId + "-05"; + private static final String assertionMsg_5 = assertionMsg_3; - private static final String ASSERTION_6 = TEST_CASE_ID + "-06"; - private static final String ASSERTION_MSG_6 = ASSERTION_MSG_4; + private static final String assertion6 = testCaseId + "-06"; + private static final String assertionMsg_6 = assertionMsg_4; - private static final String ASSERTION_7 = TEST_CASE_ID + "-07"; - private static final String ASSERTION_MSG_7 = "findEntitiesByPropertyValue found {0}/{1} expected results using parameters: {2}"; + private static final String assertion7 = testCaseId + "-07"; + private static final String assertionMsg_7 = "findEntitiesByPropertyValue found {0}/{1} expected results using parameters: {2}"; - private static final String ASSERTION_8 = TEST_CASE_ID + "-08"; - private static final String ASSERTION_MSG_8 = "findEntitiesByPropertyValue returned {0} unexpected results using parameters: {1}"; + private static final String assertion8 = testCaseId + "-08"; + private static final String assertionMsg_8 = "findEntitiesByPropertyValue returned {0} unexpected results using parameters: {1}"; - private static final String ASSERTION_9 = TEST_CASE_ID + "-09"; - private static final String ASSERTION_MSG_9 = ASSERTION_MSG_3; + private static final String assertion9 = testCaseId + "-09"; + private static final String assertionMsg_9 = assertionMsg_3; - private static final String ASSERTION_10 = TEST_CASE_ID + "-10"; - private static final String ASSERTION_MSG_10 = ASSERTION_MSG_4; + private static final String assertion10 = testCaseId + "-10"; + private static final String assertionMsg_10 = assertionMsg_4; - private static final String ASSERTION_11 = TEST_CASE_ID + "-11"; - private static final String ASSERTION_MSG_11 = "findEntitiesByPropertyValue with general regex found {0}/{1} expected results using parameters: {2}"; + private static final String assertion11 = testCaseId + "-11"; + private static final String assertionMsg_11 = "findEntitiesByPropertyValue with general regex found {0}/{1} expected results using parameters: {2}"; - private static final String ASSERTION_12 = TEST_CASE_ID + "-12"; - private static final String ASSERTION_MSG_12 = "findEntitiesByPropertyValue with general regex returned {0} unexpected results using parameters: {1}"; + private static final String assertion12 = testCaseId + "-12"; + private static final String assertionMsg_12 = "findEntitiesByPropertyValue with general regex returned {0} unexpected results using parameters: {1}"; - private static final String ASSERTION_13 = TEST_CASE_ID + "-13"; - private static final String ASSERTION_MSG_13 = "findEntitiesByProperty with general regex found {0}/{1} expected results using parameters: {2}"; + private static final String assertion13 = testCaseId + "-13"; + private static final String assertionMsg_13 = "findEntitiesByProperty with general regex found {0}/{1} expected results using parameters: {2}"; - private static final String ASSERTION_14 = TEST_CASE_ID + "-14"; - private static final String ASSERTION_MSG_14 = "findEntitiesByProperty with general regex returned {0} unexpected results using parameters: {1}"; + private static final String assertion14 = testCaseId + "-14"; + private static final String assertionMsg_14 = "findEntitiesByProperty with general regex returned {0} unexpected results using parameters: {1}"; - private static final String ASSERTION_103 = TEST_CASE_ID + "-103"; - private static final String ASSERTION_MSG_103 = "findEntities using SearchProperties with general regex found {0}/{1} expected results using parameters: {2}"; + private static final String assertion103 = testCaseId + "-103"; + private static final String assertionMsg_103 = "findEntities using SearchProperties with general regex found {0}/{1} expected results using parameters: {2}"; - private static final String ASSERTION_104 = TEST_CASE_ID + "-104"; - private static final String ASSERTION_MSG_104 = "findEntities using SearchProperties with general regex returned {0} unexpected results using parameters: {1}"; + private static final String assertion104 = testCaseId + "-104"; + private static final String assertionMsg_104 = "findEntities using SearchProperties with general regex returned {0} unexpected results using parameters: {1}"; - private static final String ASSERTION_105 = TEST_CASE_ID + "-105"; - private static final String ASSERTION_MSG_105 = "findEntitiesByProperty with null match parameters found {0}/{1} expected results using parameters: {2}"; + private static final String assertion105 = testCaseId + "-105"; + private static final String assertionMsg_105 = "findEntitiesByProperty with null match parameters found {0}/{1} expected results using parameters: {2}"; - private static final String ASSERTION_106 = TEST_CASE_ID + "-106"; - private static final String ASSERTION_MSG_106 = "findEntitiesByProperty with null match parameters returned {0} unexpected results using parameters: {1}"; + private static final String assertion106 = testCaseId + "-106"; + private static final String assertionMsg_106 = "findEntitiesByProperty with null match parameters returned {0} unexpected results using parameters: {1}"; - private static final String ASSERTION_107 = TEST_CASE_ID + "-107"; - private static final String ASSERTION_MSG_107 = "findEntities with null match parameters found {0}/{1} expected results using parameters: {2}"; + private static final String assertion107 = testCaseId + "-107"; + private static final String assertionMsg_107 = "findEntities with null match parameters found {0}/{1} expected results using parameters: {2}"; - private static final String ASSERTION_108 = TEST_CASE_ID + "-108"; - private static final String ASSERTION_MSG_108 = "findEntities with null match parameters returned {0} unexpected results using parameters: {1}"; + private static final String assertion108 = testCaseId + "-108"; + private static final String assertionMsg_108 = "findEntities with null match parameters returned {0} unexpected results using parameters: {1}"; private static final String RESULTS_MISSING_EXPECTED_GUIDS = "(results missing expected GUIDs)"; @@ -168,7 +166,7 @@ public TestSupportedEntitySearch(RepositoryConformanceWorkPad workPad, this.workPad = workPad; this.entityDef = entityDef; - this.testTypeName = this.updateTestIdByType(entityDef.getName(), TEST_CASE_ID, TEST_CASE_NAME); + this.testTypeName = this.updateTestIdByType(entityDef.getName(), testCaseId, testCaseName); this.knownInstances = null; this.knownInstancesGUIDs = null; @@ -185,9 +183,6 @@ public TestSupportedEntitySearch(RepositoryConformanceWorkPad workPad, this.pageSize = getMaxSearchResults(); - - - /* * Check that the entity type matches the known type from the repository helper */ @@ -198,8 +193,8 @@ public TestSupportedEntitySearch(RepositoryConformanceWorkPad workPad, EntityDef knownEntityDef = (EntityDef) repositoryHelper.getTypeDefByName(workPad.getLocalServerUserId(), entityDef.getName()); verifyCondition((entityDef.equals(knownEntityDef)), - ASSERTION_1, - testTypeName + ASSERTION_MSG_1, + assertion1, + testTypeName + assertionMsg_1, RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getProfileId(), RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getRequirementId()); @@ -212,11 +207,12 @@ public TestSupportedEntitySearch(RepositoryConformanceWorkPad workPad, this.attrList = getAllPropertiesForTypedef(workPad.getLocalServerUserId(), entityDef); - if ( (this.attrList != null) && !(this.attrList.isEmpty()) ) { + if ( (this.attrList != null) && !(this.attrList.isEmpty()) ) + { /* * If the TypeDef has NO attributes then it is not possible to perform a matchProperties or searchCriteria find on instances of that type. - * The MetadataCollection API does not accept null match properties and a searchCritera search on something with no values would be pointless. + * The MetadataCollection API does not accept null match properties and a searchCriteria search on something with no values would be pointless. */ /* @@ -225,10 +221,13 @@ public TestSupportedEntitySearch(RepositoryConformanceWorkPad workPad, * may be used for search narrowing. * This is only collated for primitives. */ - for (TypeDefAttribute typeDefAttribute : attrList) { - if (typeDefAttribute.getAttributeType().getCategory() == AttributeTypeDefCategory.PRIMITIVE) { + for (TypeDefAttribute typeDefAttribute : attrList) + { + if (typeDefAttribute.getAttributeType().getCategory() == AttributeTypeDefCategory.PRIMITIVE) + { definedAttributeNames.add(typeDefAttribute.getAttributeName()); - if (typeDefAttribute.isUnique()) { + if (typeDefAttribute.isUnique()) + { uniqueAttributeNames.add(typeDefAttribute.getAttributeName()); } } @@ -284,8 +283,8 @@ protected void run(TestPhase phase) throws Exception this.metadataCollection = super.getMetadataCollection(); - switch (phase) { - + switch (phase) + { case SEED: this.seedInstances(); break; @@ -304,7 +303,6 @@ protected void run(TestPhase phase) throws Exception private void seedInstances() throws Exception { - /* * Perform an initial discovery search against the repository.... * @@ -322,7 +320,8 @@ private void seedInstances() throws Exception InstanceProperties emptyMatchProperties = new InstanceProperties(); - try { + try + { knownInstances = metadataCollection.findEntitiesByProperty(workPad.getLocalServerUserId(), entityDef.getGUID(), @@ -336,7 +335,8 @@ private void seedInstances() throws Exception null, pageSize); } - catch(Exception exc) { + catch(Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -344,14 +344,15 @@ private void seedInstances() throws Exception String methodName = "findEntitiesByProperty"; String operationDescription = "find entities of type " + entityDef.getName(); Map parameters = getParameters(entityDef.getGUID(), emptyMatchProperties, MatchCriteria.ALL); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception( msg , exc ); } - if (knownInstances == null) { + if (knownInstances == null) + { /* * There are no instances of this type reported by the repository. @@ -371,8 +372,8 @@ private void seedInstances() throws Exception InstanceProperties instProps = null; - try { - + try + { knownInstances = new ArrayList<>(); createdInstances = new ArrayList<>(); /* @@ -392,8 +393,8 @@ private void seedInstances() throws Exception // We will simply average the results given there is only a single assertion (not instance-by-instance) long totalElapsedTime = 0; - for (int instanceCount = 0 ; instanceCount < numInstancesToCreate ; instanceCount++ ) { - + for (int instanceCount = 0 ; instanceCount < numInstancesToCreate ; instanceCount++ ) + { instProps = super.generatePropertiesForInstance(workPad.getLocalServerUserId(), attrList, instanceCount); long start = System.currentTimeMillis(); @@ -417,15 +418,20 @@ private void seedInstances() throws Exception * We succeeded in creating instances - record the fact */ assertCondition((true), - ASSERTION_2, - ASSERTION_MSG_2 + testTypeName, + assertion2, + assertionMsg_2 + testTypeName, RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId(), "addEntity", totalElapsedTime / numInstancesToCreate); } - catch (FunctionNotSupportedException exception) { + catch (AssertionFailureException exception) + { + throw exception; + } + catch (FunctionNotSupportedException exception) + { /* @@ -442,15 +448,16 @@ private void seedInstances() throws Exception * Report the inability to create instances and give up on the testcase.... */ - super.addNotSupportedAssertion(ASSERTION_2, - ASSERTION_MSG_2 + testTypeName, + super.addNotSupportedAssertion(assertion2, + assertionMsg_2 + testTypeName, RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); return; } - catch(Exception exc) { + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -460,9 +467,9 @@ private void seedInstances() throws Exception Map parameters = new HashMap<>(); parameters.put("typeGUID" , entityDef.getGUID()); parameters.put("initialProperties" , instProps!=null?instProps.toString():"null"); - parameters.put("initialClasiifications" , "null"); + parameters.put("initialClassifications" , "null"); parameters.put("initialStatus" , "null"); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception( msg , exc ); @@ -471,11 +478,12 @@ private void seedInstances() throws Exception } - if (knownInstances == null || knownInstances.isEmpty()) { + if (knownInstances == null || knownInstances.isEmpty()) + { /* - * Something bad has happened - if there were no instances and we failed to create any instances we should - * have abandoned in the catch block above - belt and braces check but it shows there is no point continuing. + * Something bad has happened - if there were no instances, and we failed to create any instances we should + * have abandoned in the catch block above - belt and braces check, but it shows there is no point continuing. */ return; @@ -494,10 +502,13 @@ private void seedInstances() throws Exception */ if (knownInstances.size() >= pageSize) + { pageLimited = true; + } knownInstancesGUIDs = new ArrayList<>(); - for (EntityDetail entity : knownInstances) { + for (EntityDetail entity : knownInstances) + { knownInstancesGUIDs.add(entity.getGUID()); } @@ -507,10 +518,10 @@ private void seedInstances() throws Exception * This is only performed for primitives. */ - for (TypeDefAttribute typeDefAttribute : attrList) { - - if (typeDefAttribute.getAttributeType().getCategory() == AttributeTypeDefCategory.PRIMITIVE) { - + for (TypeDefAttribute typeDefAttribute : attrList) + { + if (typeDefAttribute.getAttributeType().getCategory() == AttributeTypeDefCategory.PRIMITIVE) + { String attrName = typeDefAttribute.getAttributeName(); PrimitiveDef primDef = (PrimitiveDef) typeDefAttribute.getAttributeType(); @@ -519,15 +530,19 @@ private void seedInstances() throws Exception Map> valueMap = new HashMap<>(); propertyValueMap.put(attrName, valueMap); - for (EntityDetail entity : knownInstances) { + for (EntityDetail entity : knownInstances) + { InstanceProperties entityProperties = entity.getProperties(); - if (entityProperties != null) { + if (entityProperties != null) + { InstancePropertyValue ipValue = entityProperties.getPropertyValue(attrName); if (ipValue != null) { InstancePropertyCategory ipCategory = ipValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { Object primitiveValue = ipValue.valueAsObject(); - if (valueMap.get(primitiveValue) == null) { + if (valueMap.get(primitiveValue) == null) + { List newList = new ArrayList<>(); valueMap.put(primitiveValue, newList); } @@ -539,8 +554,6 @@ private void seedInstances() throws Exception } } } - - } @@ -550,21 +563,25 @@ private void seedInstances() throws Exception private void cleanInstances() throws Exception { - if (createdInstances != null && !createdInstances.isEmpty()) { - + if (createdInstances != null && !createdInstances.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdInstances) { - try { + for (EntityDetail entity : createdInstances) + { + try + { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), entity.getType().getTypeDefGUID(), entity.getType().getTypeDefName(), entity.getGUID()); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { // NO OP - can proceed to purge } @@ -760,48 +777,51 @@ private void performFinds() throws Exception - private List pickAttributePair() { + private List pickAttributePair() + { List returnList = null; Set propertyNameSet = propertyValueMap.keySet(); - if (propertyNameSet.size() >= 2) { - + if (propertyNameSet.size() >= 2) + { String alphaAttributeName = null; String betaAttributeName = null; - for (String attributeName : definedAttributeNames) { - + for (String attributeName : definedAttributeNames) + { Set possibleValues = propertyValueMap.get(attributeName).keySet(); Iterator possibleValueIterator = possibleValues.iterator(); /* * Perform a search using the first discovered value for the property */ - if (possibleValueIterator.hasNext()) { - + if (possibleValueIterator.hasNext()) + { alphaAttributeName = attributeName; break; - } } - for (String attributeName : definedAttributeNames) { - - if (!attributeName.equals(alphaAttributeName)) { + for (String attributeName : definedAttributeNames) + { + if (!attributeName.equals(alphaAttributeName)) + { Set possibleValues = propertyValueMap.get(attributeName).keySet(); Iterator possibleValueIterator = possibleValues.iterator(); /* * Perform a search using the first discovered value for the property */ - if (possibleValueIterator.hasNext()) { - + if (possibleValueIterator.hasNext()) + { betaAttributeName = attributeName; break; } } } - if (alphaAttributeName != null && betaAttributeName != null) { + + if (alphaAttributeName != null && betaAttributeName != null) + { returnList = new ArrayList<>(); returnList.add(alphaAttributeName); returnList.add(betaAttributeName); @@ -820,7 +840,8 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC /* * Perform a search using the first discovered value for the property */ - if (possibleValueIterator.hasNext()) { + if (possibleValueIterator.hasNext()) + { Object value = possibleValueIterator.next(); @@ -828,10 +849,13 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC PrimitivePropertyValue ppv = new PrimitivePropertyValue(); ppv.setPrimitiveDefCategory(propertyCatMap.get(attributeName)); - if (propertyCatMap.get(attributeName) == OM_PRIMITIVE_TYPE_STRING) { + if (propertyCatMap.get(attributeName) == OM_PRIMITIVE_TYPE_STRING) + { String literalisedValue = literaliseStringProperty((String) value); ppv.setPrimitiveValue(literalisedValue); - } else { + } + else + { ppv.setPrimitiveValue(value); } @@ -845,7 +869,8 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC List entitiesWithValue = propertyValueMap.get(attributeName).get(value); List expectedGUIDs = null; - switch (matchCriteria) { + switch (matchCriteria) + { case ALL: case ANY: /* This is a single property test, so ANY and ALL are equivalent */ @@ -858,6 +883,7 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC /* Invalid matchCriteria value passed */ return; } + int expectedEntityCount = expectedGUIDs.size(); // In the case where the instances were created, expected may exceed pageSize. @@ -870,8 +896,8 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC Map parameters = getParameters(entityDef.getGUID(), matchProperties, matchCriteria); long elapsedTime; - try { - + try + { long start = System.currentTimeMillis(); result = metadataCollection.findEntitiesByProperty(workPad.getLocalServerUserId(), entityDef.getGUID(), @@ -886,22 +912,24 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC pageSize); elapsedTime = System.currentTimeMillis() - start; } - catch (FunctionNotSupportedException exc) { + catch (FunctionNotSupportedException exc) + { /* * Because the above test only exercises one optional function (advanced regex support) * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FEBP, - ASSERTION_MSG_101FEBP + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FEBP, + assertionMsg_101FEBP + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -914,14 +942,15 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC return; } - catch(Exception exc) { + catch(Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ String methodName = "findEntitiesByProperty"; String operationDescription = "find entities of type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception( msg , exc ); @@ -990,7 +1019,7 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC int resultCount = result == null ? 0 : result.size(); /* * If the original discovery query was not pageLimited then we should have been able to exactly predict the expected result. - * In addition the result size should be no more than a page. + * In addition, the result size should be no more than a page. */ boolean unlimited_case = !pageLimited && resultCount == expectedEntityCount; /* @@ -1002,9 +1031,9 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC boolean limited_small_case = pageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; boolean acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - String assertionMessage = MessageFormat.format(ASSERTION_MSG_3, resultCount, expectedEntityCount, parameters); + String assertionMessage = MessageFormat.format(assertionMsg_3, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_3, + assertion3, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId(), @@ -1016,10 +1045,12 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC * If there were any result, check that all expected entities were returned and (in the pageLimited case) that any * additional entities were valid results for the search. */ - if (resultCount > 0) { + if (resultCount > 0) + { List resultGUIDs = new ArrayList<>(); - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { resultGUIDs.add(entity.getGUID()); } @@ -1032,26 +1063,34 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC String unexpectedResult = "0"; - if (!pageLimited) { - + if (!pageLimited) + { if (!resultGUIDs.containsAll(expectedGUIDs)) + { unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; + } - } else { // pageLimited, so need to allow for and verify hitherto unseen instances - - for (EntityDetail entity : result) { + } + else + { // pageLimited, so need to allow for and verify hitherto unseen instances - if (!(expectedGUIDs.contains(entity.getGUID()))) { + for (EntityDetail entity : result) + { + if (!(expectedGUIDs.contains(entity.getGUID()))) + { /* * This was an extra entity that we either did not expect or that we have not seen previously. * Check it is a valid result. */ InstanceProperties entityProperties = entity.getProperties(); - if (entityProperties != null) { + if (entityProperties != null) + { InstancePropertyValue ipValue = entityProperties.getPropertyValue(attributeName); - if (ipValue != null) { + if (ipValue != null) + { InstancePropertyCategory ipCategory = ipValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { Object primitiveValue = ipValue.valueAsObject(); @@ -1060,17 +1099,19 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC * This is because, even for strings, we used an exact match literalised property value * and match criteria was ALL - so an entity with an unequal property is not a valid result. */ - switch (matchCriteria) { + switch (matchCriteria) + { case ALL: case ANY: /* This is a single property test, so ANY and ALL are equivalent */ - if (!primitiveValue.equals(value)) { - unexpectedResult = "('" + primitiveValue.toString() + "' for guid=" + entity.getGUID() + ")"; + if (!primitiveValue.equals(value)) + { + unexpectedResult = "('" + primitiveValue + "' for guid=" + entity.getGUID() + ")"; } break; case NONE: if (primitiveValue.equals(value)) { - unexpectedResult = "('" + primitiveValue.toString() + "' for guid=" + entity.getGUID() + ")"; + unexpectedResult = "('" + primitiveValue + "' for guid=" + entity.getGUID() + ")"; } break; default: @@ -1084,21 +1125,21 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_4, unexpectedResult, parameters.toString()); + assertionMessage = MessageFormat.format(assertionMsg_4, unexpectedResult, parameters.toString()); assertCondition(unexpectedResult.equals("0"), - ASSERTION_4, + assertion4, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); } - } } - private void performMatchPropertiesTestForAttributePair(String alphaAttributeName, String betaAttributeName, MatchCriteria matchCriteria) throws Exception { - - + private void performMatchPropertiesTestForAttributePair(String alphaAttributeName, + String betaAttributeName, + MatchCriteria matchCriteria) throws Exception + { PrimitivePropertyValue alphaPpv = null; PrimitivePropertyValue betaPpv = null; @@ -1111,43 +1152,49 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam Set possibleAlphaValues = propertyValueMap.get(alphaAttributeName).keySet(); Iterator possibleAlphaValueIterator = possibleAlphaValues.iterator(); - if (possibleAlphaValueIterator.hasNext()) { - + if (possibleAlphaValueIterator.hasNext()) + { alphaValue = possibleAlphaValueIterator.next(); alphaPpv = new PrimitivePropertyValue(); alphaPpv.setPrimitiveDefCategory(propertyCatMap.get(alphaAttributeName)); - if (propertyCatMap.get(alphaAttributeName) == OM_PRIMITIVE_TYPE_STRING) { + if (propertyCatMap.get(alphaAttributeName) == OM_PRIMITIVE_TYPE_STRING) + { String literalisedValue = literaliseStringProperty((String) alphaValue); alphaPpv.setPrimitiveValue(literalisedValue); - } else { + } + else + { alphaPpv.setPrimitiveValue(alphaValue); } } + /* * Select first available value for betaAttribute */ Set possibleBetaValues = propertyValueMap.get(betaAttributeName).keySet(); Iterator possibleBetaValueIterator = possibleBetaValues.iterator(); - if (possibleBetaValueIterator.hasNext()) { - + if (possibleBetaValueIterator.hasNext()) + { betaValue = possibleBetaValueIterator.next(); - betaPpv = new PrimitivePropertyValue(); betaPpv.setPrimitiveDefCategory(propertyCatMap.get(betaAttributeName)); - if (propertyCatMap.get(betaAttributeName) == OM_PRIMITIVE_TYPE_STRING) { + if (propertyCatMap.get(betaAttributeName) == OM_PRIMITIVE_TYPE_STRING) + { String literalisedValue = literaliseStringProperty((String) betaValue); betaPpv.setPrimitiveValue(literalisedValue); - } else { + } + else + { betaPpv.setPrimitiveValue(betaValue); } } - if (alphaPpv != null && alphaValue != null && betaPpv != null && betaValue != null) { - + if (alphaPpv != null && alphaValue != null && betaPpv != null && betaValue != null) + { InstanceProperties matchProperties = new InstanceProperties(); matchProperties.setProperty(alphaAttributeName, alphaPpv); matchProperties.setProperty(betaAttributeName, betaPpv); @@ -1161,7 +1208,8 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam List entitiesWithBetaValue = propertyValueMap.get(betaAttributeName).get(betaValue); List expectedGUIDs = null; - switch (matchCriteria) { + switch (matchCriteria) + { case ALL: /* MatchCriteria.ALL ==> INTERSECTION */ expectedGUIDs = intersection(entitiesWithAlphaValue, entitiesWithBetaValue); @@ -1179,6 +1227,7 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam /* Invalid matchCriteria value passed */ return; } + int expectedEntityCount = expectedGUIDs.size(); @@ -1192,8 +1241,8 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam Map parameters = getParameters(entityDef.getGUID(), matchProperties, matchCriteria); long elapsedTime; - try { - + try + { long start = System.currentTimeMillis(); result = metadataCollection.findEntitiesByProperty(workPad.getLocalServerUserId(), entityDef.getGUID(), @@ -1208,22 +1257,24 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam pageSize); elapsedTime = System.currentTimeMillis() - start; } - catch (FunctionNotSupportedException exc) { + catch (FunctionNotSupportedException exc) + { /* * Because the above test only exercises one optional function (advanced regex support) * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FEBP, - ASSERTION_MSG_101FEBP + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FEBP, + assertionMsg_101FEBP + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -1236,14 +1287,15 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam return; } - catch(Exception exc) { + catch(Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ String methodName = "findEntitiesByProperty"; String operationDescription = "find entities of type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception( msg , exc ); @@ -1270,7 +1322,7 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam /* * If the original discovery query was not pageLimited then we should have been able to exactly predict the expected result. - * In addition the result size should be no more than a page. + * In addition, the result size should be no more than a page. */ boolean unlimited_case = !pageLimited && resultCount == expectedEntityCount; /* @@ -1282,9 +1334,9 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam boolean limited_small_case = pageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; boolean acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - String assertionMessage = MessageFormat.format(ASSERTION_MSG_5, resultCount, expectedEntityCount, parameters); + String assertionMessage = MessageFormat.format(assertionMsg_5, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_5, + assertion5, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId(), @@ -1297,9 +1349,11 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam * If there were any result, check that all expected entities were returned and (in the pageLimited case) that any * additional entities were valid results for the search. */ - if (resultCount > 0) { + if (resultCount > 0) + { List resultGUIDs = new ArrayList<>(); - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { resultGUIDs.add(entity.getGUID()); } @@ -1313,14 +1367,20 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam String alpha = ""; String beta = ""; - if (!pageLimited) { + if (!pageLimited) + { if (!resultGUIDs.containsAll(expectedGUIDs)) + { unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; - } else { // pageLimited, so need to allow for and verify hitherto unseen instances - - for (EntityDetail entity : result) { + } + } + else + { // pageLimited, so need to allow for and verify hitherto unseen instances - if (!(expectedGUIDs.contains(entity.getGUID()))) { + for (EntityDetail entity : result) + { + if (!(expectedGUIDs.contains(entity.getGUID()))) + { /* * This was an extra entity that we either did not expect or that we have not seen previously. * Check it is a valid result. @@ -1330,12 +1390,15 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam boolean alphaMatch = false; - if (entityProperties != null) { + if (entityProperties != null) + { InstancePropertyValue alphaIPValue = entityProperties.getPropertyValue(alphaAttributeName); - if (alphaIPValue != null) { + if (alphaIPValue != null) + { InstancePropertyCategory ipCategory = alphaIPValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { Object primitiveValue = alphaIPValue.valueAsObject(); alphaMatch = primitiveValue.equals(alphaValue); alpha = primitiveValue.toString(); @@ -1345,12 +1408,15 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam boolean betaMatch = false; - if (entityProperties != null) { + if (entityProperties != null) + { InstancePropertyValue betaIPValue = entityProperties.getPropertyValue(betaAttributeName); - if (betaIPValue != null) { + if (betaIPValue != null) + { InstancePropertyCategory ipCategory = betaIPValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { Object primitiveValue = betaIPValue.valueAsObject(); betaMatch = primitiveValue.equals(betaValue); beta = primitiveValue.toString(); @@ -1359,7 +1425,8 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam } - switch (matchCriteria) { + switch (matchCriteria) + { case ALL: if (!(alphaMatch && betaMatch)) unexpectedResult = "(" + alphaAttributeName + "='" + alpha + "', " + betaAttributeName + "='" + beta + "' for guid=" + entity.getGUID() + ")"; @@ -1380,19 +1447,19 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_6, unexpectedResult, parameters.toString()); + assertionMessage = MessageFormat.format(assertionMsg_6, unexpectedResult, parameters.toString()); assertCondition(unexpectedResult.equals("0"), - ASSERTION_6, + assertion6, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); } - } } - private enum RegexMatchType { + private enum RegexMatchType + { Exact, Prefix, Suffix, @@ -1401,7 +1468,8 @@ private enum RegexMatchType { - private void performSearchCriteriaTests(String attributeName, RegexMatchType matchType) throws Exception { + private void performSearchCriteriaTests(String attributeName, RegexMatchType matchType) throws Exception + { /* * The given attribute is tested for exact, prefix, suffix and contains matches for each of the values already seen. @@ -1410,7 +1478,8 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat Set possibleValues = propertyValueMap.get(attributeName).keySet(); - for (Object possibleValue : possibleValues) { + for (Object possibleValue : possibleValues) + { String stringValue = (String) possibleValue; String truncatedStringValue = null; @@ -1418,7 +1487,8 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat int stringValueLength; int truncatedLength; - switch (matchType) { + switch (matchType) + { case Exact: /* EXACT MATCH */ @@ -1427,7 +1497,8 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat case Prefix: /* PREFIX MATCH */ stringValueLength = stringValue.length(); - if (stringValueLength < 2) { + if (stringValueLength < 2) + { return; /* not a long enough string to perform a meaningful test */ } truncatedLength = (int) (Math.ceil(stringValueLength / 2.0)); @@ -1437,7 +1508,8 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat case Suffix: /* SUFFIX MATCH */ stringValueLength = stringValue.length(); - if (stringValueLength < 2) { + if (stringValueLength < 2) + { return; /* not a long enough string to perform a meaningful test */ } truncatedLength = (int) (Math.ceil(stringValueLength / 2.0)); @@ -1447,7 +1519,8 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat case Contains: /* CONTAINS MATCH */ stringValueLength = stringValue.length(); - if (stringValueLength < 3) { + if (stringValueLength < 3) + { return; /* not a long enough string to perform a meaningful test */ } truncatedLength = (int) (Math.floor(stringValueLength / 2.0)); @@ -1470,21 +1543,27 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat int expectedEntityCount = 0; List expectedGUIDs = new ArrayList<>(); Set propertyNamesSet = propertyValueMap.keySet(); - for (String propName : propertyNamesSet) { - if (propertyCatMap.get(propName) == OM_PRIMITIVE_TYPE_STRING) { + for (String propName : propertyNamesSet) + { + if (propertyCatMap.get(propName) == OM_PRIMITIVE_TYPE_STRING) + { Map> propValues = propertyValueMap.get(propName); Set propertyValuesSet = propValues.keySet(); Iterator propertyValuesSetIterator = propertyValuesSet.iterator(); - while (propertyValuesSetIterator.hasNext()) { + while (propertyValuesSetIterator.hasNext()) + { String knownStringValue = (String) (propertyValuesSetIterator.next()); - switch (matchType) { - + switch (matchType) + { case Exact: /* EXACT MATCH */ - if (stringValue.equals(knownStringValue)) { - for (String matchGUID : propValues.get(knownStringValue)) { - if (!expectedGUIDs.contains(matchGUID)) { + if (stringValue.equals(knownStringValue)) + { + for (String matchGUID : propValues.get(knownStringValue)) + { + if (!expectedGUIDs.contains(matchGUID)) + { expectedGUIDs.add(matchGUID); } } @@ -1492,9 +1571,12 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat break; case Prefix: /* PREFIX MATCH */ - if (knownStringValue.startsWith(truncatedStringValue)) { - for (String matchGUID : propValues.get(knownStringValue)) { - if (!expectedGUIDs.contains(matchGUID)) { + if (knownStringValue.startsWith(truncatedStringValue)) + { + for (String matchGUID : propValues.get(knownStringValue)) + { + if (!expectedGUIDs.contains(matchGUID)) + { expectedGUIDs.add(matchGUID); } } @@ -1502,9 +1584,12 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat break; case Suffix: /* SUFFIX MATCH */ - if (knownStringValue.endsWith(truncatedStringValue)) { - for (String matchGUID : propValues.get(knownStringValue)) { - if (!expectedGUIDs.contains(matchGUID)) { + if (knownStringValue.endsWith(truncatedStringValue)) + { + for (String matchGUID : propValues.get(knownStringValue)) + { + if (!expectedGUIDs.contains(matchGUID)) + { expectedGUIDs.add(matchGUID); } } @@ -1512,9 +1597,12 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat break; case Contains: /* CONTAINS MATCH */ - if (knownStringValue.contains(truncatedStringValue)) { - for (String matchGUID : propValues.get(knownStringValue)) { - if (!expectedGUIDs.contains(matchGUID)) { + if (knownStringValue.contains(truncatedStringValue)) + { + for (String matchGUID : propValues.get(knownStringValue)) + { + if (!expectedGUIDs.contains(matchGUID)) + { expectedGUIDs.add(matchGUID); } } @@ -1560,8 +1648,8 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FEBPV, - ASSERTION_MSG_101FEBPV + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FEBPV, + assertionMsg_101FEBPV + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_VALUE_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_VALUE_SEARCH.getRequirementId()); @@ -1589,7 +1677,7 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat String methodName = "findEntitiesByPropertyValue"; String operationDescription = "find entities using repository helper regex for type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); @@ -1613,9 +1701,9 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat boolean limited_small_case = pageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; boolean acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - String assertionMessage = MessageFormat.format(ASSERTION_MSG_7, resultCount, expectedEntityCount, parameters); + String assertionMessage = MessageFormat.format(assertionMsg_7, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_7, + assertion7, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_VALUE_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_VALUE_SEARCH.getRequirementId(), @@ -1627,10 +1715,12 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat * If there were any results, check that all expected entities were returned and (in the pageLimited case) that any * additional entities were valid results for the search. */ - if (resultCount > 0) { + if (resultCount > 0) + { List resultGUIDs = new ArrayList<>(); - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { resultGUIDs.add(entity.getGUID()); } @@ -1643,54 +1733,70 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat String unexpectedResult = "0"; - if (!pageLimited) { + if (!pageLimited) + { if (!resultGUIDs.containsAll(expectedGUIDs)) + { unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; - } else { // pageLimited, so need to allow for and verify hitherto unseen instances + } + } + else + { // pageLimited, so need to allow for and verify hitherto unseen instances - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { - if (!(expectedGUIDs.contains(entity.getGUID()))) { + if (!(expectedGUIDs.contains(entity.getGUID()))) + { /* * This was an extra entity that we either did not expect or that we have not seen previously. * Check it is a valid result. It can have any string attribute with the same value as strValue. */ boolean validEntity = false; InstanceProperties entityProperties = entity.getProperties(); - if (entityProperties != null) { + if (entityProperties != null) + { Set entityPropertyNames = entityProperties.getInstanceProperties().keySet(); - for (String propertyName : entityPropertyNames) { + for (String propertyName : entityPropertyNames) + { InstancePropertyValue ipValue = entityProperties.getPropertyValue(attributeName); - if (ipValue != null) { + if (ipValue != null) + { InstancePropertyCategory ipCategory = ipValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { PrimitivePropertyValue ppv = (PrimitivePropertyValue) ipValue; PrimitiveDefCategory pdCat = ppv.getPrimitiveDefCategory(); - if (pdCat == OM_PRIMITIVE_TYPE_STRING) { + if (pdCat == OM_PRIMITIVE_TYPE_STRING) + { String propertyValueAsString = (String) (ppv.getPrimitiveValue()); switch (matchType) { case Exact: /* EXACT MATCH */ - if (propertyValueAsString.equals(stringValue)) { + if (propertyValueAsString.equals(stringValue)) + { validEntity = true; } break; case Prefix: /* PREFIX MATCH */ - if (propertyValueAsString.startsWith(truncatedStringValue)) { + if (propertyValueAsString.startsWith(truncatedStringValue)) + { validEntity = true; } break; case Suffix: /* SUFFIX MATCH */ - if (propertyValueAsString.endsWith(truncatedStringValue)) { + if (propertyValueAsString.endsWith(truncatedStringValue)) + { validEntity = true; } break; case Contains: /* CONTAINS MATCH */ - if (propertyValueAsString.contains(truncatedStringValue)) { + if (propertyValueAsString.contains(truncatedStringValue)) + { validEntity = true; } break; @@ -1702,14 +1808,16 @@ private void performSearchCriteriaTests(String attributeName, RegexMatchType mat } } if (!validEntity) + { unexpectedResult = "(guid=" + entity.getGUID() + ")"; + } } } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_8, unexpectedResult, parameters.toString()); + assertionMessage = MessageFormat.format(assertionMsg_8, unexpectedResult, parameters.toString()); assertCondition(unexpectedResult.equals("0"), - ASSERTION_8, + assertion8, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_VALUE_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_VALUE_SEARCH.getRequirementId()); @@ -1756,9 +1864,8 @@ public InstanceProperties literaliseMatchProperties(String userId, TypeDef typeD return matchProperties; - try { - - + try + { /* * Clone the match properties to a new IP object, iterate over the matchProperties and for any that are primitive string type call the repo helper and set the literalised value in the cloned properties object */ @@ -1768,16 +1875,20 @@ public InstanceProperties literaliseMatchProperties(String userId, TypeDef typeD Iterator propertyNames = matchProperties.getPropertyNames(); - if (propertyNames != null) { - while (propertyNames.hasNext()) { + if (propertyNames != null) + { + while (propertyNames.hasNext()) + { String propertyName = propertyNames.next(); InstancePropertyValue instancePropertyValue = matchProperties.getPropertyValue(propertyName); InstancePropertyCategory ipCat = instancePropertyValue.getInstancePropertyCategory(); - if (ipCat == InstancePropertyCategory.PRIMITIVE) { + if (ipCat == InstancePropertyCategory.PRIMITIVE) + { PrimitivePropertyValue ppv = (PrimitivePropertyValue) instancePropertyValue; PrimitiveDefCategory pdCat = ppv.getPrimitiveDefCategory(); - if (pdCat == OM_PRIMITIVE_TYPE_STRING) { + if (pdCat == OM_PRIMITIVE_TYPE_STRING) + { PrimitivePropertyValue newPpv = new PrimitivePropertyValue(ppv); // Literalise the string String currentValue = (String) ppv.getPrimitiveValue(); @@ -1793,7 +1904,8 @@ public InstanceProperties literaliseMatchProperties(String userId, TypeDef typeD return literalisedInstanceProperties; } - catch (Exception e) { + catch (Exception e) + { return null; // This should force an InvalidParameterException from the MDC under test. } @@ -1803,7 +1915,8 @@ public InstanceProperties literaliseMatchProperties(String userId, TypeDef typeD /* * Return the union of the two lists */ - private List union(List l1, List l2) { + private List union(List l1, List l2) + { List l1Copy; List l2Copy; if (l1 != null) @@ -1822,7 +1935,8 @@ private List union(List l1, List l2) { /* * Return the intersection of the two lists */ - private List intersection(List l1, List l2) { + private List intersection(List l1, List l2) + { if (l1 == null || l1.isEmpty() || l2 == null || l2.isEmpty()) return new ArrayList<>(); List li = new ArrayList<>(); @@ -1838,16 +1952,20 @@ private List intersection(List l1, List l2) { * Return the difference of the two lists. This means any member in the * first list that is NOT in the second list. */ - private List diff(List lu, List ld) { + private List diff(List lu, List ld) + { if (lu == null) return new ArrayList<>(); List comp = new ArrayList<>(lu); - if (ld != null) { - for (String s : ld) { + if (ld != null) + { + for (String s : ld) + { comp.remove(s); } } + return comp; } @@ -1913,7 +2031,8 @@ private void performTypeFilteringTests(String attributeName) throws Exception /* * Perform a search using the first discovered value for the property */ - if (possibleValueIterator.hasNext()) { + if (possibleValueIterator.hasNext()) + { Object value = possibleValueIterator.next(); @@ -1921,10 +2040,13 @@ private void performTypeFilteringTests(String attributeName) throws Exception PrimitivePropertyValue ppv = new PrimitivePropertyValue(); ppv.setPrimitiveDefCategory(propertyCatMap.get(attributeName)); - if (propertyCatMap.get(attributeName) == OM_PRIMITIVE_TYPE_STRING) { + if (propertyCatMap.get(attributeName) == OM_PRIMITIVE_TYPE_STRING) + { String literalisedValue = literaliseStringProperty((String) value); ppv.setPrimitiveValue(literalisedValue); - } else { + } + else + { ppv.setPrimitiveValue(value); } @@ -1939,7 +2061,8 @@ private void performTypeFilteringTests(String attributeName) throws Exception */ List result; - try { + try + { result = metadataCollection.findEntitiesByProperty(workPad.getLocalServerUserId(), null, matchProperties, @@ -1960,15 +2083,16 @@ private void performTypeFilteringTests(String attributeName) throws Exception * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FEBP, - ASSERTION_MSG_101FEBP + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FEBP, + assertionMsg_101FEBP + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -1990,7 +2114,7 @@ private void performTypeFilteringTests(String attributeName) throws Exception String methodName = "findEntitiesByProperty"; String operationDescription = "find entities with no type filter "; Map parameters = getParameters(null, matchProperties, MatchCriteria.ALL); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception( msg , exc ); @@ -1999,9 +2123,10 @@ private void performTypeFilteringTests(String attributeName) throws Exception List expectedGUIDs; - if (result != null) { - - if (result.size() == pageSize) { + if (result != null) + { + if (result.size() == pageSize) + { /* * Need to note whether this wild search hit the page limit - if so then there may be more * entities that we have not seen; pull the expected list together (below) and the expected @@ -2016,16 +2141,19 @@ private void performTypeFilteringTests(String attributeName) throws Exception String entityTypeName = entityDef.getName(); List countableTypeNames = new ArrayList<>(); List countableSubTypeNames = repositoryConformanceWorkPad.getEntitySubTypes(entityTypeName); - if (countableSubTypeNames != null) { + if (countableSubTypeNames != null) + { countableTypeNames.addAll(countableSubTypeNames); } countableTypeNames.add(entityTypeName); expectedGUIDs = new ArrayList<>(); - for (EntityDetail entityDetail : result) { + for (EntityDetail entityDetail : result) + { String typeName = entityDetail.getType().getTypeDefName(); - if (countableTypeNames.contains(typeName)) { + if (countableTypeNames.contains(typeName)) + { expectedGUIDs.add(entityDetail.getGUID()); } } @@ -2040,7 +2168,8 @@ private void performTypeFilteringTests(String attributeName) throws Exception Map parameters = getParameters(entityDef.getGUID(), matchProperties, MatchCriteria.ALL); long elapsedTime; - try { + try + { long start = System.currentTimeMillis(); result = metadataCollection.findEntitiesByProperty(workPad.getLocalServerUserId(), @@ -2064,15 +2193,16 @@ private void performTypeFilteringTests(String attributeName) throws Exception * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FEBP, - ASSERTION_MSG_101FEBP + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FEBP, + assertionMsg_101FEBP + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -2093,7 +2223,7 @@ private void performTypeFilteringTests(String attributeName) throws Exception String methodName = "findEntitiesByProperty"; String operationDescription = "find entities of type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception( msg , exc ); @@ -2118,9 +2248,9 @@ private void performTypeFilteringTests(String attributeName) throws Exception boolean limited_small_case = wildSearchPageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; boolean acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - String assertionMessage = MessageFormat.format(ASSERTION_MSG_9, resultCount, expectedEntityCount, parameters); + String assertionMessage = MessageFormat.format(assertionMsg_9, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_9, + assertion9, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId(), @@ -2132,10 +2262,11 @@ private void performTypeFilteringTests(String attributeName) throws Exception * If there were any result, check that all expected entities were returned and (in the pageLimited case) that any * additional entities were valid results for the search. */ - if (resultCount > 0) { - + if (resultCount > 0) + { List resultGUIDs = new ArrayList<>(); - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { resultGUIDs.add(entity.getGUID()); } @@ -2148,27 +2279,35 @@ private void performTypeFilteringTests(String attributeName) throws Exception String unexpectedResult = "0"; - if (!pageLimited) { - + if (!pageLimited) + { if (!resultGUIDs.containsAll(expectedGUIDs)) + { unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; + } - } else { // pageLimited, so need to allow for and verify hitherto unseen instances + } + else + { // pageLimited, so need to allow for and verify hitherto unseen instances - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { - if (!(expectedGUIDs.contains(entity.getGUID()))) { + if (!(expectedGUIDs.contains(entity.getGUID()))) + { /* * This was an extra entity that we either did not expect or that we have not seen previously. * Check it is a valid result. */ InstanceProperties entityProperties = entity.getProperties(); - if (entityProperties != null) { + if (entityProperties != null) + { InstancePropertyValue ipValue = entityProperties.getPropertyValue(attributeName); - if (ipValue != null) { + if (ipValue != null) + { InstancePropertyCategory ipCategory = ipValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { - + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { Object primitiveValue = ipValue.valueAsObject(); /* @@ -2179,8 +2318,9 @@ private void performTypeFilteringTests(String attributeName) throws Exception */ if (!primitiveValue.equals(value)) + { unexpectedResult = "('" + primitiveValue.toString() + "' for guid=" + entity.getGUID() + ")"; - + } } } } @@ -2188,9 +2328,9 @@ private void performTypeFilteringTests(String attributeName) throws Exception } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_10, unexpectedResult, parameters.toString()); + assertionMessage = MessageFormat.format(assertionMsg_10, unexpectedResult, parameters.toString()); assertCondition(unexpectedResult.equals("0"), - ASSERTION_10, + assertion10, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); @@ -2215,16 +2355,16 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat Set possibleValues = propertyValueMap.get(attributeName).keySet(); - for (Object possibleValue : possibleValues) { - + for (Object possibleValue : possibleValues) + { String stringValue = (String) possibleValue; String truncatedStringValue = null; String regexValue = null; int stringValueLength; int truncatedLength; - switch (matchType) { - + switch (matchType) + { case Exact: /* EXACT MATCH */ stringValue = escapeRegexSpecials(stringValue); @@ -2233,7 +2373,8 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat case Prefix: /* PREFIX MATCH */ stringValueLength = stringValue.length(); - if (stringValueLength < 2) { + if (stringValueLength < 2) + { return; /* not a long enough string to perform a meaningful test */ } truncatedLength = (int) (Math.ceil(stringValueLength / 2.0)); @@ -2244,7 +2385,8 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat case Suffix: /* SUFFIX MATCH */ stringValueLength = stringValue.length(); - if (stringValueLength < 2) { + if (stringValueLength < 2) + { return; /* not a long enough string to perform a meaningful test */ } truncatedLength = (int) (Math.ceil(stringValueLength / 2.0)); @@ -2255,7 +2397,8 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat case Contains: /* CONTAINS MATCH */ stringValueLength = stringValue.length(); - if (stringValueLength < 3) { + if (stringValueLength < 3) + { return; /* not a long enough string to perform a meaningful test */ } truncatedLength = (int) (Math.floor(stringValueLength / 2.0)); @@ -2279,20 +2422,25 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat int expectedEntityCount = 0; List expectedGUIDs = new ArrayList<>(); Set propertyNamesSet = propertyValueMap.keySet(); - for (String propName : propertyNamesSet) { - if (propertyCatMap.get(propName) == OM_PRIMITIVE_TYPE_STRING) { + for (String propName : propertyNamesSet) + { + if (propertyCatMap.get(propName) == OM_PRIMITIVE_TYPE_STRING) + { Map> propValues = propertyValueMap.get(propName); Set propertyValuesSet = propValues.keySet(); for (Object o : propertyValuesSet) { String knownStringValue = (String) o; - switch (matchType) { - + switch (matchType) + { case Exact: /* EXACT MATCH */ - if (knownStringValue.matches(stringValue)) { - for (String matchGUID : propValues.get(knownStringValue)) { - if (!expectedGUIDs.contains(matchGUID)) { + if (knownStringValue.matches(stringValue)) + { + for (String matchGUID : propValues.get(knownStringValue)) + { + if (!expectedGUIDs.contains(matchGUID)) + { expectedGUIDs.add(matchGUID); } } @@ -2300,9 +2448,12 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat break; case Prefix: /* PREFIX MATCH */ - if (knownStringValue.matches(truncatedStringValue + ".*")) { - for (String matchGUID : propValues.get(knownStringValue)) { - if (!expectedGUIDs.contains(matchGUID)) { + if (knownStringValue.matches(truncatedStringValue + ".*")) + { + for (String matchGUID : propValues.get(knownStringValue)) + { + if (!expectedGUIDs.contains(matchGUID)) + { expectedGUIDs.add(matchGUID); } } @@ -2310,9 +2461,12 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat break; case Suffix: /* SUFFIX MATCH */ - if (knownStringValue.matches(".*" + truncatedStringValue)) { - for (String matchGUID : propValues.get(knownStringValue)) { - if (!expectedGUIDs.contains(matchGUID)) { + if (knownStringValue.matches(".*" + truncatedStringValue)) + { + for (String matchGUID : propValues.get(knownStringValue)) + { + if (!expectedGUIDs.contains(matchGUID)) + { expectedGUIDs.add(matchGUID); } } @@ -2320,9 +2474,12 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat break; case Contains: /* CONTAINS MATCH */ - if (knownStringValue.matches(".*" + truncatedStringValue + ".*")) { - for (String matchGUID : propValues.get(knownStringValue)) { - if (!expectedGUIDs.contains(matchGUID)) { + if (knownStringValue.matches(".*" + truncatedStringValue + ".*")) + { + for (String matchGUID : propValues.get(knownStringValue)) + { + if (!expectedGUIDs.contains(matchGUID)) + { expectedGUIDs.add(matchGUID); } } @@ -2368,15 +2525,16 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FEBPVGEN, - ASSERTION_MSG_101FEBPVGEN + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FEBPVGEN, + assertionMsg_101FEBPVGEN + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_VALUE_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_VALUE_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -2397,7 +2555,7 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat String methodName = "findEntitiesByPropertyValue"; String operationDescription = "find entities using general regex for type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); @@ -2410,7 +2568,7 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat int resultCount = result == null ? 0 : result.size(); /* * If the original discovery query was not pageLimited then we should have been able to exactly predict the expected result. - * In addition the result size should be no more than a page. + * In addition, the result size should be no more than a page. */ boolean unlimited_case = !pageLimited && resultCount == expectedEntityCount; /* @@ -2422,9 +2580,9 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat boolean limited_small_case = pageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; boolean acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - String assertionMessage = MessageFormat.format(ASSERTION_MSG_11, resultCount, expectedEntityCount, parameters); + String assertionMessage = MessageFormat.format(assertionMsg_11, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_11, + assertion11, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_VALUE_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_VALUE_SEARCH.getRequirementId(), @@ -2436,10 +2594,12 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat * If there were any results, check that all expected entities were returned and (in the pageLimited case) that any * additional entities were valid results for the search. */ - if (resultCount > 0) { + if (resultCount > 0) + { List resultGUIDs = new ArrayList<>(); - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { resultGUIDs.add(entity.getGUID()); } @@ -2452,54 +2612,70 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat String unexpectedResult = "0"; - if (!pageLimited) { + if (!pageLimited) + { if (!resultGUIDs.containsAll(expectedGUIDs)) + { unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; - } else { // pageLimited, so need to allow for and verify hitherto unseen instances - - for (EntityDetail entity : result) { + } + } + else + { // pageLimited, so need to allow for and verify hitherto unseen instances - if (!(expectedGUIDs.contains(entity.getGUID()))) { + for (EntityDetail entity : result) + { + if (!(expectedGUIDs.contains(entity.getGUID()))) + { /* * This was an extra entity that we either did not expect or that we have not seen previously. * Check it is a valid result. It can have any string attribute with the same value as strValue. */ boolean validEntity = false; InstanceProperties entityProperties = entity.getProperties(); - if (entityProperties != null) { + if (entityProperties != null) + { Set entityPropertyNames = entityProperties.getInstanceProperties().keySet(); - for (String propertyName : entityPropertyNames) { + for (String propertyName : entityPropertyNames) + { InstancePropertyValue ipValue = entityProperties.getPropertyValue(attributeName); - if (ipValue != null) { + if (ipValue != null) + { InstancePropertyCategory ipCategory = ipValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { PrimitivePropertyValue ppv = (PrimitivePropertyValue) ipValue; PrimitiveDefCategory pdCat = ppv.getPrimitiveDefCategory(); - if (pdCat == OM_PRIMITIVE_TYPE_STRING) { + if (pdCat == OM_PRIMITIVE_TYPE_STRING) + { String propertyValueAsString = (String) (ppv.getPrimitiveValue()); - switch (matchType) { + switch (matchType) + { case Exact: /* EXACT MATCH */ - if (propertyValueAsString.matches(stringValue)) { + if (propertyValueAsString.matches(stringValue)) + { validEntity = true; } break; case Prefix: /* PREFIX MATCH */ - if (propertyValueAsString.matches(truncatedStringValue + ".*")) { + if (propertyValueAsString.matches(truncatedStringValue + ".*")) + { validEntity = true; } break; case Suffix: /* SUFFIX MATCH */ - if (propertyValueAsString.matches(".*" + truncatedStringValue)) { + if (propertyValueAsString.matches(".*" + truncatedStringValue)) + { validEntity = true; } break; case Contains: /* CONTAINS MATCH */ - if (propertyValueAsString.matches(".*" + truncatedStringValue + ".*")) { + if (propertyValueAsString.matches(".*" + truncatedStringValue + ".*")) + { validEntity = true; } break; @@ -2511,14 +2687,16 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat } } if (!validEntity) + { unexpectedResult = "(guid=" + entity.getGUID() + ")"; + } } } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_12, unexpectedResult, parameters); + assertionMessage = MessageFormat.format(assertionMsg_12, unexpectedResult, parameters); assertCondition(unexpectedResult.equals("0"), - ASSERTION_12, + assertion12, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_VALUE_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_VALUE_SEARCH.getRequirementId()); @@ -2543,7 +2721,6 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat try { - long start = System.currentTimeMillis(); result = metadataCollection.findEntitiesByProperty(workPad.getLocalServerUserId(), entityDef.getGUID(), @@ -2558,23 +2735,24 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat pageSize); elapsedTime = System.currentTimeMillis() - start; } - catch (FunctionNotSupportedException exc) { - + catch (FunctionNotSupportedException exc) + { /* * Because the above test only exercises one optional function (advanced regex support) * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FEBPGEN, - ASSERTION_MSG_101FEBPGEN + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FEBPGEN, + assertionMsg_101FEBPGEN + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_PROPERTY_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -2595,10 +2773,9 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat String methodName = "findEntitiesByProperty"; String operationDescription = "find entities using general regex for type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -2608,7 +2785,7 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat resultCount = result == null ? 0 : result.size(); /* * If the original discovery query was not pageLimited then we should have been able to exactly predict the expected result. - * In addition the result size should be no more than a page. + * In addition, the result size should be no more than a page. */ unlimited_case = !pageLimited && resultCount == expectedEntityCount; /* @@ -2620,9 +2797,9 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat limited_small_case = pageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - assertionMessage = MessageFormat.format(ASSERTION_MSG_13, resultCount, expectedEntityCount, parameters); + assertionMessage = MessageFormat.format(assertionMsg_13, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_13, + assertion13, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_PROPERTY_SEARCH.getRequirementId(), @@ -2634,10 +2811,11 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat * If there were any results, check that all expected entities were returned and (in the pageLimited case) that any * additional entities were valid results for the search. */ - if (resultCount > 0) { - + if (resultCount > 0) + { List resultGUIDs = new ArrayList<>(); - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { resultGUIDs.add(entity.getGUID()); } @@ -2655,49 +2833,60 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; } else { // pageLimited, so need to allow for and verify hitherto unseen instances - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { - if (!(expectedGUIDs.contains(entity.getGUID()))) { + if (!(expectedGUIDs.contains(entity.getGUID()))) + { /* * This was an extra entity that we either did not expect or that we have not seen previously. * Check it is a valid result. It can have any string attribute with the same value as strValue. */ boolean validEntity = false; InstanceProperties entityProperties = entity.getProperties(); - if (entityProperties != null) { + if (entityProperties != null) + { Set entityPropertyNames = entityProperties.getInstanceProperties().keySet(); - for (String propertyName : entityPropertyNames) { + for (String propertyName : entityPropertyNames) + { InstancePropertyValue ipValue = entityProperties.getPropertyValue(attributeName); if (ipValue != null) { InstancePropertyCategory ipCategory = ipValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { PrimitivePropertyValue ppv = (PrimitivePropertyValue) ipValue; PrimitiveDefCategory pdCat = ppv.getPrimitiveDefCategory(); - if (pdCat == OM_PRIMITIVE_TYPE_STRING) { + if (pdCat == OM_PRIMITIVE_TYPE_STRING) + { String propertyValueAsString = (String) (ppv.getPrimitiveValue()); - switch (matchType) { + switch (matchType) + { case Exact: /* EXACT MATCH */ - if (propertyValueAsString.matches(stringValue)) { + if (propertyValueAsString.matches(stringValue)) + { validEntity = true; } break; case Prefix: /* PREFIX MATCH */ - if (propertyValueAsString.matches(truncatedStringValue + ".*")) { + if (propertyValueAsString.matches(truncatedStringValue + ".*")) + { validEntity = true; } break; case Suffix: /* SUFFIX MATCH */ - if (propertyValueAsString.matches(".*" + truncatedStringValue)) { + if (propertyValueAsString.matches(".*" + truncatedStringValue)) + { validEntity = true; } break; case Contains: /* CONTAINS MATCH */ - if (propertyValueAsString.matches(".*" + truncatedStringValue + ".*")) { + if (propertyValueAsString.matches(".*" + truncatedStringValue + ".*")) + { validEntity = true; } break; @@ -2709,14 +2898,16 @@ private void performAdvancedSearchTests(String attributeName, RegexMatchType mat } } if (!validEntity) + { unexpectedResult = "(guid=" + entity.getGUID() + ")"; + } } } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_14, unexpectedResult, parameters); + assertionMessage = MessageFormat.format(assertionMsg_14, unexpectedResult, parameters); assertCondition(unexpectedResult.equals("0"), - ASSERTION_14, + assertion14, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_ADVANCED_PROPERTY_SEARCH.getRequirementId()); @@ -2762,12 +2953,14 @@ private Map getParameters(String entityTypeGuid, * This is so that the regex (yet to be constructed) will be certain not to contain any characters that * could render the regex invalid. */ - private String escapeRegexSpecials(String inputString) { + private String escapeRegexSpecials(String inputString) + { StringBuilder outputStringBldr = new StringBuilder(); // Process chars - for (int i = 0; i < inputString.length(); i++) { + for (int i = 0; i < inputString.length(); i++) + { Character c = inputString.charAt(i); /* * No need to escape a '-' char as it is only significant if inside '[]' brackets, and these will be escaped, @@ -2861,15 +3054,16 @@ private String escapeRegexSpecials(String inputString) { * This should always deliver a TRUE result. */ - private void performSearchPropertiesTestForAttribute(String attributeName) throws Exception { - + private void performSearchPropertiesTestForAttribute(String attributeName) throws Exception + { Set possibleValues = propertyValueMap.get(attributeName).keySet(); Iterator possibleValueIterator = possibleValues.iterator(); /* * Perform a search using the first discovered value for the property */ - if (possibleValueIterator.hasNext()) { + if (possibleValueIterator.hasNext()) + { Object value = possibleValueIterator.next(); @@ -2976,22 +3170,24 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw pageSize); elapsedTime = System.currentTimeMillis() - start; } - catch (FunctionNotSupportedException exc) { + catch (FunctionNotSupportedException exc) + { /* * Because the above test only exercises one optional function (findEntities using SearchProperties) * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FE, - ASSERTION_MSG_101FE + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FE, + assertionMsg_101FE + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -3004,14 +3200,15 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw return; } - catch(Exception exc) { + catch(Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ String methodName = "findEntities"; String operationDescription = "find entities of type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception( msg , exc ); @@ -3049,7 +3246,7 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw * * In contrast, if the original result set returned a full page size then the testcase needs to * exercise a looser result matching policy. This case (of incomplete knowledge) can be summarised in - * psudo code as: + * pseudocode as: * * if original result size == page size then: * search size < expected size => fail @@ -3080,7 +3277,7 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw int resultCount = result == null ? 0 : result.size(); /* * If the original discovery query was not pageLimited then we should have been able to exactly predict the expected result. - * In addition the result size should be no more than a page. + * In addition, the result size should be no more than a page. */ boolean unlimited_case = !pageLimited && resultCount == expectedEntityCount; /* @@ -3092,9 +3289,9 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw boolean limited_small_case = pageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; boolean acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - String assertionMessage = MessageFormat.format(ASSERTION_MSG_103, resultCount, expectedEntityCount, parameters); + String assertionMessage = MessageFormat.format(assertionMsg_103, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_103, + assertion103, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getRequirementId(), @@ -3122,27 +3319,34 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw String unexpectedResult = "0"; - if (!pageLimited) { + if (!pageLimited) + { if (!resultGUIDs.containsAll(expectedGUIDs)) unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; - } else { // pageLimited, so need to allow for and verify hitherto unseen instances + } + else + { // pageLimited, so need to allow for and verify hitherto unseen instances - for (EntityDetail entity : result) { + for (EntityDetail entity : result) + { - if (!(expectedGUIDs.contains(entity.getGUID()))) { + if (!(expectedGUIDs.contains(entity.getGUID()))) + { /* * This was an extra entity that we either did not expect or that we have not seen previously. * Check it is a valid result. */ InstanceProperties entityProperties = entity.getProperties(); - if (entityProperties != null) { + if (entityProperties != null) + { InstancePropertyValue ipValue = entityProperties.getPropertyValue(attributeName); - if (ipValue != null) { + if (ipValue != null) + { InstancePropertyCategory ipCategory = ipValue.getInstancePropertyCategory(); - if (ipCategory == InstancePropertyCategory.PRIMITIVE) { - + if (ipCategory == InstancePropertyCategory.PRIMITIVE) + { Object primitiveValue = ipValue.valueAsObject(); /* @@ -3150,8 +3354,8 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw * This is because, even for strings, we used an exact match literalised property value * and match criteria was ALL - so an entity with an unequal property is not a valid result. */ - - if (!primitiveValue.equals(value)) { + if (!primitiveValue.equals(value)) + { unexpectedResult = "('" + primitiveValue.toString() + "' for guid=" + entity.getGUID() + ")"; } @@ -3162,9 +3366,9 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_104, unexpectedResult, parameters.toString()); + assertionMessage = MessageFormat.format(assertionMsg_104, unexpectedResult, parameters.toString()); assertCondition(unexpectedResult.equals("0"), - ASSERTION_104, + assertion104, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getRequirementId()); @@ -3185,13 +3389,13 @@ private void performSearchPropertiesTestForAttribute(String attributeName) throw */ private void performNonPropertySearchTests() throws Exception { - performfindEntitiesByPropertyWithNullParams(); + performFindEntitiesByPropertyWithNullParams(); - performfindEntitiesWithNullParams(); + performFindEntitiesWithNullParams(); } /* - * performfindEntitiesByPropertyWithNullParams + * performFindEntitiesByPropertyWithNullParams * * This test calls findEntitiesByProperty and findEntities with no match properties or match criteria. * Although this is similar to the discovery test at the start of this testcase, it differs by passing @@ -3200,7 +3404,7 @@ private void performNonPropertySearchTests() throws Exception * * The expected return set should be ANY of the instances created for this type. */ - private void performfindEntitiesByPropertyWithNullParams() throws Exception + private void performFindEntitiesByPropertyWithNullParams() throws Exception { /* @@ -3236,22 +3440,24 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception pageSize); elapsedTime = System.currentTimeMillis() - start; } - catch (FunctionNotSupportedException exc) { + catch (FunctionNotSupportedException exc) + { /* * Because the above test only exercises one optional function (findEntities using SearchProperties) * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FEBP, - ASSERTION_MSG_101FEBP + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FEBP, + assertionMsg_101FEBP + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -3272,7 +3478,7 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception String methodName = "findEntitiesByProperty"; String operationDescription = "find entities of type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); @@ -3300,7 +3506,7 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception * The original result set is filtered to generate the result we expect to get from a narrower * search. If the original result set returned less than the page size then we know the full * set of instances in the repository and hence completely know each narrower expected set. - * This case (of complete knowledge) can be summarised in pseudo code as: + * This case (of complete knowledge) can be summarised in pseudocode as: * if original result size < page size then: * result size < expected size => fail * result size == expected size => if search contains all expected => pass @@ -3310,7 +3516,7 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception * * In contrast, if the original result set returned a full page size then the testcase needs to * exercise a looser result matching policy. This case (of incomplete knowledge) can be summarised in - * psudo code as: + * pseudocode as: * * if original result size == page size then: * search size < expected size => fail @@ -3341,7 +3547,7 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception int resultCount = result == null ? 0 : result.size(); /* * If the original discovery query was not pageLimited then we should have been able to exactly predict the expected result. - * In addition the result size should be no more than a page. + * In addition, the result size should be no more than a page. */ boolean unlimited_case = !pageLimited && resultCount == expectedEntityCount; /* @@ -3353,9 +3559,9 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception boolean limited_small_case = pageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; boolean acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - String assertionMessage = MessageFormat.format(ASSERTION_MSG_105, resultCount, expectedEntityCount, parameters); + String assertionMessage = MessageFormat.format(assertionMsg_105, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_105, + assertion105, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId(), @@ -3387,10 +3593,10 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception if (!pageLimited) { - if (!resultGUIDs.containsAll(expectedGUIDs)) + { unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; - + } } else { // pageLimited, so need to allow for and verify hitherto unseen instances @@ -3422,9 +3628,9 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_106, unexpectedResult, parameters.toString()); + assertionMessage = MessageFormat.format(assertionMsg_106, unexpectedResult, parameters.toString()); assertCondition(unexpectedResult.equals("0"), - ASSERTION_106, + assertion106, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_PROPERTY_SEARCH.getRequirementId()); @@ -3434,7 +3640,7 @@ private void performfindEntitiesByPropertyWithNullParams() throws Exception - private void performfindEntitiesWithNullParams() throws Exception + private void performFindEntitiesWithNullParams() throws Exception { /* @@ -3470,22 +3676,24 @@ private void performfindEntitiesWithNullParams() throws Exception pageSize); elapsedTime = System.currentTimeMillis() - start; } - catch (FunctionNotSupportedException exc) { + catch (FunctionNotSupportedException exc) + { /* * Because the above test only exercises one optional function (findEntities using SearchProperties) * we can assert that it is that function that is not supported. */ - super.addNotSupportedAssertion(ASSERTION_101FE, - ASSERTION_MSG_101FE + exc.getMessage(), + super.addNotSupportedAssertion(assertion101FE, + assertionMsg_101FE + exc.getMessage(), RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getRequirementId()); return; } - catch (RepositoryTimeoutException exc) { + catch (RepositoryTimeoutException exc) + { /* * Such a query may simply timeout, in which case we do not have enough information @@ -3506,7 +3714,7 @@ private void performfindEntitiesWithNullParams() throws Exception String methodName = "findEntities"; String operationDescription = "find entities of type " + entityDef.getName(); - String msg = this.buildExceptionMessage(TEST_CASE_ID, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); @@ -3575,7 +3783,7 @@ private void performfindEntitiesWithNullParams() throws Exception int resultCount = result == null ? 0 : result.size(); /* * If the original discovery query was not pageLimited then we should have been able to exactly predict the expected result. - * In addition the result size should be no more than a page. + * In addition, the result size should be no more than a page. */ boolean unlimited_case = !pageLimited && resultCount == expectedEntityCount; /* @@ -3587,9 +3795,9 @@ private void performfindEntitiesWithNullParams() throws Exception boolean limited_small_case = pageLimited && expectedEntityCount < pageSize && resultCount >= expectedEntityCount; boolean acceptable_result_size = unlimited_case || limited_large_case || limited_small_case; - String assertionMessage = MessageFormat.format(ASSERTION_MSG_107, resultCount, expectedEntityCount, parameters); + String assertionMessage = MessageFormat.format(assertionMsg_107, resultCount, expectedEntityCount, parameters); assertCondition((acceptable_result_size), - ASSERTION_107, + assertion107, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getRequirementId(), @@ -3603,14 +3811,12 @@ private void performfindEntitiesWithNullParams() throws Exception */ if (resultCount > 0) { - List resultGUIDs = new ArrayList<>(); for (EntityDetail entity : result) { resultGUIDs.add(entity.getGUID()); } - /* * Here again, we need to be sensitive to whether there are (or may be) more entities than the page limit. * If the original search hit the limit then we may legitimately receive additional instances in the results @@ -3621,10 +3827,10 @@ private void performfindEntitiesWithNullParams() throws Exception if (!pageLimited) { - if (!resultGUIDs.containsAll(expectedGUIDs)) + { unexpectedResult = RESULTS_MISSING_EXPECTED_GUIDS; - + } } else { // pageLimited, so need to allow for and verify hitherto unseen instances @@ -3656,9 +3862,9 @@ private void performfindEntitiesWithNullParams() throws Exception } } - assertionMessage = MessageFormat.format(ASSERTION_MSG_108, unexpectedResult, parameters.toString()); + assertionMessage = MessageFormat.format(assertionMsg_108, unexpectedResult, parameters.toString()); assertCondition(unexpectedResult.equals("0"), - ASSERTION_108, + assertion108, assertionMessage, RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_CONDITION_SEARCH.getRequirementId()); diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedReferenceCopyClassificationLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedReferenceCopyClassificationLifecycle.java index d9682892707..75f8ac31153 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedReferenceCopyClassificationLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedReferenceCopyClassificationLifecycle.java @@ -2,6 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; @@ -96,7 +97,7 @@ protected void run() throws Exception * on the test by setting the discovered property to disabled and returning. */ - EntityDetail newEntity; + EntityDetail newEntity; InstanceProperties instProps = null; try @@ -114,7 +115,6 @@ protected void run() throws Exception * thereby getting into the connector-logic beyond the property validation. It also creates an * entity that is logically complete - versus an instance with just the locally-defined properties. */ - instProps = super.getAllPropertiesForInstance(workPad.getLocalServerUserId(), testEntityDef); long start = System.currentTimeMillis(); @@ -134,12 +134,9 @@ protected void run() throws Exception elapsedTime); createdEntitiesTUT.add(newEntity); - - } catch (FunctionNotSupportedException exception) { - /* * If running against a read-only repository/connector that cannot add * entities or relationships catch FunctionNotSupportedException and give up the test. @@ -153,7 +150,13 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); return; - + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; } catch (Exception exc) { @@ -171,7 +174,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } /* @@ -183,7 +185,6 @@ protected void run() throws Exception * Make a copy of the entity under a different variable name - not strictly necessary but makes things clearer - then modify it, so * it appears to be from a remote metadata collection. */ - EntityDetail remoteEntity = newEntity; /* @@ -191,21 +192,25 @@ protected void run() throws Exception * If the repository under test supports soft delete, the entity must be deleted before being purged */ - try { + try + { EntityDetail deletedEntity = metadataCollection.deleteEntity(workPad.getLocalServerUserId(), newEntity.getType().getTypeDefGUID(), newEntity.getType().getTypeDefName(), newEntity.getGUID()); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity */ - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "deleteEntity"; String operationDescription = "delete an entity of type " + testEntityDef.getName(); Map parameters = new HashMap<>(); @@ -215,17 +220,17 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - try { - - + try + { metadataCollection.purgeEntity(workPad.getLocalServerUserId(), newEntity.getType().getTypeDefGUID(), newEntity.getType().getTypeDefName(), newEntity.getGUID()); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -239,7 +244,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -273,7 +277,8 @@ protected void run() throws Exception * Save a reference copy of the 'remote' entity */ - try { + try + { long start = System.currentTimeMillis(); metadataCollection.saveEntityReferenceCopy(workPad.getLocalServerUserId(), remoteEntity); @@ -298,12 +303,14 @@ protected void run() throws Exception EntityDetail retrievedReferenceCopy = null; - try { + try + { start = System.currentTimeMillis(); retrievedReferenceCopy = metadataCollection.getEntityDetail(workPad.getLocalServerUserId(), remoteEntityGUID); elapsedTime = System.currentTimeMillis() - start; } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -315,7 +322,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((retrievedReferenceCopy.getClassifications() == null), @@ -328,7 +334,8 @@ protected void run() throws Exception EntityDetail classifiedEntity = null; - try { + try + { start = System.currentTimeMillis(); classifiedEntity = metadataCollection.classifyEntity(workPad.getLocalServerUserId(), @@ -338,7 +345,8 @@ protected void run() throws Exception elapsedTime = System.currentTimeMillis() - start; } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -352,7 +360,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((classifiedEntity != null), @@ -367,7 +374,8 @@ protected void run() throws Exception List classifications = classifiedEntity.getClassifications(); - if ((classifications != null) && (classifications.size() == 1)) { + if ((classifications != null) && (classifications.size() == 1)) + { initialClassification = classifications.get(0); } @@ -381,11 +389,13 @@ protected void run() throws Exception InstanceProperties classificationProperties = this.getPropertiesForInstance(classificationDef.getPropertiesDefinition()); - if (classificationProperties != null) { + if (classificationProperties != null) + { EntityDetail reclassifiedEntity = null; - try { + try + { start = System.currentTimeMillis(); reclassifiedEntity = metadataCollection.updateEntityClassification(workPad.getLocalServerUserId(), @@ -393,9 +403,9 @@ protected void run() throws Exception classificationDef.getName(), classificationProperties); elapsedTime = System.currentTimeMillis() - start; - } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -415,7 +425,8 @@ protected void run() throws Exception Classification updatedClassification = null; classifications = reclassifiedEntity.getClassifications(); - if ((classifications != null) && (classifications.size() == 1)) { + if ((classifications != null) && (classifications.size() == 1)) + { updatedClassification = classifications.get(0); } @@ -433,8 +444,8 @@ protected void run() throws Exception EntityDetail declassifiedEntity = null; - try { - + try + { start = System.currentTimeMillis(); declassifiedEntity = metadataCollection.declassifyEntity(workPad.getLocalServerUserId(), remoteEntity.getGUID(), @@ -442,7 +453,8 @@ protected void run() throws Exception elapsedTime = System.currentTimeMillis() - start; } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -473,7 +485,8 @@ protected void run() throws Exception */ - try { + try + { metadataCollection.purgeEntityReferenceCopy(workPad.getLocalServerUserId(), remoteEntity.getGUID(), remoteEntity.getType().getTypeDefGUID(), @@ -481,7 +494,8 @@ protected void run() throws Exception remoteEntity.getMetadataCollectionId()); } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -496,21 +510,26 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - } - catch (FunctionNotSupportedException e) { - + catch (FunctionNotSupportedException e) + { super.addNotSupportedAssertion(assertion7, assertionMsg7, RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId()); return; - } - catch (Exception exc) { + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -522,15 +541,11 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - /* * If any other exception was thrown, let it go; this method will throw it and fail the whole test */ - - super.setSuccessMessage("Classifications on entity reference copies can be managed through their lifecycle"); } @@ -549,14 +564,15 @@ public void cleanup() throws Exception * For this testcase we created master instances and reference copies at the TUT - two lists to clean up */ - if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) { + if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntitiesTUT) { - + for (EntityDetail entity : createdEntitiesTUT) + { try { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), @@ -582,14 +598,14 @@ public void cleanup() throws Exception } } - if (createdEntityRefCopiesTUT != null && !createdEntityRefCopiesTUT.isEmpty()) { - + if (createdEntityRefCopiesTUT != null && !createdEntityRefCopiesTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntityRefCopiesTUT) { - + for (EntityDetail entity : createdEntityRefCopiesTUT) + { try { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipLifecycle.java index 992fc72a660..ed957dd21b1 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipLifecycle.java @@ -7,6 +7,7 @@ import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.HistorySequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue; @@ -111,7 +112,26 @@ public class TestSupportedRelationshipLifecycle extends RepositoryConformanceTes private static final String assertion31 = testCaseId + "-31"; private static final String assertionMsg31 = " repository supports historic retrieval "; - + private static final String assertion32 = testCaseId + "-32"; + private static final String assertionMsg32 = " relationship versions NOT returned before create time "; + private static final String assertion33 = testCaseId + "-33"; + private static final String assertionMsg33 = " relationship versions returned after create "; + private static final String assertion34 = testCaseId + "-34"; + private static final String assertionMsg34 = " relationship versions returned after update "; + private static final String assertion35 = testCaseId + "-35"; + private static final String assertionMsg35 = " relationship versions returned while deleted "; + private static final String assertion36 = testCaseId + "-36"; + private static final String assertionMsg36 = " relationship versions returned after restore "; + private static final String assertion37 = testCaseId + "-37"; + private static final String assertionMsg37 = " relationship versions are ordered BACKWARDS as requested "; + private static final String assertion38 = testCaseId + "-38"; + private static final String assertionMsg38 = " relationship versions NOT returned after purge "; + private static final String assertion39 = testCaseId + "-39"; + private static final String assertionMsg39 = " relationship is not known after purge "; + private static final String assertion41 = testCaseId + "-41"; + private static final String assertionMsg41 = " relationship versions are ordered FORWARDS as requested "; + private static final String assertion42 = testCaseId + "-42"; + private static final String assertionMsg42 = " relationship is known when deleted "; private final RepositoryConformanceWorkPad workPad; private final String metadataCollectionId; @@ -132,8 +152,8 @@ public class TestSupportedRelationshipLifecycle extends RepositoryConformanceTes */ public TestSupportedRelationshipLifecycle(RepositoryConformanceWorkPad workPad, - Map entityDefs, - RelationshipDef relationshipDef) + Map entityDefs, + RelationshipDef relationshipDef) { super(workPad, RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), @@ -159,36 +179,36 @@ protected void run() throws Exception { OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - - - /* * Check that the relationship type and end entity types match the known types from the repository helper. * * The entity types used by the ends are not verified on this test - they are verified in the supported entity tests */ - OMRSRepositoryConnector cohortRepositoryConnector = null; + OMRSRepositoryConnector cohortRepositoryConnector; OMRSRepositoryHelper repositoryHelper = null; - if (workPad != null) { + if (workPad != null) + { cohortRepositoryConnector = workPad.getTutRepositoryConnector(); repositoryHelper = cohortRepositoryConnector.getRepositoryHelper(); } RelationshipDef knownRelationshipDef = (RelationshipDef) repositoryHelper.getTypeDefByName(workPad.getLocalServerUserId(), relationshipDef.getName()); - verifyCondition((relationshipDef.equals(knownRelationshipDef)), - assertion0, - testTypeName + assertionMsg0, - RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getProfileId(), - RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getRequirementId()); - + verifyObjectsAreEqual(relationshipDef, + knownRelationshipDef, + assertion0, + testTypeName + assertionMsg0, + RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getProfileId(), + RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getRequirementId(), + null, + null); /* * In this testcase the repository is believed to support the relationship type defined by - * relationshipDef - but may not support all of the entity inheritance hierarchy - it may only + * relationshipDef - but may not support all the entity inheritance hierarchy - it may only * support a subset of entity types. So although the relationship type may have end definitions - * each specifying a given entity type - the repository may only support certain sub-types of the + * each specifying a given entity type - the repository may only support certain subtypes of the * specified type. This is OK, and the testcase needs to only try to use entity types that are * supported by the repository being tested. To do this it needs to start with the specified * end type, e.g. Referenceable, and walk down the hierarchy looking for each subtype that @@ -200,7 +220,8 @@ protected void run() throws Exception String end1DefName = relationshipDef.getEndDef1().getEntityType().getName(); List end1DefTypeNames = new ArrayList<>(); end1DefTypeNames.add(end1DefName); - if (this.workPad.getEntitySubTypes(end1DefName) != null) { + if (this.workPad.getEntitySubTypes(end1DefName) != null) + { end1DefTypeNames.addAll(this.workPad.getEntitySubTypes(end1DefName)); } @@ -208,7 +229,8 @@ protected void run() throws Exception String end2DefName = relationshipDef.getEndDef2().getEntityType().getName(); List end2DefTypeNames = new ArrayList<>(); end2DefTypeNames.add(end2DefName); - if (this.workPad.getEntitySubTypes(end2DefName) != null) { + if (this.workPad.getEntitySubTypes(end2DefName) != null) + { end2DefTypeNames.addAll(this.workPad.getEntitySubTypes(end2DefName)); } @@ -217,22 +239,28 @@ protected void run() throws Exception */ List end1SupportedTypeNames = new ArrayList<>(); - for (String end1TypeName : end1DefTypeNames) { + for (String end1TypeName : end1DefTypeNames) + { if (entityDefs.get(end1TypeName) != null) + { end1SupportedTypeNames.add(end1TypeName); + } } List end2SupportedTypeNames = new ArrayList<>(); - for (String end2TypeName : end2DefTypeNames) { + for (String end2TypeName : end2DefTypeNames) + { if (entityDefs.get(end2TypeName) != null) + { end2SupportedTypeNames.add(end2TypeName); + } } /* * Check that neither list is empty */ - if (end1SupportedTypeNames.isEmpty() || end2SupportedTypeNames.isEmpty()) { - + if (end1SupportedTypeNames.isEmpty() || end2SupportedTypeNames.isEmpty()) + { /* * There are no supported types for at least one of the ends - the repository cannot test this relationship type. */ @@ -247,7 +275,7 @@ protected void run() throws Exception * It is not practical to iterate over all combinations of feasible (supported) end types as it takes too long to run. * For now, this test verifies relationship operation over a limited set of end types. The limitation is extreme in * that it ONLY takes the first available type for each end. This is undesirable for two reasons - one is that it - * provides less test coverage; the other is that the types chosen depend on the order in the lists and this could + * provides less test coverage; the other is that the types chosen depend on the order they appear in the lists and this could * vary, making results non-repeatable. For now though, it seems these limitations are necessary. * * A full permutation across end types would use the following nested loops... @@ -257,25 +285,22 @@ protected void run() throws Exception * } * } */ - - String end1TypeName = end1SupportedTypeNames.get(0); String end2TypeName = end2SupportedTypeNames.get(0); /* * To accommodate repositories that do not support the creation of instances, wrap the creation of the entity - * in a try..catch to check for FunctionNotSupportedException. If the connector throws this, then give up + * in a try...catch to check for FunctionNotSupportedException. If the connector throws this, then give up * on the test by setting the discovered property to disabled and returning. */ - EntityDetail end1 = null; EntityDetail end2 = null; EntityDef entityType = null; InstanceProperties entityInstanceProperties = null; - try { - + try + { entityType = entityDefs.get(end1TypeName); entityInstanceProperties = this.getAllPropertiesForInstance(workPad.getLocalServerUserId(), entityType); end1 = metadataCollection.addEntity(workPad.getLocalServerUserId(), entityType.getGUID(), entityInstanceProperties, null, null); @@ -285,50 +310,49 @@ protected void run() throws Exception entityInstanceProperties = this.getAllPropertiesForInstance(workPad.getLocalServerUserId(), entityType); end2 = metadataCollection.addEntity(workPad.getLocalServerUserId(), entityType.getGUID(), entityInstanceProperties, null, null); createdEntities.add(end2); - - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { /* * The repository does not support creation of entity instances; we need to report and fail the test - * */ - super.addNotSupportedAssertion(assertion101, assertionMsg101, RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); return; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "addEntity"; String operationDescription = "add an entity of type " + (entityType != null ? entityType.getName() : "null"); Map parameters = new HashMap<>(); parameters.put("typeGUID", entityType != null ? entityType.getGUID() : "null"); parameters.put("initialProperties", entityInstanceProperties != null ? entityInstanceProperties.toString() : "null"); - parameters.put("initialClasiifications", "null"); + parameters.put("initialClassifications", "null"); parameters.put("initialStatus", "null"); String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - Relationship newRelationship = null; + Relationship newRelationship; InstanceProperties relationshipInstanceProperties = null; + Date beforeRelationshipCreateTime = new Date(); long start; long elapsedTime; - try { - + try + { start = System.currentTimeMillis(); + relationshipInstanceProperties = super.getPropertiesForInstance(relationshipDef.getPropertiesDefinition()); newRelationship = metadataCollection.addRelationship(workPad.getLocalServerUserId(), relationshipDef.getGUID(), - super.getPropertiesForInstance(relationshipDef.getPropertiesDefinition()), + relationshipInstanceProperties, end1.getGUID(), end2.getGUID(), null); @@ -343,30 +367,28 @@ protected void run() throws Exception elapsedTime); createdRelationships.add(newRelationship); - - - } catch (AssertionFailureException exception) { - + } + catch (AssertionFailureException exception) + { throw exception; - - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { /* * If running against a read-only repository/connector that cannot add * entities or relationships catch FunctionNotSupportedException and give up the test. * * Report the inability to create instances and give up on the testcase.... */ - super.addNotSupportedAssertion(assertion28, assertionMsg28, RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId()); return; - - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -382,7 +404,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((newRelationship != null), @@ -391,7 +412,6 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId()); - verifyCondition(workPad.getLocalServerUserId().equals(newRelationship.getCreatedBy()), assertion2, testTypeName + assertionMsg2, @@ -418,15 +438,17 @@ protected void run() throws Exception InstanceType instanceType = newRelationship.getType(); - if (instanceType != null) { + if (instanceType != null) + { verifyCondition(((instanceType.getTypeDefGUID().equals(relationshipDef.getGUID())) && - (instanceType.getTypeDefName().equals(testTypeName))), + (instanceType.getTypeDefName().equals(testTypeName))), assertion6, testTypeName + assertionMsg6, RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId()); - - } else { + } + else + { verifyCondition(false, assertion6, testTypeName + assertionMsg6, @@ -452,72 +474,138 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getProfileId(), RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getRequirementId()); - /* - * Validate that the relationship can be consistently retrieved. + String retrievalOperationName = "getRelationshipHistory"; + + /*================== + * Validate that the relationship version can not be retrieved for a time before the relationship is created */ + start = System.currentTimeMillis(); + try + { + metadataCollection.getRelationshipHistory(workPad.getLocalServerUserId(), + newRelationship.getGUID(), + null, + beforeRelationshipCreateTime, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.FORWARDS); + elapsedTime = System.currentTimeMillis() - start; - String retrievalOperationName = ""; + /* + * This is a fail because RelationshipNotKnownException should be thrown. + */ + verifyCondition(false, + assertion32, + testTypeName + assertionMsg32, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + retrievalOperationName, + elapsedTime); + } + catch (RelationshipNotKnownException exception) + { + elapsedTime = System.currentTimeMillis() - start; - try { + verifyCondition(true, + assertion32, + testTypeName + assertionMsg32, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + retrievalOperationName, + elapsedTime); + } + catch (FunctionNotSupportedException exception) + { + /* + * If running against a repository/connector that does not support history catch FunctionNotSupportedException and give up the test. + * Report the inability to create instances and give up on the testcase.... + */ + super.addNotSupportedAssertion(assertion33, + assertionMsg33, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId()); + return; + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String operationDescription = " retrieve version history of a relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("typeGUID", relationshipDef.getGUID()); + parameters.put("initialProperties", relationshipInstanceProperties != null ? relationshipInstanceProperties.toString() : "null"); + parameters.put("initialStatus", "null"); + String msg = this.buildExceptionMessage(testCaseId, retrievalOperationName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } + + /*=================== + * Validate that the relationship can be consistently retrieved. + */ + try + { start = System.currentTimeMillis(); Relationship knownRelationship = metadataCollection.isRelationshipKnown(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; retrievalOperationName = "isRelationshipKnown"; - verifyCondition((newRelationship.equals(knownRelationship)), - assertion9, - testTypeName + assertionMsg9, - RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), - RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), - "isRelationshipKnown", - elapsedTime); + verifyObjectsAreEqual(newRelationship, + knownRelationship, + assertion9, + testTypeName + assertionMsg9, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + retrievalOperationName, + elapsedTime); start = System.currentTimeMillis(); Relationship retrievedRelationship = metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; retrievalOperationName = "getRelationship"; - verifyCondition((newRelationship.equals(retrievedRelationship)), - assertion10, - testTypeName + assertionMsg10, - RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), - RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), - "getRelationship", - elapsedTime); - - } catch (Exception exc) { + verifyObjectsAreEqual(newRelationship, + retrievedRelationship, + assertion10, + testTypeName + assertionMsg10, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + retrievalOperationName, + elapsedTime); + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); parameters.put("relationshipGUID", newRelationship.getGUID()); String msg = this.buildExceptionMessage(testCaseId, retrievalOperationName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - /* + /*=================== * Update relationship status */ long nextVersion = newRelationship.getVersion() + 1; - for (InstanceStatus validInstanceStatus : relationshipDef.getValidInstanceStatusList()) { - if (validInstanceStatus != InstanceStatus.DELETED) { - - Relationship updatedRelationship = null; - - try { - + for (InstanceStatus validInstanceStatus : relationshipDef.getValidInstanceStatusList()) + { + if (validInstanceStatus != InstanceStatus.DELETED) + { + Relationship updatedRelationship; + try + { start = System.currentTimeMillis(); updatedRelationship = metadataCollection.updateRelationshipStatus(workPad.getLocalServerUserId(), newRelationship.getGUID(), validInstanceStatus); elapsedTime = System.currentTimeMillis() - start; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -530,7 +618,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -555,13 +642,11 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getRequirementId()); nextVersion = updatedRelationship.getVersion() + 1; - - } } - try { - + try + { start = System.currentTimeMillis(); metadataCollection.updateRelationshipStatus(workPad.getLocalServerUserId(), newRelationship.getGUID(), InstanceStatus.DELETED); elapsedTime = System.currentTimeMillis() - start; @@ -574,8 +659,9 @@ protected void run() throws Exception "updateRelationshipStatus-negative", elapsedTime); - } catch (StatusNotSupportedException exception) { - + } + catch (StatusNotSupportedException exception) + { elapsedTime = System.currentTimeMillis() - start; verifyCondition((true), assertion14, @@ -584,12 +670,12 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId(), "updateRelationshipStatus-negative", elapsedTime); - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "updateRelationshipStatus"; String operationDescription = "update the status of a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -598,31 +684,30 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - - /* + /*======================= * Modify the relationship such that it has the minimum set of properties possible. If any properties are defined as * mandatory (based on their cardinality) then provide them - in order to exercise the connector more fully. * All optional properties are removed. */ - if ((newRelationship.getProperties() != null) && - (newRelationship.getProperties().getInstanceProperties() != null) && - (!newRelationship.getProperties().getInstanceProperties().isEmpty())) { - + (newRelationship.getProperties().getInstanceProperties() != null) && + (!newRelationship.getProperties().getInstanceProperties().isEmpty())) + { InstanceProperties minRelationshipProps = super.getMinPropertiesForInstance(workPad.getLocalServerUserId(), relationshipDef); - Relationship minPropertiesRelationship = null; + Relationship minPropertiesRelationship; - try { + try + { start = System.currentTimeMillis(); minPropertiesRelationship = metadataCollection.updateRelationshipProperties(workPad.getLocalServerUserId(), newRelationship.getGUID(), minRelationshipProps); elapsedTime = System.currentTimeMillis() - start; - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -635,7 +720,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -664,16 +748,110 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getProfileId(), RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getRequirementId()); - nextVersion = minPropertiesRelationship.getVersion() + 1; /* - * Test the ability (or not) to undo the changes just made + * Verify that relationship versions can be retrieved following an update */ + try + { + start = System.currentTimeMillis(); + List relationshipHistory = metadataCollection.getRelationshipHistory(workPad.getLocalServerUserId(), + newRelationship.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + elapsedTime = System.currentTimeMillis() - start; + verifyCondition(relationshipHistory != null, + assertion34, + testTypeName + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); + + verifyCondition(relationshipHistory.size() == nextVersion, + assertion34, + testTypeName + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); + + verifyObjectsAreEqual(relationshipHistory.get(0), + minPropertiesRelationship, + assertion34, + testTypeName + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); + + start = System.currentTimeMillis(); + relationshipHistory = metadataCollection.getRelationshipHistory(workPad.getLocalServerUserId(), + newRelationship.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.FORWARDS); + elapsedTime = System.currentTimeMillis() - start; + verifyCondition(relationshipHistory != null, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); + + verifyCondition(relationshipHistory.size() == nextVersion, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); + + verifyObjectsAreEqual(relationshipHistory.get(0), + newRelationship, + assertion41, + testTypeName + assertionMsg41, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion34, + assertionMsg34, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId()); + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getRelationshipHistory"; + String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("relationshipGUID", newRelationship.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - Relationship undoneRelationship = null; + throw new Exception(msg, exc); + } - try { + /*================== + * Test the ability (or not) to undo the changes just made + */ + nextVersion = minPropertiesRelationship.getVersion() + 1; + Relationship undoneRelationship; + + try + { start = System.currentTimeMillis(); undoneRelationship = metadataCollection.undoRelationshipUpdate(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -699,20 +877,20 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_UNDO.getRequirementId()); nextVersion = undoneRelationship.getVersion() + 1; - - - } catch (AssertionFailureException exception) { - + } + catch (AssertionFailureException exception) + { throw exception; - - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion29, assertionMsg29, RepositoryConformanceProfileRequirement.RETURN_PREVIOUS_VERSION.getProfileId(), RepositoryConformanceProfileRequirement.RETURN_PREVIOUS_VERSION.getRequirementId()); - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -724,40 +902,16 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - } - - /* - * Catch the current time for a later historic query test, then sleep for a second so we are sure that time has moved on + * Catch the current time for a later historic query test, then sleep for a second, so we are sure that time has moved on */ Date preDeleteDate = new Date(); - Relationship preDeleteRelationship = null; - - try { - - preDeleteRelationship = metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); - - } catch (Exception exc) { - /* - * We are not expecting any exceptions from this method call. Log and fail the test. - */ - - String methodName = "getRelationship"; - String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); - Map parameters = new HashMap<>(); - parameters.put("relationshipGUID", newRelationship.getGUID()); - String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); - throw new Exception(msg, exc); - - } - - /* + /*=================== * Test that the relationship can be soft-deleted, and that the soft deleted relationship has a higher version. * Verify that the soft deleted relationship cannot be retrieved, but can be restored and that the restored relationship has * a valid version (higher than when it was deleted). @@ -766,8 +920,8 @@ protected void run() throws Exception Relationship deletedRelationship = null; - try { - + try + { start = System.currentTimeMillis(); deletedRelationship = metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), newRelationship.getType().getTypeDefGUID(), @@ -789,10 +943,11 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getProfileId(), RepositoryConformanceProfileRequirement.INSTANCE_VERSIONING.getRequirementId()); - nextVersion = deletedRelationship.getVersion() + 1; - - try { - + /* + * Verify that the relationship cannot be retrieved when deleted + */ + try + { start = System.currentTimeMillis(); metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -800,27 +955,27 @@ protected void run() throws Exception verifyCondition((false), assertion20, testTypeName + assertionMsg20, - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), "getRelationship-negative", elapsedTime); - - } catch (RelationshipNotKnownException exception) { - + } + catch (RelationshipNotKnownException exception) + { elapsedTime = System.currentTimeMillis() - start; verifyCondition((true), assertion20, testTypeName + assertionMsg20, - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), "getRelationship-negative", elapsedTime); - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "getRelationship"; String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -828,27 +983,122 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); + } + + /* + * Verify that the relationship is known following delete + */ + try + { + start = System.currentTimeMillis(); + Relationship knownRelationship = metadataCollection.isRelationshipKnown(workPad.getLocalServerUserId(), deletedRelationship.getGUID()); + elapsedTime = System.currentTimeMillis() - start; + verifyObjectsAreEqual(deletedRelationship, + knownRelationship, + assertion42, + testTypeName + assertionMsg42, + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), + "isRelationshipKnown", + elapsedTime); + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "isRelationshipKnown"; + String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("relationshipGUID", deletedRelationship.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } + + /* + * Verify that the relationship's versions can be retrieved while the relationship is deleted + */ + try + { + start = System.currentTimeMillis(); + List relationships = metadataCollection.getRelationshipHistory(workPad.getLocalServerUserId(), + newRelationship.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + elapsedTime = System.currentTimeMillis() - start; + assertCondition(relationships != null, + assertion35, + testTypeName + assertionMsg35, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + verifyCondition(! relationships.isEmpty(), + assertion35, + testTypeName + assertionMsg35, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + + verifyCondition((relationships.get(0).getStatus() == InstanceStatus.DELETED), + assertion35, + testTypeName + assertionMsg35, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getEntityDetailHistory", + elapsedTime); + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getRelationshipHistory"; + String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newRelationship.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } + + + /*========================================= + * Verify that a relationship can be restored + */ /* * Performing the restore should advance the version number again */ nextVersion = deletedRelationship.getVersion() + 1; - Relationship restoredRelationship = null; - - try { + Relationship restoredRelationship; + try + { start = System.currentTimeMillis(); restoredRelationship = metadataCollection.restoreRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "restoreRelationship"; String operationDescription = "restore a soft-deleted relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -856,7 +1106,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } verifyCondition((restoredRelationship != null), @@ -873,26 +1122,25 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_RESTORE.getProfileId(), RepositoryConformanceProfileRequirement.NEW_VERSION_NUMBER_ON_RESTORE.getRequirementId()); - /* * Verify that relationship can be retrieved following restore */ - - try { - + try + { start = System.currentTimeMillis(); Relationship knownRelationship = metadataCollection.isRelationshipKnown(workPad.getLocalServerUserId(), restoredRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; - verifyCondition((restoredRelationship.equals(knownRelationship)), - assertion23, - testTypeName + assertionMsg23, - RepositoryConformanceProfileRequirement.UNDELETE_INSTANCE.getProfileId(), - RepositoryConformanceProfileRequirement.UNDELETE_INSTANCE.getRequirementId(), - "isRelationshipKnown", - elapsedTime); - + verifyObjectsAreEqual(restoredRelationship, + knownRelationship, + assertion23, + testTypeName + assertionMsg23, + RepositoryConformanceProfileRequirement.UNDELETE_INSTANCE.getProfileId(), + RepositoryConformanceProfileRequirement.UNDELETE_INSTANCE.getRequirementId(), + "isRelationshipKnown", + elapsedTime); } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -904,57 +1152,198 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } + /* + * Verify that relationship versions can be retrieved following restore + */ + try + { + start = System.currentTimeMillis(); + List relationshipHistory = metadataCollection.getRelationshipHistory(workPad.getLocalServerUserId(), + restoredRelationship.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + elapsedTime = System.currentTimeMillis() - start; + verifyCondition(relationshipHistory != null, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); - } catch (FunctionNotSupportedException exception) { + verifyCondition(relationshipHistory.size() == nextVersion, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); - super.addNotSupportedAssertion(assertion30, - assertionMsg30, - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), - RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId()); + verifyObjectsAreEqual(relationshipHistory.get(0), + restoredRelationship, + assertion37, + testTypeName + assertionMsg37, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); - } catch (Exception exc) { - /* - * We are not expecting any other exceptions from this method call. Log and fail the test. - */ + start = System.currentTimeMillis(); + relationshipHistory = metadataCollection.getRelationshipHistory(workPad.getLocalServerUserId(), + restoredRelationship.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.FORWARDS); + elapsedTime = System.currentTimeMillis() - start; + verifyCondition(relationshipHistory != null, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); - String methodName = "deleteRelationship"; - String operationDescription = "delete a relationship of type " + relationshipDef.getName(); - Map parameters = new HashMap<>(); - parameters.put("typeDefGUID", newRelationship.getType().getTypeDefGUID()); - parameters.put("typeDefName", newRelationship.getType().getTypeDefName()); - parameters.put("obsoleteRelationshipGUID", newRelationship.getGUID()); - String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + verifyCondition(relationshipHistory.size() == nextVersion, + assertion36, + testTypeName + assertionMsg36, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); - throw new Exception(msg, exc); + verifyObjectsAreEqual(relationshipHistory.get(0), + newRelationship, + assertion41, + testTypeName + assertionMsg41, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory", + elapsedTime); + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion31, + assertionMsg31, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId()); - } + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getRelationshipHistory"; + String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("relationshipGUID", restoredRelationship.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + throw new Exception(msg, exc); + } + /* + * Verify that historical query for the time when it was deleted does not return the relationship + */ + try + { + start = System.currentTimeMillis(); + metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID(), deletedRelationship.getUpdateTime()); + assertCondition(false, + assertion31, + testTypeName + assertionMsg31, + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId()); + } + catch (RelationshipNotKnownException exception) + { + /* + * Even if it supports historical retrieval, the repository should not return the relationship at this time. + */ + elapsedTime = System.currentTimeMillis() - start; + assertCondition((true), + assertion27, + testTypeName + assertionMsg27, + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId(), + "getRelationship-when deleted", + elapsedTime); + } + catch (AssertionFailureException exc) + { + /* + * Keep going + */ + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getRelationship"; + String operationDescription = "retrieve a historical copy of a purged relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("relationshipGUID" , newRelationship.getGUID()); + parameters.put("asOfTime" , preDeleteDate.toString()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + throw new Exception(msg, exc); + } - /* - * Now get rid of the relationship - this time for real - */ + /*===================================== + * Now soft-delete the relationship - this time for real + */ - try { - metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), - newRelationship.getType().getTypeDefGUID(), - newRelationship.getType().getTypeDefName(), - newRelationship.getGUID()); - } - catch (FunctionNotSupportedException exception) { + try + { + metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), + newRelationship.getType().getTypeDefGUID(), + newRelationship.getType().getTypeDefName(), + newRelationship.getGUID()); + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion30, + assertionMsg30, + RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), + RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId()); + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "deleteRelationship"; + String operationDescription = "delete a relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("typeDefGUID", newRelationship.getType().getTypeDefGUID()); + parameters.put("typeDefName", newRelationship.getType().getTypeDefName()); + parameters.put("obsoleteRelationshipGUID", newRelationship.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion30, assertionMsg30, RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getProfileId(), RepositoryConformanceProfileRequirement.SOFT_DELETE_INSTANCE.getRequirementId()); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -971,21 +1360,23 @@ protected void run() throws Exception } - try { - + /*======================================= + * Test that the relationship can be purged. + */ + try + { start = System.currentTimeMillis(); metadataCollection.purgeRelationship(workPad.getLocalServerUserId(), newRelationship.getType().getTypeDefGUID(), newRelationship.getType().getTypeDefName(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; - } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "purgeRelationship"; String operationDescription = "purge a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -995,23 +1386,25 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - try { - + /* + * Check the relationship can not be retrieved after purge + */ + try + { metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); verifyCondition((false), assertion24, testTypeName + assertionMsg24, - RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getProfileId(), + RepositoryConformanceProfileRequirement.METADATA_INSTANCE_ACCESS.getRequirementId(), "purgeRelationship", elapsedTime); - - } catch (RelationshipNotKnownException exception) { - + } + catch (RelationshipNotKnownException exception) + { verifyCondition((true), assertion24, testTypeName + assertionMsg24, @@ -1020,7 +1413,8 @@ protected void run() throws Exception "purgeRelationship", elapsedTime); } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1032,7 +1426,43 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); + } + + /* + * Check that the relationship is no longer known after the purge. + */ + try + { + Relationship relationshipKnown = metadataCollection.isRelationshipKnown(workPad.getLocalServerUserId(), newRelationship.getGUID()); + + assertCondition((relationshipKnown == null), + assertion39, + testTypeName + assertionMsg39, + RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getProfileId(), + RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId(), + "isRelationshipKnown", + null); + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + + String methodName = "isRelationshipKnown"; + String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("entityGUID", newRelationship.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + throw new Exception(msg, exc); } @@ -1040,7 +1470,8 @@ protected void run() throws Exception * Perform a historic get of the relationship - this should not return the relationship since it has now been [deleted and] purged * The time for the query is the time set just before the delete operation above. */ - try { + try + { start = System.currentTimeMillis(); Relationship earlierRelationship = metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID(), preDeleteDate); elapsedTime = System.currentTimeMillis() - start; @@ -1062,40 +1493,40 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId(), "getRelationship-negative", elapsedTime); - - - } catch (AssertionFailureException exception) { - + } + catch (AssertionFailureException exception) + { throw exception; - - } catch (RelationshipNotKnownException exception) { + } + catch (RelationshipNotKnownException exception) + { /* * Even if it supports historical retrieval, the repository should not return any version of a purged relationship, - * as the relationship and all of its history should have been purged. Therefore this exception being thrown + * as the relationship and all of its history should have been purged. Therefore, this exception being thrown * indicates success -- so we do not need to handle it any further. */ elapsedTime = System.currentTimeMillis() - start; assertCondition((true), - assertion25, - testTypeName + assertionMsg25, - RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), - RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId(), - "getRelationship-negative", - elapsedTime); - - } catch (FunctionNotSupportedException exception) { + assertion25, + testTypeName + assertionMsg25, + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), + RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId(), + "getRelationship-negative", + elapsedTime); + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion31, assertionMsg31, RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.HISTORICAL_PROPERTY_SEARCH.getRequirementId()); - } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "getRelationshipDetail"; String operationDescription = "retrieve a historical copy of a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -1104,25 +1535,85 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } /* - * Relationship was purged - clean up the entities..... - * + * Perform a get relationship history - this should not return any of the versions because the relationship has now been purged */ + try + { + start = System.currentTimeMillis(); + metadataCollection.getRelationshipHistory(workPad.getLocalServerUserId(), + newRelationship.getGUID(), + null, + null, + 0, + workPad.getMaxPageSize(), + HistorySequencingOrder.BACKWARDS); + + assertCondition(false, + assertion38, + testTypeName + assertionMsg38, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId()); + } + catch (RelationshipNotKnownException exception) + { + /* + * Even if it supports historical retrieval, the repository should not return any version of a purged relationship, + * as the relationship and all of its history should have been purged. Therefore, this exception being thrown + * indicates success -- so we do not need to handle it any further. + */ + elapsedTime = System.currentTimeMillis() - start; + assertCondition((true), + assertion38, + testTypeName + assertionMsg38, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId(), + "getRelationshipHistory-purged", + elapsedTime); + } + catch (FunctionNotSupportedException exception) + { + super.addNotSupportedAssertion(assertion38, + assertionMsg38, + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getProfileId(), + RepositoryConformanceProfileRequirement.GET_RELATIONSHIP_VERSIONS.getRequirementId()); - try { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { + /* + * We are not expecting any other exceptions from this method call. Log and fail the test. + */ + String methodName = "getRelationshipHistory"; + String operationDescription = "retrieve a historical versions of a purged relationship of type " + relationshipDef.getName(); + Map parameters = new HashMap<>(); + parameters.put("relationshipGUID", newRelationship.getGUID()); + String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); + + throw new Exception(msg, exc); + } + /* + * Relationship was purged - clean up the entities..... + */ + try + { /* * Delete both end entities. * Deleting either entity first would delete the relationship, but it has already been deleted as part of the test * this sequence is a little more orderly. */ - - metadataCollection.deleteEntity(workPad.getLocalServerUserId(), end1.getType().getTypeDefGUID(), end1.getType().getTypeDefName(), @@ -1134,7 +1625,9 @@ protected void run() throws Exception end2.getGUID()); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { // NO OP - can proceed to purge } @@ -1149,14 +1642,10 @@ protected void run() throws Exception end2.getType().getTypeDefName(), end2.getGUID()); - super.setSuccessMessage("Relationships can be managed through their lifecycle"); } - - - /** * Method to clean any instance created by the test case that has not already been cleaned by the running of the test. * @@ -1167,20 +1656,19 @@ public void cleanup() throws Exception OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - if (createdRelationships != null && !createdRelationships.isEmpty()) { - + if (createdRelationships != null && !createdRelationships.isEmpty()) + { /* * Instances were created - clean them up. */ - - for (Relationship relationship : createdRelationships) { - + for (Relationship relationship : createdRelationships) + { try { metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), - relationship.getType().getTypeDefGUID(), - relationship.getType().getTypeDefName(), - relationship.getGUID()); + relationship.getType().getTypeDefGUID(), + relationship.getType().getTypeDefName(), + relationship.getGUID()); } catch (FunctionNotSupportedException exception) { @@ -1194,22 +1682,20 @@ public void cleanup() throws Exception // If relationship is known then (whether delete was supported or not) issue purge metadataCollection.purgeRelationship(workPad.getLocalServerUserId(), - relationship.getType().getTypeDefGUID(), - relationship.getType().getTypeDefName(), - relationship.getGUID()); + relationship.getType().getTypeDefGUID(), + relationship.getType().getTypeDefName(), + relationship.getGUID()); } } - - - if (createdEntities != null && !createdEntities.isEmpty()) { - + if (createdEntities != null && !createdEntities.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntities) { - + for (EntityDetail entity : createdEntities) + { try { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), @@ -1237,7 +1723,6 @@ public void cleanup() throws Exception } - /** * Determine if properties are as expected. * @@ -1251,8 +1736,8 @@ private boolean doPropertiesMatch(InstanceProperties firstInstanceProps, Instanc boolean noProperties = false; if ( (secondInstanceProps == null) || - (secondInstanceProps.getInstanceProperties() == null) || - (secondInstanceProps.getInstanceProperties().isEmpty())) + (secondInstanceProps.getInstanceProperties() == null) || + (secondInstanceProps.getInstanceProperties().isEmpty())) { noProperties = true; } @@ -1260,7 +1745,7 @@ private boolean doPropertiesMatch(InstanceProperties firstInstanceProps, Instanc if (noProperties) { if ((firstInstanceProps.getInstanceProperties() == null) || - (firstInstanceProps.getInstanceProperties().isEmpty())) + (firstInstanceProps.getInstanceProperties().isEmpty())) { matchProperties = true; } @@ -1280,15 +1765,17 @@ private boolean doPropertiesMatch(InstanceProperties firstInstanceProps, Instanc Set firstPropertiesKeySet = firstPropertiesMap.keySet(); boolean matchKeys = secondPropertiesKeySet.containsAll(firstPropertiesKeySet) && - firstPropertiesKeySet.containsAll(secondPropertiesKeySet); + firstPropertiesKeySet.containsAll(secondPropertiesKeySet); if (matchKeys) { // Assume the values match and prove it if they don't... boolean matchValues = true; - for (String key : secondPropertiesKeySet) { - if (!(secondPropertiesMap.get(key).equals(firstPropertiesMap.get(key)))) { + for (String key : secondPropertiesKeySet) + { + if (!(secondPropertiesMap.get(key).equals(firstPropertiesMap.get(key)))) + { matchValues = false; } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReferenceCopyLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReferenceCopyLifecycle.java index f80fcbec969..aa11aa1f632 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReferenceCopyLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReferenceCopyLifecycle.java @@ -532,13 +532,14 @@ protected void run() throws Exception Relationship retrievedReferenceCopy = null; long start; long elapsedTime; - try { - + try + { start = System.currentTimeMillis(); retrievedReferenceCopy = metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -550,7 +551,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((retrievedReferenceCopy != null), @@ -565,7 +565,6 @@ protected void run() throws Exception /* * Verify that the retrieved reference copy matches the original relationship */ - verifyCondition((newRelationship.equals(retrievedReferenceCopy)), assertion3, testTypeName + assertionMsg3, @@ -578,11 +577,10 @@ protected void run() throws Exception * If the relationship def has any valid status values (including DELETED), attempt * to modify the status of the retrieved reference copy - this should fail */ - - for (InstanceStatus validInstanceStatus : relationshipDef.getValidInstanceStatusList()) { - - try { - + for (InstanceStatus validInstanceStatus : relationshipDef.getValidInstanceStatusList()) + { + try + { start = System.currentTimeMillis(); Relationship updatedRelationship = metadataCollection.updateRelationshipStatus(workPad.getLocalServerUserId(), retrievedReferenceCopy.getGUID(), validInstanceStatus); elapsedTime = System.currentTimeMillis() - start; @@ -595,8 +593,9 @@ protected void run() throws Exception "updateRelationshipStatus-negative", elapsedTime); - } catch (InvalidParameterException e) { - + } + catch (InvalidParameterException e) + { /* * We are not expecting the status update to work - it should have thrown an InvalidParameterException */ @@ -608,11 +607,19 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), "updateRelationshipStatus-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "updateRelationshipStatus"; String operationDescription = "update the status of a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -621,25 +628,20 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - } - - /* * Attempt to modify one or more property of the retrieved reference copy. This is illegal so it should fail. */ - - if ((retrievedReferenceCopy.getProperties() != null) && (retrievedReferenceCopy.getProperties().getInstanceProperties() != null) && - (!retrievedReferenceCopy.getProperties().getInstanceProperties().isEmpty())) { + (!retrievedReferenceCopy.getProperties().getInstanceProperties().isEmpty())) + { InstanceProperties minRelationshipProps = super.getMinPropertiesForInstance(workPad.getLocalServerUserId(), relationshipDef); - try { - + try + { start = System.currentTimeMillis(); Relationship minPropertiesRelationship = metadataCollection.updateRelationshipProperties(workPad.getLocalServerUserId(), retrievedReferenceCopy.getGUID(), minRelationshipProps); elapsedTime = System.currentTimeMillis() - start; @@ -652,7 +654,9 @@ protected void run() throws Exception "updateRelationshipProperties-negative", elapsedTime); - } catch (InvalidParameterException e) { + } + catch (InvalidParameterException e) + { /* * We are not expecting the status update to work - it should have thrown an InvalidParameterException @@ -665,11 +669,19 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), "updateRelationshipProperties-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "updateRelationshipProperties"; String operationDescription = "update the properties of a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -678,7 +690,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } } @@ -691,9 +702,8 @@ protected void run() throws Exception * uses the original type. * This test is performed against the TUT. */ - - try { - + try + { start = System.currentTimeMillis(); Relationship reTypedRelationship = metadataCollection.reTypeRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID(), @@ -709,8 +719,9 @@ protected void run() throws Exception "reTypeRelationship-negative", elapsedTime); - } catch (InvalidParameterException e) { - + } + catch (InvalidParameterException e) + { /* * We are not expecting the type update to work - it should have thrown an InvalidParameterException */ @@ -722,11 +733,19 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), "reTypeRelationship-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "reTypeRelationship"; String operationDescription = "retype a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -736,11 +755,8 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - /* * Verify that it is not possible to re-identify the reference copy. * This test is performed using a different GUID to the original. The actual value should not be looked at @@ -750,8 +766,8 @@ protected void run() throws Exception String newGUID = UUID.randomUUID().toString(); - try { - + try + { start = System.currentTimeMillis(); Relationship reIdentifiedRelationship = metadataCollection.reIdentifyRelationship(workPad.getLocalServerUserId(), relationshipDef.getGUID(), @@ -769,9 +785,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_LOCKING.getRequirementId(), "reIdentifyRelationship-negative", elapsedTime); - - } catch (InvalidParameterException e) { - + } + catch (InvalidParameterException e) + { /* * We are not expecting the identity update to work - it should have thrown an InvalidParameterException */ @@ -784,7 +800,16 @@ protected void run() throws Exception "reIdentifyRelationship-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -798,7 +823,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -807,8 +831,8 @@ protected void run() throws Exception * This test is performed against the TUT. */ - try { - + try + { start = System.currentTimeMillis(); metadataCollection.purgeRelationshipReferenceCopy(workPad.getLocalServerUserId(), refRelationship); elapsedTime = System.currentTimeMillis() - start; @@ -824,11 +848,19 @@ protected void run() throws Exception "purgeRelationshipReferenceCopy", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "purgeRelationshipReferenceCopy"; String operationDescription = "purge a reference copy of a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -836,12 +868,11 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - try { - + try + { start = System.currentTimeMillis(); metadataCollection.refreshRelationshipReferenceCopy(workPad.getLocalServerUserId(), refRelationship.getGUID(), @@ -860,11 +891,19 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId(), "refreshRelationshipReferenceCopy", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "refreshRelationshipReferenceCopy"; String operationDescription = "request a refresh of a reference copy of a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -875,7 +914,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -893,15 +931,18 @@ protected void run() throws Exception * Retrieve the ref copy from the TUT - if it does not exist, assert that ref copies are not a discovered property * Have to be prepared to wait until event has propagated and TUT has created a reference copy of the relationship. */ - try { + try + { Integer remainingCount = this.pollCount; - while (refreshedRelationshipRefCopy == null && remainingCount > 0) { + while (refreshedRelationshipRefCopy == null && remainingCount > 0) + { refreshedRelationshipRefCopy = metadataCollection.isRelationshipKnown(workPad.getLocalServerUserId(), newRelationship.getGUID()); Thread.sleep(this.pollPeriod); remainingCount--; } - if (refreshedRelationshipRefCopy == null && remainingCount == 0) { + if (refreshedRelationshipRefCopy == null && remainingCount == 0) + { ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() .logRecord(assertion10, @@ -912,7 +953,9 @@ protected void run() throws Exception overflow.getSystemAction(), overflow.getUserAction()); } - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -924,7 +967,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -932,13 +974,14 @@ protected void run() throws Exception * Verify that the reference copy can be retrieved form the TUT and matches the original... */ - try { - + try + { start = System.currentTimeMillis(); refreshedRelationshipRefCopy = metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -950,7 +993,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((refreshedRelationshipRefCopy != null), @@ -966,11 +1008,14 @@ protected void run() throws Exception * Verify that the retrieved reference copy matches the original relationship */ - verifyCondition((newRelationship.equals(refreshedRelationshipRefCopy)), - assertion11, - testTypeName + assertionMsg11, - RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), - RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId()); + verifyObjectsAreEqual(newRelationship, + refreshedRelationshipRefCopy, + assertion11, + testTypeName + assertionMsg11, + RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), + RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId(), + "getRelationship", + null); @@ -979,12 +1024,15 @@ protected void run() throws Exception * They should cause an OMRS instance event to flow to the TUT and for the ref copy to be purged */ - try { + try + { Relationship deletedRelationship = ctsMetadataCollection.deleteRelationship(workPad.getLocalServerUserId(), newRelationship.getType().getTypeDefGUID(), newRelationship.getType().getTypeDefName(), newRelationship.getGUID()); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity @@ -1006,15 +1054,19 @@ protected void run() throws Exception * Since it may take time to propagate the purge event, retry until the relationship is no longer known at the TUT. */ - try { + try + { Relationship survivingRelRefCopy; Integer remainingCount = this.pollCount; - do { + do + { survivingRelRefCopy = metadataCollection.isRelationshipKnown(workPad.getLocalServerUserId(), newRelationship.getGUID()); Thread.sleep(this.pollPeriod); remainingCount--; } while (survivingRelRefCopy != null && remainingCount > 0); - if (survivingRelRefCopy == null && remainingCount == 0) { + + if (survivingRelRefCopy == null && remainingCount == 0) + { ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() .logRecord(assertion12, @@ -1025,7 +1077,9 @@ protected void run() throws Exception overflow.getSystemAction(), overflow.getUserAction()); } - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -1037,11 +1091,11 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - try { + try + { start = System.currentTimeMillis(); metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -1054,7 +1108,9 @@ protected void run() throws Exception "getRelationship-negative", elapsedTime); - } catch (RelationshipNotKnownException exception) { + } + catch (RelationshipNotKnownException exception) + { elapsedTime = System.currentTimeMillis() - start; assertCondition((true), assertion12, @@ -1063,7 +1119,16 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.REFERENCE_COPY_DELETE.getRequirementId(), "getRelationship-negative", elapsedTime); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1075,11 +1140,8 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - - /* * Now is a good time to clean uo the entities we created at teh CTS - which will also have ref copies at the TUT * By deleting and purging the masters (on the CTS) the TUT reference copies should also be purged. @@ -1089,7 +1151,8 @@ protected void run() throws Exception * These operations are to the CTS */ - try { + try + { EntityDetail deletedEntityOne = ctsMetadataCollection.deleteEntity(workPad.getLocalServerUserId(), entityOne.getType().getTypeDefGUID(), entityOne.getType().getTypeDefName(), @@ -1099,7 +1162,9 @@ protected void run() throws Exception entityTwo.getType().getTypeDefGUID(), entityTwo.getType().getTypeDefName(), entityTwo.getGUID()); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity @@ -1158,8 +1223,8 @@ protected void run() throws Exception EntityDef entityType = null; - try { - + try + { entityType = entityDefs.get(end1TypeName); entityInstanceProperties = this.getAllPropertiesForInstance(workPad.getLocalServerUserId(), entityType); end1 = metadataCollection.addEntity(workPad.getLocalServerUserId(), entityType.getGUID(), entityInstanceProperties, null, null); @@ -1170,21 +1235,22 @@ protected void run() throws Exception end2 = metadataCollection.addEntity(workPad.getLocalServerUserId(), entityType.getGUID(), entityInstanceProperties, null, null); createdEntitiesTUT.add(end2); - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { /* * The repository does not support creation of entity instances; we need to report and fail the test * */ - super.addNotSupportedAssertion(assertion101, assertionMsg101, RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); return; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1199,7 +1265,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -1207,7 +1272,8 @@ protected void run() throws Exception Relationship relationshipWithMappingProperties = null; - try { + try + { start = System.currentTimeMillis(); relationshipWithMappingProperties = metadataCollection.addRelationship(workPad.getLocalServerUserId(), relationshipDef.getGUID(), @@ -1227,7 +1293,9 @@ protected void run() throws Exception createdRelationshipsTUT.add(relationshipWithMappingProperties); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * If running against a read-only repository/connector that cannot add @@ -1243,13 +1311,19 @@ protected void run() throws Exception return; - } catch (AssertionFailureException exc) { - throw exc; - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ - String methodName = "addRelationship"; String operationDescription = "add a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -1261,7 +1335,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -1282,21 +1355,25 @@ protected void run() throws Exception * If the repository under test supports soft delete, the entity must be deleted before being purged */ - try { + try + { metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), relationshipWithMappingProperties.getType().getTypeDefGUID(), relationshipWithMappingProperties.getType().getTypeDefName(), relationshipWithMappingProperties.getGUID()); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity */ - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "deleteRelationship"; String operationDescription = "delete a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -1306,16 +1383,18 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - try { + try + { metadataCollection.purgeRelationship(workPad.getLocalServerUserId(), relationshipWithMappingProperties.getType().getTypeDefGUID(), relationshipWithMappingProperties.getType().getTypeDefName(), relationshipWithMappingProperties.getGUID()); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1329,7 +1408,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } // Beyond this point, there should be no further references to relationshipWithMappingProperties @@ -1366,8 +1444,8 @@ protected void run() throws Exception * Save a reference copy of the 'remote' entity */ - try { - + try + { start = System.currentTimeMillis(); metadataCollection.saveRelationshipReferenceCopy(workPad.getLocalServerUserId(), remoteRelationshipWithMappingProperties); elapsedTime = System.currentTimeMillis() - start; @@ -1391,17 +1469,17 @@ protected void run() throws Exception Relationship retrievedReferenceCopyWithMappingProperties = null; - try { - + try + { start = System.currentTimeMillis(); retrievedReferenceCopyWithMappingProperties = metadataCollection.getRelationship(workPad.getLocalServerUserId(), remoteRelationshipGUID); elapsedTime = System.currentTimeMillis() - start; - - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "getRelationship"; String operationDescription = "retrieve a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -1409,16 +1487,16 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } - assertCondition((retrievedReferenceCopyWithMappingProperties.equals(remoteRelationshipWithMappingProperties)), - assertion16, - assertionMsg16 + relationshipDef.getName(), - RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), - RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId(), - "getRelationship", - elapsedTime); + assertObjectsAreEqual(retrievedReferenceCopyWithMappingProperties, + remoteRelationshipWithMappingProperties, + assertion16, + assertionMsg16 + relationshipDef.getName(), + RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), + RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId(), + "getRelationship", + elapsedTime); //--------------------------------------------- @@ -1444,7 +1522,8 @@ protected void run() throws Exception * Rehome of an instance is a pull operation - i.e. it must be conducted by the TUT as the TUT holds the ref copy. */ Relationship newMasterRelationship = null; - try { + try + { start = System.currentTimeMillis(); newMasterRelationship = metadataCollection.reHomeRelationship(workPad.getLocalServerUserId(), remoteRelationshipGUID, @@ -1464,10 +1543,9 @@ protected void run() throws Exception elapsedTime); createdRelationshipsTUT.add(newMasterRelationship); - - - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { /* * Because rehome is an optional method, this is not fatal - just record that the connector does not support rehome */ @@ -1477,7 +1555,16 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_HOME.getProfileId(), RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_HOME.getRequirementId()); - } catch (Exception exc) { + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1494,21 +1581,20 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } /* * Verify that the new master instance can be retrieved */ - try { - + try + { start = System.currentTimeMillis(); retrievedReferenceCopyWithMappingProperties = metadataCollection.getRelationship(workPad.getLocalServerUserId(), remoteRelationshipGUID); elapsedTime = System.currentTimeMillis() - start; - } - catch (Exception exc) { + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -1520,7 +1606,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } assertCondition((retrievedReferenceCopyWithMappingProperties != null), @@ -1551,18 +1636,21 @@ protected void run() throws Exception * In both cases the operation is performed at the TUT. */ - if (newMasterRelationship != null) { + if (newMasterRelationship != null) + { /* * The rehome operation worked - perform a soft delete (optional) followed by a purge. */ - try { + try + { metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), newMasterRelationship.getType().getTypeDefGUID(), newMasterRelationship.getType().getTypeDefName(), newMasterRelationship.getGUID()); } - catch (FunctionNotSupportedException exception) { + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity @@ -1574,7 +1662,8 @@ protected void run() throws Exception newMasterRelationship.getType().getTypeDefName(), newMasterRelationship.getMetadataCollectionId()); } - else { + else + { /* * The rehome operation did not work - the TUT is still holding a reference copy */ @@ -1591,23 +1680,27 @@ protected void run() throws Exception } - - - - } catch (AssertionFailureException e) { - throw e; - } catch (FunctionNotSupportedException e) { - + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (FunctionNotSupportedException e) + { super.addNotSupportedAssertion(assertion15, assertionMsg15, RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getProfileId(), RepositoryConformanceProfileRequirement.REFERENCE_COPY_STORAGE.getRequirementId()); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "saveRelationshipReferenceCopy"; String operationDescription = "save a reference copy of a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -1615,7 +1708,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -1624,17 +1716,19 @@ protected void run() throws Exception * And finally clean up the entities - these are known to be locally master (by the TUT) as they * were never subject to a rehome operation. Soft delete (optional) then purge. */ - try { + try + { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), - end1.getType().getTypeDefGUID(), - end1.getType().getTypeDefName(), - end1.getGUID()); + end1.getType().getTypeDefGUID(), + end1.getType().getTypeDefName(), + end1.getGUID()); metadataCollection.deleteEntity(workPad.getLocalServerUserId(), - end2.getType().getTypeDefGUID(), - end2.getType().getTypeDefName(), - end2.getGUID()); + end2.getType().getTypeDefGUID(), + end2.getType().getTypeDefName(), + end2.getGUID()); } - catch (FunctionNotSupportedException exception) { + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity @@ -1642,20 +1736,13 @@ protected void run() throws Exception } metadataCollection.purgeEntity(workPad.getLocalServerUserId(), - end1.getType().getTypeDefGUID(), - end1.getType().getTypeDefName(), - end1.getGUID()); + end1.getType().getTypeDefGUID(), + end1.getType().getTypeDefName(), + end1.getGUID()); metadataCollection.purgeEntity(workPad.getLocalServerUserId(), - end2.getType().getTypeDefGUID(), - end2.getType().getTypeDefName(), - end2.getGUID()); - - - - - - - + end2.getType().getTypeDefGUID(), + end2.getType().getTypeDefName(), + end2.getGUID()); super.setSuccessMessage("Reference copies of relationships can be managed through their lifecycle"); @@ -1681,13 +1768,15 @@ public void cleanup() throws Exception OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - if (createdRelationshipsCTS != null && !createdRelationshipsCTS.isEmpty()) { + if (createdRelationshipsCTS != null && !createdRelationshipsCTS.isEmpty()) + { /* * Instances were created - clean them up. */ - for (Relationship relationship : createdRelationshipsCTS) { + for (Relationship relationship : createdRelationshipsCTS) + { try { @@ -1713,14 +1802,15 @@ public void cleanup() throws Exception relationship.getGUID()); } } - if (createdRelationshipsTUT != null && !createdRelationshipsTUT.isEmpty()) { + if (createdRelationshipsTUT != null && !createdRelationshipsTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (Relationship relationship : createdRelationshipsTUT) { - + for (Relationship relationship : createdRelationshipsTUT) + { try { metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), @@ -1745,14 +1835,15 @@ public void cleanup() throws Exception relationship.getGUID()); } } - if (createdRelationshipRefCopiesTUT != null && !createdRelationshipRefCopiesTUT.isEmpty()) { + if (createdRelationshipRefCopiesTUT != null && !createdRelationshipRefCopiesTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (Relationship relationship : createdRelationshipRefCopiesTUT) { - + for (Relationship relationship : createdRelationshipRefCopiesTUT) + { try { metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), @@ -1778,15 +1869,15 @@ public void cleanup() throws Exception } } - - - if (createdEntitiesCTS != null && !createdEntitiesCTS.isEmpty()) { + if (createdEntitiesCTS != null && !createdEntitiesCTS.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntitiesCTS) { + for (EntityDetail entity : createdEntitiesCTS) + { try { @@ -1812,13 +1903,15 @@ public void cleanup() throws Exception entity.getGUID()); } } - if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) { + if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntitiesTUT) { + for (EntityDetail entity : createdEntitiesTUT) + { try { diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReidentify.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReidentify.java index 64509ee738a..dda3154ef1f 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReidentify.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReidentify.java @@ -2,6 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; @@ -324,7 +325,6 @@ protected void run() throws Exception } - assertCondition((true), assertion8, testTypeName + assertionMsg8, @@ -378,8 +378,8 @@ protected void run() throws Exception Relationship reIdentifiedRelationship = null; - try { - + try + { start = System.currentTimeMillis(); reIdentifiedRelationship = metadataCollection.reIdentifyRelationship(workPad.getLocalServerUserId(), relationshipDef.getGUID(), @@ -411,8 +411,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getProfileId(), RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getRequirementId()); - } catch (FunctionNotSupportedException exception) { - + } + catch (FunctionNotSupportedException exception) + { super.addNotSupportedAssertion(assertion9, assertionMsg9, RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getProfileId(), @@ -420,13 +421,19 @@ protected void run() throws Exception /* Give up on the rest of the testcase */ return; - } - catch (Exception exc) { + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ - String methodName = "reIdentifyRelationship"; String operationDescription = "reidentify a relationship of type " + relationshipDef.getName(); Map parameters = new HashMap<>(); @@ -436,7 +443,6 @@ protected void run() throws Exception String msg = this.buildExceptionMessage(testCaseId, methodName, operationDescription, parameters, exc.getClass().getSimpleName(), exc.getMessage()); throw new Exception(msg, exc); - } @@ -444,7 +450,8 @@ protected void run() throws Exception * Validate that the relationship can no longer be retrieved under its original GUID. */ - try { + try + { start = System.currentTimeMillis(); metadataCollection.getRelationship(workPad.getLocalServerUserId(), newRelationship.getGUID()); elapsedTime = System.currentTimeMillis() - start; @@ -456,7 +463,9 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.UPDATE_INSTANCE_IDENTIFIER.getRequirementId(), "getRelationship-negative", elapsedTime); - } catch (RelationshipNotKnownException exception) { + } + catch (RelationshipNotKnownException exception) + { elapsedTime = System.currentTimeMillis() - start; assertCondition((true), assertion5, @@ -471,7 +480,8 @@ protected void run() throws Exception * Validate that the relationship can be retrieved under its new GUID. */ - try { + try + { start = System.currentTimeMillis(); Relationship theRelationship = metadataCollection.getRelationship(workPad.getLocalServerUserId(), newGUID); elapsedTime = System.currentTimeMillis() - start; @@ -483,7 +493,9 @@ protected void run() throws Exception "getRelationship", elapsedTime); - } catch (RelationshipNotKnownException exception) { + } + catch (RelationshipNotKnownException exception) + { assertCondition((false), assertion6, testTypeName + assertionMsg6, @@ -502,12 +514,15 @@ protected void run() throws Exception * not work this will fail but that's OK. */ - try { + try + { Relationship deletedRelationship = metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), newRelationship.getType().getTypeDefGUID(), newRelationship.getType().getTypeDefName(), newGUID); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeERelationship @@ -527,7 +542,8 @@ protected void run() throws Exception * These operations are to the CTS */ - try { + try + { EntityDetail deletedEntityOne = metadataCollection.deleteEntity(workPad.getLocalServerUserId(), entityOne.getType().getTypeDefGUID(), entityOne.getType().getTypeDefName(), @@ -537,7 +553,9 @@ protected void run() throws Exception entityTwo.getType().getTypeDefGUID(), entityTwo.getType().getTypeDefName(), entityTwo.getGUID()); - } catch (FunctionNotSupportedException exception) { + } + catch (FunctionNotSupportedException exception) + { /* * This is OK - we can NO OP and just proceed to purgeEntity @@ -559,8 +577,6 @@ protected void run() throws Exception } - - /** * Method to clean any instance created by the test case that has not already been cleaned by the running of the test. * @@ -571,14 +587,15 @@ public void cleanup() throws Exception OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - if (createdRelationshipsTUT != null && !createdRelationshipsTUT.isEmpty()) { + if (createdRelationshipsTUT != null && !createdRelationshipsTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (Relationship relationship : createdRelationshipsTUT) { - + for (Relationship relationship : createdRelationshipsTUT) + { try { metadataCollection.deleteRelationship(workPad.getLocalServerUserId(), @@ -606,14 +623,15 @@ public void cleanup() throws Exception - if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) { + if (createdEntitiesTUT != null && !createdEntitiesTUT.isEmpty()) + { /* * Instances were created - clean them up. */ - for (EntityDetail entity : createdEntitiesTUT) { - + for (EntityDetail entity : createdEntitiesTUT) + { try { metadataCollection.deleteEntity(workPad.getLocalServerUserId(), diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipSearch.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipSearch.java index 6f7d3daa2e4..f91c3f9a58d 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipSearch.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipSearch.java @@ -2,6 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; +import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; @@ -741,6 +742,13 @@ private Relationship createRelationship(RelationshipDef relationshipDef, Instanc RepositoryConformanceProfileRequirement.RELATIONSHIP_LIFECYCLE.getRequirementId()); + } + catch (AssertionFailureException exception) + { + /* + * Re throw this exception, so it is not masked by Exception (below). + */ + throw exception; } catch (Exception exc) { @@ -1336,7 +1344,6 @@ private void performMatchPropertiesTestForAttribute(String attributeName, MatchC RepositoryConformanceProfileRequirement.RELATIONSHIP_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.RELATIONSHIP_PROPERTY_SEARCH.getRequirementId()); } - } } @@ -1658,12 +1665,12 @@ private void performMatchPropertiesTestForAttributePair(String alphaAttributeNam RepositoryConformanceProfileRequirement.RELATIONSHIP_PROPERTY_SEARCH.getProfileId(), RepositoryConformanceProfileRequirement.RELATIONSHIP_PROPERTY_SEARCH.getRequirementId()); } - } } - private enum RegexMatchType { + private enum RegexMatchType + { Exact, Prefix, Suffix, diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestSupportedTypeDef.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestSupportedTypeDef.java index 35e1d0d0d51..8d679267c8c 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestSupportedTypeDef.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestSupportedTypeDef.java @@ -66,9 +66,9 @@ public class TestSupportedTypeDef extends RepositoryConformanceTestCase private static final String assertion20 = rootTestCaseId + "-20"; private static final String assertionMsg20 = " type name is unique."; - private TypeDef typeDef; - private String testCaseId; - private String testTypeName; + private final TypeDef typeDef; + private final String testCaseId; + private final String testTypeName; /** * Typical constructor sets up superclass diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceProfile.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceProfile.java index b3fbe8e9e0a..58177269970 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceProfile.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceProfile.java @@ -83,10 +83,26 @@ public enum RepositoryConformanceProfile implements Serializable "The technology under test supports the use of regular expressions to search for metadata instances.", "https://egeria-project.org/guides/cts/repository-profiles/entity-advanced-search", OpenMetadataConformanceProfilePriority.OPTIONAL_PROFILE), - RELATIONSHIP_ADVANCED_SEARCH (15, "Relationship advanced search", + RELATIONSHIP_ADVANCED_SEARCH (15, "Relationship advanced search", "The technology under test supports the use of regular expressions to search for relationship instances.", "https://egeria-project.org/guides/cts/repository-profiles/relationship-advanced-search", - OpenMetadataConformanceProfilePriority.OPTIONAL_PROFILE); + OpenMetadataConformanceProfilePriority.OPTIONAL_PROFILE), + INSTANCE_VERSIONS (16, "List the versions of each instance", + "The technology under test is able to return the list of versions of an instance that are stored.", + "https://egeria-project.org/guides/cts/repository-profiles/instance-versions", + OpenMetadataConformanceProfilePriority.OPTIONAL_PROFILE), + HOME_CLASSIFICATIONS (17, "Store classifications independently of entity", + "The technology under test is able to provide a home to a classification when the entity is homed in a different repository.", + "https://egeria-project.org/guides/cts/repository-profiles/home-classifications", + OpenMetadataConformanceProfilePriority.OPTIONAL_PROFILE), + EXTERNAL_INSTANCES (18, "External instances", + "The technology under test is able to store and maintain external entities.", + "https://egeria-project.org/guides/cts/repository-profiles/external-instances", + OpenMetadataConformanceProfilePriority.OPTIONAL_PROFILE), + RESTORE_FROM_BACKUP (19, "Restore metadata from a backup", + "The technology under test is able to process events that load metadata from its own backup.", + "https://egeria-project.org/guides/cts/repository-profiles/restore-from-backup", + OpenMetadataConformanceProfilePriority.OPTIONAL_PROFILE); private static final long serialVersionUID = 1L; diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceProfileRequirement.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceProfileRequirement.java index 32096189488..6135f3aa6e7 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceProfileRequirement.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceProfileRequirement.java @@ -226,7 +226,27 @@ public enum RepositoryConformanceProfileRequirement implements Serializable RELATIONSHIP_ADVANCED_VALUE_SEARCH (50, "Relationship advanced value search", "The technology under test supports the use of regular expressions within value search criteria to search for relationship instances.", "https://egeria-project.org/guides/cts/repository-profiles/relationship-advanced-search/#advanced-value-search", - RepositoryConformanceProfile.RELATIONSHIP_ADVANCED_SEARCH); + RepositoryConformanceProfile.RELATIONSHIP_ADVANCED_SEARCH), + GET_ENTITY_VERSIONS (51, "Get entity versions", + "The technology under test supports the command to retrieve stored versions of an entity.", + "https://egeria-project.org/guides/cts/repository-profiles/instance-versions/#get-entity-versions", + RepositoryConformanceProfile.INSTANCE_VERSIONS), + GET_RELATIONSHIP_VERSIONS (52, "Get relationship versions", + "The technology under test supports the command to retrieve stored versions of a relationship.", + "https://egeria-project.org/guides/cts/repository-profiles/instance-versions/#get-relationship-versions", + RepositoryConformanceProfile.INSTANCE_VERSIONS), + STORE_EXTERNAL_ENTITIES (53, "Store external entities", + "The technology under test supports the command to create external entities and retrieve them with the correct provenance.", + "https://egeria-project.org/guides/cts/repository-profiles/external-instances/#store-external-entities", + RepositoryConformanceProfile.EXTERNAL_INSTANCES), + STORE_EXTERNAL_RELATIONSHIPS (54, "Store external relationships", + "The technology under test supports the command to create external relationships and retrieve them with the correct provenance.", + "https://egeria-project.org/guides/cts/repository-profiles/external-instances/#store-external-relationships", + RepositoryConformanceProfile.EXTERNAL_INSTANCES), + STORE_EXTERNAL_CLASSIFICATIONS (55, "Store external classifications", + "The technology under test supports the command to create external classifications and retrieve them with the correct provenance.", + "https://egeria-project.org/guides/cts/repository-profiles/external-instances/#store-external-classifications", + RepositoryConformanceProfile.EXTERNAL_INSTANCES); diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkPad.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkPad.java index 08b5c163b61..58464d77032 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkPad.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkPad.java @@ -25,7 +25,7 @@ public class RepositoryConformanceWorkPad extends OpenMetadataConformanceWorkben private static final String workbenchDocURL = "https://egeria-project.org/guides/cts/" + workbenchId; private static final String tutType = "Open Metadata Repository"; - private OMRSAuditLog auditLog; + private final OMRSAuditLog auditLog; private String tutServerName = null; private String tutMetadataCollectionId = null; @@ -38,21 +38,21 @@ public class RepositoryConformanceWorkPad extends OpenMetadataConformanceWorkben private String localMetadataCollectionId = null; private OMRSRepositoryConnector localRepositoryConnector = null; - private Map supportedAttributeTypeDefsByGUIDFromRESTAPI = new HashMap<>(); - private Map supportedAttributeTypeDefsByGUIDFromEvents = new HashMap<>(); - private Map supportedAttributeTypeDefsByName = new HashMap<>(); + private Map supportedAttributeTypeDefsByGUIDFromRESTAPI = new HashMap<>(); + private final Map supportedAttributeTypeDefsByGUIDFromEvents = new HashMap<>(); + private final Map supportedAttributeTypeDefsByName = new HashMap<>(); - private Map supportedTypeDefsByGUIDFromRESTAPI = new HashMap<>(); - private Map supportedTypeDefsByGUIDFromEvents = new HashMap<>(); - private Map supportedTypeDefsByName = new HashMap<>(); + private Map supportedTypeDefsByGUIDFromRESTAPI = new HashMap<>(); + private final Map supportedTypeDefsByGUIDFromEvents = new HashMap<>(); + private final Map supportedTypeDefsByName = new HashMap<>(); - private Map> entitySubTypes = new HashMap<>(); - private Map> relationshipSubTypes = new HashMap<>(); - private Map> relationshipEndTypes = new HashMap<>(); - private Map>> entityRelationshipTypes = new HashMap<>(); - private Map>> entityInstances = new HashMap<>(); - private Map>> relationshipInstances = new HashMap<>(); + private final Map> entitySubTypes = new HashMap<>(); + private final Map> relationshipSubTypes = new HashMap<>(); + private final Map> relationshipEndTypes = new HashMap<>(); + private final Map>> entityRelationshipTypes = new HashMap<>(); + private final Map>> entityInstances = new HashMap<>(); + private final Map>> relationshipInstances = new HashMap<>(); @@ -411,7 +411,9 @@ public synchronized void setLocalRepositoryConnector(OMRSRepositoryConnector loc /** - * {@inheritDoc} + * Accumulate the set of profile names registered with this work pad. + * + * @return the profile names */ public synchronized List getProfileNames() { @@ -426,7 +428,10 @@ public synchronized List getProfileNames() /** - * {@inheritDoc} + * Accumulate the evidences for a given profile. + * + * @param profileName for which to obtain the detailed results + * @return the test evidence organized by profile and requirement within profile */ public synchronized OpenMetadataConformanceProfileResults getProfileResults(String profileName) { @@ -744,7 +749,8 @@ public List getRelationshipSubTypes(String relationshipTypeName) void addEntityRelationshipType(String entityTypeName, String relationshipTypeName, int end) { List> bothEndLists = this.entityRelationshipTypes.get(entityTypeName); - if (bothEndLists == null) { + if (bothEndLists == null) + { List end1List = new ArrayList<>(); List end2List = new ArrayList<>(); bothEndLists = new ArrayList<>(); @@ -752,11 +758,14 @@ void addEntityRelationshipType(String entityTypeName, String relationshipTypeNam bothEndLists.add(end2List); this.entityRelationshipTypes.put(entityTypeName,bothEndLists); } - if (end == 1) { + + if (end == 1) + { List end1List = bothEndLists.get(0); end1List.add(relationshipTypeName); } - else if (end == 2) { + else if (end == 2) + { List end1List = bothEndLists.get(1); end1List.add(relationshipTypeName); } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkbench.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkbench.java index b5915094816..e06b25af7b2 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkbench.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkbench.java @@ -116,13 +116,16 @@ private void runTests() { for (TypeDef typeDef : typeDefs) { - TestSupportedTypeDef testTypeDef = new TestSupportedTypeDef(workPad, - typeDef, - null, - RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getProfileId(), - RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getRequirementId()); + if (typeDef.getStatus() != TypeDefStatus.DEPRECATED_TYPEDEF) + { + TestSupportedTypeDef testTypeDef = new TestSupportedTypeDef(workPad, + typeDef, + null, + RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getProfileId(), + RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getRequirementId()); - typeDefTestCases.add(testTypeDef); + typeDefTestCases.add(testTypeDef); + } } } @@ -158,6 +161,7 @@ private void runTests() List entityTestCases = new ArrayList<>(); List relationshipTestCases = new ArrayList<>(); List classificationTestCases = new ArrayList<>(); + /* * Reference Copy Lifecycle testcases */ @@ -179,8 +183,6 @@ private void runTests() List entityRetypeTestCases = new ArrayList<>(); - - /* * Search testcases - these are multiphase tests (create, execute, clean) */ @@ -198,26 +200,18 @@ private void runTests() * Construct a map of entity type name to list of names of subtypes of that entity type. * The map is held in the workPad. */ + OMRSRepositoryConnector cohortRepositoryConnector = workPad.getTutRepositoryConnector(); + OMRSRepositoryHelper repositoryHelper = cohortRepositoryConnector.getRepositoryHelper(); if (entityDefs != null) { - for (EntityDef entityDef : entityDefs.values()) { - String entityTypeName = entityDef.getName(); - /* - * For this entity type - find ALL its supertypes and add the entity type name to their subtype map entries. - */ - OMRSRepositoryConnector cohortRepositoryConnector = null; - OMRSRepositoryHelper repositoryHelper = null; - if (workPad != null) - { - cohortRepositoryConnector = workPad.getTutRepositoryConnector(); - repositoryHelper = cohortRepositoryConnector.getRepositoryHelper(); - } /* + * For this entity type - find ALL its supertypes and add the entity type name to their subtype map entries. + * * All entity defs are read from the known types (using the repository helper), not from the gallery returned by * the repository */ @@ -244,13 +238,10 @@ private void runTests() * These maps are useful during graph query testcases, to compose a supported graph. * The maps are held in the workPad. */ - if (relationshipDefs != null) { - for (RelationshipDef relationshipDef : relationshipDefs) { - String relationshipTypeName = relationshipDef.getName(); /* * For this relationship type - find both the end types and add the entity type names to the map. @@ -258,22 +249,14 @@ private void runTests() */ String entityOneTypeName = relationshipDef.getEndDef1().getEntityType().getName(); String entityTwoTypeName = relationshipDef.getEndDef2().getEntityType().getName(); + workPad.addRelationshipEndTypes(relationshipTypeName, entityOneTypeName, entityTwoTypeName); workPad.addEntityRelationshipType(entityOneTypeName, relationshipTypeName, 1); workPad.addEntityRelationshipType(entityTwoTypeName, relationshipTypeName, 2); /* * For this relationship type - find ALL its supertypes and add the relationship type name to their subtype map entries. - */ - OMRSRepositoryConnector cohortRepositoryConnector = null; - OMRSRepositoryHelper repositoryHelper = null; - if (workPad != null) - { - cohortRepositoryConnector = workPad.getTutRepositoryConnector(); - repositoryHelper = cohortRepositoryConnector.getRepositoryHelper(); - } - - /* + * * All relationship defs are read from the known types (using the repository helper), not from the gallery returned by * the repository */ @@ -293,21 +276,17 @@ private void runTests() } } - } - /* * Build the test cases for the entities, relationships and classifications */ if (entityDefs != null) { - for (EntityDef entityDef : entityDefs.values()) { - TestSupportedEntityLifecycle testEntityLifecycle = new TestSupportedEntityLifecycle(workPad, entityDef); entityTestCases.add(testEntityLifecycle); @@ -323,16 +302,13 @@ private void runTests() TestSupportedEntitySearch testEntitySearch = new TestSupportedEntitySearch(workPad, entityDef); entitySearchTestCases.add(testEntitySearch); } - } if (relationshipDefs != null) { - for (RelationshipDef relationshipDef : relationshipDefs) { - TestSupportedRelationshipLifecycle testRelationshipLifecycle = new TestSupportedRelationshipLifecycle(workPad, entityDefs, relationshipDef); relationshipTestCases.add(testRelationshipLifecycle); @@ -348,18 +324,14 @@ private void runTests() TestSupportedRelationshipSearch testRelationshipSearch = new TestSupportedRelationshipSearch(workPad, entityDefs, relationshipDef); relationshipSearchTestCases.add(testRelationshipSearch); - - } } if (classificationDefs != null) { - for (ClassificationDef classificationDef : classificationDefs) { - TestClassificationHasSupportedEntities testClassificationHasSupportedEntities = new TestClassificationHasSupportedEntities(workPad, entityDefs, classificationDef); testClassificationHasSupportedEntities.executeTest(); @@ -386,9 +358,6 @@ private void runTests() } - - - /* * Validate all the entities, relationships and classifications */ @@ -469,7 +438,6 @@ private void runTests() } - /* * Validate all the entity and relationship searches */ @@ -496,7 +464,6 @@ private void runTests() testCase.executeTest(OpenMetadataTestCase.TestPhase.CLEAN); } - /* * Phase 1 */ @@ -504,6 +471,7 @@ private void runTests() { testCase.executeTest(OpenMetadataTestCase.TestPhase.SEED); } + /* * Phase 2 */ @@ -536,9 +504,7 @@ private void runTests() TestGraphQueries testGraphQueries = new TestGraphQueries(workPad, relationshipDefs, entityDefs); testGraphQueries.executeTest(); } - } - } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/listener/ConformanceSuiteOMRSTopicListener.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/listener/ConformanceSuiteOMRSTopicListener.java index 9f126595986..b66927e3c59 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/listener/ConformanceSuiteOMRSTopicListener.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/listener/ConformanceSuiteOMRSTopicListener.java @@ -26,7 +26,7 @@ public class ConformanceSuiteOMRSTopicListener implements OMRSTopicListener { private static final Logger log = LoggerFactory.getLogger(ConformanceSuiteOMRSTopicListener.class); - private RepositoryConformanceWorkPad workPad; + private final RepositoryConformanceWorkPad workPad; private List bufferedTypeDefEvents = new ArrayList<>(); private int typeDefEventCount = 0; diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-spring/src/main/java/org/odpi/openmetadata/conformance/server/spring/ConformanceSuiteResource.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-spring/src/main/java/org/odpi/openmetadata/conformance/server/spring/ConformanceSuiteResource.java index 63623393dc2..fa0a0b2d72e 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-spring/src/main/java/org/odpi/openmetadata/conformance/server/spring/ConformanceSuiteResource.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-spring/src/main/java/org/odpi/openmetadata/conformance/server/spring/ConformanceSuiteResource.java @@ -82,7 +82,7 @@ public ProfileNameListResponse getProfileNames(@PathVariable String userId, /** - * Requests detailed information on the execution of a specific test case. + * Requests detailed information on the execution of a specific profile. * (Response size will vary, but could be ~25MB for the largest profile ("Metadata sharing").) * * @param userId calling user. diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/EndpointProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/EndpointProperties.java index bc74186c349..f301bfe3fc2 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/EndpointProperties.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/EndpointProperties.java @@ -25,11 +25,11 @@ public class EndpointProperties extends ReferenceableProperties { private static final long serialVersionUID = 1L; - private String technicalName = null; - private String technicalDescription = null; - private String address = null; - private String protocol = null; - private String encryptionMethod = null; + private String name = null; + private String description = null; + private String address = null; + private String protocol = null; + private String encryptionMethod = null; /** @@ -52,8 +52,8 @@ public EndpointProperties(EndpointProperties template) if (template != null) { - technicalName = template.getTechnicalName(); - technicalDescription = template.getTechnicalDescription(); + name = template.getName(); + description = template.getDescription(); address = template.getAddress(); protocol = template.getProtocol(); encryptionMethod = template.getEncryptionMethod(); @@ -64,11 +64,11 @@ public EndpointProperties(EndpointProperties template) /** * Set up the technical name for the endpoint. * - * @param technicalName String name + * @param name String name */ - public void setTechnicalName(String technicalName) + public void setName(String name) { - this.technicalName = technicalName; + this.name = name; } @@ -78,20 +78,20 @@ public void setTechnicalName(String technicalName) * * @return String name */ - public String getTechnicalName() + public String getName() { - return technicalName; + return name; } /** * Set up the technical description of the endpoint. * - * @param technicalDescription String + * @param description String */ - public void setTechnicalDescription(String technicalDescription) + public void setDescription(String description) { - this.technicalDescription = technicalDescription; + this.description = description; } @@ -100,9 +100,9 @@ public void setTechnicalDescription(String technicalDescription) * * @return String technicalDescription */ - public String getTechnicalDescription() + public String getDescription() { - return technicalDescription; + return description; } @@ -186,8 +186,8 @@ public String getEncryptionMethod() public String toString() { return "EndpointProperties{" + - "technicalName='" + technicalName + '\'' + - ", technicalDescription='" + technicalDescription + '\'' + + "name='" + name + '\'' + + ", description='" + description + '\'' + ", address='" + address + '\'' + ", protocol='" + protocol + '\'' + ", encryptionMethod='" + encryptionMethod + '\'' + @@ -221,8 +221,8 @@ public boolean equals(Object objectToCompare) return false; } EndpointProperties that = (EndpointProperties) objectToCompare; - return Objects.equals(technicalName, that.technicalName) && - Objects.equals(technicalDescription, that.technicalDescription) && + return Objects.equals(name, that.name) && + Objects.equals(description, that.description) && Objects.equals(address, that.address) && Objects.equals(protocol, that.protocol) && Objects.equals(encryptionMethod, that.encryptionMethod); @@ -237,6 +237,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(super.hashCode(), technicalName, technicalDescription, address, protocol, encryptionMethod); + return Objects.hash(super.hashCode(), name, description, address, protocol, encryptionMethod); } } diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/EndpointConverter.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/EndpointConverter.java index 2447d52ad37..40efa17eac8 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/EndpointConverter.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/EndpointConverter.java @@ -72,8 +72,8 @@ public B getNewBean(Class beanClass, endpointProperties.setQualifiedName(this.removeQualifiedName(instanceProperties)); endpointProperties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); - endpointProperties.setTechnicalName(this.removeName(instanceProperties)); - endpointProperties.setTechnicalDescription(this.removeDescription(instanceProperties)); + endpointProperties.setName(this.removeName(instanceProperties)); + endpointProperties.setDescription(this.removeDescription(instanceProperties)); endpointProperties.setAddress(this.removeNetworkAddress(instanceProperties)); endpointProperties.setProtocol(this.removeProtocol(instanceProperties)); endpointProperties.setEncryptionMethod(this.removeEncryptionMethod(instanceProperties)); diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/ConnectionRESTServices.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/ConnectionRESTServices.java index 9d41bc4c8e1..e2aa03ce6fd 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/ConnectionRESTServices.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/ConnectionRESTServices.java @@ -1079,8 +1079,8 @@ public GUIDResponse createEndpoint(String serverName, null, null, endpointProperties.getQualifiedName(), - endpointProperties.getTechnicalName(), - endpointProperties.getTechnicalDescription(), + endpointProperties.getName(), + endpointProperties.getDescription(), endpointProperties.getAddress(), endpointProperties.getProtocol(), endpointProperties.getEncryptionMethod(), @@ -1210,8 +1210,8 @@ public VoidResponse updateEndpoint(String serverName, endpointGUID, guidParameter, endpointProperties.getQualifiedName(), - endpointProperties.getTechnicalName(), - endpointProperties.getTechnicalDescription(), + endpointProperties.getName(), + endpointProperties.getDescription(), endpointProperties.getAddress(), endpointProperties.getProtocol(), endpointProperties.getEncryptionMethod(), diff --git a/open-metadata-implementation/access-services/digital-architecture/digital-architecture-api/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/properties/EndpointProperties.java b/open-metadata-implementation/access-services/digital-architecture/digital-architecture-api/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/properties/EndpointProperties.java index 463ed01b936..723c097c8af 100644 --- a/open-metadata-implementation/access-services/digital-architecture/digital-architecture-api/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/properties/EndpointProperties.java +++ b/open-metadata-implementation/access-services/digital-architecture/digital-architecture-api/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/properties/EndpointProperties.java @@ -22,11 +22,11 @@ public class EndpointProperties extends ReferenceableProperties { private static final long serialVersionUID = 1L; - private String technicalName = null; - private String technicalDescription = null; - private String address = null; - private String protocol = null; - private String encryptionMethod = null; + private String resourceName = null; + private String resourceDescription = null; + private String address = null; + private String protocol = null; + private String encryptionMethod = null; /** @@ -49,11 +49,11 @@ public EndpointProperties(EndpointProperties template) if (template != null) { - technicalName = template.getTechnicalName(); - technicalDescription = template.getTechnicalDescription(); - address = template.getAddress(); - protocol = template.getProtocol(); - encryptionMethod = template.getEncryptionMethod(); + resourceName = template.getResourceName(); + resourceDescription = template.getResourceDescription(); + address = template.getAddress(); + protocol = template.getProtocol(); + encryptionMethod = template.getEncryptionMethod(); } } @@ -61,11 +61,11 @@ public EndpointProperties(EndpointProperties template) /** * Set up the technical name for the endpoint. * - * @param technicalName String name + * @param resourceName String name */ - public void setTechnicalName(String technicalName) + public void setResourceName(String resourceName) { - this.technicalName = technicalName; + this.resourceName = resourceName; } @@ -75,20 +75,20 @@ public void setTechnicalName(String technicalName) * * @return String name */ - public String getTechnicalName() + public String getResourceName() { - return technicalName; + return resourceName; } /** * Set up the technical description of the endpoint. * - * @param technicalDescription String + * @param resourceDescription String */ - public void setTechnicalDescription(String technicalDescription) + public void setResourceDescription(String resourceDescription) { - this.technicalDescription = technicalDescription; + this.resourceDescription = resourceDescription; } @@ -97,9 +97,9 @@ public void setTechnicalDescription(String technicalDescription) * * @return String technicalDescription */ - public String getTechnicalDescription() + public String getResourceDescription() { - return technicalDescription; + return resourceDescription; } @@ -183,8 +183,8 @@ public String getEncryptionMethod() public String toString() { return "EndpointProperties{" + - "technicalName='" + technicalName + '\'' + - ", technicalDescription='" + technicalDescription + '\'' + + "resourceName='" + resourceName + '\'' + + ", resourceDescription='" + resourceDescription + '\'' + ", address='" + address + '\'' + ", protocol='" + protocol + '\'' + ", encryptionMethod='" + encryptionMethod + '\'' + @@ -220,8 +220,8 @@ public boolean equals(Object objectToCompare) return false; } EndpointProperties that = (EndpointProperties) objectToCompare; - return Objects.equals(technicalName, that.technicalName) && - Objects.equals(technicalDescription, that.technicalDescription) && + return Objects.equals(resourceName, that.resourceName) && + Objects.equals(resourceDescription, that.resourceDescription) && Objects.equals(address, that.address) && Objects.equals(protocol, that.protocol) && Objects.equals(encryptionMethod, that.encryptionMethod); @@ -236,6 +236,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(super.hashCode(), technicalName, technicalDescription, address, protocol, encryptionMethod); + return Objects.hash(super.hashCode(), resourceName, resourceDescription, address, protocol, encryptionMethod); } } diff --git a/open-metadata-implementation/access-services/digital-architecture/digital-architecture-server/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/converters/EndpointConverter.java b/open-metadata-implementation/access-services/digital-architecture/digital-architecture-server/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/converters/EndpointConverter.java index 20414d019e2..c73fb10240a 100644 --- a/open-metadata-implementation/access-services/digital-architecture/digital-architecture-server/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/converters/EndpointConverter.java +++ b/open-metadata-implementation/access-services/digital-architecture/digital-architecture-server/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/converters/EndpointConverter.java @@ -72,8 +72,8 @@ public B getNewBean(Class beanClass, endpointProperties.setQualifiedName(this.removeQualifiedName(instanceProperties)); endpointProperties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); - endpointProperties.setTechnicalName(this.removeName(instanceProperties)); - endpointProperties.setTechnicalDescription(this.removeDescription(instanceProperties)); + endpointProperties.setResourceName(this.removeName(instanceProperties)); + endpointProperties.setResourceDescription(this.removeDescription(instanceProperties)); endpointProperties.setAddress(this.removeNetworkAddress(instanceProperties)); endpointProperties.setProtocol(this.removeProtocol(instanceProperties)); endpointProperties.setEncryptionMethod(this.removeEncryptionMethod(instanceProperties)); diff --git a/open-metadata-implementation/access-services/digital-architecture/digital-architecture-server/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/server/ConnectionRESTServices.java b/open-metadata-implementation/access-services/digital-architecture/digital-architecture-server/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/server/ConnectionRESTServices.java index 028be2a49e1..268a06cf1e0 100644 --- a/open-metadata-implementation/access-services/digital-architecture/digital-architecture-server/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/server/ConnectionRESTServices.java +++ b/open-metadata-implementation/access-services/digital-architecture/digital-architecture-server/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/server/ConnectionRESTServices.java @@ -1063,8 +1063,8 @@ public GUIDResponse createEndpoint(String serverName, null, null, endpointProperties.getQualifiedName(), - endpointProperties.getTechnicalName(), - endpointProperties.getTechnicalDescription(), + endpointProperties.getResourceName(), + endpointProperties.getResourceDescription(), endpointProperties.getAddress(), endpointProperties.getProtocol(), endpointProperties.getEncryptionMethod(), @@ -1194,8 +1194,8 @@ public VoidResponse updateEndpoint(String serverName, endpointGUID, guidParameter, endpointProperties.getQualifiedName(), - endpointProperties.getTechnicalName(), - endpointProperties.getTechnicalDescription(), + endpointProperties.getResourceName(), + endpointProperties.getResourceDescription(), endpointProperties.getAddress(), endpointProperties.getProtocol(), endpointProperties.getEncryptionMethod(), diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/properties/AssetProperties.java b/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/properties/AssetProperties.java index db2de595e60..380ed00084c 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/properties/AssetProperties.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/properties/AssetProperties.java @@ -20,9 +20,9 @@ public class AssetProperties extends SupplementaryProperties { private static final long serialVersionUID = 1L; - private String technicalName = null; - private String versionIdentifier = null; - private String technicalDescription = null; + private String resourceName = null; + private String versionIdentifier = null; + private String resourceDescription = null; /** * Default constructor @@ -43,33 +43,33 @@ public AssetProperties(AssetProperties template) if (template != null) { - technicalName = template.getDisplayName(); + resourceName = template.getDisplayName(); versionIdentifier = template.getVersionIdentifier(); - technicalDescription = template.getTechnicalDescription(); + resourceDescription = template.getResourceDescription(); } } /** - * Returns the stored technical name property for the asset. + * Returns the name property for the resource as it is known by the supporting technology. * If no technical name is available then null is returned. * * @return String name */ - public String getTechnicalName() + public String getResourceName() { - return technicalName; + return resourceName; } /** - * Set up the stored technical name property for the asset. + * Set up the stored technical name property for the resource. * - * @param technicalName String name + * @param resourceName String name */ - public void setTechnicalName(String technicalName) + public void setResourceName(String resourceName) { - this.technicalName = technicalName; + this.resourceName = resourceName; } @@ -102,20 +102,20 @@ public void setVersionIdentifier(String versionIdentifier) * * @return description String text */ - public String getTechnicalDescription() + public String getResourceDescription() { - return technicalDescription; + return resourceDescription; } /** * Set up the stored technical description property associated with the asset. * - * @param technicalDescription String text + * @param resourceDescription String text */ - public void setTechnicalDescription(String technicalDescription) + public void setResourceDescription(String resourceDescription) { - this.technicalDescription = technicalDescription; + this.resourceDescription = resourceDescription; } @@ -128,9 +128,9 @@ public void setTechnicalDescription(String technicalDescription) public String toString() { return "AssetProperties{" + - "technicalName='" + technicalName + '\'' + + "resourceName='" + resourceName + '\'' + ", versionIdentifier='" + versionIdentifier + '\'' + - ", technicalDescription='" + technicalDescription + '\'' + + ", resourceDescription='" + resourceDescription + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + ", effectiveFrom=" + getEffectiveFrom() + @@ -170,7 +170,7 @@ public boolean equals(Object objectToCompare) AssetProperties that = (AssetProperties) objectToCompare; - if (technicalName != null ? ! technicalName.equals(that.technicalName) : that.technicalName != null) + if (resourceName != null ? ! resourceName.equals(that.resourceName) : that.resourceName != null) { return false; } @@ -178,7 +178,7 @@ public boolean equals(Object objectToCompare) { return false; } - return technicalDescription != null ? technicalDescription.equals(that.technicalDescription) : that.technicalDescription == null; + return resourceDescription != null ? resourceDescription.equals(that.resourceDescription) : that.resourceDescription == null; } @@ -190,6 +190,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(super.hashCode(), technicalName, versionIdentifier, technicalDescription); + return Objects.hash(super.hashCode(), resourceName, versionIdentifier, resourceDescription); } } diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/converters/AssetConverter.java b/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/converters/AssetConverter.java index 56cceae4d56..6157b07971d 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/converters/AssetConverter.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/converters/AssetConverter.java @@ -121,8 +121,8 @@ public B getNewComplexBean(Class beanClass, assetProperties.setQualifiedName(this.removeQualifiedName(instanceProperties)); assetProperties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); - assetProperties.setTechnicalName(this.removeName(instanceProperties)); - assetProperties.setTechnicalDescription(this.removeDescription(instanceProperties)); + assetProperties.setResourceName(this.removeName(instanceProperties)); + assetProperties.setResourceDescription(this.removeDescription(instanceProperties)); /* Note this value should be in the classification and have been incorporated into the element header already */ this.removeOwner(instanceProperties); diff --git a/open-metadata-implementation/access-services/stewardship-action/stewardship-action-api/src/main/java/org/odpi/openmetadata/accessservices/stewardshipaction/properties/AssetProperties.java b/open-metadata-implementation/access-services/stewardship-action/stewardship-action-api/src/main/java/org/odpi/openmetadata/accessservices/stewardshipaction/properties/AssetProperties.java index d9d3bf0835a..74d9b6d7c9c 100644 --- a/open-metadata-implementation/access-services/stewardship-action/stewardship-action-api/src/main/java/org/odpi/openmetadata/accessservices/stewardshipaction/properties/AssetProperties.java +++ b/open-metadata-implementation/access-services/stewardship-action/stewardship-action-api/src/main/java/org/odpi/openmetadata/accessservices/stewardshipaction/properties/AssetProperties.java @@ -22,9 +22,9 @@ public class AssetProperties extends SupplementaryProperties { private static final long serialVersionUID = 1L; - private String technicalName = null; - private String versionIdentifier = null; - private String technicalDescription = null; + private String resourceName = null; + private String versionIdentifier = null; + private String resourceDescription = null; /** * Default constructor @@ -45,33 +45,33 @@ public AssetProperties(AssetProperties template) if (template != null) { - technicalName = template.getDisplayName(); + resourceName = template.getDisplayName(); versionIdentifier = template.getVersionIdentifier(); - technicalDescription = template.getTechnicalDescription(); + resourceDescription = template.getResourceDescription(); } } /** - * Returns the stored technical name property for the asset. + * Returns the name of the resource as known to the technology that supports it. * If no technical name is available then null is returned. * * @return String name */ - public String getTechnicalName() + public String getResourceName() { - return technicalName; + return resourceName; } /** - * Set up the stored technical name property for the asset. + * Set up name of the resource as known to the technology that supports it. * - * @param technicalName String name + * @param resourceName String name */ - public void setTechnicalName(String technicalName) + public void setResourceName(String resourceName) { - this.technicalName = technicalName; + this.resourceName = resourceName; } @@ -99,25 +99,25 @@ public void setVersionIdentifier(String versionIdentifier) /** - * Returns the stored technical description property for the asset. + * Returns the stored technical description property from the resource. * If no description is provided then null is returned. * * @return description String text */ - public String getTechnicalDescription() + public String getResourceDescription() { - return technicalDescription; + return resourceDescription; } /** - * Set up the stored technical description property associated with the asset. + * Set up the stored technical description property associated with the resource. * - * @param technicalDescription String text + * @param resourceDescription String text */ - public void setTechnicalDescription(String technicalDescription) + public void setResourceDescription(String resourceDescription) { - this.technicalDescription = technicalDescription; + this.resourceDescription = resourceDescription; } @@ -130,9 +130,9 @@ public void setTechnicalDescription(String technicalDescription) public String toString() { return "AssetProperties{" + - "technicalName='" + technicalName + '\'' + + "resourceName='" + resourceName + '\'' + ", versionIdentifier='" + versionIdentifier + '\'' + - ", technicalDescription='" + technicalDescription + '\'' + + ", resourceDescription='" + resourceDescription + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + ", effectiveFrom=" + getEffectiveFrom() + @@ -172,7 +172,7 @@ public boolean equals(Object objectToCompare) AssetProperties that = (AssetProperties) objectToCompare; - if (technicalName != null ? ! technicalName.equals(that.technicalName) : that.technicalName != null) + if (resourceName != null ? ! resourceName.equals(that.resourceName) : that.resourceName != null) { return false; } @@ -180,7 +180,7 @@ public boolean equals(Object objectToCompare) { return false; } - return technicalDescription != null ? technicalDescription.equals(that.technicalDescription) : that.technicalDescription == null; + return resourceDescription != null ? resourceDescription.equals(that.resourceDescription) : that.resourceDescription == null; } @@ -192,6 +192,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(super.hashCode(), technicalName, versionIdentifier, technicalDescription); + return Objects.hash(super.hashCode(), resourceName, versionIdentifier, resourceDescription); } } diff --git a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/graph-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/graphrepository/repositoryconnector/GraphOMRSEntityMapper.java b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/graph-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/graphrepository/repositoryconnector/GraphOMRSEntityMapper.java index fe225090394..2496605721b 100644 --- a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/graph-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/graphrepository/repositoryconnector/GraphOMRSEntityMapper.java +++ b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/graph-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/graphrepository/repositoryconnector/GraphOMRSEntityMapper.java @@ -92,7 +92,7 @@ private void addProperty(Vertex vertex, String propertyName, String qualifiedPro /* * method to remove property from vertex. - * qualfiiedPropName is the non-prefixed name - qualified by typename if a TDA; or simple core property name + * qualifiedPropName is the non-prefixed name - qualified by typename if a TDA; or simple core property name */ private void removeProperty(Vertex vertex, String qualifiedPropName) { // no value has been specified - remove the property from the vertex diff --git a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/graph-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/graphrepository/repositoryconnector/GraphOMRSMetadataStore.java b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/graph-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/graphrepository/repositoryconnector/GraphOMRSMetadataStore.java index 1c4de33e6b6..19d6f8e541b 100644 --- a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/graph-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/graphrepository/repositoryconnector/GraphOMRSMetadataStore.java +++ b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/graph-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/graphrepository/repositoryconnector/GraphOMRSMetadataStore.java @@ -102,19 +102,19 @@ class GraphOMRSMetadataStore { private static final Logger log = LoggerFactory.getLogger(GraphOMRSMetadataStore.class); - private String repositoryName; - private String metadataCollectionId; + private final String repositoryName; + private final String metadataCollectionId; - private OMRSRepositoryHelper repositoryHelper; + private final OMRSRepositoryHelper repositoryHelper; // The instance graph is used to store entities (vertices) and relationships (edges). GraphOMRSGraphFactory graphFactory; - private JanusGraph instanceGraph; - private GraphOMRSRelationshipMapper relationshipMapper; - private GraphOMRSEntityMapper entityMapper; - private GraphOMRSClassificationMapper classificationMapper; + private final JanusGraph instanceGraph; + private final GraphOMRSRelationshipMapper relationshipMapper; + private final GraphOMRSEntityMapper entityMapper; + private final GraphOMRSClassificationMapper classificationMapper; /** @@ -368,7 +368,7 @@ synchronized void createEntityProxyInStore(EntityProxy entityProxy) * In summary * - if no entity, create the ref copy * - if existing entity, - * - if its a proxy + * - if it is a proxy * check the metadataCollectionId matches the one passed. * if matching metadataCollectionId * update the existing entity, replacing the proxy with the ref copy; the proxy flag will be cleared. @@ -415,14 +415,12 @@ synchronized void saveEntityReferenceCopyToStore(EntityDetail entity) */ String vertexMetadataCollectionId = entityMapper.getEntityMetadataCollectionId(vertex); - if (metadataCollectionId.equals(entity.getMetadataCollectionId()) - || !vertexMetadataCollectionId.equals(entity.getMetadataCollectionId())) + if (! vertexMetadataCollectionId.equals(entity.getMetadataCollectionId())) { /* * Error condition - * Either the local repository is being asked to save a reference copy of something it already owns, - * or it already has a proxy or reference copy of an entity from a repository other than the one that + * The local repository already has a proxy or reference copy of an entity from a repository other than the one that * submitted this reference copy. */ @@ -1090,19 +1088,16 @@ synchronized void saveRelationshipReferenceCopyToStore(Relationship relationship log.debug("{} found existing edge {}", methodName, edge); /* - * Check the metadataCollectionId is not local and that it matches the metadataCollectionId of the + * Check the metadataCollectionId matches the metadataCollectionId of the * passed relationship */ String edgeMetadataCollectionId = relationshipMapper.getRelationshipMetadataCollectionId(edge); - if (metadataCollectionId.equals(relationship.getMetadataCollectionId()) - || !edgeMetadataCollectionId.equals(relationship.getMetadataCollectionId())) + if (! edgeMetadataCollectionId.equals(relationship.getMetadataCollectionId())) { - /* * Error condition - * Either the local repository is being asked to save a reference copy of something it already owns, - * or it already has a reference copy of a relationship from a repository other than the one that + * Either the local repository already has a reference copy of a relationship from a repository other than the one that * submitted this reference copy. */ diff --git a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java index a4e02218042..1b861d8060a 100644 --- a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java +++ b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java @@ -936,11 +936,11 @@ public List getRelationshipHistory(String userId, if ((pageSize == 0) || (pageSize >= relationshipHistory.size())) { - return new ArrayList<>(relationshipHistory.subList(startFromElement, relationshipHistory.size() - 1)); + return new ArrayList<>(relationshipHistory.subList(startFromElement, relationshipHistory.size())); } else { - return new ArrayList<>(relationshipHistory.subList(startFromElement, pageSize - 1)); + return new ArrayList<>(relationshipHistory.subList(startFromElement, pageSize)); } } @@ -2819,11 +2819,11 @@ public List getEntityDetailHistory(String userId, if ((pageSize == 0) || (pageSize >= entityHistory.size())) { - return new ArrayList<>(entityHistory.subList(startFromElement, entityHistory.size() - 1)); + return new ArrayList<>(entityHistory.subList(startFromElement, entityHistory.size())); } else { - return new ArrayList<>(entityHistory.subList(startFromElement, pageSize - 1)); + return new ArrayList<>(entityHistory.subList(startFromElement, pageSize)); } } diff --git a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java index 3f38335b50c..6036bb0805e 100644 --- a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java +++ b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java @@ -52,7 +52,7 @@ static boolean checkInclusiveDate(Date fromTime, versionStartTime = instanceHeader.getCreateTime(); } - if (toTime.before(versionStartTime)) + if ((toTime != null) && (toTime.before(versionStartTime))) { return false; } @@ -62,6 +62,11 @@ static boolean checkInclusiveDate(Date fromTime, return true; } + if (fromTime == null) + { + return true; + } + return ! fromTime.after(versionEndTime); } @@ -893,7 +898,11 @@ void saveEntity(EntityDetail entity) throws RepositoryErrorException */ if ((this.entity == null) || (entity.getVersion() >= this.entity.getVersion())) { - entityHistory.add(0, this.entity); + if (this.entity != null) + { + entityHistory.add(0, this.entity); + } + this.entity = new EntityDetail(entity); } @@ -1005,13 +1014,12 @@ EntityDetail getEntity(Date asOfTime) /* * The element has never been updated so the initial version is still valid. */ - if (entity.getUpdateTime() != null) + if (entity.getUpdateTime() == null) { return entity; } - if ((asOfTime.equals(entity.getUpdateTime())) || - (asOfTime.after(entity.getUpdateTime()))) + if ((asOfTime.equals(entity.getUpdateTime())) || (asOfTime.after(entity.getUpdateTime()))) { /* * The asOfTime is within the window of when this instance is valid. @@ -1057,45 +1065,60 @@ List getEntityHistory(Date fromTime, boolean oldestFirst) { List historyResults = new ArrayList<>(); - Date followingUpdateTime = null; - if (this.entity != null) + /* + * Do not have a full entity + */ + if (this.entity == null) { - if (toTime.before(this.entity.getCreateTime())) - { - /* - * The entity is known - but none of its instances are in the requested date range. - */ - return historyResults; - } - else - { - /* - * The current version of the entity is in range. - */ - if (oldestFirst) - { - historyResults.add(this.entity); - } - else - { - historyResults.add(0, this.entity); - } + return null; + } - followingUpdateTime = this.entity.getUpdateTime(); - } + if ((toTime != null) && (toTime.before(this.entity.getCreateTime()))) + { + /* + * The entity is known - but the query time is from before the instance existed. + */ + return null; } + /* + * The current version of the entity is in range. + */ + if (checkInclusiveDate(fromTime, toTime, this.entity, null)) + { + historyResults.add(this.entity); + } if (! this.entityHistory.isEmpty()) { + /* + * The period when an instance is active is from its updateTime to the updateTime of the next element. + * The entityHistory has the latest version first. + */ + Date followingUpdateTime = this.entity.getUpdateTime(); + for (EntityDetail historicalInstance : this.entityHistory) { if (checkInclusiveDate(fromTime, toTime, historicalInstance, followingUpdateTime)) { - historyResults.add(historicalInstance); - followingUpdateTime = historicalInstance.getUpdateTime(); + if (oldestFirst) + { + /* + * Add to the front + */ + historyResults.add(0, historicalInstance); + } + else + { + /* + * Add to the back + */ + historyResults.add(historicalInstance); + } } + + followingUpdateTime = historicalInstance.getUpdateTime(); } } @@ -1207,8 +1230,8 @@ private class StoredRelationship { private final List relationshipHistory = new ArrayList<>(); - private volatile Relationship relationship = null; - private volatile Date purgeTime = null; + private volatile Relationship relationship = null; + private volatile Date unilateralDeleteTime = null; /** @@ -1246,7 +1269,7 @@ void purgeRelationship() if (this.relationship != null) { this.relationshipHistory.add(this.relationship); - this.purgeTime = new Date(); + this.unilateralDeleteTime = new Date(); } this.relationship = null; @@ -1295,13 +1318,12 @@ Relationship getRelationship(Date asOfTime) /* * The element has never been updated so the initial version is still valid. */ - if (relationship.getUpdateTime() != null) + if (relationship.getUpdateTime() == null) { return relationship; } - if ((asOfTime.equals(relationship.getUpdateTime())) || - (asOfTime.after(relationship.getUpdateTime()))) + if ((asOfTime.equals(relationship.getUpdateTime())) || (asOfTime.after(relationship.getUpdateTime()))) { /* * The asOfTime is within the window of when this instance is valid. @@ -1320,8 +1342,7 @@ Relationship getRelationship(Date asOfTime) return historicalRelationship; } - if ((asOfTime.equals(historicalRelationship.getUpdateTime())) || - (asOfTime.after(historicalRelationship.getUpdateTime()))) + if ((asOfTime.equals(historicalRelationship.getUpdateTime())) || (asOfTime.after(historicalRelationship.getUpdateTime()))) { /* * The asOfTime is within the window of when this instance was valid. @@ -1349,54 +1370,77 @@ List getRelationshipHistory(Date fromTime, List historyResults = new ArrayList<>(); Date followingUpdateTime = null; - if (this.relationship != null) + /* + * Do not have a relationship + */ + if (this.relationship == null) + { + return null; + } + + if ((toTime != null) && (toTime.before(this.relationship.getCreateTime()))) + { + /* + * The relationship is known - but the query time is from before the instance existed. + */ + return null; + } + + if (unilateralDeleteTime != null) { - if (toTime.before(this.relationship.getCreateTime())) + /* + * Unilateral delete set when a linked entity is deleted. + */ + if (fromTime.after(unilateralDeleteTime)) { /* - * The entity is known - but none of its instances are in the requested date range. + * The relationship has been purged before the "fromTime". */ - return historyResults; + return null; } - else - { - /* - * The current version of the entity is in range. - */ - if (oldestFirst) - { - historyResults.add(this.relationship); - } - else - { - historyResults.add(0, this.relationship); - } - followingUpdateTime = this.relationship.getUpdateTime(); - } + followingUpdateTime = unilateralDeleteTime; } - else if (purgeTime != null) + else { - if (fromTime.after(purgeTime)) + if (checkInclusiveDate(fromTime, toTime, this.relationship, null)) { /* - * The entity has been purged before the "fromTime". + * The current version of the relationship is in range. */ - return historyResults; + historyResults.add(this.relationship); } - followingUpdateTime = purgeTime; + followingUpdateTime = this.relationship.getUpdateTime(); } if (! this.relationshipHistory.isEmpty()) { + /* + * The period when an instance is active is from its updateTime to the updateTime of the next element. + * The relationshipHistory has the latest version first. + */ for (Relationship historicalInstance : this.relationshipHistory) { if (checkInclusiveDate(fromTime, toTime, historicalInstance, followingUpdateTime)) { - historyResults.add(historicalInstance); - followingUpdateTime = historicalInstance.getUpdateTime(); + if (oldestFirst) + { + /* + * Add to the front + */ + historyResults.add(0, historicalInstance); + } + else + { + /* + * Add to the back + */ + historyResults.add(historicalInstance); + } } + + followingUpdateTime = historicalInstance.getUpdateTime(); } } diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java index c374bb1e63f..e68ce90063e 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java @@ -1621,7 +1621,7 @@ public void validateUserForTypeReIdentify(String userId, */ /** - * Tests for whether a specific user should have the right to create a instance within a repository. + * Tests for whether a specific user should have the right to create an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1657,7 +1657,7 @@ public void validateUserForEntityCreate(String userId, * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection * @param instance instance details - * @return entity to return (may be altered by the connector) + * @return entity to return (maybe altered by the connector) * @throws UserNotAuthorizedException the user is not authorized to retrieve instances */ @Override @@ -1715,7 +1715,7 @@ public void validateUserForEntityProxyRead(String userId, /** - * Tests for whether a specific user should have the right to update a instance within a repository. + * Tests for whether a specific user should have the right to update an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1819,7 +1819,7 @@ public void validateUserForEntityClassificationDelete(String user /** - * Tests for whether a specific user should have the right to delete a instance within a repository. + * Tests for whether a specific user should have the right to delete an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1839,7 +1839,7 @@ public void validateUserForEntityDelete(String userId, /** - * Tests for whether a specific user should have the right to delete a instance within a repository. + * Tests for whether a specific user should have the right to delete an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1859,7 +1859,7 @@ public void validateUserForEntityRestore(String userId, /** - * Tests for whether a specific user should have the right to change the guid on a instance within a repository. + * Tests for whether a specific user should have the right to change the guid on an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1881,7 +1881,7 @@ public void validateUserForEntityReIdentification(String userId, /** - * Tests for whether a specific user should have the right to change the type of a instance within a repository. + * Tests for whether a specific user should have the right to change an instance's type within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1903,7 +1903,7 @@ public void validateUserForEntityReTyping(String userId, /** - * Tests for whether a specific user should have the right to change the home of a instance within a repository. + * Tests for whether a specific user should have the right to change the home of an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1931,7 +1931,7 @@ public void validateUserForEntityReHoming(String userId, /** - * Tests for whether a specific user should have the right to create a instance within a repository. + * Tests for whether a specific user should have the right to create an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1987,7 +1987,7 @@ public Relationship validateUserForRelationshipRead(String userId, /** - * Tests for whether a specific user should have the right to update a instance within a repository. + * Tests for whether a specific user should have the right to update an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -2007,7 +2007,7 @@ public void validateUserForRelationshipUpdate(String userId, /** - * Tests for whether a specific user should have the right to delete a instance within a repository. + * Tests for whether a specific user should have the right to delete an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -2027,7 +2027,7 @@ public void validateUserForRelationshipDelete(String userId, /** - * Tests for whether a specific user should have the right to delete a instance within a repository. + * Tests for whether a specific user should have the right to delete an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -2047,7 +2047,7 @@ public void validateUserForRelationshipRestore(String userId, /** - * Tests for whether a specific user should have the right to change the guid on a instance within a repository. + * Tests for whether a specific user should have the right to change the guid on an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -2069,7 +2069,7 @@ public void validateUserForRelationshipReIdentification(String userId, /** - * Tests for whether a specific user should have the right to change the type of a instance within a repository. + * Tests for whether a specific user should have the right to change an instance's type within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -2091,7 +2091,7 @@ public void validateUserForRelationshipReTyping(String userId, /** - * Tests for whether a specific user should have the right to change the home of a instance within a repository. + * Tests for whether a specific user should have the right to change the home of an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/TestAssetDetail.java b/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/TestAssetDetail.java index 329d37558b1..a4c2054d4c5 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/TestAssetDetail.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/TestAssetDetail.java @@ -57,10 +57,10 @@ private AssetDetail getTestObject() testObject.setClassifications(classifications); testObject.setQualifiedName("TestQualifiedName"); - testObject.setDisplayName("TestDisplayName"); + testObject.setResourceName("TestResourceName"); testObject.setOwner("TestOwner"); testObject.setConnectionDescription("TestShortDescription"); - testObject.setDescription("TestDescription"); + testObject.setResourceDescription("TestDescription"); testObject.setExtendedProperties(assetProperties); return new AssetDetail(testObject, @@ -90,7 +90,7 @@ private AssetDetail getDifferentObject() testObject.setClassifications(classifications); testObject.setQualifiedName("TestQualifiedName"); - testObject.setDisplayName("TestDisplayName"); + testObject.setResourceName("TestResourceName"); testObject.setOwner("TestOwner"); testObject.setConnectionDescription("TestShortDescription"); testObject.setExtendedProperties(assetProperties); @@ -122,10 +122,10 @@ private AssetDetail getAnotherDifferentObject() testObject.setClassifications(classifications); testObject.setQualifiedName("TestDifferentQualifiedName"); - testObject.setDisplayName("TestDisplayName"); + testObject.setResourceName("TestResourceName"); testObject.setOwner("TestOwner"); testObject.setConnectionDescription("TestShortDescription"); - testObject.setDescription("TestDescription"); + testObject.setResourceDescription("TestDescription"); testObject.setExtendedProperties(assetProperties); return new AssetDetail(testObject, @@ -215,9 +215,9 @@ private AssetDetail getAnotherDifferentObject() RelatedMediaReferences relatedMediaReferences = new MockRelatedMediaReferences( 15, 50); NoteLogs noteLogs = new MockNoteLogs( 15, 50); ExternalReferences externalReferences = new MockExternalReferences( 15, 50); - Connections connections = new MockConnections( 15, 50); - Licenses licenses = new MockLicenses(15, 50); - Certifications certifications = new MockAssetCertifications( 15, 50); + Connections connections = new MockConnections( 15, 50); + Licenses licenses = new MockLicenses(15, 50); + Certifications certifications = new MockAssetCertifications( 15, 50); AssetDetail testTemplate = new AssetDetail(new Asset(), externalIdentifiers, diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/TestAssetSummary.java b/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/TestAssetSummary.java index d2474f86d96..7d28535f273 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/TestAssetSummary.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/TestAssetSummary.java @@ -18,10 +18,10 @@ */ public class TestAssetSummary { - private ElementType type = new ElementType(); - private List classifications = new ArrayList<>(); - private List zoneMembership = new ArrayList<>(); - private Map assetProperties = new HashMap<>(); + private final ElementType type = new ElementType(); + private final List classifications = new ArrayList<>(); + private final List zoneMembership = new ArrayList<>(); + private final Map assetProperties = new HashMap<>(); /** @@ -56,11 +56,11 @@ private AssetSummary getTestObject() testObject.setClassifications(classifications); testObject.setQualifiedName("TestQualifiedName"); - testObject.setDisplayName("TestDisplayName"); + testObject.setResourceName("TestResourceName"); testObject.setOwner("TestOwner"); testObject.setOwnerType(OwnerType.PROFILE_ID); testObject.setConnectionDescription("TestShortDescription"); - testObject.setDescription("TestDescription"); + testObject.setResourceDescription("TestDescription"); testObject.setExtendedProperties(assetProperties); testObject.setZoneMembership(zoneMembership); @@ -83,10 +83,10 @@ private AssetSummary getDifferentObject() testObject.setClassifications(classifications); testObject.setQualifiedName("TestQualifiedName"); - testObject.setDisplayName("TestDisplayName"); + testObject.setResourceName("TestResourceName"); testObject.setOwner("TestOwner"); testObject.setConnectionDescription("TestShortDescription"); - testObject.setDescription("TestDescription"); + testObject.setResourceDescription("TestDescription"); testObject.setExtendedProperties(assetProperties); return new AssetSummary(testObject); @@ -108,11 +108,11 @@ private AssetSummary getAnotherDifferentObject() testObject.setClassifications(classifications); testObject.setQualifiedName("TestDifferentQualifiedName"); - testObject.setDisplayName("TestDisplayName"); + testObject.setResourceName("TestResourceName"); testObject.setOwner("TestOwner"); testObject.setOwnerType(OwnerType.PROFILE_ID); testObject.setConnectionDescription("TestShortDescription"); - testObject.setDescription("TestDescription"); + testObject.setResourceDescription("TestDescription"); testObject.setExtendedProperties(assetProperties); return new AssetSummary(testObject); @@ -132,8 +132,8 @@ private void validateResultObject(AssetSummary resultObject) assertTrue(resultObject.getClassifications() != null); assertTrue(resultObject.getQualifiedName().equals("TestQualifiedName")); - assertTrue(resultObject.getDisplayName().equals("TestDisplayName")); - assertTrue(resultObject.getDescription().equals("TestDescription")); + assertTrue(resultObject.getResourceName().equals("TestResourceName")); + assertTrue(resultObject.getResourceDescription().equals("TestDescription")); assertTrue(resultObject.getConnectionDescription().equals("TestShortDescription")); assertTrue(resultObject.getOwner().equals("TestOwner")); assertTrue(resultObject.getZoneMembership() != null); @@ -155,8 +155,8 @@ private void validateNullObject(AssetSummary nullObject) assertTrue(nullObject.getClassifications() == null); assertTrue(nullObject.getQualifiedName() == null); - assertTrue(nullObject.getDisplayName() == null); - assertTrue(nullObject.getDescription() == null); + assertTrue(nullObject.getResourceName() == null); + assertTrue(nullObject.getResourceDescription() == null); assertTrue(nullObject.getConnectionDescription() == null); assertTrue(nullObject.getOwner() == null); assertTrue(nullObject.getExtendedProperties() == null); diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/TestAsset.java b/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/TestAsset.java index 3ab54c3a472..682296a6dd6 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/TestAsset.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/test/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/TestAsset.java @@ -73,6 +73,7 @@ private Asset getTestObject() * * @param resultObject object returned by the test */ + @SuppressWarnings(value="deprecation") private void validateResultObject(Asset resultObject) { assertTrue(resultObject.getType().equals(type)); @@ -116,7 +117,7 @@ private void validateResultObject(Asset resultObject) assertTrue(nullObject.getAdditionalProperties() == null); assertTrue(nullObject.getDisplayName() == null); - assertTrue(nullObject.getDescription() == null); + assertTrue(nullObject.getResourceDescription() == null); assertTrue(nullObject.getConnectionDescription() == null); assertTrue(nullObject.getOwner() == null); assertTrue(nullObject.getZoneMembership() == null); @@ -133,7 +134,7 @@ private void validateResultObject(Asset resultObject) assertTrue(nullObject.getAdditionalProperties() == null); assertTrue(nullObject.getDisplayName() == null); - assertTrue(nullObject.getDescription() == null); + assertTrue(nullObject.getResourceDescription() == null); assertTrue(nullObject.getConnectionDescription() == null); assertTrue(nullObject.getOwner() == null); assertTrue(nullObject.getZoneMembership() == null); diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OMRSMetadataCollection.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OMRSMetadataCollection.java index ffb73b8042b..d168f19ed56 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OMRSMetadataCollection.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OMRSMetadataCollection.java @@ -876,10 +876,8 @@ public abstract EntityDetail getEntityDetail(String userId, * @param sequencingOrder Enum defining how the results should be ordered. * @return {@code List} of each historical version of the entity detail within the bounds, and in the order requested. * @throws InvalidParameterException the guid or date is null or fromTime is after the toTime - * @throws RepositoryErrorException there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws EntityNotKnownException the requested entity instance is not known in the metadata collection - * at the time requested. + * @throws RepositoryErrorException there is a problem communicating with the metadata repository where the metadata collection is stored. + * @throws EntityNotKnownException the requested entity instance is not active in the metadata collection at the time requested. * @throws EntityProxyOnlyException the requested entity instance is only a proxy in the metadata collection. * @throws FunctionNotSupportedException the repository does not support history. * @throws UserNotAuthorizedException the userId is not permitted to perform this operation. diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OpenMetadataRepositorySecurity.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OpenMetadataRepositorySecurity.java index 20bba20d6e2..76ecb2c44d5 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OpenMetadataRepositorySecurity.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OpenMetadataRepositorySecurity.java @@ -146,7 +146,7 @@ void validateUserForTypeReIdentify(String userId, /** - * Tests for whether a specific user should have the right to create a instance within a repository. + * Tests for whether a specific user should have the right to create an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -170,7 +170,7 @@ void validateUserForEntityCreate(String userId, * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection * @param instance instance details - * @return entity to return (may be altered by the connector) + * @return entity to return (maybe altered by the connector) * @throws UserNotAuthorizedException the user is not authorized to retrieve instances */ EntityDetail validateUserForEntityRead(String userId, @@ -205,7 +205,7 @@ void validateUserForEntityProxyRead(String userId, /** - * Tests for whether a specific user should have the right to update a instance within a repository. + * Tests for whether a specific user should have the right to update an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -270,7 +270,7 @@ void validateUserForEntityClassificationDelete(String userId, /** - * Tests for whether a specific user should have the right to delete a instance within a repository. + * Tests for whether a specific user should have the right to delete an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -283,7 +283,7 @@ void validateUserForEntityDelete(String userId, /** - * Tests for whether a specific user should have the right to restore a instance within a repository. + * Tests for whether a specific user should have the right to restore an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -296,7 +296,7 @@ void validateUserForEntityRestore(String userId, /** - * Tests for whether a specific user should have the right to change the guid on a instance within a repository. + * Tests for whether a specific user should have the right to change the guid on an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -311,7 +311,7 @@ void validateUserForEntityReIdentification(String userId, /** - * Tests for whether a specific user should have the right to change the type of a instance within a repository. + * Tests for whether a specific user should have the right to change an instance's type within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -326,7 +326,7 @@ void validateUserForEntityReTyping(String userId, /** - * Tests for whether a specific user should have the right to change the home of a instance within a repository. + * Tests for whether a specific user should have the right to change the home of an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -343,7 +343,7 @@ void validateUserForEntityReHoming(String userId, /** - * Tests for whether a specific user should have the right to create a instance within a repository. + * Tests for whether a specific user should have the right to create an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -369,7 +369,7 @@ void validateUserForRelationshipCreate(String userId, * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection * @param instance instance details - * @return relationship to return (may be altered by the connector) + * @return relationship to return (maybe altered by the connector) * @throws UserNotAuthorizedException the user is not authorized to retrieve instances */ Relationship validateUserForRelationshipRead(String userId, @@ -378,7 +378,7 @@ Relationship validateUserForRelationshipRead(String userId, /** - * Tests for whether a specific user should have the right to update a instance within a repository. + * Tests for whether a specific user should have the right to update an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -391,7 +391,7 @@ void validateUserForRelationshipUpdate(String userId, /** - * Tests for whether a specific user should have the right to delete a instance within a repository. + * Tests for whether a specific user should have the right to delete an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -404,7 +404,7 @@ void validateUserForRelationshipDelete(String userId, /** - * Tests for whether a specific user should have the right to restore a instance within a repository. + * Tests for whether a specific user should have the right to restore an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -417,7 +417,7 @@ void validateUserForRelationshipRestore(String userId, /** - * Tests for whether a specific user should have the right to change the guid on a instance within a repository. + * Tests for whether a specific user should have the right to change the guid on an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -432,7 +432,7 @@ void validateUserForRelationshipReIdentification(String userId, /** - * Tests for whether a specific user should have the right to change the type of a instance within a repository. + * Tests for whether a specific user should have the right to change an instance's type within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -447,7 +447,7 @@ void validateUserForRelationshipReTyping(String userId, /** - * Tests for whether a specific user should have the right to change the home of a instance within a repository. + * Tests for whether a specific user should have the right to change the home of an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/RepositoryElementHeader.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/RepositoryElementHeader.java index 2c5aba5b470..708d5f2bb1a 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/RepositoryElementHeader.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/RepositoryElementHeader.java @@ -5,19 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.ArrayPropertyValue; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.ClassificationEntityExtension; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceAuditHeader; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceElementHeader; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceGraph; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceType; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefElementHeader; - import java.io.Serializable; -import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; @@ -34,11 +22,10 @@ public abstract class RepositoryElementHeader implements Serializable private static final long serialVersionUID = 1L; /* - * Version number for this header. This is used to ensure that all the critical header information - * in read in a back-level version of the OMRS. The default is 0 to indicate that the element came from - * a version of the OMRS that does not have a version number encoded. + * Version number for this header. The default is 1 to indicate that the element came from + * the first version of the OMRS. */ - private long headerVersion = 0; + private long headerVersion = 1L; /** @@ -66,8 +53,6 @@ public RepositoryElementHeader(RepositoryElementHeader template) } - - /** * Return the version of this header. This is used by the OMRS to determine if it is back level and * should not process events from a source that is more advanced because it does not have the ability diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/instances/InstanceElementHeader.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/instances/InstanceElementHeader.java index 8ca004ea864..e0906754e9f 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/instances/InstanceElementHeader.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/instances/InstanceElementHeader.java @@ -23,7 +23,8 @@ @JsonSubTypes.Type(value = InstanceAuditHeader.class, name = "InstanceAuditHeader"), @JsonSubTypes.Type(value = InstanceGraph.class, name = "InstanceGraph"), @JsonSubTypes.Type(value = InstanceType.class, name = "InstanceType"), - @JsonSubTypes.Type(value = InstancePropertyValue.class, name = "InstancePropertyValue") + @JsonSubTypes.Type(value = InstancePropertyValue.class, name = "InstancePropertyValue"), + @JsonSubTypes.Type(value = InstanceProperties.class, name = "InstanceProperties") }) public abstract class InstanceElementHeader extends RepositoryElementHeader { diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/typedefs/TypeDefElementHeader.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/typedefs/TypeDefElementHeader.java index f5df3ddede2..b491da337d6 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/typedefs/TypeDefElementHeader.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/typedefs/TypeDefElementHeader.java @@ -27,13 +27,6 @@ public class TypeDefElementHeader extends RepositoryElementHeader public static final long CURRENT_TYPE_DEF_HEADER_VERSION = 1; - /* - * Version number for this header. This is used to ensure that all the critical header information - * in read in a back-level version of the OMRS. The default is 0 to indicate that the instance came from - * a version of the OMRS that does not have a version number encoded. - */ - private long headerVersion = 0; - /** * Default constructor sets TypeDef to nulls. */ diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/test/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/typedefs/TypeDefElementHeaderTest.java b/open-metadata-implementation/repository-services/repository-services-apis/src/test/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/typedefs/TypeDefElementHeaderTest.java index 8fff14b7a90..b5f5448e14f 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/test/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/typedefs/TypeDefElementHeaderTest.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/test/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/typedefs/TypeDefElementHeaderTest.java @@ -16,12 +16,12 @@ public class TypeDefElementHeaderTest { TypeDefElementHeaderMock testObject = new TypeDefElementHeaderMock(); - assertTrue(testObject.getHeaderVersion() == 0); + assertTrue(testObject.getHeaderVersion() == 1); - testObject.setHeaderVersion(TypeDefElementHeader.CURRENT_TYPE_DEF_HEADER_VERSION); + testObject.setHeaderVersion(TypeDefElementHeader.CURRENT_TYPE_DEF_HEADER_VERSION+1); TypeDefElementHeaderMock cloneObject = new TypeDefElementHeaderMock(testObject); - assertTrue(cloneObject.getHeaderVersion() == TypeDefElementHeader.CURRENT_TYPE_DEF_HEADER_VERSION); + assertTrue(cloneObject.getHeaderVersion() == TypeDefElementHeader.CURRENT_TYPE_DEF_HEADER_VERSION+1); } } diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/localrepository/repositorycontentmanager/OMRSRepositoryContentHelper.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/localrepository/repositorycontentmanager/OMRSRepositoryContentHelper.java index 86bfedc4957..7901badc4db 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/localrepository/repositorycontentmanager/OMRSRepositoryContentHelper.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/localrepository/repositorycontentmanager/OMRSRepositoryContentHelper.java @@ -838,7 +838,6 @@ private void populateSkeletonEntity(EntitySummary entity, entity.setStatus(repositoryContentManager.getInitialStatus(sourceName, typeName, methodName)); entity.setCreatedBy(userName); entity.setInstanceURL(repositoryContentManager.getEntityURL(sourceName, guid)); - } diff --git a/open-metadata-test/open-metadata-fvt/access-services-fvt/asset-owner-fvt/src/main/java/org/odpi/openmetadata/accessservices/assetowner/fvt/connections/CreateConnectionTest.java b/open-metadata-test/open-metadata-fvt/access-services-fvt/asset-owner-fvt/src/main/java/org/odpi/openmetadata/accessservices/assetowner/fvt/connections/CreateConnectionTest.java index f03b757cae7..458b512af97 100644 --- a/open-metadata-test/open-metadata-fvt/access-services-fvt/asset-owner-fvt/src/main/java/org/odpi/openmetadata/accessservices/assetowner/fvt/connections/CreateConnectionTest.java +++ b/open-metadata-test/open-metadata-fvt/access-services-fvt/asset-owner-fvt/src/main/java/org/odpi/openmetadata/accessservices/assetowner/fvt/connections/CreateConnectionTest.java @@ -443,11 +443,11 @@ private void checkEndpointOK(AssetOwner client, { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad qualifiedName from Retrieve) =>>" + retrievedEndpoint); } - if (! endpointDisplayName.equals(retrievedEndpoint.getTechnicalName())) + if (! endpointDisplayName.equals(retrievedEndpoint.getName())) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad displayName from Retrieve) =>>" + retrievedEndpoint); } - if (! endpointDescription.equals(retrievedEndpoint.getTechnicalDescription())) + if (! endpointDescription.equals(retrievedEndpoint.getDescription())) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad description from Retrieve) =>>" + retrievedEndpoint); } @@ -476,11 +476,11 @@ else if (endpointList.size() != 1) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad qualifiedName from RetrieveByName) =>>" + retrievedEndpoint); } - if (! endpointDisplayName.equals(retrievedEndpoint.getTechnicalName())) + if (! endpointDisplayName.equals(retrievedEndpoint.getName())) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad displayName from RetrieveByName) =>>" + retrievedEndpoint); } - if (! endpointDescription.equals(retrievedEndpoint.getTechnicalDescription())) + if (! endpointDescription.equals(retrievedEndpoint.getDescription())) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad description from RetrieveByName) =>>" + retrievedEndpoint); } @@ -558,8 +558,8 @@ private String createEndpoint(AssetOwner client, EndpointProperties properties = new EndpointProperties(); properties.setQualifiedName(endpointName); - properties.setTechnicalName(endpointDisplayName); - properties.setTechnicalDescription(endpointDescription); + properties.setName(endpointDisplayName); + properties.setDescription(endpointDescription); String endpointGUID = client.createEndpoint(userId, properties); diff --git a/open-metadata-test/open-metadata-fvt/access-services-fvt/digital-architecture-fvt/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/fvt/connections/CreateConnectionTest.java b/open-metadata-test/open-metadata-fvt/access-services-fvt/digital-architecture-fvt/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/fvt/connections/CreateConnectionTest.java index 458db7d2790..1a25fb03612 100644 --- a/open-metadata-test/open-metadata-fvt/access-services-fvt/digital-architecture-fvt/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/fvt/connections/CreateConnectionTest.java +++ b/open-metadata-test/open-metadata-fvt/access-services-fvt/digital-architecture-fvt/src/main/java/org/odpi/openmetadata/accessservices/digitalarchitecture/fvt/connections/CreateConnectionTest.java @@ -521,11 +521,11 @@ private void checkEndpointOK(ConnectionManager client, { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad qualifiedName from Retrieve) =>>" + retrievedEndpoint); } - if (! endpointTechnicalName.equals(retrievedEndpoint.getTechnicalName())) + if (! endpointTechnicalName.equals(retrievedEndpoint.getResourceName())) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad technicalName from Retrieve) =>>" + retrievedEndpoint); } - if (! endpointTechnicalDescription.equals(retrievedEndpoint.getTechnicalDescription())) + if (! endpointTechnicalDescription.equals(retrievedEndpoint.getResourceDescription())) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad technicalDescription from Retrieve) =>>" + retrievedEndpoint); } @@ -555,11 +555,11 @@ else if (endpointList.size() != 1) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad qualifiedName from RetrieveByName) =>>" + retrievedEndpoint); } - if (! endpointTechnicalName.equals(retrievedEndpoint.getTechnicalName())) + if (! endpointTechnicalName.equals(retrievedEndpoint.getResourceName())) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad displayName from RetrieveByName) =>>" + retrievedEndpoint); } - if (! endpointTechnicalDescription.equals(retrievedEndpoint.getTechnicalDescription())) + if (! endpointTechnicalDescription.equals(retrievedEndpoint.getResourceDescription())) { throw new FVTUnexpectedCondition(testCaseName, activityName + "(Bad description from RetrieveByName) =>>" + retrievedEndpoint); } @@ -636,8 +636,8 @@ private String createEndpoint(ConnectionManager client, EndpointProperties properties = new EndpointProperties(); properties.setQualifiedName(endpointName); - properties.setTechnicalName(endpointTechnicalName); - properties.setTechnicalDescription(endpointTechnicalDescription); + properties.setResourceName(endpointTechnicalName); + properties.setResourceDescription(endpointTechnicalDescription); String endpointGUID = client.createEndpoint(userId, properties);