private RelationshipProxy relationship( int offset ) { int type = directedTypes[offset]; if ( type >= 0 ) { return new RelationshipProxy( proxySPI, relationships[offset], nodes[offset], type, nodes[offset + 1] ); } else { return new RelationshipProxy( proxySPI, relationships[offset], nodes[offset + 1], ~type, nodes[offset] ); } }
@Override public RelationshipProxy newRelationshipProxy( long id ) { return new RelationshipProxy( this, id ); }
@Override public RelationshipProxy newRelationshipProxy( long id, long startNodeId, int typeId, long endNodeId ) { return new RelationshipProxy( this, id, startNodeId, typeId, endNodeId ); }
@Override public RelationshipProxy newRelationshipProxy( long id ) { return new RelationshipProxy( this, id ); }
private RelationshipProxy createRelationshipProxy( int startNodeId, int endNodeId ) { return new RelationshipProxy( spi, 1L, startNodeId, 1, endNodeId ); }
@Override public Relationship mapRelationship( VirtualRelationshipValue value ) { assert !(value instanceof RelationshipReference); if ( value instanceof RelationshipProxyWrappingValue ) { // this is the back door through which "virtual relationships" slip return ((RelationshipProxyWrappingValue) value).relationshipProxy(); } return new RelationshipProxy( proxySPI, value.id() ); }
private TxStateTransactionDataSnapshot snapshot() { EmbeddedProxySPI spi = mock( EmbeddedProxySPI.class ); when( spi.newNodeProxy( anyLong() ) ).thenAnswer( invocation -> new NodeProxy( spi, invocation.getArgument( 0 ) ) ); when( spi.newRelationshipProxy( anyLong() ) ).thenAnswer( invocation -> new RelationshipProxy( spi, invocation.getArgument( 0 ) ) ); when( spi.newRelationshipProxy( anyLong(), anyLong(), anyInt(), anyLong() ) ).thenAnswer( invocation -> new RelationshipProxy( spi, invocation.getArgument( 0 ), invocation.getArgument( 1 ), invocation.getArgument( 2 ), invocation.getArgument( 3 ) ) ); return new TxStateTransactionDataSnapshot( state, spi, ops, transaction ); } }
private void verifyIds( EmbeddedProxySPI actions, long relationshipId, long nodeId1, int typeId, long nodeId2 ) { RelationshipProxy proxy = new RelationshipProxy( actions, relationshipId, nodeId1, typeId, nodeId2 ); assertEquals( relationshipId, proxy.getId() ); // our mock above is known to return RelationshipTypeToken assertEquals( nodeId1, proxy.getStartNode().getId() ); assertEquals( nodeId1, proxy.getStartNodeId() ); assertEquals( nodeId2, proxy.getEndNode().getId() ); assertEquals( nodeId2, proxy.getEndNodeId() ); assertEquals( nodeId2, proxy.getOtherNode( nodeWithId( nodeId1 ) ).getId() ); assertEquals( nodeId2, proxy.getOtherNodeId( nodeId1 ) ); assertEquals( nodeId1, proxy.getOtherNode( nodeWithId( nodeId2 ) ).getId() ); assertEquals( nodeId1, proxy.getOtherNodeId( nodeId2 ) ); }
@Override public RelationshipProxy newRelationshipProxy( long id ) { return new RelationshipProxy( this, id ); }
@Override public RelationshipProxy newRelationshipProxy( long id, long startNodeId, int typeId, long endNodeId ) { return new RelationshipProxy( this, id, startNodeId, typeId, endNodeId ); }
private RelationshipProxy relationship( int offset ) { int type = directedTypes[offset]; if ( type >= 0 ) { return new RelationshipProxy( proxySPI, relationships[offset], nodes[offset], type, nodes[offset + 1] ); } else { return new RelationshipProxy( proxySPI, relationships[offset], nodes[offset + 1], ~type, nodes[offset] ); } }
@Override public Relationship mapRelationship( VirtualRelationshipValue value ) { assert !(value instanceof RelationshipReference); if ( value instanceof RelationshipProxyWrappingValue ) { // this is the back door through which "virtual relationships" slip return ((RelationshipProxyWrappingValue) value).relationshipProxy(); } return new RelationshipProxy( proxySPI, value.id() ); }