//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(Factory.class) void shouldSeeMultipleGroupsSomeOfThemWithEntity(Factory factory)
        internal virtual void ShouldSeeMultipleGroupsSomeOfThemWithEntity(Factory factory)
        {
            // given
            EntityCommandGrouper grouper = new EntityCommandGrouper <>(factory.command(0).GetType(), 64);

            Group[] groups = new Group[_random.Next(10, 30)];
            for (int entityId = 0; entityId < groups.Length; entityId++)
            {
                Command.BaseCommand entityCommand = _random.nextBoolean() ? factory.command(entityId) : null;
                groups[entityId] = new Group(entityId, entityCommand);
                if (entityCommand != null)
                {
                    grouper.add(entityCommand);                                // <-- storage transaction logs are sorted such that entity commands comes before property commands
                }
            }
            int totalNumberOfProperties = _random.Next(10, 100);

            for (int i = 0; i < totalNumberOfProperties; i++)
            {
                int entityId = _random.Next(groups.Length);
                Command.PropertyCommand property = property(factory.command(entityId).After);
                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);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(Factory.class) void shouldHandleEmptyList(Factory factory)
        internal virtual void ShouldHandleEmptyList(Factory factory)
        {
            // given
            EntityCommandGrouper grouper = new EntityCommandGrouper <>(factory.command(0).GetType(), 8);

            // when
            EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();
            bool hasNext = cursor.NextEntity();

            // then
            assertFalse(hasNext);
        }
 private void AssertGroups(EntityCommandGrouper.Cursor cursor, params Group[] groups)
 {
     foreach (Group group in groups)
     {
         if (group.Empty)
         {
             continue;
         }
         assertTrue(cursor.NextEntity());
         group.AssertGroup(cursor);
     }
     assertFalse(cursor.NextEntity());
 }
        private EntityUpdates Convert(long[] labelsBefore, long[] labelsAfter, params Command.PropertyCommand[] changes)
        {
            long nodeId = 0;

            EntityUpdates.Builder updates = EntityUpdates.ForEntity(( long )0, false).withTokens(labelsBefore).withTokensAfter(labelsAfter);
            EntityCommandGrouper  grouper = new EntityCommandGrouper <>(typeof(Command.NodeCommand), 8);

            grouper.add(new Command.NodeCommand(new NodeRecord(nodeId), new NodeRecord(nodeId)));
            foreach (Command.PropertyCommand change in changes)
            {
                grouper.add(change);
            }
            EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();
            assertTrue(cursor.NextEntity());
            _converter.convertPropertyRecord(cursor, updates);
            return(updates.Build());
        }
            internal virtual void AssertGroup(EntityCommandGrouper.Cursor cursor)
            {
                assertEquals(EntityId, cursor.CurrentEntityId());
                assertSame(EntityCommand, cursor.CurrentEntityCommand());
                ISet <Command.PropertyCommand> fromGrouper = new HashSet <Command.PropertyCommand>();

                while (true)
                {
                    Command.PropertyCommand property = cursor.NextProperty();
                    if (property == null)
                    {
                        break;
                    }
                    fromGrouper.Add(property);
                }
                assertEquals(fromGrouper, Properties);
            }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(Factory.class) void shouldSeeSingleGroupOfPropertiesWithoutEntity(Factory factory)
        internal virtual void ShouldSeeSingleGroupOfPropertiesWithoutEntity(Factory factory)
        {
            // given
            EntityCommandGrouper grouper = new EntityCommandGrouper <>(factory.command(0).GetType(), 8);
            long entityId = 1;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.impl.transaction.command.Command.BaseCommand<? extends org.neo4j.kernel.impl.store.record.PrimitiveRecord> entity = factory.command(entityId);
            Command.BaseCommand <PrimitiveRecord> entity = factory.command(entityId);
            Command.PropertyCommand property1            = Property(entity.After);
            Command.PropertyCommand property2            = Property(entity.After);
            // intentionally DO NOT add the entity command
            grouper.add(property1);
            grouper.add(property2);
            EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();

            // when/then
            AssertGroups(cursor, Group(entityId, null, property1, property2));
        }