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
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerated type for control of multiphase tests -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Integerprotected Integerprotected ExceptionBeanprotected Stringprotected Stringprotected Stringprotected Stringprotected OpenMetadataConformanceWorkbenchWorkPad -
Constructor Summary
ConstructorsConstructorDescriptionDefault 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 voidaddDiscoveredProperty(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 voidaddNotSupportedAssertion(String assertionId, String assertionMessage, Integer profileId, Integer requirementId) Log the correct response to an unsupported function.protected voidassertCondition(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId) Throw an exception if the condition is not true; else returnprotected voidassertCondition(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 voidassertObjectsAreEqual(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 returnvoidprotected voidcleanup()Default implementation - over-ridden by some test cases.voidRequest from the workbench to log the start of an asynchronous test.voidRequest from the workbench to execute this test and generate a result object.voidRequest 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.booleanHas the test case passed? If it has not run then false is returned.booleanHas the test case run yet?protected abstract voidlogTestEnd(String methodName) Log that the test case is ending.protected abstract voidlogTestStart(String methodName) Log that the test case is starting.protected abstract voidrun()Method implemented by the actual test case.protected voidMethod implemented by the actual test case.protected voidsetSuccessMessage(String message) Set up the success message.voidRequest from the workbench to log the start of an asynchronous test.toString()toString() JSON-styleprotected voidupdateTestId(String testCaseRootId, String testCaseId, String testCaseName) Update the test case id, name and documentation URL if not already supplied in the constructor.protected voidverifyCondition(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId) Log if the condition is not true; else returnprotected voidverifyCondition(boolean condition, String assertionId, String assertionMessage, Integer profileId, Integer requirementId, String methodName, Long elapsedTime) Log if the condition is not true; else returnprotected voidverifyObjectsAreEqual(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
-