Search in sources :

Example 6 with BdioId

use of com.synopsys.integration.bdio.model.BdioId in project synopsys-detect by blackducksoftware.

the class GraphCompare method assertSummaries.

private static void assertSummaries(GraphSummary expected, GraphSummary actual) {
    assertSet(expected.rootExternalDataIds, actual.rootExternalDataIds, "Root external ids");
    assertSet(expected.dependencySummaries.keySet(), actual.dependencySummaries.keySet(), "Dependencies in graph");
    Set<BdioId> expectedRelationshipIds = expected.externalDataIdRelationships.keySet();
    Set<BdioId> expectedExistingRelationshipsIds = expectedRelationshipIds.stream().filter(key -> expected.externalDataIdRelationships.get(key) != null && expected.externalDataIdRelationships.get(key).size() > 0).collect(Collectors.toSet());
    Set<BdioId> actualRelationshipIds = actual.externalDataIdRelationships.keySet();
    Set<BdioId> actualExistingRelationshipsIds = actualRelationshipIds.stream().filter(key -> actual.externalDataIdRelationships.get(key) != null && actual.externalDataIdRelationships.get(key).size() > 0).collect(Collectors.toSet());
    assertSet(expectedExistingRelationshipsIds, actualExistingRelationshipsIds, "Existing relationships");
    for (BdioId key : expected.dependencySummaries.keySet()) {
        Assertions.assertEquals(expected.dependencySummaries.get(key).getName(), actual.dependencySummaries.get(key).getName());
        Assertions.assertEquals(expected.dependencySummaries.get(key).getVersion(), actual.dependencySummaries.get(key).getVersion());
    }
    for (BdioId key : expectedExistingRelationshipsIds) {
        assertSet(expected.externalDataIdRelationships.get(key), actual.externalDataIdRelationships.get(key), "External data id relationships for " + key);
    }
}
Also used : HashSet(java.util.HashSet) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Gson(com.google.gson.Gson) Assertions(org.junit.jupiter.api.Assertions) Set(java.util.Set) Collectors(java.util.stream.Collectors) GsonBuilder(com.google.gson.GsonBuilder) BdioId(com.synopsys.integration.bdio.model.BdioId) BdioId(com.synopsys.integration.bdio.model.BdioId)

Aggregations

BdioId (com.synopsys.integration.bdio.model.BdioId)6 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)2 NameVersion (com.synopsys.integration.util.NameVersion)2 LinkedList (java.util.LinkedList)2 Assertions (org.junit.jupiter.api.Assertions)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1