Search in sources :

Example 1 with BatchingRelationshipTypeTokenRepository

use of org.neo4j.unsafe.impl.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository in project neo4j by neo4j.

the class RelationshipTypeCheckerStepTest method shouldReturnRelationshipTypesInDescendingOrder.

@Test
public void shouldReturnRelationshipTypesInDescendingOrder() throws Throwable {
    // GIVEN
    BatchingRelationshipTypeTokenRepository repository = mock(BatchingRelationshipTypeTokenRepository.class);
    RelationshipTypeCheckerStep step = new RelationshipTypeCheckerStep(mock(StageControl.class), DEFAULT, repository);
    Batch<InputRelationship, RelationshipRecord> relationships = batchOfRelationshipsWithRandomTypes(10, true);
    step.process(relationships, mock(BatchSender.class));
    // WHEN
    step.done();
    // THEN
    TreeSet<Integer> expected = idsOf(relationships);
    Object[] processed = step.getRelationshipTypes(100);
    int i = 0;
    for (Object expectedType : loop(expected.descendingIterator())) {
        assertEquals(expectedType, processed[i++]);
    }
}
Also used : BatchSender(org.neo4j.unsafe.impl.batchimport.staging.BatchSender) StageControl(org.neo4j.unsafe.impl.batchimport.staging.StageControl) BatchingRelationshipTypeTokenRepository(org.neo4j.unsafe.impl.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) InputRelationship(org.neo4j.unsafe.impl.batchimport.input.InputRelationship) Test(org.junit.Test)

Example 2 with BatchingRelationshipTypeTokenRepository

use of org.neo4j.unsafe.impl.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository in project neo4j by neo4j.

the class RelationshipTypeCheckerStepTest method shouldReturnRelationshipTypeIdsInReverseOrderOfTokenCreation.

private void shouldReturnRelationshipTypeIdsInReverseOrderOfTokenCreation(boolean typeIds) throws Throwable {
    // GIVEN
    BatchingRelationshipTypeTokenRepository repository = mock(BatchingRelationshipTypeTokenRepository.class);
    RelationshipTypeCheckerStep step = new RelationshipTypeCheckerStep(mock(StageControl.class), DEFAULT, repository);
    // WHEN
    Batch<InputRelationship, RelationshipRecord> relationships = batchOfRelationshipsWithRandomTypes(10, typeIds);
    step.process(relationships, mock(BatchSender.class));
    step.done();
    // THEN
    Object[] processed = step.getRelationshipTypes(100);
    InOrder inOrder = inOrder(repository);
    for (Object type : reversed(processed)) {
        inOrder.verify(repository).getOrCreateId(type);
    }
    inOrder.verifyNoMoreInteractions();
}
Also used : BatchSender(org.neo4j.unsafe.impl.batchimport.staging.BatchSender) StageControl(org.neo4j.unsafe.impl.batchimport.staging.StageControl) InOrder(org.mockito.InOrder) BatchingRelationshipTypeTokenRepository(org.neo4j.unsafe.impl.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) InputRelationship(org.neo4j.unsafe.impl.batchimport.input.InputRelationship)

Aggregations

RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)2 InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)2 BatchSender (org.neo4j.unsafe.impl.batchimport.staging.BatchSender)2 StageControl (org.neo4j.unsafe.impl.batchimport.staging.StageControl)2 BatchingRelationshipTypeTokenRepository (org.neo4j.unsafe.impl.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository)2 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1