Search in sources :

Example 16 with MarkLogicInputProperties

use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.

the class MarkLogicSourceOrSinkTest method testInitializeOKInputProperties.

@Test
public void testInitializeOKInputProperties() {
    MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProperties");
    inputProperties.init();
    ValidationResult vr = sourceOrSink.initialize(null, inputProperties);
    assertEquals(ValidationResult.Result.OK, vr.getStatus());
}
Also used : ValidationResult(org.talend.daikon.properties.ValidationResult) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 17 with MarkLogicInputProperties

use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.

the class MarkLogicSourceOrSinkTest method testDocContentTypeNotExists.

@Test(expected = MarkLogicException.class)
public void testDocContentTypeNotExists() {
    MarkLogicInputProperties testInputProperties = new MarkLogicInputProperties("inputProperties");
    testInputProperties.init();
    Schema wrongSchema = AvroUtils.createEmptySchema();
    testInputProperties.datasetProperties.main.schema.setValue(wrongSchema);
    sourceOrSink.checkDocContentTypeSupported(testInputProperties.datasetProperties.main);
}
Also used : Schema(org.apache.avro.Schema) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 18 with MarkLogicInputProperties

use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.

the class MarkLogicCriteriaReaderTest method testStartWithoutConnection.

@Test
public void testStartWithoutConnection() throws IOException {
    MarkLogicSource mockedSource = mock(MarkLogicSource.class);
    when(mockedSource.connect(any(RuntimeContainer.class))).thenReturn(null);
    MarkLogicInputProperties properties = new MarkLogicInputProperties("inputProperties");
    properties.init();
    MarkLogicCriteriaReader criteriaReader = new MarkLogicCriteriaReader(mockedSource, null, properties);
    assertFalse(criteriaReader.start());
}
Also used : RuntimeContainer(org.talend.components.api.container.RuntimeContainer) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) Test(org.junit.Test)

Example 19 with MarkLogicInputProperties

use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.

the class MarkLogicInputSinkTest method testValidate.

@Test
public void testValidate() {
    MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProps");
    inputProperties.init();
    inputProperties.connection.referencedComponent.componentInstanceId.setValue("some value");
    RuntimeContainer mockedContainer = mock(RuntimeContainer.class);
    DatabaseClient client = mock(DatabaseClient.class);
    when(mockedContainer.getComponentData(inputProperties.connection.getReferencedComponentId(), "connection")).thenReturn(client);
    inputSink.initialize(mockedContainer, inputProperties);
    ValidationResult result = inputSink.validate(mockedContainer);
    assertEquals(ValidationResult.Result.OK, result.getStatus());
}
Also used : DatabaseClient(com.marklogic.client.DatabaseClient) ValidationResult(org.talend.daikon.properties.ValidationResult) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 20 with MarkLogicInputProperties

use of org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties in project components by Talend.

the class MarkLogicRowProcessorTest method testWriteWithoutDocIdField.

@Test(expected = MarkLogicException.class)
public void testWriteWithoutDocIdField() throws IOException {
    MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProps");
    inputProperties.init();
    inputProperties.inputSchema.schema.setValue(AvroUtils.createEmptySchema());
    inputProperties.docIdColumn.setValue("someValue");
    MarkLogicInputSink inputSink = new MarkLogicInputSink();
    MarkLogicInputWriteOperation writeOperation = new MarkLogicInputWriteOperation(inputSink, inputProperties);
    MarkLogicRowProcessor rowProcessor = writeOperation.createWriter(null);
    GenericData.Record someRecord = new GenericData.Record(inputProperties.datasetProperties.main.schema.getValue());
    rowProcessor.write(someRecord);
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) GenericData(org.apache.avro.generic.GenericData) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)23 MarkLogicInputProperties (org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties)23 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 DatabaseClient (com.marklogic.client.DatabaseClient)8 Schema (org.apache.avro.Schema)8 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)8 ValidationResult (org.talend.daikon.properties.ValidationResult)4 GenericData (org.apache.avro.generic.GenericData)2 IndexedRecord (org.apache.avro.generic.IndexedRecord)2 Result (org.talend.components.api.component.runtime.Result)2 MarkLogicConnectionProperties (org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties)2 DatabaseClientFactory (com.marklogic.client.DatabaseClientFactory)1 ForbiddenUserException (com.marklogic.client.ForbiddenUserException)1 SearchHandle (com.marklogic.client.io.SearchHandle)1 QueryManager (com.marklogic.client.query.QueryManager)1 StringQueryDefinition (com.marklogic.client.query.StringQueryDefinition)1 ArrayList (java.util.ArrayList)1 DocContentReader (org.talend.components.marklogic.runtime.input.strategies.DocContentReader)1