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(); } }
private Node createNode( GraphDatabaseService db, Label... labels ) { try ( Transaction tx = db.beginTx() ) { Node node = db.createNode( labels ); tx.success(); return node; } }
@Test public void testNodeWithProperties() { gdb.createNode().setProperty( "name", "Andres" ); assertEquals( "create (_0 {`name`:\"Andres\"})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) ); }
@Test public void testFromSimpleCypherResult() { Node n = gdb.createNode(); final ExecutionResult result = result( "node", n ); final SubGraph graph = CypherResultSubGraph.from( result, gdb, false ); assertEquals( "create (_" + n.getId() + ")" + lineSeparator() + ";" + lineSeparator(), doExportGraph( graph ) ); }
@Test public void testNodeAddPropertyWithNullKey() { Node node1 = getGraphDb().createNode(); try { node1.setProperty( null, "bar" ); fail( "Null key should result in exception." ); } catch ( IllegalArgumentException ignored ) { } }
private void makeSureRightAmountOfDynamicRecordsUsed( Object value, int expectedAddedDynamicRecords, DynamicRecordCounter recordCounter ) { long stringRecordsBefore = recordCounter.count(); Node node = getGraphDb().createNode(); node.setProperty( "name", value ); newTransaction(); long stringRecordsAfter = recordCounter.count(); assertEquals( stringRecordsBefore + expectedAddedDynamicRecords, stringRecordsAfter ); }
@Override protected Relationship create( Map<String, Object> properties ) { assertEquals( value, properties.get( key ) ); assertEquals( 1, properties.size() ); return root.createRelationshipTo( graphDatabase().createNode(), type ); } };
private void createSomeData( Label label, String propertyKey ) { try ( Transaction tx = db.beginTx() ) { Node node = db.createNode( label ); node.setProperty( propertyKey, "yeah" ); 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 createAndClearCacheBeforeCommit() { Node node = getGraphDb().createNode(); node.createRelationshipTo( getGraphDb().createNode(), TEST ); assertEquals( 1, Iterables.count( node.getRelationships() ) ); }
@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(); }
private void numericValueForGet( Index<Node> index ) { Node node = graphDb.createNode(); long id = 100L; index.add( node, "name", ValueContext.numeric( id ) ); assertEquals( node, index.get( "name", ValueContext.numeric( id ) ).getSingle() ); restartTx(); assertEquals( node, index.get( "name", ValueContext.numeric( id ) ).getSingle() ); }
private Node createNode() { try ( Transaction tx = db.beginTx() ) { Node n = db.createNode(); tx.success(); return n; } } }
private static Node createNodeWithProperty( GraphDatabaseService db, String key, Object value ) { try ( Transaction tx = db.beginTx() ) { Node node = db.createNode(); node.setProperty( key, value ); tx.success(); return node; } }
@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 testSingleNode() { Node n = gdb.createNode(); final ExecutionResult result = result( "node", n ); final SubGraph graph = CypherResultSubGraph.from( result, gdb, false ); assertEquals( "create (_" + n.getId() + ")" + lineSeparator() + ";" + lineSeparator(), doExportGraph( graph ) ); }
@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 ) ); }
private void createNode() { try ( Transaction transaction = db.beginTx() ) { db.createNode(); transaction.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 setPropertyAndClearCacheBeforeCommit() { Node node = getGraphDb().createNode(); node.setProperty( "name", "Test" ); assertEquals( "Test", node.getProperty( "name" ) ); }