@Override public Object apply( long nodeId ) { propertyStore.getRecord( nodeId, propertyRecord, CHECK ); if ( !propertyRecord.inUse() ) { return null; } return propertyRecord.iterator().next().newPropertyValue( propertyStore ).asObject(); } }
Iterator<PropertyBlock> iterator = record.iterator(); assertIteratorRemoveThrowsIllegalState( iterator );
@Test public void shouldIterateOverBlocks() { // GIVEN PropertyRecord record = new PropertyRecord( 0 ); PropertyBlock[] blocks = new PropertyBlock[3]; for ( int i = 0; i < blocks.length; i++ ) { blocks[i] = new PropertyBlock(); record.addPropertyBlock( blocks[i] ); } // WHEN Iterator<PropertyBlock> iterator = record.iterator(); // THEN for ( PropertyBlock block : blocks ) { assertTrue( iterator.hasNext() ); assertEquals( block, iterator.next() ); } assertFalse( iterator.hasNext() ); }
@Override public void assertRecordsEquals( PropertyRecord written, PropertyRecord read ) { assertEquals( written.getPrevProp(), read.getPrevProp() ); assertEquals( written.getNextProp(), read.getNextProp() ); assertEquals( written.isNodeSet(), read.isNodeSet() ); if ( written.isNodeSet() ) { assertEquals( written.getNodeId(), read.getNodeId() ); } else { assertEquals( written.getRelId(), read.getRelId() ); } assertEquals( written.numberOfProperties(), read.numberOfProperties() ); Iterator<PropertyBlock> writtenBlocks = written.iterator(); Iterator<PropertyBlock> readBlocks = read.iterator(); while ( writtenBlocks.hasNext() ) { assertTrue( readBlocks.hasNext() ); assertBlocksEquals( writtenBlocks.next(), readBlocks.next() ); } }
@Test public void shouldCreateProperBeforeAndAfterPropertyCommandsWhenAddingProperty() throws Exception { // GIVEN NeoStores neoStores = neoStoresRule.builder().build(); TransactionRecordState recordState = newTransactionRecordState( neoStores ); int nodeId = 1; recordState.nodeCreate( nodeId ); // WHEN recordState.nodeAddProperty( nodeId, propertyId1, value1 ); Collection<StorageCommand> commands = new ArrayList<>(); recordState.extractCommands( commands ); PropertyCommand propertyCommand = singlePropertyCommand( commands ); // THEN PropertyRecord before = propertyCommand.getBefore(); assertFalse( before.inUse() ); assertFalse( before.iterator().hasNext() ); PropertyRecord after = propertyCommand.getAfter(); assertTrue( after.inUse() ); assertEquals( 1, count( after ) ); }
@Override public Object apply( long nodeId ) { propertyStore.getRecord( nodeId, propertyRecord, CHECK ); if ( !propertyRecord.inUse() ) { return null; } return propertyRecord.iterator().next().newPropertyValue( propertyStore ).asObject(); } }