Search in sources :

Example 1 with IdSequence

use of org.neo4j.kernel.impl.store.id.IdSequence 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

Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 ReusableRecordsAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)1 IdSequence (org.neo4j.kernel.impl.store.id.IdSequence)1 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)1 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)1