Skip to content

Commit

Permalink
Merge pull request #8918 from IoannisPanagiotas/unflakey-wcc-stream-p…
Browse files Browse the repository at this point in the history
…roc-test

Unflakey test
  • Loading branch information
IoannisPanagiotas authored Apr 9, 2024
2 parents dd34ced + 8a6e289 commit cc8bca9
Showing 1 changed file with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.neo4j.gds.BaseProcTest;
import org.neo4j.gds.CommunityHelper;
import org.neo4j.gds.GdsCypher;
import org.neo4j.gds.Orientation;
import org.neo4j.gds.catalog.GraphProjectProc;
Expand All @@ -41,6 +40,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -121,7 +121,14 @@ void testStreamWithDefaults() {
communities.put(nodeId, setId);
});

CommunityHelper.assertCommunities(communities, EXPECTED_COMMUNITIES);
assertThat(communities.values().stream().distinct()).hasSize(3);

for (var community : EXPECTED_COMMUNITIES) {
for (int j = 0; j < community.length - 1; ++j) {
assertThat(communities.get(community[j])).isEqualTo(communities.get(community[j + 1]));
}
}

}

@Test
Expand Down Expand Up @@ -210,7 +217,21 @@ void testStreamWithMinComponentSize(Map<String, Long> parameters, Map<String, Lo
);
});

assertThat(actualComponents).isEqualTo(expectedCommunities);
String[] keySet = expectedCommunities.keySet().toArray(new String[0]);
assertThat(actualComponents.keySet()).containsExactlyInAnyOrder(keySet);

BiFunction<String, String, Boolean> actualCompare = (a, b) ->
actualComponents.get(a).equals(actualComponents.get(b));
BiFunction<String, String, Boolean> expectedCompare = (a, b) ->
expectedCommunities.get(a).equals(expectedCommunities.get(b));

for (int j = 0; j < keySet.length; ++j) {
for (int z = j + 1; z < keySet.length; ++z) {
assertThat(actualCompare.apply(keySet[j], keySet[z]))
.isEqualTo(expectedCompare.apply(keySet[j], keySet[z]));
}
}

}

@Test
Expand Down

0 comments on commit cc8bca9

Please sign in to comment.