use of org.neo4j.helpers.progress.ProgressListener in project neo4j by neo4j.
the class EncodingIdMapperTest method shouldReportyProgressForSortAndDetect.
@Test
public void shouldReportyProgressForSortAndDetect() throws Exception {
// GIVEN
IdMapper idMapper = mapper(new StringEncoder(), Radix.STRING, NO_MONITOR);
ProgressListener progress = mock(ProgressListener.class);
idMapper.prepare(null, mock(Collector.class), progress);
// WHEN
long id = idMapper.get("123", GLOBAL);
// THEN
assertEquals(ID_NOT_FOUND, id);
verify(progress, times(3)).started(anyString());
verify(progress, times(3)).done();
}
use of org.neo4j.helpers.progress.ProgressListener in project neo4j by neo4j.
the class EncodingIdMapperTest method shouldCopeWithCollisionsBasedOnDifferentInputIds.
@Test
public void shouldCopeWithCollisionsBasedOnDifferentInputIds() throws Exception {
// GIVEN
Monitor monitor = mock(Monitor.class);
Encoder encoder = mock(Encoder.class);
when(encoder.encode(any())).thenReturn(12345L);
IdMapper mapper = mapper(encoder, Radix.STRING, monitor);
InputIterable<Object> ids = wrap("source", Arrays.<Object>asList("10", "9"));
try (ResourceIterator<Object> iterator = ids.iterator()) {
for (int i = 0; iterator.hasNext(); i++) {
mapper.put(iterator.next(), i, GLOBAL);
}
}
// WHEN
ProgressListener progress = mock(ProgressListener.class);
Collector collector = mock(Collector.class);
mapper.prepare(ids, collector, progress);
// THEN
verifyNoMoreInteractions(collector);
verify(monitor).numberOfCollisions(2);
assertEquals(0L, mapper.get("10", GLOBAL));
assertEquals(1L, mapper.get("9", GLOBAL));
// 7 times since SPLIT+SORT+DETECT+RESOLVE+SPLIT+SORT,DEDUPLICATE
verify(progress, times(7)).started(anyString());
verify(progress, times(7)).done();
}
Aggregations