Class OpenMetadataTestCase
java.lang.Object
org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase
- Direct Known Subclasses:
OpenMetadataPerformanceTestCase
,OpenMetadataPlatformTestCase
,RepositoryConformanceTestCase
OpenMetadataTestCase is the superclass for an open metadata conformance test. It manages the
test environment and reporting.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumerated type for control of multiphase tests -
Field Summary
Modifier and TypeFieldDescriptionprotected Integer
protected Integer
protected ExceptionBean
protected String
protected String
protected String
protected String
protected OpenMetadataConformanceWorkbenchWorkPad
-
Constructor Summary
ConstructorDescriptionDefault constructorOpenMetadataTestCase
(OpenMetadataConformanceWorkbenchWorkPad workPad, Integer defaultProfileId, Integer defaultRequirementId) Typical constructor used when the test case id needs to be constructed by the test case code.OpenMetadataTestCase
(OpenMetadataConformanceWorkbenchWorkPad workPad, String testCaseId, String testCaseName, Integer defaultProfileId, Integer defaultRequirementId) Typical constructor used when the test case id is fixed. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDiscoveredProperty
(String propertyName, Object propertyValue, Integer profileId, Integer requirementId) Add the name and value of a discovered property that is relevant to a specific requirement within a profile.protected void
addNotSupportedAssertion
(String assertionId, String assertionMessage, Integer profileId, Integer requirementId) Log the correct response to an unsupported function.protected void
assertCondition
(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId) Throw an exception if the condition is not true; else returnprotected void
assertCondition
(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) Throw an exception if the condition is not true; else returnprotected void
assertObjectsAreEqual
(Object object1, Object object2, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) Throw an exception if the condition is not true; else returnvoid
protected void
cleanup()
Default implementation - over-ridden by some test cases.void
Request from the workbench to log the start of an asynchronous test.void
Request from the workbench to execute this test and generate a result object.void
Request from the workbench to execute this test and generate a result object.Return the result object for this test case.Return a summary bean for this test case.Return the URL of the description of the test case.Return the unique identifier of the test case.Return the display name of the test case.boolean
Has the test case passed? If it has not run then false is returned.boolean
Has the test case run yet?protected abstract void
logTestEnd
(String methodName) Log that the test case is ending.protected abstract void
logTestStart
(String methodName) Log that the test case is starting.protected abstract void
run()
Method implemented by the actual test case.protected void
Method implemented by the actual test case.protected void
setSuccessMessage
(String message) Set up the success message.void
Request from the workbench to log the start of an asynchronous test.toString()
toString() JSON-styleprotected void
updateTestId
(String testCaseRootId, String testCaseId, String testCaseName) Update the test case id, name and documentation URL if not already supplied in the constructor.protected void
verifyCondition
(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId) Log if the condition is not true; else returnprotected void
verifyCondition
(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) Log if the condition is not true; else returnprotected void
verifyObjectsAreEqual
(Object object1, Object object2, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) Log if the condition is not true; else return
-
Field Details
-
testCaseId
-
testCaseName
-
testCaseDescriptionURL
-
defaultProfileId
-
defaultRequirementId
-
workPad
-
successfulAssertions
-
unsuccessfulAssertions
-
notSupportedAssertions
-
discoveredProperties
-
exceptionBean
-
successMessage
-
-
Constructor Details
-
OpenMetadataTestCase
public OpenMetadataTestCase()Default constructor -
OpenMetadataTestCase
public OpenMetadataTestCase(OpenMetadataConformanceWorkbenchWorkPad workPad, String testCaseId, String testCaseName, Integer defaultProfileId, Integer defaultRequirementId) Typical constructor used when 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)
-
OpenMetadataTestCase
public OpenMetadataTestCase(OpenMetadataConformanceWorkbenchWorkPad workPad, Integer defaultProfileId, Integer defaultRequirementId) Typical constructor used when the test case id needs to be constructed by the 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
-
updateTestId
Update the test case id, name and documentation URL if not already supplied in the constructor.- Parameters:
testCaseRootId
- common identifier of test casetestCaseId
- unique identifier of test casetestCaseName
- name of test case
-
logTestStart
Log that the test case is starting.- Parameters:
methodName
- calling method name
-
logTestEnd
Log that the test case is ending.- Parameters:
methodName
- calling method name
-
getTestCaseId
Return the unique identifier of the test case.- Returns:
- string id
-
getTestCaseName
Return the display name of the test case.- Returns:
- string name
-
getTestCaseDescriptionURL
Return the URL of the description of the test case.- Returns:
- string url
-
isTestRan
public boolean isTestRan()Has the test case run yet?- Returns:
- boolean flag
-
isTestPassed
public boolean isTestPassed()Has the test case passed? If it has not run then false is returned.- Returns:
- boolean flag
-
getResult
Return the result object for this test case. It will be null if the test case has not run.- Returns:
- result bean (or null if the test has not yet been run).
-
getSummary
Return a summary bean for this test case.- Returns:
- summary bean
-
assertCondition
protected void assertCondition(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId) throws AssertionFailureException Throw an exception if the condition is not true; else return- Parameters:
condition
- condition to testassertionId
- identifier for the assertionassertionMessage
- descriptive message of the assertionprofileId
- identifier of profile for this assertionrequirementId
- identifier of requirement for this assertion- Throws:
AssertionFailureException
- condition was false
-
assertObjectsAreEqual
protected void assertObjectsAreEqual(Object object1, Object object2, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) throws AssertionFailureException Throw an exception if the condition is not true; else return- Parameters:
object1
- object to testobject2
- object to testassertionId
- identifier for the assertionassertionMessage
- descriptive message of the assertionprofileId
- identifier of profile for this assertionrequirementId
- identifier of requirement for this assertionmethodName
- method that this condition testselapsedTime
- of the test executing (in milliseconds)- Throws:
AssertionFailureException
- condition was false
-
assertCondition
protected void assertCondition(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) throws AssertionFailureException Throw an exception if the condition is not true; else return- Parameters:
condition
- condition to testassertionId
- identifier for the assertionassertionMessage
- descriptive message of the assertionprofileId
- identifier of profile for this assertionrequirementId
- identifier of requirement for this assertionmethodName
- method that this condition testselapsedTime
- of the test executing (in milliseconds)- Throws:
AssertionFailureException
- condition was false
-
verifyCondition
protected void verifyCondition(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId) Log if the condition is not true; else return- Parameters:
condition
- condition to testassertionId
- identifier for the assertionassertionMessage
- descriptive message of the assertionprofileId
- identifier of profile for this assertionrequirementId
- identifier of requirement for this assertion
-
verifyObjectsAreEqual
protected void verifyObjectsAreEqual(Object object1, Object object2, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) Log if the condition is not true; else return- Parameters:
object1
- object to testobject2
- object to testassertionId
- identifier for the assertionassertionMessage
- descriptive message of the assertionprofileId
- identifier of profile for this assertionrequirementId
- identifier of requirement for this assertionmethodName
- method that this condition testselapsedTime
- of the test executing (in milliseconds)
-
verifyCondition
protected void verifyCondition(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) Log if the condition is not true; else return- Parameters:
condition
- condition to testassertionId
- identifier for the assertionassertionMessage
- descriptive message of the assertionprofileId
- identifier of profile for this assertionrequirementId
- identifier of requirement for this assertionmethodName
- method that this condition testselapsedTime
- of the test executing (in milliseconds)
-
addNotSupportedAssertion
protected void addNotSupportedAssertion(String assertionId, String assertionMessage, Integer profileId, Integer requirementId) Log the correct response to an unsupported function.- Parameters:
assertionId
- identifier for the assertionassertionMessage
- descriptive message of the assertionprofileId
- identifier of profile for this assertionrequirementId
- identifier of requirement for this assertion
-
addDiscoveredProperty
protected void addDiscoveredProperty(String propertyName, Object propertyValue, Integer profileId, Integer requirementId) Add the name and value of a discovered property that is relevant to a specific requirement within a profile.- Parameters:
propertyName
- name of the propertypropertyValue
- value of the property as objectprofileId
- identifier of profilerequirementId
- identifier of requirement within the profile
-
setSuccessMessage
Set up the success message.- Parameters:
message
- text of message
-
startAsynchronousTest
public void startAsynchronousTest()Request from the workbench to log the start of an asynchronous test. -
endAsynchronousTest
public void endAsynchronousTest()Request from the workbench to log the start of an asynchronous test. -
executeTest
public void executeTest()Request from the workbench to execute this test and generate a result object. This method is used for synchronous test cases. This variant of the method calls the parameter-less run method of the testcase. -
executeTest
Request from the workbench to execute this test and generate a result object. This method is used for synchronous test cases. This variant of the method accepts a test phase parameter to allow explicit execution of create, execute and clean phases.- Parameters:
phase
- test phase
-
cleanTest
public void cleanTest() -
cleanup
Default implementation - over-ridden by some test cases.- Throws:
Exception
- something went wrong with the test.
-
run
Method implemented by the actual test case.- Throws:
Exception
- something went wrong with the test.
-
run
Method implemented by the actual test case.- Parameters:
phase
- test phase- Throws:
Exception
- something went wrong with the test.
-
toString
toString() JSON-style
-