Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(DescriptorFactory.class) void shouldLookupSingleKeyAndSharedCompositeKeyDescriptors(DescriptorFactory factory)
        internal virtual void ShouldLookupSingleKeyAndSharedCompositeKeyDescriptors(DescriptorFactory factory)
        {
            // given
            SchemaDescriptorLookupSet <SchemaDescriptor> set = new SchemaDescriptorLookupSet <SchemaDescriptor>();
            SchemaDescriptor expected1 = factory.descriptor(1, 2);
            SchemaDescriptor expected2 = factory.descriptor(1, 2, 3);

            set.Add(expected1);
            set.Add(expected2);

            // when
            ISet <SchemaDescriptor> descriptors = new HashSet <SchemaDescriptor>();

            set.MatchingDescriptorsForPartialListOfProperties(descriptors, Longs(1), Ints(2));

            // then
            assertEquals(asSet(expected1, expected2), descriptors);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(DescriptorFactory.class) void shouldLookupCompositeKeyDescriptor(DescriptorFactory factory)
        internal virtual void ShouldLookupCompositeKeyDescriptor(DescriptorFactory factory)
        {
            // given
            SchemaDescriptorLookupSet <SchemaDescriptor> set = new SchemaDescriptorLookupSet <SchemaDescriptor>();
            SchemaDescriptor descriptor1 = factory.descriptor(1, 2, 3);
            SchemaDescriptor descriptor2 = factory.descriptor(1, 2, 4);
            SchemaDescriptor descriptor3 = factory.descriptor(1, 2, 5, 6);

            set.Add(descriptor1);
            set.Add(descriptor2);
            set.Add(descriptor3);

            // when
            ISet <SchemaDescriptor> descriptors = new HashSet <SchemaDescriptor>();

            set.MatchingDescriptorsForCompleteListOfProperties(descriptors, Longs(1), Ints(2, 5, 6));

            // then
            assertEquals(asSet(descriptor3), descriptors);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(DescriptorFactory.class) void shouldLookupAllByEntityToken(DescriptorFactory factory)
        internal virtual void ShouldLookupAllByEntityToken(DescriptorFactory factory)
        {
            // given
            SchemaDescriptorLookupSet <SchemaDescriptor> set = new SchemaDescriptorLookupSet <SchemaDescriptor>();
            SchemaDescriptor descriptor1 = factory.descriptor(1, 2, 3);
            SchemaDescriptor descriptor2 = factory.descriptor(1, 2, 4);
            SchemaDescriptor descriptor3 = factory.descriptor(1, 2, 5, 6);
            SchemaDescriptor descriptor4 = factory.descriptor(2, 2, 3);
            SchemaDescriptor descriptor5 = factory.descriptor(3, 2, 5, 6);

            set.Add(descriptor1);
            set.Add(descriptor2);
            set.Add(descriptor3);
            set.Add(descriptor4);
            set.Add(descriptor5);

            // when
            ISet <SchemaDescriptor> descriptors = new HashSet <SchemaDescriptor>();

            set.MatchingDescriptors(descriptors, Longs(1));

            // then
            assertEquals(asSet(descriptor1, descriptor2, descriptor3), descriptors);
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @MethodSource("nodeAndRelationshipEntityTypes") void shouldMatchOnAnyEntityAndPropertyTokenForPartialPropertySchemaType(org.neo4j.storageengine.api.EntityType entityType)
        internal virtual void ShouldMatchOnAnyEntityAndPropertyTokenForPartialPropertySchemaType(EntityType entityType)
        {
            // given
            SchemaDescriptorLookupSet <SchemaDescriptor> set = new SchemaDescriptorLookupSet <SchemaDescriptor>();
            MultiTokenSchemaDescriptor descriptor1           = SchemaDescriptorFactory.multiToken(Ints(0, 1, 2), entityType, 3, 4, 5);
            MultiTokenSchemaDescriptor descriptor2           = SchemaDescriptorFactory.multiToken(Ints(0, 1), entityType, 3, 4);
            MultiTokenSchemaDescriptor descriptor3           = SchemaDescriptorFactory.multiToken(Ints(0, 2), entityType, 4, 5);

            set.Add(descriptor1);
            set.Add(descriptor2);
            set.Add(descriptor3);

            // given that this test revolves around entity tokens 0,1,2 and property tokens 3,4,5 these 3 descriptors below matches either
            // only those tokens for entity or property or neither. I.e. these should never be included in matching results
            set.Add(SchemaDescriptorFactory.multiToken(Ints(3, 4), entityType, 4, 5));
            set.Add(SchemaDescriptorFactory.multiToken(Ints(0, 1), entityType, 6, 7));
            set.Add(SchemaDescriptorFactory.multiToken(Ints(3, 4), entityType, 6, 7));

            // when matching these descriptors (in this case partial/complete list doesn't quite matter because the descriptors
            // themselves are partially matched anyway.
            ISet <SchemaDescriptor> descriptors1        = new HashSet <SchemaDescriptor>();
            ISet <SchemaDescriptor> descriptors1Partial = new HashSet <SchemaDescriptor>();
            ISet <SchemaDescriptor> descriptors2        = new HashSet <SchemaDescriptor>();
            ISet <SchemaDescriptor> descriptors2Partial = new HashSet <SchemaDescriptor>();
            ISet <SchemaDescriptor> descriptors3        = new HashSet <SchemaDescriptor>();
            ISet <SchemaDescriptor> descriptors3Partial = new HashSet <SchemaDescriptor>();

            set.MatchingDescriptorsForCompleteListOfProperties(descriptors1, Longs(0, 1), Ints(4, 5));
            set.MatchingDescriptorsForPartialListOfProperties(descriptors1Partial, Longs(0, 1), Ints(4, 5));
            set.MatchingDescriptorsForCompleteListOfProperties(descriptors2, Longs(0), Ints(3));
            set.MatchingDescriptorsForPartialListOfProperties(descriptors2Partial, Longs(0), Ints(3));
            set.MatchingDescriptorsForCompleteListOfProperties(descriptors3, Longs(1), Ints(5));
            set.MatchingDescriptorsForPartialListOfProperties(descriptors3Partial, Longs(1), Ints(5));

            // then
            assertEquals(asSet(descriptor1, descriptor2, descriptor3), descriptors1);
            assertEquals(asSet(descriptor1, descriptor2, descriptor3), descriptors1Partial);
            assertEquals(asSet(descriptor1, descriptor2), descriptors2);
            assertEquals(asSet(descriptor1, descriptor2), descriptors2Partial);
            assertEquals(asSet(descriptor1), descriptors3);
            assertEquals(asSet(descriptor1), descriptors3Partial);
        }
Ejemplo n.º 5
0
        private void ShouldAddRemoveAndLookupRandomDescriptors(bool includeIdempotentAddsAndRemoves)
        {
            // given
            IList <SchemaDescriptor> all = new List <SchemaDescriptor>();
            SchemaDescriptorLookupSet <SchemaDescriptor> set = new SchemaDescriptorLookupSet <SchemaDescriptor>();
            int highEntityKeyId         = 8;
            int highPropertyKeyId       = 8;
            int maxNumberOfEntityKeys   = 3;
            int maxNumberOfPropertyKeys = 3;

            // when/then
            for (int i = 0; i < 100; i++)
            {
                // add some
                int countToAdd = _random.Next(1, 5);
                for (int a = 0; a < countToAdd; a++)
                {
                    SchemaDescriptor descriptor = RandomSchemaDescriptor(highEntityKeyId, highPropertyKeyId, maxNumberOfEntityKeys, maxNumberOfPropertyKeys);
                    if (!includeIdempotentAddsAndRemoves && all.IndexOf(descriptor) != -1)
                    {
                        // Oops, we randomly generated a descriptor that already exists
                        continue;
                    }

                    set.Add(descriptor);
                    all.Add(descriptor);
                }

                // remove some
                int countToRemove = _random.Next(0, 2);
                for (int r = 0; r < countToRemove && all.Count > 0; r++)
                {
                    SchemaDescriptor descriptor = all.RemoveAt(_random.Next(all.Count));
                    set.Remove(descriptor);
                    if (includeIdempotentAddsAndRemoves)
                    {
                        set.Remove(descriptor);
                        while (all.Remove(descriptor))
                        {
                            // Just continue removing duplicates until all are done
                        }
                    }
                }

                // lookup
                int countToLookup = 20;
                for (int l = 0; l < countToLookup; l++)
                {
                    int[]  entityTokenIdsInts      = RandomUniqueSortedIntArray(highEntityKeyId, _random.Next(1, 3));
                    long[] entityTokenIds          = ToLongArray(entityTokenIdsInts);
                    int[]  propertyKeyIds          = RandomUniqueSortedIntArray(highPropertyKeyId, _random.Next(1, maxNumberOfPropertyKeys));
                    ISet <SchemaDescriptor> actual = new HashSet <SchemaDescriptor>();

                    // lookup by only entity tokens
                    actual.Clear();
                    set.MatchingDescriptors(actual, entityTokenIds);
                    assertEquals(ExpectedDescriptors(all, FilterByEntity(entityTokenIdsInts)), actual);

                    // lookup by partial property list
                    actual.Clear();
                    set.MatchingDescriptorsForPartialListOfProperties(actual, entityTokenIds, propertyKeyIds);
                    assertEquals(ExpectedDescriptors(all, FilterByEntityAndPropertyPartial(entityTokenIdsInts, propertyKeyIds)), actual);

                    // lookup by complete property list
                    actual.Clear();
                    set.MatchingDescriptorsForCompleteListOfProperties(actual, entityTokenIds, propertyKeyIds);
                    assertEquals(ExpectedDescriptors(all, FilterByEntityAndPropertyComplete(entityTokenIdsInts, propertyKeyIds)), actual);
                }
            }
        }