Files
alfresco-community-repo/source/test-java/org/alfresco/util/schemacomp/RedundantDbObjectTest.java
Alan Davis 91eb2644ad Merged 5.2.N (5.2.1) to HEAD (5.2)
125781 rmunteanu: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
      125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
         125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127808 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-06-03 16:40:56 +00:00

81 lines
2.2 KiB
Java

package org.alfresco.util.schemacomp;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.util.schemacomp.model.AbstractDbObject;
import org.alfresco.util.schemacomp.model.DbObject;
import org.junit.Before;
import org.junit.Test;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Tests for the {@link RedundantDbObject} class.
*
* @author Matt Ward
*/
public class RedundantDbObjectTest
{
@Before
public void setUp()
{
I18NUtil.registerResourceBundle("alfresco.messages.system-messages");
}
@Test
public void describe()
{
DbObject reference = new MyDbObject("reference");
List<DbObject> matches = makeMatches(3);
RedundantDbObject redundantDBO = new RedundantDbObject(reference, matches);
assertEquals("Redundancy: 3 items matching MyDbObject[name=reference], " +
"matches: MyDbObject[name=match1], MyDbObject[name=match2], MyDbObject[name=match3]",
redundantDBO.describe());
}
@Test
public void describeTooManyMatches()
{
DbObject reference = new MyDbObject("reference");
List<DbObject> matches = makeMatches(4);
RedundantDbObject redundantDBO = new RedundantDbObject(reference, matches);
assertEquals("4 redundant items? reference: MyDbObject[name=reference], " +
"matches: MyDbObject[name=match1], MyDbObject[name=match2], MyDbObject[name=match3] and 1 more...",
redundantDBO.describe());
}
/**
* @return
*/
private List<DbObject> makeMatches(int numMatches)
{
List<DbObject> matches = new ArrayList<DbObject>();
for (int i = 0; i < numMatches; i++)
{
matches.add(new MyDbObject("match" + (i+1)));
}
return matches;
}
private static class MyDbObject extends AbstractDbObject
{
public MyDbObject(String name)
{
super(null, name);
}
@Override
public void accept(DbObjectVisitor visitor)
{
}
}
}