Class RepositoryConformanceTestCase
java.lang.Object
org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase
org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase
- Direct Known Subclasses:
TestClassificationHasSupportedEntities,TestConsistentAttributeTypeDef,TestConsistentTypeDef,TestFindAttributeTypeDefsByCategory,TestFindTypeDefByExternalId,TestFindTypeDefsByCategory,TestGetTypeDefGallery,TestInstanceEvent,TestMetadataCollectionId,TestRepositoryServerIds,TestSupportedAttributeTypeDef,TestSupportedClassificationLifecycle,TestSupportedEffectivityConditions,TestSupportedEntityClassificationSearch,TestSupportedEntityLifecycle,TestSupportedEntityProxyLifecycle,TestSupportedEntityReferenceCopyLifecycle,TestSupportedEntityReidentify,TestSupportedEntityRetype,TestSupportedEntitySearch,TestSupportedEntitySubtypeSearch,TestSupportedExternalInstances,TestSupportedInstanceCounts,TestSupportedReferenceCopyClassificationLifecycle,TestSupportedRelationshipEffectivityConditions,TestSupportedRelationshipEndCriteria,TestSupportedRelationshipLifecycle,TestSupportedRelationshipReferenceCopyLifecycle,TestSupportedRelationshipReidentify,TestSupportedRelationshipSearch,TestSupportedRelationshipSubtypeSearch,TestSupportedTypeDef,TestValidTypeDefEvent
OpenMetadataTestCase is the superclass for an open metadata conformance test. It manages the
test environment and reporting.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase
OpenMetadataTestCase.TestPhase -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected OMRSRepositoryConnectorprotected RepositoryConformanceWorkPadFields inherited from class org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase
defaultProfileId, defaultRequirementId, discoveredProperties, exceptionBean, notSupportedAssertions, successfulAssertions, successMessage, testCaseDescriptionURL, testCaseId, testCaseName, unsuccessfulAssertions, workPad -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRepositoryConformanceTestCase(RepositoryConformanceWorkPad workPad, Integer defaultProfileId, Integer defaultRequirementId) Typical constructor used when the test case id needs to be constructed by th test case code.protectedRepositoryConformanceTestCase(RepositoryConformanceWorkPad workPad, String testCaseId, String testCaseName, Integer defaultProfileId, Integer defaultRequirementId) Typical constructor used when the name of the test case id is fixed -
Method Summary
Modifier and TypeMethodDescriptionaddEntityProxyToRepository(String userId, OMRSMetadataCollection metadataCollection, EntityDef entityDef, String homeMetadataCollectionId) Adds an entity proxy of the requested type to the repository.addEntityToRepository(String userId, OMRSMetadataCollection metadataCollection, EntityDef entityDef) Adds an entity of the requested type to the repository.protected StringbuildExceptionMessage(String testName, String methodName, String operationDescription, Map<String, String> parameters, String originalExceptionClassName, String originalExceptionMessage) protected InstancePropertiesgeneratePropertiesForInstance(String userId, List<TypeDefAttribute> allTypeDefAttributes, int instanceCount) Return generated instance properties specialised for search testsprotected InstancePropertiesgetAllPropertiesForInstance(String userId, TypeDef typeDef) Return instance properties for the properties defined in the TypeDef and all of its supertypes.protected InstancePropertiesgetAllUniquePropertiesForInstance(String userId, TypeDef typeDef) Return only the unique properties for the properties defined in the TypeDef and all of its supertypes.getEntityDef(Map<String, EntityDef> supportedEntityDefs, TypeDefLink entityIdentifiers) Returns the appropriate entity definition for the supplied entity identifiers.protected intReturn the page size to use for testing the repository.protected OMRSMetadataCollectionReturn the metadata collection used to call the repository.protected InstancePropertiesgetMinPropertiesForInstance(String userId, TypeDef typeDef) Return instance properties for only the mandatory properties defined in the TypeDef and all of its supertypes.protected InstancePropertiesgetPropertiesForInstance(List<TypeDefAttribute> typeDefAttributes) Return instance properties for the properties defined in the TypeDef, but do not include properties from supertypes.protected List<TypeDefAttribute> getPropertiesForTypeDef(String userId, TypeDef typeDef) Recursively walk the supertype hierarchy starting at the given typeDef, and collect all the TypeDefAttributes.protected InstancePropertyValuegetPropertyValueForAttributeType(String attributeName, AttributeTypeDef attributeType) Return a generated value for any attribute type, not just the primitive ones.protected OMRSRepositoryConnectorReturn the repository connector generated from the cohort registration event.protected voidFor test cases that are invoked many times, count the successful invocations.protected voidFor test cases that are invoked many times, count the unsuccessful invocations.protected voidlogTestEnd(String methodName) Log that the test case is ending.protected voidlogTestStart(String methodName) Log that the test case is starting.protected booleanpropertyValueMatchesSearch(InstanceProperties properties, Predicate<String> matches) Does any value anywhere in these properties satisfy the caller's match test?
findEntitiesByPropertyValue and findRelationshipsByPropertyValue match against the string values held in an instance, and "held in" reaches inside the structured property types.protected booleanpropertyValueMatchesSearch(InstancePropertyValue propertyValue, Predicate<String> matches) Does this value - or any value nested inside it - satisfy the caller's match test?protected StringupdateTestIdByType(String typeName, String rootTestCaseId, String testCaseName) Verify that the name of the type (which forms part of the test id) is not null.Methods inherited from class org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase
addDiscoveredProperty, addNotSupportedAssertion, assertCondition, assertCondition, assertObjectsAreEqual, cleanTest, cleanup, endAsynchronousTest, executeTest, executeTest, getResult, getSummary, getTestCaseDescriptionURL, getTestCaseId, getTestCaseName, isTestPassed, isTestRan, run, run, setSuccessMessage, startAsynchronousTest, toString, updateTestId, verifyCondition, verifyCondition, verifyObjectsAreEqual
-
Field Details
-
repositoryConformanceWorkPad
-
cohortRepositoryConnector
-
-
Constructor Details
-
RepositoryConformanceTestCase
protected RepositoryConformanceTestCase(RepositoryConformanceWorkPad workPad, String testCaseId, String testCaseName, Integer defaultProfileId, Integer defaultRequirementId) Typical constructor used when the name of the test case id is fixed- Parameters:
workPad- location for workbench resultstestCaseId- identifier of test casetestCaseName- name of test casedefaultProfileId- identifier of default profile (for unexpected exceptions)defaultRequirementId- identifier of default required (for unexpected exceptions)
-
RepositoryConformanceTestCase
protected RepositoryConformanceTestCase(RepositoryConformanceWorkPad workPad, Integer defaultProfileId, Integer defaultRequirementId) Typical constructor used when the test case id needs to be constructed by th test case code.- Parameters:
workPad- location for workbench resultsdefaultProfileId- identifier of default profile (for unexpected exceptions)defaultRequirementId- identifier of default required (for unexpected exceptions)
-
-
Method Details
-
logTestStart
Log that the test case is starting.- Specified by:
logTestStartin classOpenMetadataTestCase- Parameters:
methodName- calling method name
-
logTestEnd
Log that the test case is ending.- Specified by:
logTestEndin classOpenMetadataTestCase- Parameters:
methodName- calling method name
-
incrementSuccessfulCount
protected void incrementSuccessfulCount()For test cases that are invoked many times, count the successful invocations. -
incrementUnsuccessfulCount
protected void incrementUnsuccessfulCount()For test cases that are invoked many times, count the unsuccessful invocations. -
updateTestIdByType
Verify that the name of the type (which forms part of the test id) is not null.- Parameters:
typeName- name of the type being testedrootTestCaseId- base test case IdtestCaseName- name of the test case- Returns:
- typeName (or "null" if null so messages are displayed properly.)
-
getMaxSearchResults
protected int getMaxSearchResults()Return the page size to use for testing the repository.- Returns:
- page size
-
getRepositoryConnector
Return the repository connector generated from the cohort registration event.- Returns:
- OMRSRepositoryConnector object
- Throws:
Exception- if the connector is not properly set up.
-
getMetadataCollection
Return the metadata collection used to call the repository.- Returns:
- OMRSMetadataCollection object
- Throws:
Exception- if the connector is not properly set up.
-
getPropertyValueForAttributeType
protected InstancePropertyValue getPropertyValueForAttributeType(String attributeName, AttributeTypeDef attributeType) Return a generated value for any attribute type, not just the primitive ones.
The open metadata types use enumerations, arrays and maps as freely as they use primitives, so a test that only ever populates primitive attributes leaves whole categories of the model unexercised - in create, in update and in search alike. A repository that stores or searches those values then has nothing checking that it does so correctly.- Parameters:
attributeName- name of the attribute being populatedattributeType- its type- Returns:
- a value to store, or null if no value can be generated for that type
-
getPropertiesForInstance
Return instance properties for the properties defined in the TypeDef, but do not include properties from supertypes.- Parameters:
typeDefAttributes- attributes defined for a specific type- Returns:
- properties for an instance of this type
-
getAllPropertiesForInstance
protected InstanceProperties getAllPropertiesForInstance(String userId, TypeDef typeDef) throws Exception Return instance properties for the properties defined in the TypeDef and all of its supertypes.- Parameters:
userId- calling usertypeDef- the definition of the type- Returns:
- properties for an instance of this type
- Throws:
Exception- problem manipulating types
-
generatePropertiesForInstance
protected InstanceProperties generatePropertiesForInstance(String userId, List<TypeDefAttribute> allTypeDefAttributes, int instanceCount) throws Exception Return generated instance properties specialised for search tests- Parameters:
userId- calling userallTypeDefAttributes- list of all the TDAs for typeinstanceCount- a generator parameter for customisation of individual instance properties- Returns:
- properties for an instance of this type
- Throws:
Exception- problem manipulating types
-
getAllUniquePropertiesForInstance
protected InstanceProperties getAllUniquePropertiesForInstance(String userId, TypeDef typeDef) throws Exception Return only the unique properties for the properties defined in the TypeDef and all of its supertypes.- Parameters:
userId- calling usertypeDef- the definition of the type- Returns:
- properties for an instance of this type
- Throws:
Exception- problem manipulating types
-
propertyValueMatchesSearch
protected boolean propertyValueMatchesSearch(InstanceProperties properties, Predicate<String> matches) Does any value anywhere in these properties satisfy the caller's match test?
findEntitiesByPropertyValue and findRelationshipsByPropertyValue match against the string values held in an instance, and "held in" reaches inside the structured property types. The shared implementation of that rule - OMRSRepositoryContentValidator.verifyInstancePropertiesMatchSearchCriteria - matches on a primitive string, on an enum's symbolic name, or on any value nested inside a struct, an array or a map. A check that only looked at primitive strings would call a repository wrong for correctly returning an instance whose matching value happened to live in a map or an array, which is a legitimate result.- Parameters:
properties- properties of the instance that was returnedmatches- decides whether one string value satisfies the search- Returns:
- whether some value in the instance justifies it being returned
-
propertyValueMatchesSearch
protected boolean propertyValueMatchesSearch(InstancePropertyValue propertyValue, Predicate<String> matches) Does this value - or any value nested inside it - satisfy the caller's match test?- Parameters:
propertyValue- value to testmatches- decides whether one string value satisfies the search- Returns:
- whether this value justifies the instance being returned
-
getMinPropertiesForInstance
protected InstanceProperties getMinPropertiesForInstance(String userId, TypeDef typeDef) throws Exception Return instance properties for only the mandatory properties defined in the TypeDef and all of its supertypes.- Parameters:
userId- calling usertypeDef- the definition of the type- Returns:
- properties for an instance of this type
- Throws:
Exception- problem manipulating types
-
getPropertiesForTypeDef
Recursively walk the supertype hierarchy starting at the given typeDef, and collect all the TypeDefAttributes. This method does not use the properties defined in the TypeDef provided since that TypeDef is from the gallery returned by the repository connector. Instead it uses the name of the TypeDef to look up the TypeDef in the RepositoryHelper - using the Known types rather than the Active types. This is to ensure consistency with the open metadata type definition.- Parameters:
userId- the userId of the caller, needed for retrieving type definitionstypeDef- the definition of the type- Returns:
- properties for an instance of this type
-
getEntityDef
public EntityDef getEntityDef(Map<String, EntityDef> supportedEntityDefs, TypeDefLink entityIdentifiers) Returns the appropriate entity definition for the supplied entity identifiers. This may be the entity specified, or a subclass of the entity that is supported.- Parameters:
supportedEntityDefs- map of entity type name to entity type definitionentityIdentifiers- guid and name of desired entity definition- Returns:
- entity definition (EntityDef)
-
addEntityToRepository
public EntityDetail addEntityToRepository(String userId, OMRSMetadataCollection metadataCollection, EntityDef entityDef) throws Exception Adds an entity of the requested type to the repository.- Parameters:
userId- userId for the new entitymetadataCollection- metadata connection to access the repositoryentityDef- type of entity to create- Returns:
- new entity
- Throws:
Exception- error in create
-
addEntityProxyToRepository
public String addEntityProxyToRepository(String userId, OMRSMetadataCollection metadataCollection, EntityDef entityDef, String homeMetadataCollectionId) throws Exception Adds an entity proxy of the requested type to the repository.- Parameters:
userId- userId for the new entitymetadataCollection- metadata connection to access the repositoryentityDef- type of entity to createhomeMetadataCollectionId- - metadataCollectionId of the repository that is master for instance- Returns:
- string - entity proxy's GUID
- Throws:
Exception- error in create
-
buildExceptionMessage
-