For IntelliJ IDEA and
Android Studio


@Test public void shouldReportRelationshipForOtherNodes() throws Exception { // given NodeRecord node = inUse( new NodeRecord( 42, false, 7, NONE ) ); RelationshipRecord relationship = add( inUse( new RelationshipRecord( 7, 1, 2, 0 ) ) ); // when ConsistencyReport.NodeConsistencyReport report = check( node ); // then verify( report ).relationshipForOtherNode( relationship ); verifyNoMoreInteractions( report ); }
@Override public RelationshipRecord newRecord() { return new RelationshipRecord( -1 ); }
private StoreSingleRelationshipCursor createRelationshipCursor() { InstanceCache<StoreSingleRelationshipCursor> instanceCache = mock(InstanceCache.class); return new StoreSingleRelationshipCursor( new RelationshipRecord( -1 ), instanceCache, new RecordCursors( neoStores ), LockService.NO_LOCK_SERVICE ); } }
@Override public RelationshipRecord clone() { RelationshipRecord record = new RelationshipRecord( getId() ).initialize( inUse(), nextProp, firstNode, secondNode, type, firstPrevRel, firstNextRel, secondPrevRel, secondNextRel, firstInFirstChain, firstInSecondChain ); record.setSecondaryUnitId( getSecondaryUnitId() ); return record; }
private RelationshipRecord createRelationship( long id, long nextRelationship ) { return new RelationshipRecord( id, true, getFirstNode(), getSecondNode(), TYPE, NO_NEXT_RELATIONSHIP.intValue(), nextRelationship, NO_NEXT_RELATIONSHIP.intValue(), nextRelationship, false, false ); }
@Test public void useVariableLengthFormatWhenRecordSizeIsTooSmall() throws IOException { RelationshipRecord source = new RelationshipRecord( 1 ); RelationshipRecord target = new RelationshipRecord( 1 ); source.initialize( true, randomFixedReference(), randomFixedReference(), randomFixedReference(), randomType(), randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference(), true, true ); writeReadRecord( source, target, RelationshipRecordFormat.FIXED_FORMAT_RECORD_SIZE - 1 ); assertFalse( "Record should use variable length reference if format record is too small.", target.isUseFixedReferences() ); verifySameReferences( source, target); }
@Test public void shouldNotReportAnythingForNodeWithConsistentReferences() throws Exception { // given NodeRecord node = inUse( new NodeRecord( 42, false, 7, 11 ) ); add( inUse( new RelationshipRecord( 7, 42, 0, 0 ) ) ); add( inUse( new PropertyRecord( 11 ) ) ); // when ConsistencyReport.NodeConsistencyReport report = check( node ); // then verifyNoMoreInteractions( report ); }
@Override public Generator<RelationshipRecord> relationship() { return ( recordSize, format, recordId ) -> new RelationshipRecord( recordId ).initialize( random.nextBoolean(), randomLongOrOccasionallyNull( propertyBits ), random.nextLong( entityBits ), random.nextLong( entityBits ), randomInt( tokenBits ), randomLongOrOccasionallyNull( entityBits ), randomLongOrOccasionallyNull( entityBits ), randomLongOrOccasionallyNull( entityBits ), randomLongOrOccasionallyNull( entityBits ), random.nextBoolean(), random.nextBoolean() ); }
private static RelationshipRecord relationship( long id, long startNodeId, long endNodeId ) { return new RelationshipRecord( id ).initialize( true, Record.NO_NEXT_PROPERTY.longValue(), startNodeId, endNodeId, 0, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), false, false ); } }
public static RelationshipCommand createRelationship( long id, long startNode, long endNode, int type ) { RelationshipRecord before = new RelationshipRecord( id ); before.setInUse( false ); RelationshipRecord after = new RelationshipRecord( id, startNode, endNode, type ); after.setInUse( true ); after.setCreated(); return new RelationshipCommand( before, after ); }
@Test public void useVariableLengthFormatWhenAtLeastOneOfTheReferencesIsTooBig() throws IOException { RelationshipRecord source = new RelationshipRecord( 1 ); RelationshipRecord target = new RelationshipRecord( 1 ); verifyRecordsWithPoisonedReference( source, target, 1L << Integer.SIZE + 5, randomType() ); }
public void delete( RelationshipRecord record ) { record.setInUse( false ); add( record, new RelationshipRecord( record.getId() ) ); }
@Test public void useVariableLengthFormatWhenTypeIsTooBig() throws IOException { RelationshipRecord source = new RelationshipRecord( 1 ); RelationshipRecord target = new RelationshipRecord( 1 ); source.initialize( true, randomFixedReference(), randomFixedReference(), randomFixedReference(), 1 << 16, randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference(), true, true ); writeReadRecord( source, target ); assertFalse( "Record should use variable length format.", target.isUseFixedReferences() ); verifySameReferences( source, target); }
@Test public void useFixedRecordFormatWhenAtLeastOneOfTheReferencesIsMissing() throws IOException { RelationshipRecord source = new RelationshipRecord( 1 ); RelationshipRecord target = new RelationshipRecord( 1 ); verifyRecordsWithPoisonedReference( source, target, NULL, randomShortType() ); }
@Test public void useFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord() throws IOException { RelationshipRecord source = new RelationshipRecord( 1 ); RelationshipRecord target = new RelationshipRecord( 1 ); source.initialize( true, randomFixedReference(), randomFixedReference(), randomFixedReference(), randomShortType(), randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference(), true, true ); writeReadRecord( source, target, RelationshipRecordFormat.FIXED_FORMAT_RECORD_SIZE ); assertTrue( "Record should use fixed reference if can fit in format record.", target.isUseFixedReferences() ); verifySameReferences( source, target); }