Class AbstractChangesTestCase<M extends Model,​O>

  • All Implemented Interfaces:
    junit.framework.Test

    public abstract class AbstractChangesTestCase<M extends Model,​O>
    extends OfficeFrameTestCase
    Abstract operations TestCase.
    Author:
    Daniel Sagenschneider
    • Field Detail

      • model

        protected M extends Model model
        Model loaded for testing.
      • operations

        protected O operations
        Operations.
    • Constructor Detail

      • AbstractChangesTestCase

        public AbstractChangesTestCase()
        Initiate.
      • AbstractChangesTestCase

        public AbstractChangesTestCase​(boolean isSpecificSetupFilePerTest)
        Initiate.
        Parameters:
        isSpecificSetupFilePerTest - Flags if there is a specific setup file per test.
    • Method Detail

      • setUp

        protected void setUp()
                      throws java.lang.Exception
        Overrides:
        setUp in class junit.framework.TestCase
        Throws:
        java.lang.Exception
      • retrieveModel

        protected abstract M retrieveModel​(ConfigurationItem configurationItem)
                                    throws java.lang.Exception
        Retrieves the Model.
        Parameters:
        configurationItem - ConfigurationItem containing the Model.
        Returns:
        Model.
        Throws:
        java.lang.Exception - If fails to retrieve the Model.
      • createModelOperations

        protected abstract O createModelOperations​(M model)
        Creates the Model operations.
        Parameters:
        model - Model to create operations for.
        Returns:
        Model operations.
      • getModelFileExtension

        protected abstract java.lang.String getModelFileExtension()
        Obtains the extension for the file containing the Model.
        Returns:
        Extension for the file containing the Model.
      • useTestSetupModel

        protected void useTestSetupModel()
        Allows particular tests of a TestCase to override using the default setup ConfigurationItem and use the specific test ConfigurationItem.
      • assertChange

        protected <T> void assertChange​(Change<T> change,
                                        T expectedTarget,
                                        java.lang.String expectedChangeDescription,
                                        boolean expectCanApply,
                                        java.lang.String... expectedConflictDescriptions)
        Asserts the Change is correct.
        Type Parameters:
        T - Expected target.
        Parameters:
        change - Change to verify.
        expectedTarget - Expected target.
        expectedChangeDescription - Expected description of the Change.
        expectCanApply - Expected if can apply the Change. Should it be able to be applied, both the Change.apply() and Change.revert() will be also tested.
        expectedConflictDescriptions - Expected descriptions for the Conflict instances on the Change.
      • assertChanges

        protected void assertChanges​(Change<?>... changes)
        Assets all the Change instances result in a correct change.
        Parameters:
        changes - Change instances to verify.
      • validateModel

        protected void validateModel()
        Validates the Model against the default Model file for the test.
      • validateModel

        protected void validateModel​(java.lang.String specific)
        Validates the Model against the specific Model file for the test.
        Parameters:
        specific - Indicates the specific Model file for the test.
      • validateAsSetupModel

        protected void validateAsSetupModel()

        Validates the Model against the Model setup for testing.

        This is useful to test the revert functionality of a Change.

      • assertModels

        protected void assertModels​(M expected,
                                    M actual)
                             throws java.lang.Exception
        Asserts the models are the same.
        Parameters:
        expected - Expected model.
        actual - Actual model.
        Throws:
        java.lang.Exception - If fails.