use of org.neo4j.internal.recordstorage.Command.BaseCommand in project neo4j by neo4j.
the class EntityCommandGrouperTest method shouldSeeMultipleGroupsSomeOfThemWithEntity.
@ParameterizedTest
@EnumSource(Factory.class)
void shouldSeeMultipleGroupsSomeOfThemWithEntity(Factory factory) {
// given
EntityCommandGrouper grouper = new EntityCommandGrouper<>(factory.command(0).getClass(), 64);
Group[] groups = new Group[random.nextInt(10, 30)];
for (int entityId = 0; entityId < groups.length; entityId++) {
BaseCommand entityCommand = random.nextBoolean() ? factory.command(entityId) : null;
groups[entityId] = new Group(entityId, entityCommand);
if (entityCommand != null) {
// <-- storage transaction logs are sorted such that entity commands comes before property commands
grouper.add(entityCommand);
}
}
int totalNumberOfProperties = random.nextInt(10, 100);
for (int i = 0; i < totalNumberOfProperties; i++) {
int entityId = random.nextInt(groups.length);
PropertyCommand property = property(factory.command(entityId).getAfter());
groups[entityId].addProperty(property);
grouper.add(property);
}
// ^^^ OK so we've generated property commands for random entities in random order, let's sort them
EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();
// then
assertGroups(cursor, groups);
}
Aggregations