Skip to content

Commit

Permalink
MODE-1742 - Added explicit error messages for the GitConnectorTests's…
Browse files Browse the repository at this point in the history
… tag tests. Also, enabled the connectors module in the main build.
  • Loading branch information
Horia Chiorean committed Jan 2, 2013
1 parent 3a2060a commit 1c501de
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void shouldReadFederatedNodeInProjection() throws Exception {
public void shouldReadTags() throws Exception {
Node git = gitNode();
Node tags = git.getNode("tags");
assertChildrenInclude(tags, expectedTagNames());
assertChildrenInclude("Make sure you run <git fetch --tags>", tags, expectedTagNames());
}

@Test
Expand Down Expand Up @@ -175,7 +175,7 @@ public void shouldContainTagsAndBranchNamesAndCommitsUnderTreeNode() throws Exce
Node tree = git.getNode("tree");
assertThat(tree.getPrimaryNodeType().getName(), is("git:trees"));
assertChildrenInclude(tree, expectedBranchNames());
assertChildrenInclude(tree, expectedTagNames());
assertChildrenInclude("Make sure you run <git fetch --tags>", tree, expectedTagNames());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,21 +473,36 @@ protected static int calculateTotalNumberOfNodesInTree( int numberOfChildrenPerN

protected void assertChildrenInclude( Node parentNode,
String... minimalChildNamesWithSns ) throws RepositoryException {
assertChildrenInclude(null, parentNode, minimalChildNamesWithSns);
}

protected void assertChildrenInclude( String errorMessage,
Node parentNode,
String... minimalChildNamesWithSns
) throws RepositoryException {
Set<String> childNames = new HashSet<String>();
for (String childName : minimalChildNamesWithSns) {
childNames.add(childName);
}
childNames.addAll(Arrays.asList(minimalChildNamesWithSns));

NodeIterator iter = parentNode.getNodes();
while (iter.hasNext()) {
Node child = iter.nextNode();
String name = child.getName();
if (child.getIndex() > 1) name = name + "[" + child.getIndex() + "]";
if (child.getIndex() > 1) {
name = name + "[" + child.getIndex() + "]";
}
childNames.remove(name);
// If we've found all of the expected child names, then return immediately
// (in case there are a very large number of children) ...
if (childNames.isEmpty()) return;
if (childNames.isEmpty()) {
return;
}
}

String message = "Names of children not found under node: " + childNames;
if (!StringUtil.isBlank(errorMessage)) {
message += ". " + errorMessage;
}
assertThat("Names of children not found under node: " + childNames, childNames.isEmpty(), is(true));
assertThat(message, childNames.isEmpty(), is(true));
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<module>extractors</module>

<!--Connectors-->
<!--<module>connectors</module>-->
<module>connectors</module>
<!--
The REST client needs the JDBC driver
-->
Expand Down

0 comments on commit 1c501de

Please sign in to comment.