fixing the PathNode.includes()

This commit is contained in:
Vincent Batts 2012-11-09 16:26:43 -05:00
parent 8f57255c06
commit de9f279ed4
2 changed files with 14 additions and 13 deletions

View file

@ -218,8 +218,6 @@ public class PathNode {
/** /**
* check whether current PathNode, includes the paths in PathNode that, like a mask. * check whether current PathNode, includes the paths in PathNode that, like a mask.
* *
* FIXME This is not working correctly yet
*
* @param that PathNode to check for * @param that PathNode to check for
* @return boolean of truth! * @return boolean of truth!
*/ */
@ -234,20 +232,21 @@ public class PathNode {
List<Boolean> found = new ArrayList<Boolean>(); List<Boolean> found = new ArrayList<Boolean>();
boolean result; boolean result;
for (NodePair thisnp : this.getChildren()) { for (NodePair thatnp : that.getChildren()) {
for (NodePair thatnp : that.getChildren()) { for (NodePair thisnp : this.getChildren()) {
// keep checking, even if we hist a variablized value // keep checking, even if we hit a variablized value
if (thisnp.getName().startsWith("$") || thisnp.getName().equals(thatnp.getName())) { if ( thatnp.getName().startsWith("$") ||
thisnp.getName().startsWith("$") ||
thisnp.getName().equals(thatnp.getName()) ) {
result = thisnp.getConnection().includes(thatnp.getConnection()); result = thisnp.getConnection().includes(thatnp.getConnection());
found.add(new Boolean(result).booleanValue()); found.add(new Boolean(result).booleanValue());
log.debug("includes: " + thisnp + " == " + thatnp); log.debug("includes: this: " + thisnp.getName() + " == that:" + thatnp.getName());
break;
} }
found.add(Boolean.FALSE);
} }
} }
return (!found.contains(Boolean.FALSE)); // return true, if we've found all of thats children
return (found.size() == that.getChildren().size());
} }
/** /**

View file

@ -62,12 +62,15 @@ public class TestPathNode {
List<String> contents1 = TestHelpers.loadContents(this, "contents_small.list"); List<String> contents1 = TestHelpers.loadContents(this, "contents_small.list");
try { try {
// this will be the authority
pt0.setContentSets(contents0); pt0.setContentSets(contents0);
pn0 = pt0.getRootPathNode(); // setup the larger PathNode pn0 = pt0.getRootPathNode(); // setup the larger PathNode
// small tree, that is a subset of the contents in the authority
pt1.setContentSets(contents1); pt1.setContentSets(contents1);
pn1 = pt1.getRootPathNode(); // setup the small PathNode pn1 = pt1.getRootPathNode(); // setup the small PathNode
// of that small tree, add an entry that is _not_ in the authority
contents1.add(new String("/this/is/not/in/the/list")); contents1.add(new String("/this/is/not/in/the/list"));
pt2.setContentSets(contents1); pt2.setContentSets(contents1);
pn2 = pt2.getRootPathNode(); // setup the small PathNode pn2 = pt2.getRootPathNode(); // setup the small PathNode
@ -79,9 +82,8 @@ public class TestPathNode {
assertNotNull(pn1); assertNotNull(pn1);
assertNotNull(pn2); assertNotNull(pn2);
// FIXME - Finish the test first assertTrue(pn0.includes(pn1));
//assertTrue(pn0.includes(pn1)); assertFalse(pn0.includes(pn2));
//assertFalse(pn0.includes(pn2));
} }
} }