Adding additional messages to graph assertions.
@@ -20,8 +20,8 @@ class DependencyGraphTestUtil {
}
public static void assertSummarries(GraphSummary expected, GraphSummary actual) {
- assertSet(expected.rootExternalDataIds, actual.rootExternalDataIds);
- assertSet(expected.dependencySummaries.keySet(), actual.dependencySummaries.keySet());
+ assertSet(expected.rootExternalDataIds, actual.rootExternalDataIds, "Root external ids");
+ assertSet(expected.dependencySummaries.keySet(), actual.dependencySummaries.keySet(), "Dependencies in graph");
def expectedRelationshipIds = expected.externalDataIdRelationships.keySet()
def expectedExistingRelationshipsIds = expectedRelationshipIds.findAll{ key -> expected.externalDataIdRelationships.get(key) != null && expected.externalDataIdRelationships.get(key).size() > 0}
@@ -29,25 +29,25 @@ class DependencyGraphTestUtil {
def actualRelationshipIds = actual.externalDataIdRelationships.keySet()
def actualExistingRelationshipsIds = actualRelationshipIds.findAll{ key -> actual.externalDataIdRelationships.get(key) != null && actual.externalDataIdRelationships.get(key).size() > 0}
- assertSet(expectedExistingRelationshipsIds, actualExistingRelationshipsIds);
+ assertSet(expectedExistingRelationshipsIds, actualExistingRelationshipsIds, "Existing relationships");
for (String key : expected.dependencySummaries.keySet()){
assertEquals(expected.dependencySummaries.get(key).name, actual.dependencySummaries.get(key).name);
assertEquals(expected.dependencySummaries.get(key).version, actual.dependencySummaries.get(key).version);
}
for (String key : expectedExistingRelationshipsIds){
- assertSet(expected.externalDataIdRelationships.get(key), actual.externalDataIdRelationships.get(key));
+ assertSet(expected.externalDataIdRelationships.get(key), actual.externalDataIdRelationships.get(key), "External data id relationships for " + key);
}
}
- public static <T> void assertSet (Set<T> expected, Set<T> actual) {
+ public static <T> void assertSet (Set<T> expected, Set<T> actual, String title) {
Set<String> missingExpected = new HashSet<>(expected);
missingExpected.removeAll(actual)
Set<String> extraActual = new HashSet<>(actual);
extraActual.removeAll(expected)
- assertEquals(0, missingExpected.size());
- assertEquals(0, extraActual.size());
+ assertTrue(title + ": Found missing expected " + missingExpected.toString(), missingExpected.size() == 0);
+ assertTrue(title + ": Found extra actual " + extraActual.toString(), extraActual.size() == 0);
}
}
