fixing the PathNode.includes()
This commit is contained in:
parent
8f57255c06
commit
de9f279ed4
2 changed files with 14 additions and 13 deletions
|
@ -218,8 +218,6 @@ public class PathNode {
|
|||
/**
|
||||
* 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
|
||||
* @return boolean of truth!
|
||||
*/
|
||||
|
@ -234,20 +232,21 @@ public class PathNode {
|
|||
List<Boolean> found = new ArrayList<Boolean>();
|
||||
boolean result;
|
||||
|
||||
for (NodePair thisnp : this.getChildren()) {
|
||||
for (NodePair thatnp : that.getChildren()) {
|
||||
// keep checking, even if we hist a variablized value
|
||||
if (thisnp.getName().startsWith("$") || thisnp.getName().equals(thatnp.getName())) {
|
||||
for (NodePair thisnp : this.getChildren()) {
|
||||
// keep checking, even if we hit a variablized value
|
||||
if ( thatnp.getName().startsWith("$") ||
|
||||
thisnp.getName().startsWith("$") ||
|
||||
thisnp.getName().equals(thatnp.getName()) ) {
|
||||
result = thisnp.getConnection().includes(thatnp.getConnection());
|
||||
found.add(new Boolean(result).booleanValue());
|
||||
log.debug("includes: " + thisnp + " == " + thatnp);
|
||||
break;
|
||||
log.debug("includes: this: " + thisnp.getName() + " == that:" + thatnp.getName());
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,12 +62,15 @@ public class TestPathNode {
|
|||
List<String> contents1 = TestHelpers.loadContents(this, "contents_small.list");
|
||||
|
||||
try {
|
||||
// this will be the authority
|
||||
pt0.setContentSets(contents0);
|
||||
pn0 = pt0.getRootPathNode(); // setup the larger PathNode
|
||||
|
||||
// small tree, that is a subset of the contents in the authority
|
||||
pt1.setContentSets(contents1);
|
||||
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"));
|
||||
pt2.setContentSets(contents1);
|
||||
pn2 = pt2.getRootPathNode(); // setup the small PathNode
|
||||
|
@ -79,9 +82,8 @@ public class TestPathNode {
|
|||
assertNotNull(pn1);
|
||||
assertNotNull(pn2);
|
||||
|
||||
// FIXME - Finish the test first
|
||||
//assertTrue(pn0.includes(pn1));
|
||||
//assertFalse(pn0.includes(pn2));
|
||||
assertTrue(pn0.includes(pn1));
|
||||
assertFalse(pn0.includes(pn2));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue