Search in sources :

Example 16 with ReusableRecordsAllocator

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.

the class NodeRecordTest method shouldToStringBothUsedAndUnusedDynamicLabelRecords.

@Test
public void shouldToStringBothUsedAndUnusedDynamicLabelRecords() throws Exception {
    // GIVEN
    IdSequence ids = mock(IdSequence.class);
    when(ids.nextId()).thenReturn(1L, 2L);
    ReusableRecordsAllocator recordAllocator = new ReusableRecordsAllocator(30, new DynamicRecord(1), new DynamicRecord(2));
    NodeRecord node = newUsedNodeRecord(0);
    long labelId = 10_123;
    // A dynamic label record
    Collection<DynamicRecord> existing = allocateRecordsForDynamicLabels(node.getId(), new long[] { labelId }, recordAllocator);
    // and a deleted one as well (simulating some deleted labels)
    DynamicRecord unused = newDeletedDynamicRecord(ids.nextId());
    unused.setInUse(false);
    existing.add(unused);
    node.setLabelField(dynamicPointer(existing), existing);
    // WHEN
    String toString = node.toString();
    // THEN
    assertThat(toString, containsString(String.valueOf(labelId)));
    assertThat(toString, containsString(unused.toString()));
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) IdSequence(org.neo4j.kernel.impl.store.id.IdSequence) Matchers.containsString(org.hamcrest.Matchers.containsString) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator) Test(org.junit.Test)

Aggregations

ReusableRecordsAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)16 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)16 Test (org.junit.Test)13 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)10 ArrayList (java.util.ArrayList)4 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)4 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)4 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)4 Collection (java.util.Collection)3 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)3 DynamicLabelConsistencyReport (org.neo4j.consistency.report.ConsistencyReport.DynamicLabelConsistencyReport)3 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)3 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Applier (org.neo4j.consistency.checking.GraphStoreFixture.Applier)1 IdSequence (org.neo4j.kernel.impl.store.id.IdSequence)1 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)1