예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testCreateIndexWithGivenProvider(String label, String... properties) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private void TestCreateIndexWithGivenProvider(string label, params string[] properties)
        {
            // given
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());
            int         labelId     = transaction.TokenWrite().labelGetOrCreateForName(label);

            int[]     propertyKeyIds = CreateProperties(transaction, properties);
            TextValue value          = stringValue("some value");
            long      node           = CreateNodeWithPropertiesAndLabel(transaction, labelId, propertyKeyIds, value);

            Commit();

            // when
            NewTransaction(AnonymousContext.full());
            string pattern           = IndexPattern(label, properties);
            string specifiedProvider = NATIVE10.providerName();
            RawIterator <object[], ProcedureException> result = CallIndexProcedure(pattern, specifiedProvider);

            // then
            assertThat(Arrays.asList(result.Next()), contains(pattern, specifiedProvider, ExpectedSuccessfulCreationStatus));
            Commit();
            AwaitIndexOnline();

            // and then
            transaction = NewTransaction(AnonymousContext.read());
            SchemaRead     schemaRead = transaction.SchemaRead();
            IndexReference index      = schemaRead.Index(labelId, propertyKeyIds);

            AssertCorrectIndex(labelId, propertyKeyIds, UniquenessConstraint, index);
            AssertIndexData(transaction, propertyKeyIds, value, node, index);
            Commit();
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void throwIfIndexAlreadyExists() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ThrowIfIndexAlreadyExists()
        {
            // given
            string label       = "Superhero";
            string propertyKey = "primaryPower";

            using (Org.Neo4j.Graphdb.Transaction tx = Db.beginTx())
            {
                Db.schema().indexFor(Label.label(label)).on(propertyKey).create();
                tx.Success();
            }
            AwaitIndexOnline();

            // when
            NewTransaction(AnonymousContext.full());
            string pattern = IndexPattern(label, propertyKey);

            try
            {
                CallIndexProcedure(pattern, GraphDatabaseSettings.SchemaIndex.NATIVE20.providerName());
                fail("Should have failed");
            }
            catch (ProcedureException e)
            {
                // then
                assertThat(e.Message, containsString("There already exists an index "));
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void askingForNonExistantReltypeOnDenseNodeShouldNotCorruptState() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AskingForNonExistantReltypeOnDenseNodeShouldNotCorruptState()
        {
            // Given a dense node with one type of rels
            long[] rels = new long[200];
            long   refNode;
            int    relTypeTheNodeDoesUse;
            int    relTypeTheNodeDoesNotUse;
            {
                Transaction transaction = NewTransaction(AnonymousContext.writeToken());

                relTypeTheNodeDoesUse    = transaction.TokenWrite().relationshipTypeGetOrCreateForName("Type1");
                relTypeTheNodeDoesNotUse = transaction.TokenWrite().relationshipTypeGetOrCreateForName("Type2");

                refNode = transaction.DataWrite().nodeCreate();
                long otherNode = transaction.DataWrite().nodeCreate();

                for (int i = 0; i < rels.Length; i++)
                {
                    rels[i] = transaction.DataWrite().relationshipCreate(refNode, relTypeTheNodeDoesUse, otherNode);
                }
                Commit();
            }
            Transaction transaction = NewTransaction();

            // When I've asked for rels that the node does not have
            AssertRels(NodeGetRelationships(transaction, refNode, Direction.INCOMING, new int[] { relTypeTheNodeDoesNotUse }));

            // Then the node should still load the real rels
            AssertRels(NodeGetRelationships(transaction, refNode, Direction.BOTH, new int[] { relTypeTheNodeDoesUse }), rels);
            Commit();
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void throwOnNonUniqueStore() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ThrowOnNonUniqueStore()
        {
            assumeThat("Only relevant for uniqueness constraints", UniquenessConstraint, @is(true));

            // given
            string label = "SomeLabel";

            string[]    properties  = new string[] { "key1", "key2" };
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());
            int         labelId     = transaction.TokenWrite().labelGetOrCreateForName(label);

            int[]     propertyKeyIds = CreateProperties(transaction, properties);
            TextValue value          = stringValue("some value");

            CreateNodeWithPropertiesAndLabel(transaction, labelId, propertyKeyIds, value);
            CreateNodeWithPropertiesAndLabel(transaction, labelId, propertyKeyIds, value);
            Commit();

            // when
            try
            {
                CreateConstraint(label, properties);
                fail("Should have failed");
            }
            catch (ProcedureException e)
            {
                // then
                // good
                assertThat(rootCause(e), instanceOf(typeof(IndexEntryConflictException)));
            }
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("SameParameterValue") private void testThrowOnUniquenessViolation(String label, String... properties) throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        private void TestThrowOnUniquenessViolation(string label, params string[] properties)
        {
            assumeThat("Only relevant for uniqueness constraints", UniquenessConstraint, @is(true));

            // given
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());
            int         labelId     = transaction.TokenWrite().labelGetOrCreateForName(label);

            int[]     propertyKeyIds = CreateProperties(transaction, properties);
            TextValue value          = stringValue("some value");

            CreateNodeWithPropertiesAndLabel(transaction, labelId, propertyKeyIds, value);
            Commit();

            CreateConstraint(label, properties);

            // when
            try
            {
                transaction = NewTransaction(AnonymousContext.write());
                CreateNodeWithPropertiesAndLabel(transaction, labelId, propertyKeyIds, value);
                fail("Should have failed");
            }
            catch (UniquePropertyValueValidationException)
            {
                // then
                // ok
            }
        }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInterleaveModifiedRelationshipsWithExistingOnes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInterleaveModifiedRelationshipsWithExistingOnes()
        {
            // given
            long refNode;
            long fromRefToOther1;
            long fromRefToOther2;
            int  relType1;
            int  relType2;
            {
                Transaction transaction = NewTransaction(AnonymousContext.writeToken());

                relType1 = transaction.TokenWrite().relationshipTypeGetOrCreateForName("Type1");
                relType2 = transaction.TokenWrite().relationshipTypeGetOrCreateForName("Type2");

                refNode = transaction.DataWrite().nodeCreate();
                long otherNode = transaction.DataWrite().nodeCreate();
                fromRefToOther1 = transaction.DataWrite().relationshipCreate(refNode, relType1, otherNode);
                fromRefToOther2 = transaction.DataWrite().relationshipCreate(refNode, relType2, otherNode);
                Commit();
            }
            {
                Transaction transaction = NewTransaction(AnonymousContext.writeToken());

                // When
                transaction.DataWrite().relationshipDelete(fromRefToOther1);
                long endNode    = transaction.DataWrite().nodeCreate();
                long localTxRel = transaction.DataWrite().relationshipCreate(refNode, relType1, endNode);

                // Then
                AssertRels(NodeGetRelationships(transaction, refNode, BOTH), fromRefToOther2, localTxRel);
                AssertRelsInSeparateTx(refNode, BOTH, fromRefToOther1, fromRefToOther2);
                Commit();
            }
        }
예제 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAllowModifyingPropertiesOnDeletedRelationship() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAllowModifyingPropertiesOnDeletedRelationship()
        {
            // given
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());
            int         prop1       = transaction.TokenWrite().propertyKeyGetOrCreateForName("prop1");
            int         type        = transaction.TokenWrite().relationshipTypeGetOrCreateForName("RELATED");
            long        startNodeId = transaction.DataWrite().nodeCreate();
            long        endNodeId   = transaction.DataWrite().nodeCreate();
            long        rel         = transaction.DataWrite().relationshipCreate(startNodeId, type, endNodeId);

            transaction.DataWrite().relationshipSetProperty(rel, prop1, Values.stringValue("As"));
            transaction.DataWrite().relationshipDelete(rel);

            // When
            try
            {
                transaction.DataWrite().relationshipRemoveProperty(rel, prop1);
                fail("Should have failed.");
            }
            catch (EntityNotFoundException e)
            {
                assertThat(e.Message, equalTo("Unable to load RELATIONSHIP with id " + rel + "."));
            }
            Commit();
        }
예제 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToRemoveResetAndTwiceRemovePropertyOnRelationship() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToRemoveResetAndTwiceRemovePropertyOnRelationship()
        {
            // given
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());
            int         prop        = transaction.TokenWrite().propertyKeyGetOrCreateForName("foo");
            int         type        = transaction.TokenWrite().relationshipTypeGetOrCreateForName("RELATED");

            long startNodeId = transaction.DataWrite().nodeCreate();
            long endNodeId   = transaction.DataWrite().nodeCreate();
            long rel         = transaction.DataWrite().relationshipCreate(startNodeId, type, endNodeId);

            transaction.DataWrite().relationshipSetProperty(rel, prop, Values.of("bar"));

            Commit();

            // when
            Write write = DataWriteInNewTransaction();

            write.RelationshipRemoveProperty(rel, prop);
            write.RelationshipSetProperty(rel, prop, Values.of("bar"));
            write.RelationshipRemoveProperty(rel, prop);
            write.RelationshipRemoveProperty(rel, prop);

            Commit();

            // then
            transaction = NewTransaction();
            assertThat(RelationshipGetProperty(transaction, rel, prop), equalTo(Values.NO_VALUE));
            Commit();
        }
예제 #9
0
 public virtual void AddLabelToNode(long node, string labelName)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.writeToken()))
     {
         _database.Graph.getNodeById(node).addLabel(label(labelName));
         tx.Success();
     }
 }
예제 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGetEmptyUsernameForAnonymousContext()
        public virtual void ShouldGetEmptyUsernameForAnonymousContext()
        {
            when(_transaction.securityContext()).thenReturn(AnonymousContext.read().authorize(s => - 1, GraphDatabaseSettings.DEFAULT_DATABASE_NAME));

            TxStateTransactionDataSnapshot transactionDataSnapshot = Snapshot();

            assertEquals("", transactionDataSnapshot.Username());
        }
예제 #11
0
 public virtual void DeleteNode(long id)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.write()))
     {
         Node node = _database.Graph.getNodeById(id);
         node.Delete();
         tx.Success();
     }
 }
예제 #12
0
 public virtual long CreateNode(params Label[] labels)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.writeToken()))
     {
         Node node = _database.Graph.createNode(labels);
         tx.Success();
         return(node.Id);
     }
 }
예제 #13
0
 public virtual Relationship GetRelationship(long relationshipId)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.read()))
     {
         Relationship relationship = _database.Graph.getRelationshipById(relationshipId);
         tx.Success();
         return(relationship);
     }
 }
예제 #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void createConstraint(String label, String... properties) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException, org.neo4j.internal.kernel.api.exceptions.ProcedureException
        private void CreateConstraint(string label, params string[] properties)
        {
            NewTransaction(AnonymousContext.full());
            string pattern           = IndexPattern(label, properties);
            string specifiedProvider = NATIVE10.providerName();

            CallIndexProcedure(pattern, specifiedProvider);
            Commit();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = org.neo4j.graphdb.NotInTransactionException.class) public void shouldThrowNotInTransactionWhenTransactionClosedAndAccessingOperations() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowNotInTransactionWhenTransactionClosedAndAccessingOperations()
        {
            KernelTransaction transaction = newTransaction(AnonymousContext.write());

            transaction.Success();
            transaction.Close();

            TransactionOperation.operate(transaction.DataRead(), transaction.DataWrite(), transaction.SchemaRead());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = org.neo4j.graphdb.TransactionTerminatedException.class) public void shouldThrowTerminateExceptionWhenTransactionTerminated() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowTerminateExceptionWhenTransactionTerminated()
        {
            KernelTransaction transaction = newTransaction(AnonymousContext.write());

            transaction.Success();
            transaction.MarkForTermination(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError);

            TransactionOperation.operate(transaction.DataRead(), transaction.DataWrite(), transaction.SchemaRead());
        }
예제 #17
0
 public virtual IDictionary <string, object> GetNodeProperties(long nodeId)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.read()))
     {
         Node node = _database.Graph.getNodeById(nodeId);
         IDictionary <string, object> allProperties = node.AllProperties;
         tx.Success();
         return(allProperties);
     }
 }
예제 #18
0
 public virtual IDictionary <string, object> GetRelationshipProperties(long relationshipId)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.read()))
     {
         Relationship relationship = _database.Graph.getRelationshipById(relationshipId);
         IDictionary <string, object> allProperties = relationship.AllProperties;
         tx.Success();
         return(allProperties);
     }
 }
예제 #19
0
 public virtual long CreateRelationship(string type)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.writeToken()))
     {
         Node         startNode    = _database.Graph.createNode();
         Node         endNode      = _database.Graph.createNode();
         Relationship relationship = startNode.CreateRelationshipTo(endNode, RelationshipType.withName(type));
         tx.Success();
         return(relationship.Id);
     }
 }
예제 #20
0
 public virtual void SetNodeProperties(long nodeId, IDictionary <string, object> properties)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.writeToken()))
     {
         Node node = _database.Graph.getNodeById(nodeId);
         foreach (KeyValuePair <string, object> propertyEntry in properties.SetOfKeyValuePairs())
         {
             node.SetProperty(propertyEntry.Key, propertyEntry.Value);
         }
         tx.Success();
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = org.neo4j.graphdb.NotInTransactionException.class) public void shouldThrowNotInTransactionWhenTransactionClosedAndAttemptingOperations() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowNotInTransactionWhenTransactionClosedAndAttemptingOperations()
        {
            KernelTransaction transaction = newTransaction(AnonymousContext.write());

            Read       read       = transaction.DataRead();
            Write      write      = transaction.DataWrite();
            SchemaRead schemaRead = transaction.SchemaRead();

            transaction.Success();
            transaction.Close();

            TransactionOperation.operate(read, write, schemaRead);
        }
예제 #22
0
 public virtual long CreateNode(IDictionary <string, object> properties, params Label[] labels)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.writeToken()))
     {
         Node node = _database.Graph.createNode(labels);
         foreach (KeyValuePair <string, object> entry in properties.SetOfKeyValuePairs())
         {
             node.SetProperty(entry.Key, entry.Value);
         }
         tx.Success();
         return(node.Id);
     }
 }
예제 #23
0
 public virtual ICollection <long> GetIndexedRelationships(string indexName, string key, object value)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.write()))
     {
         ICollection <long> result = new List <long>();
         foreach (Relationship relationship in _database.Graph.index().forRelationships(indexName).get(key, value))
         {
             result.Add(relationship.Id);
         }
         tx.Success();
         return(result);
     }
 }
예제 #24
0
 public virtual ICollection <long> QueryIndexedNodes(string indexName, string key, object value)
 {
     using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.write()))
     {
         ICollection <long> result = new List <long>();
         foreach (Node node in _database.Graph.index().forNodes(indexName).query(key, value))
         {
             result.Add(node.Id);
         }
         tx.Success();
         return(result);
     }
 }
예제 #25
0
        public virtual void SetRelationshipProperties(long relationshipId, IDictionary <string, object> properties)

        {
            using (Transaction tx = _database.Graph.beginTransaction(@implicit, AnonymousContext.writeToken()))
            {
                Relationship relationship = _database.Graph.getRelationshipById(relationshipId);
                foreach (KeyValuePair <string, object> propertyEntry in properties.SetOfKeyValuePairs())
                {
                    relationship.SetProperty(propertyEntry.Key, propertyEntry.Value);
                }
                tx.Success();
            }
        }
예제 #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnRelsWhenAskingForRelsWhereOnlySomeTypesExistInCurrentRel() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnRelsWhenAskingForRelsWhereOnlySomeTypesExistInCurrentRel()
        {
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());

            int relType1 = transaction.TokenWrite().relationshipTypeGetOrCreateForName("Type1");
            int relType2 = transaction.TokenWrite().relationshipTypeGetOrCreateForName("Type2");

            long refNode   = transaction.DataWrite().nodeCreate();
            long otherNode = transaction.DataWrite().nodeCreate();
            long theRel    = transaction.DataWrite().relationshipCreate(refNode, relType1, otherNode);

            AssertRels(NodeGetRelationships(transaction, refNode, OUTGOING, new int[] { relType2, relType1 }), theRel);
            Commit();
        }
예제 #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void threadThatBlocksNewTxsCantStartNewTxs() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ThreadThatBlocksNewTxsCantStartNewTxs()
        {
            KernelTransactions kernelTransactions = NewKernelTransactions();

            kernelTransactions.BlockNewTransactions();
            try
            {
                kernelTransactions.NewInstance(KernelTransaction.Type.@implicit, AnonymousContext.write(), 0L);
                fail("Exception expected");
            }
            catch (Exception e)
            {
                assertThat(e, instanceOf(typeof(System.InvalidOperationException)));
            }
        }
예제 #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListRelationshipsInCurrentAndSubsequentTx() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldListRelationshipsInCurrentAndSubsequentTx()
        {
            // given
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());
            int         relType1    = transaction.TokenWrite().relationshipTypeGetOrCreateForName("Type1");
            int         relType2    = transaction.TokenWrite().relationshipTypeGetOrCreateForName("Type2");

            long refNode         = transaction.DataWrite().nodeCreate();
            long otherNode       = transaction.DataWrite().nodeCreate();
            long fromRefToOther1 = transaction.DataWrite().relationshipCreate(refNode, relType1, otherNode);
            long fromRefToOther2 = transaction.DataWrite().relationshipCreate(refNode, relType2, otherNode);
            long fromOtherToRef  = transaction.DataWrite().relationshipCreate(otherNode, relType1, refNode);
            long fromRefToRef    = transaction.DataWrite().relationshipCreate(refNode, relType2, refNode);
            long endNode         = transaction.DataWrite().nodeCreate();
            long fromRefToThird  = transaction.DataWrite().relationshipCreate(refNode, relType2, endNode);

            // when & then
            AssertRels(NodeGetRelationships(transaction, refNode, BOTH), fromRefToOther1, fromRefToOther2, fromRefToRef, fromRefToThird, fromOtherToRef);

            AssertRels(NodeGetRelationships(transaction, refNode, BOTH, new int[] { relType1 }), fromRefToOther1, fromOtherToRef);

            AssertRels(NodeGetRelationships(transaction, refNode, BOTH, new int[] { relType1, relType2 }), fromRefToOther1, fromRefToOther2, fromRefToRef, fromRefToThird, fromOtherToRef);

            AssertRels(NodeGetRelationships(transaction, refNode, INCOMING), fromOtherToRef);

            AssertRels(NodeGetRelationships(transaction, refNode, INCOMING, new int[] { relType1 }));

            AssertRels(NodeGetRelationships(transaction, refNode, OUTGOING, new int[] { relType1, relType2 }), fromRefToOther1, fromRefToOther2, fromRefToThird, fromRefToRef);

            // when
            Commit();
            transaction = NewTransaction();

            // when & then
            AssertRels(NodeGetRelationships(transaction, refNode, BOTH), fromRefToOther1, fromRefToOther2, fromRefToRef, fromRefToThird, fromOtherToRef);

            AssertRels(NodeGetRelationships(transaction, refNode, BOTH, new int[] { relType1 }), fromRefToOther1, fromOtherToRef);

            AssertRels(NodeGetRelationships(transaction, refNode, BOTH, new int[] { relType1, relType2 }), fromRefToOther1, fromRefToOther2, fromRefToRef, fromRefToThird, fromOtherToRef);

            AssertRels(NodeGetRelationships(transaction, refNode, INCOMING), fromOtherToRef);

            AssertRels(NodeGetRelationships(transaction, refNode, INCOMING, new int[] { relType1 }));

            AssertRels(NodeGetRelationships(transaction, refNode, OUTGOING, new int[] { relType1, relType2 }), fromRefToOther1, fromRefToOther2, fromRefToThird, fromRefToRef);
            Commit();
        }
예제 #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void throwIfNullProvider() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ThrowIfNullProvider()
        {
            // given
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());

            transaction.TokenWrite().labelGetOrCreateForName("Person");
            CreateProperties(transaction, "name");
            Commit();

            // when
            NewTransaction(AnonymousContext.full());
            string             pattern = IndexPattern("Person", "name");
            ProcedureException e       = assertThrows(typeof(ProcedureException), () => CallIndexProcedure(pattern, null));

            // then
            assertThat(e.Message, containsString("Could not create index with specified index provider being null"));
            Commit();
        }
예제 #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAbortConstraintCreationWhenDuplicatesExist() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAbortConstraintCreationWhenDuplicatesExist()
        {
            // given
            Transaction transaction = newTransaction(AnonymousContext.writeToken());
            // name is not unique for Foo in the existing data

            int foo  = transaction.TokenWrite().labelGetOrCreateForName("Foo");
            int name = transaction.TokenWrite().propertyKeyGetOrCreateForName("name");

            long node1 = transaction.DataWrite().nodeCreate();

            transaction.DataWrite().nodeAddLabel(node1, foo);
            transaction.DataWrite().nodeSetProperty(node1, name, Values.of("foo"));

            long node2 = transaction.DataWrite().nodeCreate();

            transaction.DataWrite().nodeAddLabel(node2, foo);

            transaction.DataWrite().nodeSetProperty(node2, name, Values.of("foo"));
            commit();

            // when
            LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(foo, name);

            try
            {
                SchemaWrite schemaWriteOperations = schemaWriteInNewTransaction();
                schemaWriteOperations.UniquePropertyConstraintCreate(descriptor);

                fail("expected exception");
            }
            // then
            catch (CreateConstraintFailureException ex)
            {
                assertEquals(ConstraintDescriptorFactory.uniqueForSchema(descriptor), ex.Constraint());
                Exception cause = ex.InnerException;
                assertThat(cause, instanceOf(typeof(ConstraintValidationException)));

                string expectedMessage = string.Format("Both Node({0:D}) and Node({1:D}) have the label `Foo` and property `name` = 'foo'", node1, node2);
                string actualMessage   = UserMessage(( ConstraintValidationException )cause);
                assertEquals(expectedMessage, actualMessage);
            }
        }