mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-11519: changed ONLY_IN_LEFT to ONLY_IN_REFERENCE, ONLY_IN_RIGHT to ONLY_IN_TARGET
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32111 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -102,7 +102,7 @@ public class DefaultComparisonUtils implements ComparisonUtils
|
|||||||
{
|
{
|
||||||
// No equivalent object in the right hand collection.
|
// No equivalent object in the right hand collection.
|
||||||
// Using rightIndexedProperty would result in index out of bounds error.
|
// Using rightIndexedProperty would result in index out of bounds error.
|
||||||
differences.add(Where.ONLY_IN_LEFT, leftIndexedProp, rightProp, strength);
|
differences.add(Where.ONLY_IN_REFERENCE, leftIndexedProp, rightProp, strength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ public class DefaultComparisonUtils implements ComparisonUtils
|
|||||||
{
|
{
|
||||||
DbProperty rightIndexedProp = new DbProperty(rightProp.getDbObject(), rightProp.getPropertyName(), rightIndex);
|
DbProperty rightIndexedProp = new DbProperty(rightProp.getDbObject(), rightProp.getPropertyName(), rightIndex);
|
||||||
// No equivalent object in the left hand collection.
|
// No equivalent object in the left hand collection.
|
||||||
differences.add(Where.ONLY_IN_RIGHT, leftProp, rightIndexedProp, strength);
|
differences.add(Where.ONLY_IN_TARGET, leftProp, rightIndexedProp, strength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ public class DefaultComparisonUtils implements ComparisonUtils
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No equivalent object in the right hand collection.
|
// No equivalent object in the right hand collection.
|
||||||
differences.add(Where.ONLY_IN_LEFT, new DbProperty(leftObj, null), null, strength);
|
differences.add(Where.ONLY_IN_REFERENCE, new DbProperty(leftObj, null), null, strength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ public class DefaultComparisonUtils implements ComparisonUtils
|
|||||||
if (leftObj == null)
|
if (leftObj == null)
|
||||||
{
|
{
|
||||||
// No equivalent object in the left hand collection.
|
// No equivalent object in the left hand collection.
|
||||||
differences.add(Where.ONLY_IN_RIGHT, null, new DbProperty(rightObj, null), strength);
|
differences.add(Where.ONLY_IN_TARGET, null, new DbProperty(rightObj, null), strength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,12 +214,12 @@ public class DefaultComparisonUtils implements ComparisonUtils
|
|||||||
else if (left == null)
|
else if (left == null)
|
||||||
{
|
{
|
||||||
// right can't be null, or left == right would have been true
|
// right can't be null, or left == right would have been true
|
||||||
where = Where.ONLY_IN_RIGHT;
|
where = Where.ONLY_IN_TARGET;
|
||||||
}
|
}
|
||||||
else if (right == null)
|
else if (right == null)
|
||||||
{
|
{
|
||||||
// left can't be null, or left == right would have been true
|
// left can't be null, or left == right would have been true
|
||||||
where = Where.ONLY_IN_LEFT;
|
where = Where.ONLY_IN_REFERENCE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -74,10 +74,10 @@ public class DefaultComparisonUtilsTest
|
|||||||
verify(differences).add(Where.IN_BOTH_BUT_DIFFERENCE, prop("left"), prop("right"), Strength.ERROR);
|
verify(differences).add(Where.IN_BOTH_BUT_DIFFERENCE, prop("left"), prop("right"), Strength.ERROR);
|
||||||
|
|
||||||
comparisonUtils.compareSimple(prop("left"), prop(null), ctx, Strength.ERROR);
|
comparisonUtils.compareSimple(prop("left"), prop(null), ctx, Strength.ERROR);
|
||||||
verify(differences).add(Where.ONLY_IN_LEFT, prop("left"), prop(null), Strength.ERROR);
|
verify(differences).add(Where.ONLY_IN_REFERENCE, prop("left"), prop(null), Strength.ERROR);
|
||||||
|
|
||||||
comparisonUtils.compareSimple(prop(null), prop("right"), ctx, Strength.ERROR);
|
comparisonUtils.compareSimple(prop(null), prop("right"), ctx, Strength.ERROR);
|
||||||
verify(differences).add(Where.ONLY_IN_RIGHT, prop(null), prop("right"), Strength.ERROR);
|
verify(differences).add(Where.ONLY_IN_TARGET, prop(null), prop("right"), Strength.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbProperty prop(String propValue)
|
public DbProperty prop(String propValue)
|
||||||
@@ -111,8 +111,8 @@ public class DefaultComparisonUtilsTest
|
|||||||
verify(db4).diff(db4, ctx, Strength.ERROR);
|
verify(db4).diff(db4, ctx, Strength.ERROR);
|
||||||
|
|
||||||
// Objects in only one collections are marked as such
|
// Objects in only one collections are marked as such
|
||||||
verify(differences).add(Where.ONLY_IN_LEFT, new DbProperty(db2), null, Strength.ERROR);
|
verify(differences).add(Where.ONLY_IN_REFERENCE, new DbProperty(db2), null, Strength.ERROR);
|
||||||
verify(differences).add(Where.ONLY_IN_RIGHT, null, new DbProperty(db3), Strength.ERROR);
|
verify(differences).add(Where.ONLY_IN_TARGET, null, new DbProperty(db3), Strength.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -163,28 +163,28 @@ public class DefaultComparisonUtilsTest
|
|||||||
dbPropForValue(rightDbObj, "collection[2]", subCollectionRight),
|
dbPropForValue(rightDbObj, "collection[2]", subCollectionRight),
|
||||||
Strength.WARN);
|
Strength.WARN);
|
||||||
verify(differences).add(
|
verify(differences).add(
|
||||||
Where.ONLY_IN_LEFT,
|
Where.ONLY_IN_REFERENCE,
|
||||||
dbPropForValue(leftDbObj, "collection[3]", 456),
|
dbPropForValue(leftDbObj, "collection[3]", 456),
|
||||||
dbPropForValue(rightDbObj, "collection", rightCollection),
|
dbPropForValue(rightDbObj, "collection", rightCollection),
|
||||||
Strength.WARN);
|
Strength.WARN);
|
||||||
verify(differences).add(
|
verify(differences).add(
|
||||||
Where.ONLY_IN_LEFT,
|
Where.ONLY_IN_REFERENCE,
|
||||||
dbPropForValue(leftDbObj, "collection[4]", "left only"),
|
dbPropForValue(leftDbObj, "collection[4]", "left only"),
|
||||||
dbPropForValue(rightDbObj, "collection", rightCollection),
|
dbPropForValue(rightDbObj, "collection", rightCollection),
|
||||||
Strength.WARN);
|
Strength.WARN);
|
||||||
|
|
||||||
verify(differences).add(
|
verify(differences).add(
|
||||||
Where.ONLY_IN_RIGHT,
|
Where.ONLY_IN_TARGET,
|
||||||
dbPropForValue(leftDbObj, "collection", leftCollection),
|
dbPropForValue(leftDbObj, "collection", leftCollection),
|
||||||
dbPropForValue(rightDbObj, "collection[1]", 789),
|
dbPropForValue(rightDbObj, "collection[1]", 789),
|
||||||
Strength.WARN);
|
Strength.WARN);
|
||||||
verify(differences).add(
|
verify(differences).add(
|
||||||
Where.ONLY_IN_RIGHT,
|
Where.ONLY_IN_TARGET,
|
||||||
dbPropForValue(leftDbObj, "collection", leftCollection),
|
dbPropForValue(leftDbObj, "collection", leftCollection),
|
||||||
dbPropForValue(rightDbObj, "collection[3]", "right only"),
|
dbPropForValue(rightDbObj, "collection[3]", "right only"),
|
||||||
Strength.WARN);
|
Strength.WARN);
|
||||||
verify(differences).add(
|
verify(differences).add(
|
||||||
Where.ONLY_IN_RIGHT,
|
Where.ONLY_IN_TARGET,
|
||||||
dbPropForValue(leftDbObj, "collection", leftCollection),
|
dbPropForValue(leftDbObj, "collection", leftCollection),
|
||||||
dbPropForValue(rightDbObj, "collection[5]", "one more right only"),
|
dbPropForValue(rightDbObj, "collection[5]", "one more right only"),
|
||||||
Strength.WARN);
|
Strength.WARN);
|
||||||
|
@@ -28,7 +28,7 @@ package org.alfresco.util.schemacomp;
|
|||||||
public final class Difference extends Result
|
public final class Difference extends Result
|
||||||
{
|
{
|
||||||
/** Specifies the type of differences */
|
/** Specifies the type of differences */
|
||||||
public enum Where { ONLY_IN_LEFT, ONLY_IN_RIGHT, IN_BOTH_NO_DIFFERENCE, IN_BOTH_BUT_DIFFERENCE };
|
public enum Where { ONLY_IN_REFERENCE, ONLY_IN_TARGET, IN_BOTH_NO_DIFFERENCE, IN_BOTH_BUT_DIFFERENCE };
|
||||||
private final Where where;
|
private final Where where;
|
||||||
private final DbProperty left;
|
private final DbProperty left;
|
||||||
private final DbProperty right;
|
private final DbProperty right;
|
||||||
|
@@ -43,9 +43,9 @@ public class DifferenceTest
|
|||||||
DbProperty targetDbProp = mock(DbProperty.class);
|
DbProperty targetDbProp = mock(DbProperty.class);
|
||||||
when(targetDbProp.getPath()).thenReturn("alfresco.some_table.some_column.name");
|
when(targetDbProp.getPath()).thenReturn("alfresco.some_table.some_column.name");
|
||||||
when(targetDbProp.getPropertyValue()).thenReturn("nood_ref");
|
when(targetDbProp.getPropertyValue()).thenReturn("nood_ref");
|
||||||
Difference diff = new Difference(Where.ONLY_IN_LEFT, refDbProp, targetDbProp);
|
Difference diff = new Difference(Where.ONLY_IN_REFERENCE, refDbProp, targetDbProp);
|
||||||
|
|
||||||
assertEquals("Difference: ONLY_IN_LEFT reference path:alfresco.some_table.some_column.name (value: node_ref) " +
|
assertEquals("Difference: ONLY_IN_REFERENCE reference path:alfresco.some_table.some_column.name (value: node_ref) " +
|
||||||
"target path:alfresco.some_table.some_column.name (value: nood_ref)", diff.describe());
|
"target path:alfresco.some_table.some_column.name (value: nood_ref)", diff.describe());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -96,7 +96,7 @@ public class SchemaComparatorTest
|
|||||||
|
|
||||||
// Table table_in_reference only appears in the reference schema
|
// Table table_in_reference only appears in the reference schema
|
||||||
Difference diff = (Difference) it.next();
|
Difference diff = (Difference) it.next();
|
||||||
assertEquals(Where.ONLY_IN_LEFT, diff.getWhere());
|
assertEquals(Where.ONLY_IN_REFERENCE, diff.getWhere());
|
||||||
assertEquals("schema.table_in_reference", diff.getLeft().getPath());
|
assertEquals("schema.table_in_reference", diff.getLeft().getPath());
|
||||||
assertEquals(null, diff.getRight());
|
assertEquals(null, diff.getRight());
|
||||||
assertEquals(null, diff.getLeft().getPropertyName());
|
assertEquals(null, diff.getLeft().getPropertyName());
|
||||||
@@ -104,7 +104,7 @@ public class SchemaComparatorTest
|
|||||||
|
|
||||||
// Table tbl_has_diff_pk has PK of "id" in reference and "nodeRef" in target
|
// Table tbl_has_diff_pk has PK of "id" in reference and "nodeRef" in target
|
||||||
diff = (Difference) it.next();
|
diff = (Difference) it.next();
|
||||||
assertEquals(Where.ONLY_IN_LEFT, diff.getWhere());
|
assertEquals(Where.ONLY_IN_REFERENCE, diff.getWhere());
|
||||||
assertEquals("schema.tbl_has_diff_pk.pk_is_diff.columnNames[0]", diff.getLeft().getPath());
|
assertEquals("schema.tbl_has_diff_pk.pk_is_diff.columnNames[0]", diff.getLeft().getPath());
|
||||||
assertEquals("schema.tbl_has_diff_pk.pk_is_diff.columnNames", diff.getRight().getPath());
|
assertEquals("schema.tbl_has_diff_pk.pk_is_diff.columnNames", diff.getRight().getPath());
|
||||||
assertEquals("columnNames[0]", diff.getLeft().getPropertyName());
|
assertEquals("columnNames[0]", diff.getLeft().getPropertyName());
|
||||||
@@ -114,7 +114,7 @@ public class SchemaComparatorTest
|
|||||||
|
|
||||||
// Table tbl_has_diff_pk has PK of "id" in reference and "nodeRef" in target
|
// Table tbl_has_diff_pk has PK of "id" in reference and "nodeRef" in target
|
||||||
diff = (Difference) it.next();
|
diff = (Difference) it.next();
|
||||||
assertEquals(Where.ONLY_IN_RIGHT, diff.getWhere());
|
assertEquals(Where.ONLY_IN_TARGET, diff.getWhere());
|
||||||
assertEquals("schema.tbl_has_diff_pk.pk_is_diff.columnNames", diff.getLeft().getPath());
|
assertEquals("schema.tbl_has_diff_pk.pk_is_diff.columnNames", diff.getLeft().getPath());
|
||||||
assertEquals("schema.tbl_has_diff_pk.pk_is_diff.columnNames[0]", diff.getRight().getPath());
|
assertEquals("schema.tbl_has_diff_pk.pk_is_diff.columnNames[0]", diff.getRight().getPath());
|
||||||
assertEquals("columnNames", diff.getLeft().getPropertyName());
|
assertEquals("columnNames", diff.getLeft().getPropertyName());
|
||||||
@@ -133,7 +133,7 @@ public class SchemaComparatorTest
|
|||||||
|
|
||||||
// Table table_in_target does not exist in the reference schema
|
// Table table_in_target does not exist in the reference schema
|
||||||
diff = (Difference) it.next();
|
diff = (Difference) it.next();
|
||||||
assertEquals(Where.ONLY_IN_RIGHT, diff.getWhere());
|
assertEquals(Where.ONLY_IN_TARGET, diff.getWhere());
|
||||||
assertEquals("schema.table_in_target", diff.getRight().getPath());
|
assertEquals("schema.table_in_target", diff.getRight().getPath());
|
||||||
assertEquals(null, diff.getLeft());
|
assertEquals(null, diff.getLeft());
|
||||||
assertEquals(null, diff.getRight().getPropertyName());
|
assertEquals(null, diff.getRight().getPropertyName());
|
||||||
|
Reference in New Issue
Block a user