From: Kal A. <kal...@us...> - 2004-12-13 18:25:20
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18216/test Modified Files: AssociationTest.java Log Message: Fixed representation of TM4J Member objects with multiple players. Index: AssociationTest.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/test/AssociationTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AssociationTest.java 8 Dec 2004 10:34:03 -0000 1.13 --- AssociationTest.java 13 Dec 2004 18:25:04 -0000 1.14 *************** *** 11,14 **** --- 11,17 ---- import java.util.Iterator; + import org.tm4j.tmapi.core.TMAPITopicMapImpl; + import org.tm4j.tmapi.helpers.Wrapper; + import org.tm4j.topicmap.Member; import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; *************** *** 100,102 **** --- 103,132 ---- assertEquals(2, a.getAssociationRoles().size()); } + + public void testMultiplePlayers() throws Exception + { + Association a = m_topicMap.createAssociation(); + org.tm4j.topicmap.Association raw = Wrapper.unwrap(a); + Member m1 = raw.createMember(null); + m1.setRoleSpec(raw.getTopicMap().createTopic("t1")); + m1.addPlayer(raw.getTopicMap().createTopic("p1")); + Member m2 = raw.createMember(null); + m2.setRoleSpec(raw.getTopicMap().createTopic("t2")); + m2.addPlayer(raw.getTopicMap().createTopic("p2")); + m2.addPlayer(raw.getTopicMap().createTopic("p3")); + a = Wrapper.wrap(raw, (TMAPITopicMapImpl)a.getTopicMap()); + assertEquals(3, a.getAssociationRoles().size()); + Iterator it = a.getAssociationRoles().iterator(); + while (it.hasNext()) { + AssociationRole ar = (AssociationRole)it.next(); + if (ar.getPlayer().getObjectId().equals("p1")) { + assertEquals("t1", ar.getType().getObjectId()); + } else if (ar.getPlayer().getObjectId().equals("p2") + || ar.getPlayer().getObjectId().equals("p3")) { + assertEquals("t2", ar.getType().getObjectId()); + } else { + fail("Unexpected association role player ID: "+ ar.getPlayer().getObjectId()); + } + } + } } |