use of org.talend.components.marklogic.tmarklogicoutput.MarkLogicOutputProperties in project components by Talend.
the class MarkLogicWriterTest method testInitDocManagerJSON.
@Test
public void testInitDocManagerJSON() throws IOException {
MarkLogicSink sink = new MarkLogicSink();
MarkLogicOutputProperties properties = new MarkLogicOutputProperties("outputProperties");
properties.init();
properties.connection.referencedComponent.componentInstanceId.setValue("Not null value");
properties.docType.setValue(MarkLogicOutputProperties.DocType.JSON);
sink.ioProperties = properties;
RuntimeContainer mockedContainer = mock(RuntimeContainer.class);
DatabaseClient mockedClient = mock(DatabaseClient.class);
Mockito.when(mockedContainer.getComponentData(anyString(), anyString())).thenReturn(mockedClient);
writer = sink.createWriteOperation().createWriter(mockedContainer);
writer.open("123");
verify(mockedClient).newJSONDocumentManager();
}
use of org.talend.components.marklogic.tmarklogicoutput.MarkLogicOutputProperties in project components by Talend.
the class MarkLogicWriteOperationTest method setUp.
@Before
public void setUp() {
sink = new MarkLogicSink();
MarkLogicOutputProperties outputProperties = new MarkLogicOutputProperties("outputProperties");
writeOperation = new MarkLogicWriteOperation(sink, outputProperties);
}
use of org.talend.components.marklogic.tmarklogicoutput.MarkLogicOutputProperties in project components by Talend.
the class MarkLogicInputSinkTest method testValidateWrongProperties.
@Test
public void testValidateWrongProperties() {
MarkLogicOutputProperties wrongProperties = new MarkLogicOutputProperties("notInputProps");
wrongProperties.init();
inputSink.initialize(null, wrongProperties);
ValidationResult result = inputSink.validate(null);
assertEquals(ValidationResult.Result.ERROR, result.getStatus());
}
use of org.talend.components.marklogic.tmarklogicoutput.MarkLogicOutputProperties in project components by Talend.
the class MarkLogicWriterTest method testFailedInitDocManager.
@Test
public void testFailedInitDocManager() throws IOException {
MarkLogicSink sink = mock(MarkLogicSink.class);
MarkLogicOutputProperties properties = new MarkLogicOutputProperties("outputProperties");
properties.init();
MarkLogicWriteOperation writeOperation = new MarkLogicWriteOperation(sink, properties);
Mockito.when(sink.connect((RuntimeContainer) anyObject())).thenReturn(null);
writer = writeOperation.createWriter(null);
writer.open("123");
assertNull(writer.docMgr);
}
use of org.talend.components.marklogic.tmarklogicoutput.MarkLogicOutputProperties in project components by Talend.
the class MarkLogicWriterTest method prepareDocManagerText.
private DocumentManager prepareDocManagerText(MarkLogicOutputProperties.Action action, MarkLogicOutputProperties.DocType docType, Object docContent) throws IOException {
MarkLogicSink sink = new MarkLogicSink();
MarkLogicOutputProperties properties = new MarkLogicOutputProperties("outputProperties");
properties.init();
properties.connection.referencedComponent.componentInstanceId.setValue("Not null value");
properties.docType.setValue(docType);
properties.action.setValue(action);
sink.ioProperties = properties;
RuntimeContainer mockedContainer = mock(RuntimeContainer.class);
DatabaseClient mockedClient = mock(DatabaseClient.class);
Mockito.when(mockedContainer.getComponentData(anyString(), anyString())).thenReturn(mockedClient);
DocumentManager markLogicDocMngrMock = mock(DocumentManager.class);
writer = sink.createWriteOperation().createWriter(mockedContainer);
GenericData.Record indexedRecord = new GenericData.Record(properties.datasetProperties.main.schema.getValue());
indexedRecord.put(0, "docId");
indexedRecord.put(1, docContent);
writer.open("123");
writer.docMgr = markLogicDocMngrMock;
writer.write(indexedRecord);
return markLogicDocMngrMock;
}
Aggregations