@Test public void propertyTypeShouldBeTxStateAware() throws Exception { // Given long node; try ( Transaction tx = beginTransaction() ) { node = tx.dataWrite().nodeCreate(); tx.success(); } // Then try ( Transaction tx = beginTransaction() ) { try ( NodeCursor nodes = tx.cursors().allocateNodeCursor(); PropertyCursor properties = tx.cursors().allocatePropertyCursor() ) { tx.dataRead().singleNode( node, nodes ); assertTrue( nodes.next() ); assertFalse( hasProperties( nodes, properties ) ); int prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); tx.dataWrite().nodeSetProperty( node, prop, stringValue( "foo" ) ); nodes.properties( properties ); assertTrue( properties.next() ); assertThat( properties.propertyType(), equalTo( ValueGroup.TEXT ) ); } } }
@Test public void propertyTypeShouldBeTxStateAware() throws Exception { // Given long relationship; try ( Transaction tx = beginTransaction() ) { Write write = tx.dataWrite(); int token = tx.tokenWrite().relationshipTypeGetOrCreateForName( "R" ); relationship = write.relationshipCreate( write.nodeCreate(), token, write.nodeCreate() ); tx.success(); } // Then try ( Transaction tx = beginTransaction() ) { try ( RelationshipScanCursor relationships = tx.cursors().allocateRelationshipScanCursor(); PropertyCursor properties = tx.cursors().allocatePropertyCursor() ) { tx.dataRead().singleRelationship( relationship, relationships ); assertTrue( relationships.next() ); assertFalse( hasProperties( relationships, tx ) ); int prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); tx.dataWrite().relationshipSetProperty( relationship, prop, stringValue( "foo" ) ); relationships.properties( properties ); assertTrue( properties.next() ); assertThat( properties.propertyType(), equalTo( ValueGroup.TEXT ) ); } } }
private void assertAccessSingleProperty( long nodeId, Object expectedValue, ValueGroup expectedValueType ) { // given try ( NodeCursor node = cursors.allocateNodeCursor(); PropertyCursor props = cursors.allocatePropertyCursor() ) { // when read.singleNode( nodeId, node ); assertTrue( "node by reference", node.next() ); assertTrue( "has properties", hasProperties( node, props ) ); node.properties( props ); assertTrue( "has properties by direct method", props.next() ); assertEquals( "correct value", expectedValue, props.propertyValue() ); assertEquals( "correct value type ", expectedValueType, props.propertyType() ); assertFalse( "single property", props.next() ); read.nodeProperties( node.nodeReference(), node.propertiesReference(), props ); assertTrue( "has properties via property ref", props.next() ); assertEquals( "correct value", expectedValue, props.propertyValue() ); assertFalse( "single property", props.next() ); } }