Author: batosai
Date: 2008-09-05 17:48:40 +0000 (Fri, 05 Sep 2008)
New Revision: 22471
Modified:
trunk/apps/WoT/src/plugins/WoT/WoTTest.java
Log:
Check two more cases that were causing errors with previous algorithm.
Modified: trunk/apps/WoT/src/plugins/WoT/WoTTest.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTTest.java 2008-09-05 16:57:37 UTC (rev
22470)
+++ trunk/apps/WoT/src/plugins/WoT/WoTTest.java 2008-09-05 17:48:40 UTC (rev
22471)
@@ -196,4 +196,76 @@
ObjectSet<Object> all = db.queryByExample(new Object());
while(all.hasNext()) db.delete(all.next());
}
+
+ public void testTrustLoop() throws MalformedURLException,
InvalidParameterException, DuplicateScoreException, DuplicateTrustException,
NotInTrustTreeException {
+ OwnIdentity a = new OwnIdentity(uriA, uriA, "A", "true",
"test");
+ Identity b = new Identity(uriB, "B", "true", "test");
+ Identity c = new Identity(uriC, "C", "true", "test");
+ db.store(a);
+ db.store(b);
+ db.store(c);
+ a.initTrustTree(db);
+ a.setTrust(db, b, 100, "Foo");
+ b.setTrust(db, c, 50, "Bar");
+ c.setTrust(db, a, 100, "Bleh");
+ c.setTrust(db, b, 50, "Oops");
+
+ // Check we have the correct number of objects
+ assertTrue(wot.getNbOwnIdentities() == 1);
+ assertTrue(wot.getNbIdentities() == 2);
+ assertTrue(Trust.getNb(db) == 4);
+ assertTrue(Score.getNb(db) == 3);
+
+ // Check a's Score object
+ assertTrue(a.getScore(a, db).getScore() == 100);
+ assertTrue(a.getScore(a, db).getRank() == 0);
+ assertTrue(a.getScore(a, db).getCapacity() == 100);
+
+ // Check B's Score object
+ assertTrue(b.getScore(a, db).getScore() == 108);
+ assertTrue(b.getScore(a, db).getRank() == 1);
+ assertTrue(b.getScore(a, db).getCapacity() == 40);
+
+ // Check C's Score object
+ assertTrue(c.getScore(a, db).getScore() == 20);
+ assertTrue(c.getScore(a, db).getRank() == 2);
+ assertTrue(c.getScore(a, db).getCapacity() == 16);
+ }
+
+ public void testOwnIndentitiesTrust() throws MalformedURLException,
InvalidParameterException, DuplicateScoreException, DuplicateTrustException,
NotTrustedException, NotInTrustTreeException {
+ OwnIdentity a = new OwnIdentity(uriA, uriA, "A", "true",
"test");
+ OwnIdentity b = new OwnIdentity(uriB, uriB, "B", "true",
"test");
+ db.store(a);
+ db.store(b);
+ a.initTrustTree(db);
+ b.initTrustTree(db);
+ a.setTrust(db, b, 100, "Foo");
+ b.setTrust(db, a, 100, "Bar");
+
+ // Check we have the correct number of objects
+ assertTrue(wot.getNbOwnIdentities() == 2);
+ assertTrue(wot.getNbIdentities() == 0);
+ assertTrue(Trust.getNb(db) == 2);
+ assertTrue(Score.getNb(db) == 4);
+
+ // Check a's own Score object
+ assertTrue(a.getScore(a, db).getScore() == 100);
+ assertTrue(a.getScore(a, db).getRank() == 0);
+ assertTrue(a.getScore(a, db).getCapacity() == 100);
+
+ // Check a's Score object
+ assertTrue(a.getScore(b, db).getScore() == 100);
+ assertTrue(a.getScore(b, db).getRank() == 1);
+ assertTrue(a.getScore(b, db).getCapacity() == 40);
+
+ // Check B's own Score object
+ assertTrue(b.getScore(b, db).getScore() == 100);
+ assertTrue(b.getScore(b, db).getRank() == 0);
+ assertTrue(b.getScore(b, db).getCapacity() == 100);
+
+ // Check B's Score object
+ assertTrue(b.getScore(a, db).getScore() == 100);
+ assertTrue(b.getScore(a, db).getRank() == 1);
+ assertTrue(b.getScore(a, db).getCapacity() == 40);
+ }
}