ALF-10771: schema validation and differences rules

Laying some groundwork for the main code.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31921 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2011-11-14 10:16:59 +00:00
parent 60688d34b9
commit 4c863f5e0a
16 changed files with 165 additions and 84 deletions

View File

@@ -18,14 +18,17 @@
*/
package org.alfresco.util.schemacomp.model;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
import java.util.Arrays;
import org.alfresco.util.schemacomp.DbProperty;
import org.alfresco.util.schemacomp.Result.Strength;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.mockito.Mockito.verify;
/**
@@ -34,14 +37,18 @@ import static org.mockito.Mockito.verify;
*/
public class IndexTest extends DbObjectTestBase<Index>
{
private Table thisTable;
private Index thisIndex;
private Table thatTable;
private Index thatIndex;
@Before
public void setUp()
{
thisIndex = new Index(null, "this_index", Arrays.asList("id", "name", "age"));
thatIndex = new Index(null, "that_index", Arrays.asList("a", "b"));
thisTable = new Table("this_table");
thisIndex = new Index(thisTable, "this_index", Arrays.asList("id", "name", "age"));
thatTable = new Table("that_table");
thatIndex = new Index(thatTable, "that_index", Arrays.asList("a", "b"));
}
@Override
@@ -82,19 +89,23 @@ public class IndexTest extends DbObjectTestBase<Index>
public void sameAs()
{
assertTrue("Indexes should be logically the same.",
thisIndex.sameAs(new Index(null, "this_index", Arrays.asList("id", "name", "age"))));
thisIndex.sameAs(new Index(thisTable, "this_index", Arrays.asList("id", "name", "age"))));
assertFalse("Indexes have logically different parents",
thisIndex.sameAs(new Index(thatTable, "this_index", Arrays.asList("id", "name", "age"))));
assertTrue("Indexes should be logically the same, despite different names (as same column order)",
thisIndex.sameAs(new Index(null, "different_name", Arrays.asList("id", "name", "age"))));
thisIndex.sameAs(new Index(thisTable, "different_name", Arrays.asList("id", "name", "age"))));
assertTrue("Indexes should be identified as the same despite different column order (as same name).",
thisIndex.sameAs(new Index(null, "this_index", Arrays.asList("name", "id", "age"))));
thisIndex.sameAs(new Index(thisTable, "this_index", Arrays.asList("name", "id", "age"))));
assertFalse("Indexes should be identified different (different name and column order)",
thisIndex.sameAs(new Index(null, "different_name", Arrays.asList("name", "id", "age"))));
thisIndex.sameAs(new Index(thisTable, "different_name", Arrays.asList("name", "id", "age"))));
assertFalse("Indexes should be identified different (different name & different columns)",
thisIndex.sameAs(new Index(null, "different_name", Arrays.asList("node_ref", "url"))));
thisIndex.sameAs(new Index(thisTable, "different_name", Arrays.asList("node_ref", "url"))));
}