### Question:
OwningNodeRelationshipChain { public RecordSet<RelationshipRecord> findRelationshipChainsThatThisRecordShouldBelongTo( RelationshipRecord relationship ) { RecordSet<RelationshipRecord> records = new RecordSet<>(); for ( RelationshipNodeField field : RelationshipNodeField.values() ) { long nodeId = field.get( relationship ); nodeStore.getRecord( nodeId, nodeRecord, RecordLoad.FORCE ); records.addAll( relationshipChainExplorer.followChainFromNode( nodeId, nodeRecord.getNextRel() ) ); } return records; } OwningNodeRelationshipChain( RelationshipChainExplorer relationshipChainExplorer,
                                        RecordStore<NodeRecord> nodeStore ); RecordSet<RelationshipRecord> findRelationshipChainsThatThisRecordShouldBelongTo(
            RelationshipRecord relationship );  }### Answer:
@Test void shouldFindBothChainsThatTheRelationshipRecordShouldBelongTo() { long node1 = 101; long node1Rel = 1001; long node2 = 201; long node2Rel = 2001; long sharedRel = 1000; int relType = 0; RecordSet<RelationshipRecord> node1RelChain = asSet( new RelationshipRecord( node1Rel, node1, node1 - 1, relType ), new RelationshipRecord( sharedRel, node1, node2, relType ), new RelationshipRecord( node1Rel + 1, node1 + 1, node1, relType ) ); RecordSet<RelationshipRecord> node2RelChain = asSet( new RelationshipRecord( node2Rel, node2 - 1, node2, relType ), new RelationshipRecord( sharedRel, node1, node2, relType ), new RelationshipRecord( node2Rel + 1, node2, node2 + 1, relType ) ); @SuppressWarnings( "unchecked" ) RecordStore<NodeRecord> recordStore = mock( RecordStore.class ); when( recordStore.getRecord( eq( node1 ), any( NodeRecord.class ), any( RecordLoad.class ) ) ) .thenAnswer( new ReadNodeAnswer( false, node1Rel, NO_NEXT_PROPERTY.intValue() ) ); when( recordStore.getRecord( eq( node2 ), any( NodeRecord.class ), any( RecordLoad.class ) ) ) .thenAnswer( new ReadNodeAnswer( false, node2Rel, NO_NEXT_PROPERTY.intValue() ) ); when( recordStore.newRecord() ).thenReturn( new NodeRecord( -1 ) ); RelationshipChainExplorer relationshipChainExplorer = mock( RelationshipChainExplorer.class ); when( relationshipChainExplorer.followChainFromNode( node1, node1Rel ) ).thenReturn( node1RelChain ); when( relationshipChainExplorer.followChainFromNode( node2, node2Rel ) ).thenReturn( node2RelChain ); OwningNodeRelationshipChain owningChainFinder = new OwningNodeRelationshipChain( relationshipChainExplorer, recordStore ); RecordSet<RelationshipRecord> recordsInChains = owningChainFinder .findRelationshipChainsThatThisRecordShouldBelongTo( new RelationshipRecord( sharedRel, node1, node2, relType ) ); assertThat( recordsInChains, containsAllRecords( node1RelChain ) ); assertThat( recordsInChains, containsAllRecords( node2RelChain ) ); }