Search in sources :

Example 6 with MarkLogicInputProperties

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

the class MarkLogicSourceOrSinkTest method testDocContentObjectTypeSupported.

@Test
public void testDocContentObjectTypeSupported() {
    MarkLogicInputProperties testInputProperties = new MarkLogicInputProperties("inputProperties");
    testInputProperties.init();
    Schema bytesSchema = prepareSchema(AvroUtils._short(), "id_Object");
    testInputProperties.datasetProperties.main.schema.setValue(bytesSchema);
    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 7 with MarkLogicInputProperties

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

the class MarkLogicCriteriaReaderTest method testStartWithoutDocContentField.

@Test
public void testStartWithoutDocContentField() throws IOException {
    StringQueryDefinition mockedStringQueryDefinition = mock(StringQueryDefinition.class);
    QueryManager mockedQueryManager = mock(QueryManager.class);
    when(mockedQueryManager.newStringDefinition()).thenReturn(mockedStringQueryDefinition);
    when(mockedQueryManager.newStringDefinition(anyString())).thenReturn(mockedStringQueryDefinition);
    DatabaseClient mockedClient = mock(DatabaseClient.class);
    when(mockedClient.newDocumentManager()).thenReturn(null);
    when(mockedClient.newQueryManager()).thenReturn(mockedQueryManager);
    SearchHandle searchHandle = Mockito.mock(SearchHandle.class);
    Mockito.when(mockedQueryManager.search(Mockito.eq(mockedStringQueryDefinition), Mockito.any(SearchHandle.class))).thenReturn(searchHandle);
    MarkLogicSource mockedSource = mock(MarkLogicSource.class);
    when(mockedSource.connect(any(RuntimeContainer.class))).thenReturn(mockedClient);
    MarkLogicInputProperties properties = new MarkLogicInputProperties("inputProperties");
    properties.init();
    Schema.Field docIdField = new Schema.Field("docId", AvroUtils._string(), null, (Object) null, Schema.Field.Order.IGNORE);
    properties.datasetProperties.main.schema.setValue(Schema.createRecord("docIdOnlySchema", null, null, false, Collections.singletonList(docIdField)));
    MarkLogicCriteriaReader criteriaReader = new MarkLogicCriteriaReader(mockedSource, null, properties);
    System.out.println(criteriaReader.start());
}
Also used : StringQueryDefinition(com.marklogic.client.query.StringQueryDefinition) DatabaseClient(com.marklogic.client.DatabaseClient) SearchHandle(com.marklogic.client.io.SearchHandle) Schema(org.apache.avro.Schema) QueryManager(com.marklogic.client.query.QueryManager) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) Test(org.junit.Test)

Example 8 with MarkLogicInputProperties

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

the class MarkLogicSourceTest 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);
    source.initialize(mockedContainer, inputProperties);
    ValidationResult result = source.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 9 with MarkLogicInputProperties

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

the class MarkLogicSourceTest method testCreateReader.

@Test
public void testCreateReader() {
    MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProps");
    inputProperties.init();
    source.initialize(null, inputProperties);
    MarkLogicCriteriaReader reader = source.createReader(null);
    assertNotNull(reader);
}
Also used : MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) Test(org.junit.Test)

Example 10 with MarkLogicInputProperties

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

the class MarkLogicSinkTest method testCreateWriteOperationWithWrongProperties.

@Test(expected = MarkLogicException.class)
public void testCreateWriteOperationWithWrongProperties() {
    MarkLogicInputProperties fakeOutputProperties = new MarkLogicInputProperties("fakeOutProps");
    sink.initialize(null, fakeOutputProperties);
    sink.createWriteOperation();
}
Also used : 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