Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeProfileIfPresent() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIncludeProfileIfPresent()
        {
            // Given
            QueryStatistics queryStatistics = mock(typeof(QueryStatistics));

            when(queryStatistics.ContainsUpdates()).thenReturn(false);
            QueryResult result = mock(typeof(QueryResult));

            when(result.FieldNames()).thenReturn(new string[0]);
            when(result.ExecutionType()).thenReturn(explained(READ_ONLY));
            when(result.QueryStatistics()).thenReturn(queryStatistics);
            when(result.Notifications).thenReturn(Collections.emptyList());
            when(result.ExecutionPlanDescription()).thenReturn(Plan("Join", map("arg1", 1), 2, 4, 3, 1, singletonList("id1"), Plan("Scan", map("arg2", 1), 2, 4, 7, 1, singletonList("id2"))));

            TransactionalContext tc     = mock(typeof(TransactionalContext));
            CypherAdapterStream  stream = new CypherAdapterStream(result, Clock.systemUTC());

            // When
            MapValue meta = MetadataOf(stream);

            // Then
            MapValue expectedChild = MapValues("args", MapValues("arg2", intValue(1)), "identifiers", list(stringValue("id2")), "operatorType", stringValue("Scan"), "children", VirtualValues.EMPTY_LIST, "rows", longValue(1L), "dbHits", longValue(2L), "pageCacheHits", longValue(4L), "pageCacheMisses", longValue(7L), "pageCacheHitRatio", doubleValue(4.0 / 11));

            MapValue expectedProfile = MapValues("args", MapValues("arg1", intValue(1)), "identifiers", list(stringValue("id1")), "operatorType", stringValue("Join"), "children", list(expectedChild), "rows", longValue(1L), "dbHits", longValue(2L), "pageCacheHits", longValue(4L), "pageCacheMisses", longValue(3L), "pageCacheHitRatio", doubleValue(4.0 / 7));

            AssertMapEqualsWithDelta(( MapValue )meta.Get("profile"), expectedProfile, 0.0001);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeNotificationsIfPresent() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIncludeNotificationsIfPresent()
        {
            // Given
            QueryResult result = mock(typeof(QueryResult));

            when(result.FieldNames()).thenReturn(new string[0]);

            QueryStatistics queryStatistics = mock(typeof(QueryStatistics));

            when(queryStatistics.ContainsUpdates()).thenReturn(false);

            when(result.QueryStatistics()).thenReturn(queryStatistics);
            when(result.ExecutionType()).thenReturn(query(READ_WRITE));

            when(result.Notifications).thenReturn(Arrays.asList(NotificationCode.INDEX_HINT_UNFULFILLABLE.notification(InputPosition.empty), NotificationCode.PLANNER_UNSUPPORTED.notification(new InputPosition(4, 5, 6))));
            TransactionalContext tc     = mock(typeof(TransactionalContext));
            CypherAdapterStream  stream = new CypherAdapterStream(result, Clock.systemUTC());

            // When
            MapValue meta = MetadataOf(stream);

            // Then
            MapValue msg1 = MapValues("severity", stringValue("WARNING"), "code", stringValue("Neo.ClientError.Schema.IndexNotFound"), "title", stringValue("The request (directly or indirectly) referred to an index that does not exist."), "description", stringValue("The hinted index does not exist, please check the schema"));
            MapValue msg2 = MapValues("severity", stringValue("WARNING"), "code", stringValue("Neo.ClientNotification.Statement.PlannerUnsupportedWarning"), "title", stringValue("This query is not supported by the COST planner."), "description", stringValue("Using COST planner is unsupported for this query, please use RULE planner instead"), "position", MapValues("offset", intValue(4), "column", intValue(6), "line", intValue(5)));

            assertThat(meta.Get("notifications"), equalTo(list(msg1, msg2)));
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludePlanIfPresent() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIncludePlanIfPresent()
        {
            // Given
            QueryStatistics queryStatistics = mock(typeof(QueryStatistics));

            when(queryStatistics.ContainsUpdates()).thenReturn(false);
            QueryResult result = mock(typeof(QueryResult));

            when(result.FieldNames()).thenReturn(new string[0]);
            when(result.ExecutionType()).thenReturn(explained(READ_ONLY));
            when(result.QueryStatistics()).thenReturn(queryStatistics);
            when(result.Notifications).thenReturn(Collections.emptyList());
            when(result.ExecutionPlanDescription()).thenReturn(Plan("Join", map("arg1", 1), singletonList("id1"), Plan("Scan", map("arg2", 1), singletonList("id2"))));

            TransactionalContext tc     = mock(typeof(TransactionalContext));
            CypherAdapterStream  stream = new CypherAdapterStream(result, Clock.systemUTC());

            // When
            MapValue meta = MetadataOf(stream);

            // Then
            MapValue expectedChild = MapValues("args", MapValues("arg2", intValue(1)), "identifiers", list(stringValue("id2")), "operatorType", stringValue("Scan"), "children", VirtualValues.EMPTY_LIST);
            MapValue expectedPlan  = MapValues("args", MapValues("arg1", intValue(1)), "identifiers", list(stringValue("id1")), "operatorType", stringValue("Join"), "children", list(expectedChild));

            assertThat(meta.Get("plan"), equalTo(expectedPlan));
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.values.virtual.MapValue metadataOf(CypherAdapterStream stream) throws Exception
        private MapValue MetadataOf(CypherAdapterStream stream)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.virtual.MapValueBuilder meta = new org.neo4j.values.virtual.MapValueBuilder();
            MapValueBuilder meta = new MapValueBuilder();

            stream.Accept(new BoltResult_VisitorAnonymousInnerClass(this, meta));
            return(meta.Build());
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeBasicMetadata() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIncludeBasicMetadata()
        {
            // Given
            QueryStatistics queryStatistics = mock(typeof(QueryStatistics));

            when(queryStatistics.ContainsUpdates()).thenReturn(true);
            when(queryStatistics.NodesCreated).thenReturn(1);
            when(queryStatistics.NodesDeleted).thenReturn(2);
            when(queryStatistics.RelationshipsCreated).thenReturn(3);
            when(queryStatistics.RelationshipsDeleted).thenReturn(4);
            when(queryStatistics.PropertiesSet).thenReturn(5);
            when(queryStatistics.IndexesAdded).thenReturn(6);
            when(queryStatistics.IndexesRemoved).thenReturn(7);
            when(queryStatistics.ConstraintsAdded).thenReturn(8);
            when(queryStatistics.ConstraintsRemoved).thenReturn(9);
            when(queryStatistics.LabelsAdded).thenReturn(10);
            when(queryStatistics.LabelsRemoved).thenReturn(11);

            QueryResult result = mock(typeof(QueryResult));

            when(result.FieldNames()).thenReturn(new string[0]);
            when(result.ExecutionType()).thenReturn(query(READ_WRITE));
            when(result.QueryStatistics()).thenReturn(queryStatistics);
            when(result.Notifications).thenReturn(Collections.emptyList());

            Clock clock = mock(typeof(Clock));

            when(clock.millis()).thenReturn(0L, 1337L);

            TransactionalContext tc     = mock(typeof(TransactionalContext));
            CypherAdapterStream  stream = new CypherAdapterStream(result, clock);

            // When
            MapValue meta = MetadataOf(stream);

            // Then
            assertThat(meta.Get("type"), equalTo(stringValue("rw")));
            assertThat(meta.Get("stats"), equalTo(MapValues("nodes-created", intValue(1), "nodes-deleted", intValue(2), "relationships-created", intValue(3), "relationships-deleted", intValue(4), "properties-set", intValue(5), "indexes-added", intValue(6), "indexes-removed", intValue(7), "constraints-added", intValue(8), "constraints-removed", intValue(9), "labels-added", intValue(10), "labels-removed", intValue(11))));
            assertThat(meta.Get("result_consumed_after"), equalTo(longValue(1337L)));
        }