use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testStop.
@Test
public void testStop() throws KettleException {
String sql = "SELECT * FROM " + DATA_SERVICE_NAME;
when(serviceTrans.isRunning()).thenReturn(true);
when(genTrans.isRunning()).thenReturn(true);
DataServiceExecutor executor = new DataServiceExecutor.Builder(new SQL(sql), dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).build();
executor.stop();
verify(serviceTrans).stopAll();
verify(genTrans).stopAll();
}
use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testHasErrors.
@Test
public void testHasErrors() throws KettleException {
String sql = "SELECT * FROM " + DATA_SERVICE_NAME;
when(serviceTrans.isRunning()).thenReturn(true);
when(genTrans.isRunning()).thenReturn(true);
when(sqlTransGenerator.getRowLimit()).thenReturn(999);
DataServiceExecutor executor = new DataServiceExecutor.Builder(new SQL(sql), dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).build();
assertFalse(executor.hasErrors());
when(serviceTrans.getErrors()).thenReturn(1);
when(genTrans.getErrors()).thenReturn(1);
assertTrue(executor.hasErrors());
when(serviceTrans.getErrors()).thenReturn(0);
when(genTrans.getErrors()).thenReturn(1);
assertTrue(executor.hasErrors());
when(serviceTrans.getErrors()).thenReturn(1);
when(genTrans.getErrors()).thenReturn(0);
assertTrue(executor.hasErrors());
}
use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testStopStreaming.
@Test
public void testStopStreaming() throws KettleException {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
when(serviceTrans.getTransMeta().listParameters()).thenReturn(new String[0]);
when(sqlTransGenerator.getSql()).thenReturn(sql);
PushDownOptimizationMeta optimization = mock(PushDownOptimizationMeta.class);
when(optimization.isEnabled()).thenReturn(true);
dataService.getPushDownOptimizationMeta().add(optimization);
dataService.setStreaming(true);
IMetaStore metastore = mock(IMetaStore.class);
DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).windowMode(IDataServiceClientService.StreamingMode.ROW_BASED).windowSize(1).windowEvery(0).windowLimit(0).build();
executor.stop();
verify(serviceTrans, times(0)).stopAll();
verify(genTrans, times(0)).stopAll();
}
use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testNullNotNullKeywords.
@Test
public void testNullNotNullKeywords() throws Exception {
String sql = "SELECT * FROM " + DATA_SERVICE_NAME + " WHERE column1 IS NOT NULL AND column2 IS NULL";
DataServiceExecutor executor = new DataServiceExecutor.Builder(new SQL(sql), dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).build();
Condition condition = executor.getSql().getWhereCondition().getCondition();
Condition condition1 = condition.getCondition(0);
Condition condition2 = condition.getCondition(1);
assertEquals("column1", condition1.getLeftValuename());
assertNull(condition1.getRightExact());
assertEquals(Condition.FUNC_NOT_NULL, condition1.getFunction());
assertEquals("column2", condition2.getLeftValuename());
assertNull(condition2.getRightExact());
assertEquals(Condition.FUNC_NULL, condition2.getFunction());
}
use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testBuilderBuildNullServiceTransformation.
@Test(expected = KettleException.class)
public void testBuilderBuildNullServiceTransformation() throws Exception {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
dataService.setName(DATA_SERVICE_NAME);
dataService.setServiceTrans(null);
IMetaStore metastore = mock(IMetaStore.class);
new DataServiceExecutor.Builder(sql, dataService, context).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).enableMetrics(false).normalizeConditions(false).rowLimit(50).build();
}
Aggregations