示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updatesShouldEqualRegardlessOfCreationMethod()
        public virtual void UpdatesShouldEqualRegardlessOfCreationMethod()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleAdd = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> singleAdd = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);

            Value[] singleAsArray = new Value[] { _singleValue };
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiAdd = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
            IndexEntryUpdate <object> multiAdd = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleRemove = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> singleRemove = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiRemove = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
            IndexEntryUpdate <object> multiRemove = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue, singleValue);
            IndexEntryUpdate <object> singleChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue, _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray, singleAsArray);
            IndexEntryUpdate <object> multiChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray, singleAsArray);

            assertThat(singleAdd, equalTo(multiAdd));
            assertThat(singleRemove, equalTo(multiRemove));
            assertThat(singleChange, equalTo(multiChange));
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEnforceUniqueConstraintsDirectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldEnforceUniqueConstraintsDirectly()
            {
                // when
                IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());

                WithPopulator(IndexProvider.getPopulator(Descriptor, indexSamplingConfig, heapBufferFactory(1024)), p =>
                {
                    try
                    {
                        p.add(Arrays.asList(IndexEntryUpdate.Add(NodeId1, Descriptor.schema(), Value1, Value2), IndexEntryUpdate.Add(NodeId2, Descriptor.schema(), Value1, Value2)));
                        TestNodePropertyAccessor propertyAccessor = new TestNodePropertyAccessor(NodeId1, Descriptor.schema(), Value1, Value2);
                        propertyAccessor.AddNode(NodeId2, Descriptor.schema(), Value1, Value2);
                        p.scanCompleted(PhaseTracker.nullInstance);
                        p.verifyDeferredConstraints(propertyAccessor);

                        fail("expected exception");
                    }
                    // then
                    catch (IndexEntryConflictException conflict)
                    {
                        assertEquals(NodeId1, conflict.ExistingNodeId);
                        assertEquals(ValueTuple.of(Value1, Value2), conflict.PropertyValues);
                        assertEquals(NodeId2, conflict.AddedNodeId);
                    }
                }, false);
            }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addShouldThrowIfAskedForChanged()
        public virtual void AddShouldThrowIfAskedForChanged()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> single = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> single = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);

            Thrown.expect(typeof(System.NotSupportedException));
            single.BeforeValues();
        }
示例#4
0
            /// <summary>
            /// All entries in composite index look like (booleanValue, randomValue ).
            /// Range queries in composite only work if all predicates before it is exact.
            /// We use boolean values for exact part so that we get some real ranges to work
            /// on in second composite slot where the random values are.
            /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testRangeMatchOnRandomValues() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void TestRangeMatchOnRandomValues()
            {
                Assume.assumeTrue("Assume support for granular composite queries", TestSuite.supportsGranularCompositeQueries());
                // given
                ValueType[]            types        = RandomSetOfSupportedAndSortableTypes();
                ISet <ValueTuple>      uniqueValues = new HashSet <ValueTuple>();
                SortedSet <ValueAndId> sortedValues = new SortedSet <ValueAndId>((v1, v2) => ValueTuple.COMPARATOR.Compare(v1.value, v2.value));
                MutableLong            nextId       = new MutableLong();

                for (int i = 0; i < 5; i++)
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<IndexEntryUpdate<?>> updates = new java.util.ArrayList<>();
                    IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >();
                    if (i == 0)
                    {
                        // The initial batch of data can simply be additions
                        updates = GenerateUpdatesFromValues(GenerateValuesFromType(types, uniqueValues, 20_000), nextId);
                        sortedValues.addAll(updates.Select(u => new ValueAndId(ValueTuple.of(u.values()), u.EntityId)).ToList());
                    }
                    else
                    {
                        // Then do all sorts of updates
                        for (int j = 0; j < 1_000; j++)
                        {
                            int type = Random.intBetween(0, 2);
                            if (type == 0)
                            {                                             // add
                                ValueTuple value = GenerateUniqueRandomValue(types, uniqueValues);
                                long       id    = nextId.AndIncrement;
                                sortedValues.Add(new ValueAndId(value, id));
                                updates.Add(IndexEntryUpdate.Add(id, Descriptor.schema(), value.Values));
                            }
                            else if (type == 1)
                            {                                             // update
                                ValueAndId existing = Random.among(sortedValues.toArray(new ValueAndId[0]));
                                sortedValues.remove(existing);
                                ValueTuple newValue = GenerateUniqueRandomValue(types, uniqueValues);
                                uniqueValues.remove(existing.Value);
                                sortedValues.Add(new ValueAndId(newValue, existing.Id));
                                updates.Add(IndexEntryUpdate.Change(existing.Id, Descriptor.schema(), existing.Value.Values, newValue.Values));
                            }
                            else
                            {                                             // remove
                                ValueAndId existing = Random.among(sortedValues.toArray(new ValueAndId[0]));
                                sortedValues.remove(existing);
                                uniqueValues.remove(existing.Value);
                                updates.Add(IndexEntryUpdate.Remove(existing.Id, Descriptor.schema(), existing.Value.Values));
                            }
                        }
                    }
                    UpdateAndCommit(updates);
                    VerifyRandomRanges(types, sortedValues);
                }
            }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void indexEntryUpdatesShouldBeEqual()
        public virtual void IndexEntryUpdatesShouldBeEqual()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> a = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> a = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> b = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> b = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);

            assertThat(a, equalTo(b));
            assertThat(a.GetHashCode(), equalTo(b.GetHashCode()));
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addShouldRetainValues()
        public virtual void AddShouldRetainValues()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> single = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> single = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multi = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4, 5), multiValue);
            IndexEntryUpdate <object> multi = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4, 5), _multiValue);

            assertThat(single, not(equalTo(multi)));
            assertThat(single.Values(), equalTo(new object[] { _singleValue }));
            assertThat(multi.Values(), equalTo(_multiValue));
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotRestrictUpdatesDifferingOnSecondProperty() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldNotRestrictUpdatesDifferingOnSecondProperty()
            {
                // given
                IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());

                WithPopulator(IndexProvider.getPopulator(Descriptor, indexSamplingConfig, heapBufferFactory(1024)), p =>
                {
                    // when
                    p.add(Arrays.asList(IndexEntryUpdate.Add(NodeId1, Descriptor.schema(), Value1, Value2), IndexEntryUpdate.Add(NodeId2, Descriptor.schema(), Value1, Value3)));

                    TestNodePropertyAccessor propertyAccessor = new TestNodePropertyAccessor(NodeId1, Descriptor.schema(), Value1, Value2);
                    propertyAccessor.AddNode(NodeId2, Descriptor.schema(), Value1, Value3);

                    // then this should pass fine
                    p.verifyDeferredConstraints(propertyAccessor);
                });
            }
示例#8
0
 public static IndexEntryUpdate <SchemaDescriptor> Add(long nodeId, SchemaDescriptor schema, params object[] objects)
 {
     return(IndexEntryUpdate.Add(nodeId, schema, ToValues(objects)));
 }
示例#9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForFullNonSchemaIndexUpdate()
        public virtual void ShouldGenerateUpdateForFullNonSchemaIndexUpdate()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).added(_property1.propertyKeyId(), _property1.value()).added(_property2.propertyKeyId(), _property2.value()).added(_property3.propertyKeyId(), _property3.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _nonSchemaIndex, _values123)));
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateWhenAddingMultipleTokensForNonSchemaIndex()
        public virtual void ShouldGenerateUpdateWhenAddingMultipleTokensForNonSchemaIndex()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_empty).withTokensAfter(_allLabels).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _nonSchemaIndex, _values123)));
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForPartialNonSchemaIndexUpdate()
        public virtual void ShouldGenerateUpdateForPartialNonSchemaIndexUpdate()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).added(PROPERTY_KEY_ID1, Values.of("Neo")).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _nonSchemaIndex, _property1.value(), null, null)));
        }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdatesForMultiplePropertyAdditionWithLabels()
        public virtual void ShouldGenerateUpdatesForMultiplePropertyAdditionWithLabels()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).added(_property1.propertyKeyId(), _property1.value()).added(_property2.propertyKeyId(), _property2.value()).added(_property3.propertyKeyId(), _property3.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _index1, _property1.value()), IndexEntryUpdate.Add(NODE_ID, _index2, _property2.value()), IndexEntryUpdate.Add(NODE_ID, _index3, _property3.value()), IndexEntryUpdate.Add(NODE_ID, _index123, _values123)));
        }
示例#13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForWhenCompletingCompositeSchemaIndexUpdate()
        public virtual void ShouldGenerateUpdateForWhenCompletingCompositeSchemaIndexUpdate()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).added(PROPERTY_KEY_ID1, Values.of("Neo")).added(PROPERTY_KEY_ID3, Values.pointValue(CoordinateReferenceSystem.WGS84, 12.3, 45.6)).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_index123), PropertyLoader(_property2), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _index123, _values123)));
        }
示例#14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdatesForLabelAdditionWithExistingProperties()
        public virtual void ShouldGenerateUpdatesForLabelAdditionWithExistingProperties()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_empty).withTokensAfter(_label).existing(PROPERTY_KEY_ID1, Values.of("Neo")).existing(PROPERTY_KEY_ID2, Values.of(100L)).existing(PROPERTY_KEY_ID3, Values.pointValue(CoordinateReferenceSystem.WGS84, 12.3, 45.6)).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _index1, _property1.value()), IndexEntryUpdate.Add(NODE_ID, _index2, _property2.value()), IndexEntryUpdate.Add(NODE_ID, _index3, _property3.value()), IndexEntryUpdate.Add(NODE_ID, _index123, _values123)));
        }
示例#15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForLabelAdditionWithExistingProperty()
        public virtual void ShouldGenerateUpdateForLabelAdditionWithExistingProperty()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_empty).withTokensAfter(_label).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(_property1), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _index1, _property1.value())));
        }