use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.
the class MarkLogicRowProcessorTest method testCloseReferencedConnectionNotReleased.
@Test
public void testCloseReferencedConnectionNotReleased() throws IOException {
DatabaseClient mockedClient = mock(DatabaseClient.class);
MarkLogicInputSink mockedSink = mock(MarkLogicInputSink.class);
MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProps");
inputProperties.init();
inputProperties.connection.referencedComponent.componentInstanceId.setValue(MarkLogicConnectionDefinition.COMPONENT_NAME + "_1");
MarkLogicInputWriteOperation writeOperation = new MarkLogicInputWriteOperation(mockedSink, inputProperties);
MarkLogicRowProcessor rowProcessor = writeOperation.createWriter(null);
when(mockedSink.connect(any(RuntimeContainer.class))).thenReturn(mockedClient);
rowProcessor.open("1");
verify(mockedClient).newDocumentManager();
rowProcessor.close();
verifyNoMoreInteractions(mockedClient);
}
use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.
the class MarkLogicRowProcessorTest method testClose.
@Test
public void testClose() 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);
String uId = "123";
rowProcessor.open(uId);
Result result = rowProcessor.close();
assertNotNull(result);
assertEquals(uId, result.getuId());
verify(mockedClient).release();
}
use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.
the class MarkLogicSourceOrSinkTest method testDocContentDocumentTypeSupported.
@Test
public void testDocContentDocumentTypeSupported() {
MarkLogicInputProperties testInputProperties = new MarkLogicInputProperties("inputProperties");
testInputProperties.init();
Schema bytesSchema = prepareSchema(AvroUtils._short(), "id_Document");
testInputProperties.datasetProperties.main.schema.setValue(bytesSchema);
sourceOrSink.checkDocContentTypeSupported(testInputProperties.datasetProperties.main);
}
use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.
the class MarkLogicSourceOrSinkTest method testDocContentBytesTypeSupported.
@Test
public void testDocContentBytesTypeSupported() {
MarkLogicInputProperties testInputProperties = new MarkLogicInputProperties("inputProperties");
testInputProperties.init();
Schema bytesSchema = prepareSchema(AvroUtils._bytes(), null);
testInputProperties.inputSchema.schema.setValue(bytesSchema);
sourceOrSink.checkDocContentTypeSupported(testInputProperties.datasetProperties.main);
}
use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.
the class MarkLogicSourceOrSinkTest method testValidateWithReferenceConnection.
@Test
public void testValidateWithReferenceConnection() {
RuntimeContainer container = mock(RuntimeContainer.class);
DatabaseClient mockedClient = mock(DatabaseClient.class);
when(container.getComponentData(anyString(), eq(MarkLogicConnection.CONNECTION))).thenReturn(mockedClient);
MarkLogicConnectionProperties connectionProperties = new MarkLogicConnectionProperties("connection");
connectionProperties.init();
MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProperties");
inputProperties.connection.referencedComponent.setReference(connectionProperties);
inputProperties.connection.referencedComponent.componentInstanceId.setValue(MarkLogicConnectionDefinition.COMPONENT_NAME + "_1");
inputProperties.init();
sourceOrSink.initialize(container, inputProperties);
ValidationResult vr = sourceOrSink.validate(container);
assertEquals(ValidationResult.Result.OK, vr.getStatus());
}
Aggregations