mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-10771: DiffContext is now passed around to provide the DB Dialect.
Instead of the Differences being passed around on their own, the DiffContext is able to provide more information -- at present just the Dialect. The dialect can be used to change the way database objects are validated or differenced. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31466 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,8 +24,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.util.schemacomp.ComparisonUtils;
|
||||
import org.alfresco.util.schemacomp.DiffContext;
|
||||
import org.alfresco.util.schemacomp.Differences;
|
||||
import org.alfresco.util.schemacomp.Result.Strength;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -41,18 +43,21 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public abstract class DbObjectTestBase<T extends AbstractDbObject>
|
||||
{
|
||||
protected @Mock Dialect dialect;
|
||||
protected @Mock Differences differences;
|
||||
protected DiffContext ctx;
|
||||
protected @Mock ComparisonUtils comparisonUtils;
|
||||
protected InOrder inOrder;
|
||||
protected abstract T getThisObject();
|
||||
protected abstract T getThatObject();
|
||||
|
||||
@Before
|
||||
public void setUpMockito()
|
||||
public void baseSetUp()
|
||||
{
|
||||
// Check that the correct calls happened in the correct order.
|
||||
List<Object> mocks = getMocksUsedInDiff();
|
||||
inOrder = inOrder(mocks.toArray());
|
||||
ctx = new DiffContext(dialect, differences);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +84,7 @@ public abstract class DbObjectTestBase<T extends AbstractDbObject>
|
||||
thatObject.setComparisonUtils(comparisonUtils);
|
||||
|
||||
// Invoke the method under test
|
||||
thisObject.diff(thatObject, differences, Strength.ERROR);
|
||||
thisObject.diff(thatObject, ctx, Strength.ERROR);
|
||||
|
||||
// The name of the object should be pushed on to the differences path.
|
||||
inOrder.verify(differences).pushPath(thisObject.getName());
|
||||
@@ -88,7 +93,7 @@ public abstract class DbObjectTestBase<T extends AbstractDbObject>
|
||||
inOrder.verify(comparisonUtils).compareSimple(
|
||||
thisObject.getName(),
|
||||
thatObject.getName(),
|
||||
differences,
|
||||
ctx,
|
||||
thisObject.getNameStrength());
|
||||
|
||||
// Then the doDiff() method should be processed...
|
||||
|
Reference in New Issue
Block a user