Search in sources :

Example 1 with BaseCommand

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);
}
Also used : BaseCommand(org.neo4j.internal.recordstorage.Command.BaseCommand) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1 BaseCommand (org.neo4j.internal.recordstorage.Command.BaseCommand)1 PropertyCommand (org.neo4j.internal.recordstorage.Command.PropertyCommand)1