Search in sources :

Example 1 with ForbiddenUserException

use of com.marklogic.client.ForbiddenUserException 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

DatabaseClient (com.marklogic.client.DatabaseClient)1 DatabaseClientFactory (com.marklogic.client.DatabaseClientFactory)1 ForbiddenUserException (com.marklogic.client.ForbiddenUserException)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 MarkLogicInputProperties (org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties)1