use of com.torodb.core.d2r.D2RTranslator in project torodb by torodb.
the class D2RTranslationBatchFunctionTest method testApply.
@Test
public void testApply() {
D2RTranslator translator = mock(D2RTranslator.class);
CollectionData colData = mock(CollectionData.class);
KvDocument doc1 = mock(KvDocument.class);
KvDocument doc2 = mock(KvDocument.class);
given(translator.getCollectionDataAccumulator()).willReturn(colData);
given(translatorFactory.createTranslator(metaDb, batchMetaCol)).willReturn(translator);
List<KvDocument> docs = Lists.newArrayList(doc1, doc2);
//when
CollectionData result = fun.apply(docs);
//then
verify(batchMetaCol).newBatch();
verify(translator).translate(doc1);
verify(translator).translate(doc2);
verify(translator).getCollectionDataAccumulator();
verifyNoMoreInteractions(translator);
verify(translatorFactory).createTranslator(metaDb, batchMetaCol);
verifyNoMoreInteractions(translatorFactory);
assertEquals(colData, result);
}
use of com.torodb.core.d2r.D2RTranslator in project torodb by torodb.
the class D2RTranslationBatchFunction method apply.
@Override
public CollectionData apply(List<KvDocument> docs) {
metaDocCollection.newBatch();
D2RTranslator translator = translatorFactory.createTranslator(metaDatabase, metaDocCollection);
for (KvDocument doc : docs) {
translator.translate(doc);
}
return translator.getCollectionDataAccumulator();
}
Aggregations