new org.candlepin.json.model.Content();
cont.setPath("/head/neck/shoulders/heart" + i + "/waist" +
i + "/leg/foot/heel");
contentList.add(cont);
}
PathNode location = v3extensionUtil.makePathTree(contentList,
v3extensionUtil.new PathNode());
v3extensionUtil.printTree(location, 0);
assertEquals(location.getChildren().size(), 1);
assertEquals(location.getChildren().get(0).getName(), "head");
location = location.getChildren().get(0).getConnection();
assertEquals(location.getChildren().size(), 1);
assertEquals(location.getChildren().get(0).getName(), "neck");
location = location.getChildren().get(0).getConnection();
assertEquals(location.getChildren().size(), 1);
assertEquals(location.getChildren().get(0).getName(), "shoulders");
location = location.getChildren().get(0).getConnection();
assertEquals(location.getChildren().size(), 20);
// find the common footer nodes and make sure they are merged.
long legId = -1;
long footId = -1;
long heelId = -1;
for (NodePair np : location.getChildren()) {
// np is a "heart" pair
assertTrue(np.getName().startsWith("heart"));
// now waist node
PathNode waist = np.getConnection();
assertEquals(waist.getChildren().size(), 1);
assertTrue(waist.getChildren().get(0).getName().startsWith("waist"));
// go to "leg" node
PathNode leg = waist.getChildren().get(0).getConnection();
if (legId == -1) {
legId = leg.getId();
}
else {
assertEquals(leg.getId(), legId);
}
assertEquals(leg.getChildren().size(), 1);
assertEquals(leg.getChildren().get(0).getName(), "leg");
// go to "foot" node
PathNode foot = leg.getChildren().get(0).getConnection();
if (footId == -1) {
footId = foot.getId();
}
else {
assertEquals(foot.getId(), footId);
}
assertEquals(foot.getChildren().size(), 1);
assertEquals(foot.getChildren().get(0).getName(), "foot");
// go to "heel" node
PathNode heel = foot.getChildren().get(0).getConnection();
if (heelId == -1) {
heelId = heel.getId();
}
else {
assertEquals(heel.getId(), heelId);
}
assertEquals(heel.getChildren().size(), 1);
assertEquals(heel.getChildren().get(0).getName(), "heel");
}
}