use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRealTest method testServiceTransKeepsRunningWhenDataServiceIsNotUserDefined.
@Test
public void testServiceTransKeepsRunningWhenDataServiceIsNotUserDefined() throws Exception {
TransMeta transMeta = new TransMeta(getClass().getResource("/GenerateOneMillion.ktr").getPath());
DataServiceMeta dataServiceMeta = new DataServiceMeta(transMeta);
dataServiceMeta.setName("table");
dataServiceMeta.setStepname("Delay Row");
dataServiceMeta.setUserDefined(false);
PentahoCacheSystemConfiguration systemConfiguration = new PentahoCacheSystemConfiguration();
systemConfiguration.setData(new HashMap<>());
PentahoCacheManagerImpl pentahoCacheManager = new PentahoCacheManagerImpl(systemConfiguration, new HeapCacheProvidingService());
ServiceCacheFactory cacheFactory = new ServiceCacheFactory(pentahoCacheManager, Executors.newSingleThreadExecutor());
DataServiceContext dataServiceContext = new DataServiceContext(singletonList(cacheFactory), emptyList(), pentahoCacheManager, new UIFactory(), new LogChannel(""));
SQL countSql = new SQL("select count(*) from table");
DataServiceExecutor countExecutor = new DataServiceExecutor.Builder(countSql, dataServiceMeta, dataServiceContext).build();
countExecutor.executeQuery();
SQL limitSql = new SQL("select field1,field2 from table limit 5");
DataServiceExecutor limitExecutor = new DataServiceExecutor.Builder(limitSql, dataServiceMeta, dataServiceContext).build();
limitExecutor.executeQuery();
limitExecutor.waitUntilFinished();
assertTrue(countExecutor.getGenTrans().isRunning());
assertTrue(countExecutor.getServiceTrans().isRunning());
countExecutor.getServiceTrans().stopAll();
}
use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testIsComplete.
@Test
public void testIsComplete() throws KettleException {
String sql = "SELECT * FROM " + DATA_SERVICE_NAME;
when(genTrans.isStopped()).thenReturn(true);
DataServiceExecutor executor = new DataServiceExecutor.Builder(new SQL(sql), dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).build();
assertTrue(executor.isStopped());
}
use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testMutatorGetsCalled.
@Test
public void testMutatorGetsCalled() throws Exception {
when(serviceTransMeta.realClone(false)).thenReturn(serviceTransMeta);
when(serviceTransMeta.listVariables()).thenReturn(new String[] {});
when(serviceTransMeta.listParameters()).thenReturn(new String[] {});
new DataServiceExecutor.Builder(new SQL("SELECT * FROM " + DATA_SERVICE_NAME), dataService, context).serviceTransMutator(mutator).serviceTrans(serviceTransMeta);
Mockito.verify(mutator).accept(dataService.getStepname(), serviceTransMeta);
}
use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testWaitInterruptedException.
@Test(expected = RuntimeException.class)
public void testWaitInterruptedException() throws Exception {
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();
doThrow(InterruptedException.class).when(genTrans).isFinishedOrStopped();
executor.waitUntilFinished();
}
use of org.pentaho.di.core.sql.SQL in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testBuilderBuildServiceServiceTransNotNull.
@Test
public void testBuilderBuildServiceServiceTransNotNull() throws Exception {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
RowMeta rowMeta = new RowMeta();
ValueMetaInterface vm = new ValueMetaString("aBinaryStoredString");
vm.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
vm.setStorageMetadata(new ValueMetaString());
rowMeta.addValueMeta(vm);
when(serviceTrans.getTransMeta()).thenReturn(serviceTransMeta);
when(serviceTransMeta.realClone(false)).thenReturn(serviceTransMeta);
when(serviceTransMeta.listVariables()).thenReturn(new String[] {});
when(serviceTransMeta.listParameters()).thenReturn(new String[] {});
when(serviceTransMeta.getStepFields(DATA_SERVICE_STEP)).thenReturn(rowMeta);
dataService.setServiceTrans(serviceTrans.getTransMeta());
dataService.setStreaming(true);
IMetaStore metastore = mock(IMetaStore.class);
DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).enableMetrics(false).normalizeConditions(false).rowLimit(50).build();
assertSame(dataService.getServiceTrans(), serviceTrans.getTransMeta());
}
Aggregations