Refine search
@Test public void shouldHandleRemovePropertyConcurrentlyWithIndexDrop() throws Throwable { shouldHandleIndexDropConcurrentlyWithOperation( nodeId -> db.getNodeById( nodeId ).removeProperty( KEY ) ); }
@SuppressWarnings( "boxing" ) @Override public Void beforeCommit( TransactionData data ) { if ( Iterables.count( data.createdRelationships() ) == 0 ) { return null; } node.setProperty( "counter", ((Long) node.removeProperty( "counter" )) + 1 ); return null; }
@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 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 public void testNodeRemoveProperty() { Node node1 = getGraphDb().getNodeById( node1Id ); Node node2 = getGraphDb().getNodeById( node2Id ); Relationship rel = node1.getSingleRelationship( MyRelTypes.TEST, Direction.BOTH ); // test remove property assertEquals( 1, node1.removeProperty( key1 ) ); assertEquals( 2, node2.removeProperty( key1 ) ); assertEquals( 1, rel.removeProperty( key1 ) ); assertEquals( string1, node1.removeProperty( key2 ) ); assertEquals( string2, node2.removeProperty( key2 ) ); assertEquals( string1, rel.removeProperty( key2 ) ); assertNotNull( node1.removeProperty( arrayKey ) ); assertNotNull( node2.removeProperty( arrayKey ) ); assertNotNull( rel.removeProperty( arrayKey ) ); }
private void setAndRemoveSomeProperties( GraphDatabaseService graphDatabaseService, Object value ) { Node commonNode; try ( Transaction transaction = graphDatabaseService.beginTx() ) { commonNode = graphDatabaseService.createNode(); for ( int i = 0; i < 10; i++ ) { commonNode.setProperty( "key" + i, value ); } transaction.success(); } try ( Transaction transaction = graphDatabaseService.beginTx() ) { for ( int i = 0; i < 10; i++ ) { commonNode.removeProperty( "key" + i ); } transaction.success(); } } }
@Test public void removingPropertyDoesNotBreakPreviouslyCreatedNodePropertyKeysIterator() { // GIVEN GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); try ( Transaction tx = db.beginTx() ) { Node node = db.createNode(); node.setProperty( "name", "Horst" ); node.setProperty( "age", "72" ); Iterator<String> iterator = node.getPropertyKeys().iterator(); while ( iterator.hasNext() ) { node.removeProperty( iterator.next() ); } tx.success(); } }
private void changeRandomNode( GraphDatabaseService db, int nodeCount, RandomValues random ) { try ( Transaction tx = db.beginTx() ) { long nodeId = random.nextInt( nodeCount ); Node node = db.getNodeById( nodeId ); Object[] keys = Iterables.asCollection( node.getPropertyKeys() ).toArray(); String key = (String) random.among( keys ); if ( random.nextFloat() < 0.1 ) { // REMOVE node.removeProperty( key ); } else { // CHANGE node.setProperty( key, random.nextValue().asObject() ); } tx.success(); } catch ( NotFoundException e ) { // It's OK, it happens if some other thread deleted that property in between us reading it and // removing or setting it } }
@Test public void removeOneOfThree() { Node node = getGraphDb().createNode(); node.setProperty( "1", 1 ); node.setProperty( "2", 2 ); node.setProperty( "3", 3 ); newTransaction(); node.removeProperty( "2" ); newTransaction(); assertNull( node.getProperty( "2", null ) ); }
node.setProperty( key, random.nextValueAsObject() ); random.among( nodes, node -> node.setProperty( random.among( keys ), random.nextValueAsObject() ) ); random.among( nodes, node -> node.removeProperty( random.among( keys ) ) );
@Test public void testNodeChangeProperty2() { String key1 = "key1"; Integer int1 = 1; Integer int2 = 2; String string1 = "1"; String string2 = "2"; Boolean bool1 = Boolean.TRUE; Boolean bool2 = Boolean.FALSE; Node node1 = getGraphDb().createNode(); node1.setProperty( key1, int1 ); node1.setProperty( key1, int2 ); assertEquals( int2, node1.getProperty( key1 ) ); node1.removeProperty( key1 ); node1.setProperty( key1, string1 ); node1.setProperty( key1, string2 ); assertEquals( string2, node1.getProperty( key1 ) ); node1.removeProperty( key1 ); node1.setProperty( key1, bool1 ); node1.setProperty( key1, bool2 ); assertEquals( bool2, node1.getProperty( key1 ) ); node1.removeProperty( key1 ); node1.delete(); }
if ( random.nextBoolean() ) node.setProperty( randomKey(), random.nextValueAsObject() ); random.among( nodes, node -> node.setProperty( randomKey(), random.nextValueAsObject() ) ); random.among( nodes, node -> node.removeProperty( randomKey() ) );
@Test public void removeAndAddSameProperty() { Node node = getGraphDb().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 ) ); }
Object catValue = cat.getProperty(copiedKey, null); if (catValue == null) { cat.setProperty(copiedKey, copiedValue); node.removeProperty(copiedKey); } else if (copiedValue.equals(catValue)) { node.removeProperty(copiedKey); node.removeProperty(sourceKey);
@Test public void testChangeProperty() { Node node = getGraphDb().createNode(); node.setProperty( "test", "test1" ); tx.success(); tx.begin(); node.setProperty( "test", "test2" ); node.removeProperty( "test" ); node.setProperty( "test", "test3" ); assertEquals( "test3", node.getProperty( "test" ) ); node.removeProperty( "test" ); node.setProperty( "test", "test4" ); tx.success(); tx.begin(); assertEquals( "test4", node.getProperty( "test" ) ); }
public void dropIndex() { if (indexExists()) { Transaction tx = graphDb.beginTx(); // ...cleanup the index. int counter = 0; for (Node n : graphDb.getAllNodes()) { n.removeProperty(IN_LIST_PROPERTY); n.removeProperty(OUT_LIST_PROPERTY); tx = batchTransactions(tx, counter++); } // reset the flag. metaDataNode.setProperty(INDEX_EXISTS_PROPERTY, false); tx.success(); tx.close(); logger.info("Reachability index dropped."); } else { logger.warning("There was no reachability index to drop."); } }
@Test public void testNodeRemoveProperty() if ( node1.removeProperty( key1 ) != null ) node1.removeProperty( null ); fail( "Remove null property should throw exception." ); node1.setProperty( key1, int1 ); node2.setProperty( key1, string1 ); node1.setProperty( key2, string2 ); node2.setProperty( key2, int2 ); try node1.removeProperty( null ); fail( "Null argument should result in exception." ); assertEquals( int1, node1.removeProperty( key1 ) ); assertEquals( string1, node2.removeProperty( key1 ) ); if ( node2.removeProperty( key1 ) != null )
@Test public void addAndRemovePropertiesWithinOneTransaction2() { Node node = getGraphDb().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 e ) { // good } }
@Test public void testNodeMultiRemoveProperty() { Node node = getGraphDb().createNode(); node.setProperty( "key0", "0" ); node.setProperty( "key1", "1" ); node.setProperty( "key2", "2" ); node.setProperty( "key3", "3" ); node.setProperty( "key4", "4" ); newTransaction(); node.removeProperty( "key3" ); node.removeProperty( "key2" ); node.removeProperty( "key3" ); newTransaction(); assertEquals( "0", node.getProperty( "key0" ) ); assertEquals( "1", node.getProperty( "key1" ) ); assertEquals( "4", node.getProperty( "key4" ) ); assertTrue( !node.hasProperty( "key2" ) ); assertTrue( !node.hasProperty( "key3" ) ); node.delete(); }
@Test public void testAdditionHappensInTheMiddleIfItFits() { Node node = getGraphDb().createNode(); long recordsInUseAtStart = propertyRecordsInUse(); node.setProperty( "int1", 1 ); node.setProperty( "double1", 1.0 ); node.setProperty( "int2", 2 ); int stuffedShortStrings = 0; for ( ; stuffedShortStrings < PropertyType.getPayloadSizeLongs(); stuffedShortStrings++ ) { node.setProperty( "shortString" + stuffedShortStrings, String.valueOf( stuffedShortStrings ) ); } newTransaction(); assertEquals( recordsInUseAtStart + 2, propertyRecordsInUse() ); node.removeProperty( "shortString" + 1 ); node.setProperty( "int3", 3 ); newTransaction(); assertEquals( recordsInUseAtStart + 2, propertyRecordsInUse() ); }