Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readArrayAndStringPropertiesWithDifferentBlockSizes()
        public virtual void ReadArrayAndStringPropertiesWithDifferentBlockSizes()
        {
            string stringValue = RandomStringUtils.randomAlphanumeric(10000);

            sbyte[] arrayValue = RandomStringUtils.randomAlphanumeric(10000).Bytes;

            GraphDatabaseService db = (new TestGraphDatabaseFactory()).setFileSystem(Fs.get()).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.string_block_size, "1024").setConfig(GraphDatabaseSettings.array_block_size, "2048").newGraphDatabase();

            try
            {
                long nodeId;
                using (Transaction tx = Db.beginTx())
                {
                    Node node = Db.createNode();
                    nodeId = node.Id;
                    node.SetProperty("string", stringValue);
                    node.SetProperty("array", arrayValue);
                    tx.Success();
                }

                using (Transaction tx = Db.beginTx())
                {
                    Node node = Db.getNodeById(nodeId);
                    assertEquals(stringValue, node.GetProperty("string"));
                    assertArrayEquals(arrayValue, ( sbyte[] )node.GetProperty("array"));
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void name()
        public virtual void Name()
        {
            Node node = GraphDb.createNode();

            node.SetProperty("name", "yo");
            node.GetProperty("name");
            Commit();

            using (Transaction tx = GraphDb.beginTx())
            {
                node.GetProperty("name");
                tx.Success();
            }
        }
Exemple #3
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));
        }
Exemple #4
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));
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void loadManyProperties()
        public virtual void LoadManyProperties()
        {
            Node node = GraphDb.createNode();

            for (int i = 0; i < 200; i++)
            {
                node.SetProperty("property " + i, "value");
            }
            NewTransaction();
            assertEquals("value", node.GetProperty("property 0"));
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetDoubleArrayProperty()
        public virtual void TestSetDoubleArrayProperty()
        {
            using (Transaction ignore = _db.beginTx())
            {
                Node node = _db.createNode();
                for (int i = 0; i < 100; i++)
                {
                    node.SetProperty("foo", new double[] { 0, 0, i, i });
                    assertArrayEquals(new double[] { 0, 0, i, i }, ( double[] )node.GetProperty("foo"), 0.1D);
                }
            }
        }
Exemple #7
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));
        }
Exemple #8
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));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canReplaceShortStringWithLongString()
        public virtual void CanReplaceShortStringWithLongString()
        {
            Node node = Graphdb.GraphDatabaseAPI.createNode();

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

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

            node.SetProperty("key", LONG_STRING);
            Commit();

            assertThat(node, inTx(Graphdb.GraphDatabaseAPI, hasProperty("key").withValue(LONG_STRING)));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canUpdateShortStringInplace()
        public virtual void CanUpdateShortStringInplace()
        {
            Node node = Graphdb.GraphDatabaseAPI.createNode();

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

            NewTx();

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

            node.SetProperty("key", "other");
            Commit();

            assertThat(node, inTx(Graphdb.GraphDatabaseAPI, hasProperty("key").withValue("other")));
        }
//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"))));
        }
 private Node Highest(string key, IndexHits <Node> query)
 {
     using (IndexHits <Node> hits = query)
     {
         long highestValue = long.MinValue;
         Node highestNode  = null;
         while (hits.MoveNext())
         {
             Node node  = hits.Current;
             long value = (( Number )node.GetProperty(key)).longValue();
             if (value > highestValue)
             {
                 highestValue = value;
                 highestNode  = node;
             }
         }
         return(highestNode);
     }
 }
Exemple #13
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
            }
        }
Exemple #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNotInTransactionException()
        public virtual void TestNotInTransactionException()
        {
            Node node1 = _graph.createNode();

            node1.SetProperty("test", 1);
            Node         node2 = _graph.createNode();
            Node         node3 = _graph.createNode();
            Relationship rel   = node1.CreateRelationshipTo(node2, MyRelTypes.TEST);

            rel.SetProperty("test", 11);
            Commit();
            try
            {
                _graph.createNode();
                fail("Create node with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node1.CreateRelationshipTo(node2, MyRelTypes.TEST);
                fail("Create relationship with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node1.SetProperty("test", 2);
                fail("Set property with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                rel.SetProperty("test", 22);
                fail("Set property with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node3.Delete();
                fail("Delete node with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                rel.Delete();
                fail("Delete relationship with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            NewTransaction();
            assertEquals(node1.GetProperty("test"), 1);
            assertEquals(rel.GetProperty("test"), 11);
            assertEquals(rel, node1.GetSingleRelationship(MyRelTypes.TEST, Direction.OUTGOING));
            node1.Delete();
            node2.Delete();
            rel.Delete();
            node3.Delete();

            // Finally
            Rollback();
        }
Exemple #15
0
 private void SetPropertyAndAssertIt(Node node, object value)
 {
     node.SetProperty("key", value);
     assertEquals(value, node.GetProperty("key"));
 }