use of org.pentaho.metastore.api.IMetaStore in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testBuilderBuildWrongServiceName.
@Test(expected = KettleException.class)
public void testBuilderBuildWrongServiceName() throws Exception {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME2);
IMetaStore metastore = mock(IMetaStore.class);
new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).enableMetrics(false).normalizeConditions(false).rowLimit(50).build();
}
use of org.pentaho.metastore.api.IMetaStore in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testWaitUntilFinishedStreaming.
@Test
public void testWaitUntilFinishedStreaming() 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).rowLimit(1).timeLimit(10000).windowMode(IDataServiceClientService.StreamingMode.ROW_BASED).windowSize(1).windowEvery(0).windowLimit(0).build();
when(genTrans.isFinishedOrStopped()).thenAnswer(new Answer<Boolean>() {
int numberThreadSleeps = 3;
@Override
public Boolean answer(InvocationOnMock invocationOnMock) throws Throwable {
return numberThreadSleeps-- <= 0;
}
});
executor.waitUntilFinished();
verify(genTrans, times(4)).isFinishedOrStopped();
when(genTrans.isFinishedOrStopped()).thenReturn(true);
executor.waitUntilFinished();
verify(genTrans, times(5)).isFinishedOrStopped();
}
use of org.pentaho.metastore.api.IMetaStore 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.metastore.api.IMetaStore 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();
}
use of org.pentaho.metastore.api.IMetaStore in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testBuilderBuildStreamingServiceContext.
@Test
public void testBuilderBuildStreamingServiceContext() throws Exception {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
when(serviceTransExecutor.getServiceTrans()).thenReturn(serviceTrans);
when(serviceTransExecutor.getId()).thenReturn(DATA_SERVICE_NAME);
context.addServiceTransExecutor(serviceTransExecutor);
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();
verify(serviceTransExecutor).getServiceTrans();
assertSame(executor.getServiceTrans(), serviceTrans);
}
Aggregations