コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRejectNodeNotInUse()
        public virtual void ShouldRejectNodeNotInUse()
        {
            // given
            NodeValueClientFilter filter = InitializeFilter(IndexQuery.exists(12));

            // when
            filter.Next();
            assertFalse(filter.AcceptNode(17, null));
            filter.Close();

            // then
            AssertEvents(Initialize(), Event.NEXT, Event.CLOSE);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAcceptAllNodesOnNoFilters()
        public virtual void ShouldAcceptAllNodesOnNoFilters()
        {
            // given
            _node.withNode(17);
            NodeValueClientFilter filter = InitializeFilter();

            // when
            filter.Next();
            assertTrue(filter.AcceptNode(17, null));
            filter.Close();

            // then
            AssertEvents(Initialize(), Event.NEXT, new Event.Node(17, null), Event.CLOSE);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAcceptNodeWithoutMatchingProperty()
        public virtual void ShouldNotAcceptNodeWithoutMatchingProperty()
        {
            // given
            _node.withNode(17, new long[0], genericMap(7, stringValue("wrong")));
            NodeValueClientFilter filter = InitializeFilter(IndexQuery.exists(12));

            // when
            filter.Next();
            assertFalse(filter.AcceptNode(17, null));
            filter.Close();

            // then
            AssertEvents(Initialize(), Event.NEXT, Event.CLOSE);
        }
コード例 #4
0
        private void ShouldConsultProvidedFilters(System.Func <Value[], Value[]> filterValues, bool filterAcceptsValue)
        {
            // given
            long nodeReference = 123;
            int  labelId       = 10;
            int  slots         = Random.Next(3, 8);

            IndexQuery[]             filters      = new IndexQuery[slots];
            Value[]                  actualValues = new Value[slots];
            Value[]                  values       = new Value[slots];
            IDictionary <int, Value> properties   = new Dictionary <int, Value>();

            int[] propertyKeyIds = new int[slots];
            int   filterCount    = 0;

            for (int i = 0; i < slots; i++)
            {
                actualValues[i] = Random.nextValue();
                int propertyKeyId = i;
                propertyKeyIds[i] = propertyKeyId;
                //    we want at least one filter         ,  randomly add filter or not
                if ((filterCount == 0 && i == slots - 1) || Random.nextBoolean())
                {
                    object filterValue = (filterAcceptsValue ? actualValues[i] : AnyOtherValueThan(actualValues[i])).asObjectCopy();
                    filters[i] = IndexQuery.exact(propertyKeyId, filterValue);
                    filterCount++;
                }
                values[i] = Random.nextBoolean() ? NO_VALUE : actualValues[i];
                properties[propertyKeyId] = actualValues[i];
            }
            _node.withNode(nodeReference, new long[] { labelId }, properties);

            // when
            NodeValueClientFilter filter = new NodeValueClientFilter(this, _node, _property, _read, filters);

            filter.Initialize(TestIndexDescriptorFactory.forLabel(labelId, propertyKeyIds), this, null, IndexOrder.NONE, true);
            bool accepted = filter.AcceptNode(nodeReference, filterValues(values));

            // then
            assertEquals(filterAcceptsValue, accepted);
        }