use of org.neo4j.internal.recordstorage.FlatRelationshipModifications.RelationshipData in project neo4j by neo4j.
the class RelationshipModifierTest method shouldCreateAndDelete.
// ... other known cases ...
@RepeatedTest(20)
void shouldCreateAndDelete() {
// given and initial state
long node = createEmptyNode();
IntSupplier typeStrategy = randomTypes(10);
Supplier<RelationshipDirection> directionStrategy = RANDOM_DIRECTION;
LongSupplier otherNodeStrategy = this::createEmptyNode;
int maxRelationships = 100;
List<RelationshipData> expectedRelationships = generateRelationshipData(random.nextInt(0, maxRelationships), node, typeStrategy, otherNodeStrategy, directionStrategy);
createRelationships(expectedRelationships);
// ... a set of relationships to create and delete
List<RelationshipData> relationshipsToCreate = generateRelationshipData((int) random.among(new long[] { 0, 1, 10, 100 }), node, typeStrategy, otherNodeStrategy, directionStrategy);
int numRelationshipsToDelete = min((int) random.among(new long[] { 0, 1, 10, maxRelationships }), expectedRelationships.size());
RelationshipData[] relationshipsToDelete = random.selection(expectedRelationships.toArray(RelationshipData[]::new), numRelationshipsToDelete, numRelationshipsToDelete, false);
// ... and rules for how the world changes "concurrently" while we perform these modifications
// on locked
monitors.addMonitorListener(new ResourceTypeLockOrderVerifier());
// on read
monitors.addMonitorListener(new ChangeWorldOnReadMonitor(node, typeStrategy, otherNodeStrategy, directionStrategy, expectedRelationships));
// when
RelationshipModifications modifications = modifications(relationshipsToCreate.toArray(RelationshipData[]::new), relationshipsToDelete);
modify(modifications);
applyModificationsToExpectedRelationships(modifications, expectedRelationships);
// then
assertThat(readRelationshipsFromStore(node, store)).isEqualTo(asSet(expectedRelationships));
}
Aggregations