Search in sources :

Example 1 with MarkLogicInputProperties

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

the class MarkLogicSourceOrSinkTest method testIntegerAvroTypeNotSupported.

@Test(expected = MarkLogicException.class)
public void testIntegerAvroTypeNotSupported() {
    MarkLogicInputProperties testInputProperties = new MarkLogicInputProperties("inputProperties");
    testInputProperties.init();
    Schema bytesSchema = prepareSchema(AvroUtils._int(), null);
    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 2 with MarkLogicInputProperties

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

the class MarkLogicSourceOrSinkTest method testGetMarkLogicConnectionProperties.

@Test
public void testGetMarkLogicConnectionProperties() {
    MarkLogicInputProperties expectedInputProperties = new MarkLogicInputProperties("inputProperties");
    expectedInputProperties.init();
    sourceOrSink.initialize(null, expectedInputProperties);
    MarkLogicConnectionProperties actualConnectionProperties = sourceOrSink.getMarkLogicConnectionProperties();
    assertEquals(expectedInputProperties.connection, actualConnectionProperties);
}
Also used : MarkLogicConnectionProperties(org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with MarkLogicInputProperties

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

the class MarkLogicSourceOrSinkTest method testDocContentStringTypeSupported.

@Test
public void testDocContentStringTypeSupported() {
    MarkLogicInputProperties testInputProperties = new MarkLogicInputProperties("inputProperties");
    testInputProperties.init();
    Schema stringSchema = prepareSchema(AvroUtils._string(), null);
    testInputProperties.inputSchema.schema.setValue(stringSchema);
    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 4 with MarkLogicInputProperties

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

the class MarkLogicSourceOrSinkTest method testIntegerTalendTypeNotSupported.

@Test(expected = MarkLogicException.class)
public void testIntegerTalendTypeNotSupported() {
    MarkLogicInputProperties testInputProperties = new MarkLogicInputProperties("inputProperties");
    testInputProperties.init();
    Schema bytesSchema = prepareSchema(AvroUtils._short(), "id_Integer");
    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 5 with MarkLogicInputProperties

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

the class MarkLogicSourceOrSinkTest method testValidateCannotConnect.

@Test
public void testValidateCannotConnect() {
    DatabaseClient mockedClient = mock(DatabaseClient.class);
    when(mockedClient.openTransaction()).thenThrow(new ForbiddenUserException("User not allowed"));
    PowerMockito.mockStatic(DatabaseClientFactory.class);
    when(DatabaseClientFactory.newClient(anyString(), anyInt(), anyString(), (DatabaseClientFactory.SecurityContext) anyObject())).thenReturn(mockedClient);
    MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProperties");
    sourceOrSink.initialize(null, inputProperties);
    assertEquals(Result.ERROR, sourceOrSink.validate(null).getStatus());
}
Also used : DatabaseClient(com.marklogic.client.DatabaseClient) DatabaseClientFactory(com.marklogic.client.DatabaseClientFactory) ForbiddenUserException(com.marklogic.client.ForbiddenUserException) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) 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