use of org.pentaho.metastore.api.IMetaStore in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testWaitUntilFinished.
@Test
public void testWaitUntilFinished() throws Exception {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
when(serviceTrans.getTransMeta().listParameters()).thenReturn(new String[0]);
PushDownOptimizationMeta optimization = mock(PushDownOptimizationMeta.class);
when(optimization.isEnabled()).thenReturn(true);
dataService.getPushDownOptimizationMeta().add(optimization);
IMetaStore metastore = mock(IMetaStore.class);
DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).build();
executor.waitUntilFinished();
verify(genTrans, times(0)).isFinishedOrStopped();
verify(serviceTrans, times(1)).waitUntilFinished();
}
use of org.pentaho.metastore.api.IMetaStore in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testBuilderBuildNullQueryServiceName.
@Test(expected = KettleException.class)
public void testBuilderBuildNullQueryServiceName() throws Exception {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
dataService.setName(null);
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 testRowLimitAux.
private StreamingServiceTransExecutor testRowLimitAux(int userLimit, int metaLimit, String kettleLimit) throws Exception {
when(genTrans.isFinishedOrStopped()).thenReturn(true);
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
when(serviceTrans.getTransMeta().listParameters()).thenReturn(new String[0]);
when(sqlTransGenerator.getSql()).thenReturn(sql);
System.setProperty(DataServiceConstants.ROW_LIMIT_PROPERTY, kettleLimit);
dataService.setStreaming(true);
dataService.setRowLimit(metaLimit);
IMetaStore metastore = mock(IMetaStore.class);
DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).rowLimit(userLimit).windowMode(IDataServiceClientService.StreamingMode.ROW_BASED).windowSize(1).windowEvery(0).windowLimit(0).build();
StreamingServiceTransExecutor exec = context.getServiceTransExecutor(dataService.getName());
context.removeServiceTransExecutor(dataService.getName());
return exec;
}
use of org.pentaho.metastore.api.IMetaStore in project pdi-dataservice-server-plugin by pentaho.
the class ExecutorQueryServiceTest method testQueryBuildsWithMetastore.
@Test
public void testQueryBuildsWithMetastore() throws Exception {
final DataServiceFactory factory = mock(DataServiceFactory.class);
final DataServiceContext context = mock(DataServiceContext.class);
final DataServiceResolver dataServiceResolver = mock(DataServiceResolver.class);
final DataServiceExecutor dataServiceExecutor = mock(DataServiceExecutor.class);
final Trans serviceTrans = mock(Trans.class);
final Trans genTrans = mock(Trans.class);
when(context.getMetaStoreUtil()).thenReturn(factory);
DataServiceExecutor.Builder builder = mock(DataServiceExecutor.Builder.class);
final IMetaStore metastore = mock(IMetaStore.class);
final MetastoreLocator metastoreLocator = mock(MetastoreLocator.class);
when(metastoreLocator.getMetastore()).thenReturn(metastore);
SQL sql = new SQL("select field from table");
HashMap<String, String> parameters = new HashMap<>();
int rowLimit = 5432;
ExecutorQueryService executorQueryService = new ExecutorQueryService(dataServiceResolver, metastoreLocator);
when(dataServiceResolver.createBuilder(argThat(matchesSql(sql)))).thenReturn(builder);
when(factory.getMetaStore()).thenReturn(metastore);
when(builder.rowLimit(rowLimit)).thenReturn(builder);
when(builder.parameters(parameters)).thenReturn(builder);
when(builder.metastore(metastore)).thenReturn(builder);
when(builder.windowMode(null)).thenReturn(builder);
when(builder.windowSize(0)).thenReturn(builder);
when(builder.windowEvery(0)).thenReturn(builder);
when(builder.windowLimit(0)).thenReturn(builder);
when(builder.build()).thenReturn(dataServiceExecutor);
when(dataServiceExecutor.getServiceTrans()).thenReturn(serviceTrans);
when(dataServiceExecutor.getGenTrans()).thenReturn(genTrans);
Query result = executorQueryService.prepareQuery(sql.getSqlString(), rowLimit, parameters);
assertEquals(ImmutableList.of(serviceTrans, genTrans), result.getTransList());
verify(builder).rowLimit(rowLimit);
verify(builder).parameters(parameters);
verify(builder).metastore(metastore);
}
use of org.pentaho.metastore.api.IMetaStore in project pdi-dataservice-server-plugin by pentaho.
the class TransImportExtensionPointPluginTest method callExtensionPoint.
@Test
public void callExtensionPoint() throws Exception {
DataServiceReferenceSynchronizer referenceSynchronizer = mock(DataServiceReferenceSynchronizer.class);
TransMeta transMeta = mock(TransMeta.class);
Repository transRepository = mock(Repository.class);
IMetaStore transMetaStore = mock(IMetaStore.class);
when(transRepository.getMetaStore()).thenReturn(transMetaStore);
when(transMeta.getRepository()).thenReturn(transRepository);
when(transMeta.getMetaStore()).thenReturn(transMetaStore);
TransImportExtensionPointPlugin plugin = new TransImportExtensionPointPlugin(referenceSynchronizer);
LogChannelInterface log = mock(LogChannelInterface.class);
plugin.callExtensionPoint(log, null);
verify(referenceSynchronizer, times(0)).sync(same(transMeta), any(Function.class), eq(true));
plugin.callExtensionPoint(log, "Not TransMeta");
verify(referenceSynchronizer, times(0)).sync(same(transMeta), any(Function.class), eq(true));
plugin.callExtensionPoint(log, transMeta);
ArgumentCaptor<Function> exceptionHandlerCaptor = ArgumentCaptor.forClass(Function.class);
verify(referenceSynchronizer).sync(same(transMeta), exceptionHandlerCaptor.capture(), eq(true));
Exception e = new Exception();
exceptionHandlerCaptor.getValue().apply(e);
verify(log).logError(anyString(), same(e));
DataServiceMeta dsMeta = mock(DataServiceMeta.class);
DataServiceAlreadyExistsException dsaee = new DataServiceAlreadyExistsException(dsMeta);
exceptionHandlerCaptor.getValue().apply(dsaee);
verify(log).logBasic(anyString());
}
Aggregations