Search in sources :

Example 6 with Query

use of org.pentaho.di.trans.dataservice.clients.Query in project pdi-dataservice-server-plugin by pentaho.

the class TransDataServletTest method testDoPut.

@Test
public void testDoPut() throws Exception {
    headers.put(HEADER_MAX_ROWS, TEST_MAX_ROWS);
    headers.put(HEADER_SQL, TEST_SQL_QUERY);
    parameters.put("PARAMETER_FOO", "BAR");
    parameters.put(PARAM_DEBUG_TRANS, debugTrans.getPath());
    Query query = mock(Query.class);
    doReturn(query).when(client).prepareQuery(TEST_SQL_QUERY, Integer.valueOf(TEST_MAX_ROWS), ImmutableMap.of("FOO", "BAR"));
    when(query.getTransList()).thenReturn(ImmutableList.of(serviceTrans, genTrans));
    when(request.getMethod()).thenReturn("POST");
    servlet.service(request, response);
    verify(logChannel, never()).logError(anyString(), (Throwable) any());
    verify(request, times(1)).getParameter(HEADER_SQL);
    verify(request, times(1)).getParameter(HEADER_MAX_ROWS);
    verify(response).setStatus(HttpServletResponse.SC_OK);
    verify(response).setContentType("binary/jdbc");
    verify(query).writeTo(outputStream);
    verify(transformationMap).addTransformation(eq(DATA_SERVICE_NAME), eq(serviceTransUUID), eq(serviceTrans), (TransConfiguration) argThat(hasProperty("transMeta", is(transMeta))));
    verify(transformationMap).addTransformation(eq(TEST_SQL_QUERY), eq(genTransUUID), eq(genTrans), (TransConfiguration) argThat(hasProperty("transMeta", is(genTransMeta))));
    Files.readLines(debugTrans, Charsets.UTF_8).contains(GEN_TRANS_XML);
}
Also used : Query(org.pentaho.di.trans.dataservice.clients.Query) Test(org.junit.Test)

Aggregations

Query (org.pentaho.di.trans.dataservice.clients.Query)6 OutputStream (java.io.OutputStream)3 Map (java.util.Map)2 Before (org.junit.Before)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 Trans (org.pentaho.di.trans.Trans)2 XulComponent (org.pentaho.ui.xul.XulComponent)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 SQL (org.pentaho.di.core.sql.SQL)1 SQLField (org.pentaho.di.core.sql.SQLField)1