Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsRelationshipTypeIds()
        public virtual void VisitsRelationshipTypeIds()
        {
            // GIVEN
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));
            Node lhs = _graph.createNode();
            Node rhs = _graph.createNode();

            lhs.CreateRelationshipTo(rhs, withName("KNOWS"));
            lhs.CreateRelationshipTo(rhs, withName("LOVES"));
            lhs.CreateRelationshipTo(rhs, withName("FAWNS_AT"));
            int knowsId;
            int lovesId;
            int fawnsAtId;
            KernelTransaction ktx = ktx();

            TokenRead tokenRead = ktx.TokenRead();

            knowsId   = tokenRead.RelationshipType("KNOWS");
            lovesId   = tokenRead.RelationshipType("LOVES");
            fawnsAtId = tokenRead.RelationshipType("FAWNS_AT");

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitRelationshipType(knowsId, "KNOWS");
            verify(visitor).visitRelationshipType(lovesId, "LOVES");
            verify(visitor).visitRelationshipType(fawnsAtId, "FAWNS_AT");
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsLabelIds()
        public virtual void VisitsLabelIds()
        {
            // GIVEN
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));

            _graph.createNode(label("Person"));
            _graph.createNode(label("Party"));
            _graph.createNode(label("Animal"));
            int personLabelId;
            int partyLabelId;
            int animalLabelId;

            KernelTransaction ktx       = ktx();
            TokenRead         tokenRead = ktx.TokenRead();

            personLabelId = tokenRead.NodeLabel("Person");
            partyLabelId  = tokenRead.NodeLabel("Party");
            animalLabelId = tokenRead.NodeLabel("Animal");

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitLabel(personLabelId, "Person");
            verify(visitor).visitLabel(partyLabelId, "Party");
            verify(visitor).visitLabel(animalLabelId, "Animal");
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void traceDb(String generator, String generatedClazzPackage, String generatedClazzName, org.neo4j.graphdb.GraphDatabaseService graph, Appendable output) throws java.io.IOException
        private void TraceDb(string generator, string generatedClazzPackage, string generatedClazzName, GraphDatabaseService graph, Appendable output)
        {
            InvocationTracer <DbStructureVisitor> tracer = new InvocationTracer <DbStructureVisitor>(generator, generatedClazzPackage, generatedClazzName, typeof(DbStructureVisitor), DbStructureArgumentFormatter.INSTANCE, output);

            DbStructureVisitor    visitor = tracer.NewProxy();
            GraphDbStructureGuide guide   = new GraphDbStructureGuide(graph);

            guide.Accept(visitor);
            tracer.Close();
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void outputCompilesWithoutErrors() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OutputCompilesWithoutErrors()
        {
            // GIVEN
            StringBuilder output = new StringBuilder();
            InvocationTracer <DbStructureVisitor> tracer = new InvocationTracer <DbStructureVisitor>("Test", _packageName, _className, typeof(DbStructureVisitor), DbStructureArgumentFormatter.Instance, output);
            DbStructureVisitor visitor = tracer.NewProxy();

            // WHEN
            ExerciseVisitor(from => visitor);
            tracer.Close();

            // THEN
            AssertCompiles(_classNameWithPackage, output.ToString());
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsPropertyKeyIds() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void VisitsPropertyKeyIds()
        {
            // GIVEN
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));
            int nameId = CreatePropertyKey("name");
            int ageId  = CreatePropertyKey("age");
            int osId   = CreatePropertyKey("os");

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitPropertyKey(nameId, "name");
            verify(visitor).visitPropertyKey(ageId, "age");
            verify(visitor).visitPropertyKey(osId, "os");
        }
Ejemplo n.º 6
0
        public virtual void Accept(DbStructureVisitor visitor)
        {
            CommitAndReOpen();

            _graph.schema().awaitIndexesOnline(10, TimeUnit.SECONDS);
            Commit();

            if (_bridge.hasTransaction())
            {
                throw new System.InvalidOperationException("Dangling transaction before running visitable");
            }

            GraphDbStructureGuide analyzer = new GraphDbStructureGuide(_graph);

            analyzer.Accept(visitor);
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsIndexes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void VisitsIndexes()
        {
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));
            int labelId = CreateLabel("Person");
            int pkId    = CreatePropertyKey("name");

            CommitAndReOpen();

            IndexReference reference = CreateSchemaIndex(labelId, pkId);

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitIndex(( IndexDescriptor )reference, ":Person(name)", 1.0d, 0L);
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsNodeCounts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void VisitsNodeCounts()
        {
            // GIVEN
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));
            int personLabelId          = CreateLabeledNodes("Person", 40);
            int partyLabelId           = CreateLabeledNodes("Party", 20);
            int animalLabelId          = CreateLabeledNodes("Animal", 30);

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitAllNodesCount(90);
            verify(visitor).visitNodeCount(personLabelId, "Person", 40);
            verify(visitor).visitNodeCount(partyLabelId, "Party", 20);
            verify(visitor).visitNodeCount(animalLabelId, "Animal", 30);
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsUniqueConstraintsAndIndices() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void VisitsUniqueConstraintsAndIndices()
        {
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));
            int labelId = CreateLabel("Person");
            int pkId    = CreatePropertyKey("name");

            CommitAndReOpen();

            ConstraintDescriptor constraint = CreateUniqueConstraint(labelId, pkId);
            IndexDescriptor      descriptor = TestIndexDescriptorFactory.uniqueForLabel(labelId, pkId);

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitIndex(descriptor, ":Person(name)", 1.0d, 0L);
            verify(visitor).visitUniqueConstraint(( UniquenessConstraintDescriptor )constraint, "CONSTRAINT ON ( person:Person ) ASSERT person.name IS " + "UNIQUE");
        }
Ejemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsRelCounts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void VisitsRelCounts()
        {
            // GIVEN
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));

            int personLabelId = CreateLabeledNodes("Person", 40);
            int partyLabelId  = CreateLabeledNodes("Party", 20);

            int knowsId = CreateRelTypeId("KNOWS");
            int lovesId = CreateRelTypeId("LOVES");

            long personNode = CreateLabeledNode(personLabelId);
            long partyNode  = CreateLabeledNode(partyLabelId);

            CreateRel(personNode, knowsId, personNode);
            CreateRel(personNode, lovesId, partyNode);

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitRelCount(ANY_LABEL, knowsId, ANY_LABEL, "MATCH ()-[:KNOWS]->() RETURN count(*)", 1L);
            verify(visitor).visitRelCount(ANY_LABEL, lovesId, ANY_LABEL, "MATCH ()-[:LOVES]->() RETURN count(*)", 1L);
            verify(visitor).visitRelCount(ANY_LABEL, ANY_LABEL, ANY_LABEL, "MATCH ()-[]->() RETURN count(*)", 2L);

            verify(visitor).visitRelCount(personLabelId, knowsId, ANY_LABEL, "MATCH (:Person)-[:KNOWS]->() RETURN count(*)", 1L);
            verify(visitor).visitRelCount(ANY_LABEL, knowsId, personLabelId, "MATCH ()-[:KNOWS]->(:Person) RETURN count(*)", 1L);

            verify(visitor).visitRelCount(personLabelId, lovesId, ANY_LABEL, "MATCH (:Person)-[:LOVES]->() RETURN count(*)", 1L);
            verify(visitor).visitRelCount(ANY_LABEL, lovesId, personLabelId, "MATCH ()-[:LOVES]->(:Person) RETURN count(*)", 0L);

            verify(visitor).visitRelCount(personLabelId, ANY_RELATIONSHIP_TYPE, ANY_LABEL, "MATCH (:Person)-[]->() RETURN count(*)", 2L);
            verify(visitor).visitRelCount(ANY_LABEL, ANY_RELATIONSHIP_TYPE, personLabelId, "MATCH ()-[]->(:Person) RETURN count(*)", 1L);

            verify(visitor).visitRelCount(partyLabelId, knowsId, ANY_LABEL, "MATCH (:Party)-[:KNOWS]->() RETURN count(*)", 0L);
            verify(visitor).visitRelCount(ANY_LABEL, knowsId, partyLabelId, "MATCH ()-[:KNOWS]->(:Party) RETURN count(*)", 0L);

            verify(visitor).visitRelCount(partyLabelId, lovesId, ANY_LABEL, "MATCH (:Party)-[:LOVES]->() RETURN count(*)", 0L);
            verify(visitor).visitRelCount(ANY_LABEL, lovesId, partyLabelId, "MATCH ()-[:LOVES]->(:Party) RETURN count(*)", 1L);

            verify(visitor).visitRelCount(partyLabelId, ANY_RELATIONSHIP_TYPE, ANY_LABEL, "MATCH (:Party)-[]->() RETURN count(*)", 0L);
            verify(visitor).visitRelCount(ANY_LABEL, ANY_RELATIONSHIP_TYPE, partyLabelId, "MATCH ()-[]->(:Party) RETURN count(*)", 1L);
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void compiledOutputCreatesInputTrace() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CompiledOutputCreatesInputTrace()
        {
            // GIVEN
            StringBuilder output = new StringBuilder();
            InvocationTracer <DbStructureVisitor> tracer = new InvocationTracer <DbStructureVisitor>("Test", _packageName, _className, typeof(DbStructureVisitor), DbStructureArgumentFormatter.Instance, output);

            ExerciseVisitor(from => tracer.NewProxy());
            tracer.Close();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.helpers.collection.Visitable<DbStructureVisitor> visitable = compileVisitable(classNameWithPackage, output.toString());
            Visitable <DbStructureVisitor> visitable = CompileVisitable(_classNameWithPackage, output.ToString());
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final DbStructureVisitor visitor = mock(DbStructureVisitor.class);
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));

            // WHEN
            visitable.Accept(visitor);

            // THEN
            ExerciseVisitor(o => verify(visitor));
            verifyNoMoreInteractions(visitor);
        }
Ejemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void compiledOutputProducesSameCompiledOutputIfCompiledAgain() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CompiledOutputProducesSameCompiledOutputIfCompiledAgain()
        {
            // GIVEN
            StringBuilder output1 = new StringBuilder();
            InvocationTracer <DbStructureVisitor> tracer1 = new InvocationTracer <DbStructureVisitor>("Test", _packageName, _className, typeof(DbStructureVisitor), DbStructureArgumentFormatter.Instance, output1);
            DbStructureVisitor visitor1 = tracer1.NewProxy();

            ExerciseVisitor(from => visitor1);
            tracer1.Close();
            string source1 = output1.ToString();
            Visitable <DbStructureVisitor> visitable = CompileVisitable(_classNameWithPackage, source1);

            // WHEN
            StringBuilder output2 = new StringBuilder();
            InvocationTracer <DbStructureVisitor> tracer2 = new InvocationTracer <DbStructureVisitor>("Test", _packageName, _className, typeof(DbStructureVisitor), DbStructureArgumentFormatter.Instance, output2);
            DbStructureVisitor visitor2 = tracer2.NewProxy();

            visitable.Accept(visitor2);
            tracer2.Close();
            string source2 = output2.ToString();

            // THEN
            assertEquals(source1, source2);
        }