[isidorus-cvs] r517 - branches/gdl-frontend/src/anaToMia/GDL_TmEngine/test/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Mon Jun 27 21:02:45 UTC 2011


Author: lgiessmann
Date: Mon Jun 27 14:02:45 2011
New Revision: 517

Log:
gdl-frontend: Topic Maps Engine: added a unit-test for the class Association;

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_TmEngine/test/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/JtmsTmEngineTest.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_TmEngine/test/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/JtmsTmEngineTest.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_TmEngine/test/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/JtmsTmEngineTest.java	Mon Jun 27 14:00:43 2011	(r516)
+++ branches/gdl-frontend/src/anaToMia/GDL_TmEngine/test/us/isidor/gdl/anaToMia/TmEngine/jtmsBasedEngine/JtmsTmEngineTest.java	Mon Jun 27 14:02:45 2011	(r517)
@@ -19,6 +19,7 @@
 	final String tmLocator2 = "http://us.isidor.gdl.anaToMia/tm-2";
 	final String siLocator1 = "http'://us.isidor.gdl.anaToMia/si-1";
 	final String siLocator2 = "http'://us.isidor.gdl.anaToMia/si-2";
+	final String siLocator3 = "http'://us.isidor.gdl.anaToMia/si-3";
 	final String slLocator1 = "http'://us.isidor.gdl.anaToMia/sl-1";
 	final String slLocator2 = "http'://us.isidor.gdl.anaToMia/sl-2";
 	final String iiLocator1 = "http'://us.isidor.gdl.anaToMia/ii-1";
@@ -63,7 +64,7 @@
 	}
 
 
-	public void testTopicMap(){
+	public void testTopic(){
 		jtme = new JtmsTmEngine();
 
 		TopicMap tm = jtme.createTopicMap(tmLocator1);
@@ -244,7 +245,50 @@
 	}
 	
 	
-	// TODO: Association
+	public void testAssociation(){
+		jtme = new JtmsTmEngine();
+
+		TopicMap tm = jtme.createTopicMap(tmLocator1);
+		Topic type1 = tm.createTopic();
+		Topic type2 = tm.createTopic();
+		Topic theme1 = tm.createTopicBySubjectIdentifier(tm.createLocator(siLocator1));
+		Topic theme2 = tm.createTopicBySubjectIdentifier(tm.createLocator(siLocator2));
+		Topic theme3 = tm.createTopicBySubjectIdentifier(tm.createLocator(siLocator3));
+		Topic reifier = tm.createTopic();
+		ArrayList<Topic> scope = new ArrayList<Topic>();
+		scope.add(theme1);
+		scope.add(theme2);
+		Association assoc1 = tm.createAssociation(type1, createJsArray(scope));
+		Association assoc2 = tm.createAssociation(type2, appendToJsArray(null, null));
+		assoc1.addItemIdentifier(tm.createLocator(iiLocator1));
+		assoc1.addItemIdentifier(tm.createLocator(iiLocator2));
+		assoc1.setReifier(reifier);
+		assoc1.addTheme(theme3);
+		
+		assertEquals(2, tm.getAssociations().length());
+		assertTrue(assoc1.equals(tm.getAssociations().get(0)) || assoc1.equals(tm.getAssociations().get(1)));
+		assertTrue(assoc2.equals(tm.getAssociations().get(0)) || assoc2.equals(tm.getAssociations().get(1)));
+		assertEquals(2, assoc1.getItemIdentifiers().length());
+		assertTrue(iiLocator1.equals(assoc1.getItemIdentifiers().get(0).getReference()) || iiLocator1.equals(assoc1.getItemIdentifiers().get(1).getReference()));
+		assertTrue(iiLocator2.equals(assoc1.getItemIdentifiers().get(0).getReference()) || iiLocator2.equals(assoc1.getItemIdentifiers().get(1).getReference()));
+		assertEquals(reifier, assoc1.getReifier());
+		assertEquals(3, assoc1.getScope().length());
+		assertTrue(theme1.equals(assoc1.getScope().get(0)) || theme1.equals(assoc1.getScope().get(1)) || theme1.equals(assoc1.getScope().get(2)));
+		assertTrue(theme2.equals(assoc1.getScope().get(0)) || theme2.equals(assoc1.getScope().get(1)) || theme2.equals(assoc1.getScope().get(2)));  
+		assertTrue(theme3.equals(assoc1.getScope().get(0)) || theme3.equals(assoc1.getScope().get(1)) || theme3.equals(assoc1.getScope().get(2)));
+		assoc1.removeTheme(theme3);
+		assoc1.removeTheme(theme2);
+		assoc1.removeItemIdentifier(tm.createLocator(iiLocator1));
+		assertEquals(1, assoc1.getItemIdentifiers().length());
+		assertEquals(iiLocator2, assoc1.getItemIdentifiers().get(0).getReference());
+		assertEquals(1, assoc1.getScope().length());
+		assertEquals(theme1, assoc1.getScope().get(0));
+		assoc1.remove();
+		assertEquals(1, tm.getAssociations().length());
+		assertEquals(assoc2, tm.getAssociations().get(0));
+	}
+	
+	
 	// TODO: Role
 	// TODO: JTM 1.1 import
 	// TODO: JTM 1.1 export 




More information about the Isidorus-cvs mailing list