コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void removeAndAddSameProperty()
        public virtual void RemoveAndAddSameProperty()
        {
            Node node = GraphDb.createNode();

            node.SetProperty("foo", "bar");
            NewTransaction();

            node.RemoveProperty("foo");
            node.SetProperty("foo", "bar");
            NewTransaction();
            assertEquals("bar", node.GetProperty("foo"));

            node.SetProperty("foo", "bar");
            node.RemoveProperty("foo");
            NewTransaction();
            assertNull(node.GetProperty("foo", null));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotFindRemovedProperties() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotFindRemovedProperties()
        {
            IndexReference index;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, "prop", "prop2");
                index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                tx.Success();
            }
            Await(index);
            long firstID;
            long secondID;
            long thirdID;

            using (Transaction tx = Db.beginTx())
            {
                firstID  = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again.");
                secondID = CreateNodeIndexableByPropertyValue(Label, "A zebroid (also zedonk, zorse, zebra mule, zonkey, and zebmule) is the offspring of any " + "cross between a zebra and any other equine: essentially, a zebra hybrid.");
                thirdID  = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again.");

                SetNodeProp(firstID, "zebra");
                SetNodeProp(secondID, "Hello. Hello again.");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                Node node  = Db.getNodeById(firstID);
                Node node2 = Db.getNodeById(secondID);
                Node node3 = Db.getNodeById(thirdID);

                node.SetProperty("prop", "tomtar");
                node.SetProperty("prop2", "tomtar");

                node2.SetProperty("prop", "tomtar");
                node2.SetProperty("prop2", "Hello");

                node3.RemoveProperty("prop");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "hello", secondID);
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "zebra");
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "zedonk");
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "cross");
            }
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addAndRemovePropertiesWithinOneTransaction()
        public virtual void AddAndRemovePropertiesWithinOneTransaction()
        {
            Node node = GraphDb.createNode();

            node.SetProperty("name", "oscar");
            node.SetProperty("favourite_numbers", new long?[] { 1L, 2L, 3L });
            node.SetProperty("favourite_colors", new string[] { "blue", "red" });
            node.RemoveProperty("favourite_colors");
            NewTransaction();

            assertNotNull(node.GetProperty("favourite_numbers", null));
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void removeOneOfThree()
        public virtual void RemoveOneOfThree()
        {
            Node node = GraphDb.createNode();

            node.SetProperty("1", 1);
            node.SetProperty("2", 2);
            node.SetProperty("3", 3);
            NewTransaction();

            node.RemoveProperty("2");
            NewTransaction();
            assertNull(node.GetProperty("2", null));
        }
コード例 #5
0
        public override void Perform(long nodeId, string value)
        {
            Node node = _db.getNodeById(nodeId);

            if (node.HasProperty(value))
            {
                node.RemoveProperty(value);
            }
            else
            {
                node.SetProperty(value, 10);
            }
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canRemoveShortStringProperty()
        public virtual void CanRemoveShortStringProperty()
        {
            GraphDatabaseService db = Graphdb.GraphDatabaseAPI;
            Node node = Db.createNode();

            node.SetProperty("key", "value");
            NewTx();

            assertEquals("value", node.GetProperty("key"));

            node.RemoveProperty("key");
            Commit();

            assertThat(node, inTx(db, not(hasProperty("key"))));
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void removeSomeAndSetSome()
        public virtual void RemoveSomeAndSetSome()
        {
            Node node = GraphDb.createNode();

            node.SetProperty("remove me", "trash");
            NewTransaction();

            node.RemoveProperty("remove me");
            node.SetProperty("foo", "bar");
            node.SetProperty("baz", 17);
            NewTransaction();

            assertEquals("bar", node.GetProperty("foo"));
            assertEquals(17, node.GetProperty("baz"));
            assertNull(node.GetProperty("remove me", null));
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addAndRemovePropertiesWithinOneTransaction2()
        public virtual void AddAndRemovePropertiesWithinOneTransaction2()
        {
            Node node = GraphDb.createNode();

            node.SetProperty("foo", "bar");

            NewTransaction();
            node.SetProperty("foo2", "bar");
            node.RemoveProperty("foo");

            NewTransaction();

            try
            {
                node.GetProperty("foo");
                fail("property should not exist");
            }
            catch (NotFoundException)
            {
                // good
            }
        }
コード例 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canAvoidDeadlockThatWouldHappenIfTheRelationshipTypeCreationTransactionModifiedData()
        public virtual void CanAvoidDeadlockThatWouldHappenIfTheRelationshipTypeCreationTransactionModifiedData()
        {
            GraphDatabaseService graphdb = Database.GraphDatabaseAPI;
            Node node = null;

            using (Transaction tx = graphdb.BeginTx())
            {
                node = graphdb.CreateNode();
                node.SetProperty("counter", 0L);
                tx.Success();
            }

            graphdb.RegisterTransactionEventHandler(new RelationshipCounterTransactionEventHandler(node));

            using (Transaction tx = graphdb.BeginTx())
            {
                node.SetProperty("state", "not broken yet");
                node.CreateRelationshipTo(graphdb.CreateNode(), RelationshipType.withName("TEST"));
                node.RemoveProperty("state");
                tx.Success();
            }

            assertThat(node, inTx(graphdb, hasProperty("counter").withValue(1L)));
        }