@Override public void check( DynamicRecord record, CheckerEngine<DynamicRecord, DynamicLabelConsistencyReport> engine, RecordAccess records ) { if ( record.inUse() && record.isStartRecord() ) { Long ownerId = readOwnerFromDynamicLabelsRecord( record ); if ( null == ownerId ) { // no owner but in use indicates a broken record engine.report().orphanDynamicLabelRecord(); } else { // look at owning node record to verify consistency engine.comparativeCheck( records.node( ownerId ), VALID_NODE_RECORD ); } } }
@Test public void shouldReadFirstFromSingleRecordDynamicLongArray() { // GIVEN Long expectedId = 12L; long[] ids = new long[]{expectedId, 23L, 42L}; DynamicRecord firstRecord = new DynamicRecord( 0L ); allocateFromNumbers( new ArrayList<>(), ids, new ReusableRecordsAllocator( 60, firstRecord ) ); // WHEN Long firstId = readOwnerFromDynamicLabelsRecord( firstRecord ); // THEN assertEquals( expectedId, firstId ); }
@Test public void shouldReadFirstAsNullFromEmptyDynamicLongArray() { // GIVEN Long expectedId = null; long[] ids = new long[]{}; DynamicRecord firstRecord = new DynamicRecord( 0L ); allocateFromNumbers( new ArrayList<>(), ids, new ReusableRecordsAllocator( 60, firstRecord ) ); // WHEN Long firstId = readOwnerFromDynamicLabelsRecord( firstRecord ); // THEN assertEquals( expectedId, firstId ); }
@Test public void shouldReadFirstFromTwoRecordDynamicLongArray() { // GIVEN Long expectedId = 12L; long[] ids = new long[]{expectedId, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L}; DynamicRecord firstRecord = new DynamicRecord( 0L ); allocateFromNumbers( new ArrayList<>(), ids, new ReusableRecordsAllocator( 8, firstRecord, new DynamicRecord( 1L ) ) ); // WHEN Long firstId = readOwnerFromDynamicLabelsRecord( firstRecord ); // THEN assertEquals( expectedId, firstId ); }