Class OpenMetadataTestCase

java.lang.Object
org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase
Direct Known Subclasses:
OpenMetadataPerformanceTestCase, OpenMetadataPlatformTestCase, RepositoryConformanceTestCase

public abstract class OpenMetadataTestCase extends Object
OpenMetadataTestCase is the superclass for an open metadata conformance test. It manages the test environment and reporting.
  • Field Details

    • testCaseId

      protected String testCaseId
    • testCaseName

      protected String testCaseName
    • testCaseDescriptionURL

      protected String testCaseDescriptionURL
    • defaultProfileId

      protected Integer defaultProfileId
    • defaultRequirementId

      protected Integer defaultRequirementId
    • workPad

    • successfulAssertions

      protected List<String> successfulAssertions
    • unsuccessfulAssertions

      protected List<String> unsuccessfulAssertions
    • notSupportedAssertions

      protected List<String> notSupportedAssertions
    • discoveredProperties

      protected Map<String,Object> discoveredProperties
    • exceptionBean

      protected ExceptionBean exceptionBean
    • successMessage

      protected String 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 results
      testCaseId - identifier of test case
      testCaseName - name of test case
      defaultProfileId - 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 results
      defaultProfileId - identifier of default profile (for unexpected exceptions)
      defaultRequirementId - identifier of default required (for unexpected exceptions)
  • Method Details

    • updateTestId

      protected void updateTestId(String testCaseRootId, String testCaseId, String testCaseName)
      Update the test case id, name and documentation URL if not already supplied in the constructor.
      Parameters:
      testCaseRootId - common identifier of test case
      testCaseId - unique identifier of test case
      testCaseName - name of test case
    • logTestStart

      protected abstract void logTestStart(String methodName)
      Log that the test case is starting.
      Parameters:
      methodName - calling method name
    • logTestEnd

      protected abstract void logTestEnd(String methodName)
      Log that the test case is ending.
      Parameters:
      methodName - calling method name
    • getTestCaseId

      public String getTestCaseId()
      Return the unique identifier of the test case.
      Returns:
      string id
    • getTestCaseName

      public String getTestCaseName()
      Return the display name of the test case.
      Returns:
      string name
    • getTestCaseDescriptionURL

      public String 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

      public OpenMetadataTestCaseResult 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

      public OpenMetadataTestCaseSummary 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 test
      assertionId - identifier for the assertion
      assertionMessage - descriptive message of the assertion
      profileId - identifier of profile for this assertion
      requirementId - 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 test
      object2 - object to test
      assertionId - identifier for the assertion
      assertionMessage - descriptive message of the assertion
      profileId - identifier of profile for this assertion
      requirementId - identifier of requirement for this assertion
      methodName - method that this condition tests
      elapsedTime - 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 test
      assertionId - identifier for the assertion
      assertionMessage - descriptive message of the assertion
      profileId - identifier of profile for this assertion
      requirementId - identifier of requirement for this assertion
      methodName - method that this condition tests
      elapsedTime - 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 test
      assertionId - identifier for the assertion
      assertionMessage - descriptive message of the assertion
      profileId - identifier of profile for this assertion
      requirementId - 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 test
      object2 - object to test
      assertionId - identifier for the assertion
      assertionMessage - descriptive message of the assertion
      profileId - identifier of profile for this assertion
      requirementId - identifier of requirement for this assertion
      methodName - method that this condition tests
      elapsedTime - 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 test
      assertionId - identifier for the assertion
      assertionMessage - descriptive message of the assertion
      profileId - identifier of profile for this assertion
      requirementId - identifier of requirement for this assertion
      methodName - method that this condition tests
      elapsedTime - 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 assertion
      assertionMessage - descriptive message of the assertion
      profileId - identifier of profile for this assertion
      requirementId - 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 property
      propertyValue - value of the property as object
      profileId - identifier of profile
      requirementId - identifier of requirement within the profile
    • setSuccessMessage

      protected void setSuccessMessage(String message)
      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

      public void executeTest(OpenMetadataTestCase.TestPhase phase)
      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

      protected void cleanup() throws Exception
      Default implementation - over-ridden by some test cases.
      Throws:
      Exception - something went wrong with the test.
    • run

      protected abstract void run() throws Exception
      Method implemented by the actual test case.
      Throws:
      Exception - something went wrong with the test.
    • run

      protected void run(OpenMetadataTestCase.TestPhase phase) throws Exception
      Method implemented by the actual test case.
      Parameters:
      phase - test phase
      Throws:
      Exception - something went wrong with the test.
    • toString

      public String toString()
      toString() JSON-style
      Overrides:
      toString in class Object
      Returns:
      string description