It holds RoleInfo objects for all roles in the relation.
Revisions:
20020312 Adrian Brock:
20020715 Adrian Brock:
363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
{ RoleInfo roleInfo1 = null; RoleInfo roleInfo2 = null; RoleInfo[] roleInfos = null; RelationService rs = null; RelationTypeSupport rtsupp = null; // Null relation type boolean caught = false; try { roleInfo1 = new RoleInfo("roleInfo1", Trivial.class.getName()); roleInfo2 = new RoleInfo("roleInfo2", Trivial.class.getName()); roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 }; rs = new RelationService(true); rs.addRelationType(null); } catch (IllegalArgumentException e) { caught = true; } if (caught == false) fail("addRelationType allows null relation type"); // Duplicate relation types caught = false; try { rtsupp = new RelationTypeSupport("RelationTypeName", roleInfos); rs.addRelationType(rtsupp); rs.addRelationType(rtsupp); } catch (InvalidRelationTypeException e) { caught = true; } if (caught == false) fail("addRelationType allows duplication relation types"); // Duplicate role infos caught = false; try { roleInfos[1] = roleInfos[0]; rtsupp = new RelationTypeSupport("RelationTypeName1", roleInfos); rs.addRelationType(rtsupp); } catch (InvalidRelationTypeException e) { caught = true; } if (caught == false) fail("addRelationType allows duplicate role names"); // Null role info caught = false; try { roleInfos[1] = null; rtsupp = new RelationTypeSupport("RelationTypeName1", roleInfos); rs.addRelationType(rtsupp); } catch (InvalidRelationTypeException e) { caught = true; } if (caught == false) fail("addRelationType allows null role info"); // No role info caught = false; try { rtsupp = new RelationTypeSupport("RelationTypeName1", new RoleInfo[0]); rs.addRelationType(rtsupp); } catch (InvalidRelationTypeException e) { caught = true;
756757758759760761762763764765766767768769
compareRelationException(o1, o2); } public void compareRelationTypeSupport(Object o1, Object o2) { RelationTypeSupport r1 = (RelationTypeSupport)o1; RelationTypeSupport r2 = (RelationTypeSupport)o2; if (!r1.getRelationTypeName().equals(r2.getRelationTypeName())) throw new RuntimeException(); List infos1 = r1.getRoleInfos(); List infos2 = r2.getRoleInfos(); // RoleInfo does not override equals() so List.equals() fails; just use size() here if (infos1.size() != infos2.size()) throw new RuntimeException(); }