use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.
the class MarkLogicRowProcessorTest method testOpen.
@Test
public void testOpen() throws IOException {
DatabaseClient mockedClient = mock(DatabaseClient.class);
MarkLogicInputSink mockedSink = mock(MarkLogicInputSink.class);
MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProps");
inputProperties.init();
MarkLogicInputWriteOperation writeOperation = new MarkLogicInputWriteOperation(mockedSink, inputProperties);
MarkLogicRowProcessor rowProcessor = writeOperation.createWriter(null);
when(mockedSink.connect(any(RuntimeContainer.class))).thenReturn(mockedClient);
rowProcessor.open("123");
assertNotNull(rowProcessor.docContentReader);
}
use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.
the class MarkLogicRowProcessorTest method testWriteCorrectRecord.
@Test
public void testWriteCorrectRecord() throws IOException {
MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProps");
inputProperties.init();
inputProperties.docIdColumn.setValue(inputProperties.datasetProperties.main.schema.getValue().getFields().get(0).name());
MarkLogicInputSink inputSink = new MarkLogicInputSink();
MarkLogicInputWriteOperation inputWriteOperation = new MarkLogicInputWriteOperation(inputSink, inputProperties);
MarkLogicRowProcessor rowProcessor = inputWriteOperation.createWriter(null);
DocContentReader mockedDocContentReader = mock(DocContentReader.class);
rowProcessor.docContentReader = mockedDocContentReader;
GenericData.Record correctRecord = new GenericData.Record(inputProperties.datasetProperties.main.schema.getValue());
correctRecord.put(0, "docId");
rowProcessor.write(correctRecord);
verify(mockedDocContentReader).readDocument("docId");
assertTrue(((ArrayList<IndexedRecord>) rowProcessor.getSuccessfulWrites()).size() > 0);
}
use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.
the class MarkLogicRowProcessorTest method testCloseResult.
@Test
public void testCloseResult() throws IOException {
MarkLogicInputSink sink = new MarkLogicInputSink();
// set reference connection to avoid closing
MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProps");
inputProperties.init();
inputProperties.connection.referencedComponent.componentInstanceId.setValue(MarkLogicConnectionDefinition.COMPONENT_NAME + "_1");
MarkLogicInputWriteOperation writeOperation = new MarkLogicInputWriteOperation(sink, inputProperties);
MarkLogicRowProcessor rowProcessor = writeOperation.createWriter(null);
long longNBLine = Long.MAX_VALUE;
rowProcessor.totalCounter = longNBLine;
Result longResult = rowProcessor.close();
assertTrue(longResult instanceof ResultWithLongNB);
assertEquals(longNBLine, ((ResultWithLongNB) longResult).totalCountLong);
}
Aggregations