private void createNonUniqueNodes() { try ( Transaction tx = db.beginTx() ) { Node originNode = db.createNode( LABEL ); originNode.setProperty( KEY, point1 ); Node centerNode = db.createNode( LABEL ); centerNode.setProperty( KEY, point1 ); tx.success(); } }
@Test public void testNodeWithDoubleProperty() { final double doubleValue = 123456.123456; final String expected = "123456.123456"; gdb.createNode().setProperty( "double", doubleValue ); assertEquals( "create (_0 {`double`:" + expected + "})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) ); }
@Test public void testPointTypeWithTwoOtherProperties() { Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 ); String key = "location"; node1.setProperty( "prop1", 1 ); node1.setProperty( "prop2", 2 ); node1.setProperty( key, point ); newTransaction(); Object property = node1.getProperty( key ); assertEquals( point, property ); }
@Test public void lookupWithoutTransaction() { // when Node node; try ( Transaction tx = db.beginTx() ) { (node = db.createNode( label( "Node" ) )).setProperty( "prop", store ); tx.success(); } // then try ( Transaction tx = db.beginTx() ) { assertEquals( 1, count( db.findNodes( label( "Node" ), "prop", lookup ) ) ); tx.success(); } deleteNode( node ); }
@Test public void largeTx() { Node node = getGraphDb().createNode(); node.setProperty( "anchor", "hi" ); for ( int i = 0; i < 255; i++ ) { node.setProperty( "foo", 1 ); node.removeProperty( "foo" ); } commit(); }
@Test public void txMustFailIfExceedingIndexKeySizeLimit() { createIndex(); // Write try ( Transaction tx = db.beginTx() ) { String propValue = getString( keySizeLimit + 1 ); db.createNode( LABEL_ONE ).setProperty( propKey, propValue ); tx.success(); } catch ( IllegalArgumentException e ) { assertThat( e.getMessage(), Matchers.containsString( "Property value size is too large for index. Please see index documentation for limitations." ) ); } }
private void setProperty( Node node, String key, Object value ) { try ( Transaction tx = db.beginTx() ) { node.setProperty( key, value ); tx.success(); } }
void setProperty( String nodeName, String propertyName, Object propertyValue ) { Node i = this.getNode( nodeName ); GraphDatabaseService db = i.getGraphDatabase(); try ( Transaction tx = db.beginTx() ) { i.setProperty( propertyName, propertyValue ); tx.success(); } }
private void createAliens() { try ( Transaction tx = db.beginTx() ) { for ( int i = 0; i < 32; i++ ) { Node alien = db.createNode( ALIEN ); alien.setProperty( SPECIMEN, i / 2 ); } tx.success(); } }
@Test public void testNodeWithProperties() { gdb.createNode().setProperty( "name", "Andres" ); assertEquals( "create (_0 {`name`:\"Andres\"})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) ); }
@Test public void testPointTypeWithOneOtherProperty() { Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 ); String key = "location"; node1.setProperty( "prop1", 1 ); node1.setProperty( key, point ); newTransaction(); Object property = node1.getProperty( key ); assertEquals( point, property ); }
@Test public void lookupWithoutTransactionWithCacheEviction() { // when Node node; try ( Transaction tx = db.beginTx() ) { (node = db.createNode( label( "Node" ) )).setProperty( "prop", store ); tx.success(); } // then try ( Transaction tx = db.beginTx() ) { assertEquals( 1, count( db.findNodes( label( "Node" ), "prop", lookup ) ) ); tx.success(); } deleteNode( node ); } }
@Test public void addAndRemovePropertiesWithinOneTransaction() { Node node = getGraphDb().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 ) ); }
@Test( timeout = 30_000 ) public void terminateExpiredTransaction() throws Exception { try ( Transaction transaction = database.beginTx() ) { database.createNode(); transaction.success(); } expectedException.expectMessage( "The transaction has been terminated." ); try ( Transaction transaction = database.beginTx() ) { Node nodeById = database.getNodeById( NODE_ID ); nodeById.setProperty( "a", "b" ); executor.submit( startAnotherTransaction() ).get(); } }
void setNodeProp( long nodeId, String propertyKey, String value ) { try ( Transaction tx = db.beginTx() ) { Node node = db.getNodeById( nodeId ); node.setProperty( propertyKey, value ); tx.success(); } }
private static void createNode( GraphDatabaseService database, String propertyName, Label testLabel ) { try ( Transaction transaction = database.beginTx() ) { Node node = database.createNode( testLabel ); node.setProperty( propertyName, "value" ); transaction.success(); } }
@Test public void testNodeWithFloatProperty() { final float floatValue = 10.1f; final String expected = "10.100000"; gdb.createNode().setProperty( "float", floatValue ); assertEquals( "create (_0 {`float`:" + expected + "})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) ); }
@Test public void testPointType() { Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 ); String key = "location"; node1.setProperty( key, point ); newTransaction(); Object property = node1.getProperty( key ); assertEquals( point, property ); }
@Test public void testNodeAddPropertyWithNullKey() { Node node1 = getGraphDb().createNode(); try { node1.setProperty( null, "bar" ); fail( "Null key should result in exception." ); } catch ( IllegalArgumentException ignored ) { } }
@Test public void testPropertyStoreReferencesOnWrite() throws Throwable { // Given GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); // and Given the cache contains a LazyProperty long nId = ensurePropertyIsCachedLazyProperty( db, "some" ); // When restartNeoDataSource( db ); // Then it should still be possible to manipulate properties on this node try ( Transaction tx = db.beginTx() ) { db.getNodeById( nId ).setProperty( "some", new long[]{-1, 2, 2, 3, 4, 5, 5} ); tx.success(); } }