Class AbstractChangesTestCase<M extends Model,O>

java.lang.Object
junit.framework.Assert
junit.framework.TestCase
net.officefloor.frame.test.OfficeFrameTestCase
net.officefloor.model.test.changes.AbstractChangesTestCase<M,O>
All Implemented Interfaces:
junit.framework.Test

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

    • model

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

      protected O operations
      Operations.
  • Constructor Details

    • AbstractChangesTestCase

      public AbstractChangesTestCase()
      Initiate.
    • AbstractChangesTestCase

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

    • setUp

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

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

      protected abstract void storeModel(M model, WritableConfigurationItem configurationItem) throws Exception
      Stores the Model.
      Parameters:
      model - Model.
      configurationItem - WritableConfigurationItem to store the Model.
      Throws:
      Exception - If fails to store 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 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, String expectedChangeDescription, boolean expectCanApply, 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(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 Exception
      Asserts the models are the same.
      Parameters:
      expected - Expected model.
      actual - Actual model.
      Throws:
      Exception - If fails.