Search in sources :

Example 31 with IMetaStore

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();
}
Also used : IMetaStore(org.pentaho.metastore.api.IMetaStore) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 32 with IMetaStore

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();
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Matchers.anyBoolean(org.mockito.Matchers.anyBoolean) IMetaStore(org.pentaho.metastore.api.IMetaStore) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 33 with IMetaStore

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();
}
Also used : PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 34 with IMetaStore

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();
}
Also used : IMetaStore(org.pentaho.metastore.api.IMetaStore) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 35 with IMetaStore

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);
}
Also used : IMetaStore(org.pentaho.metastore.api.IMetaStore) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Aggregations

IMetaStore (org.pentaho.metastore.api.IMetaStore)75 Test (org.junit.Test)55 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)20 SQL (org.pentaho.di.core.sql.SQL)17 Repository (org.pentaho.di.repository.Repository)17 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)11 TransMeta (org.pentaho.di.trans.TransMeta)11 Matchers.anyString (org.mockito.Matchers.anyString)10 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)10 StepMeta (org.pentaho.di.trans.step.StepMeta)10 KettleException (org.pentaho.di.core.exception.KettleException)9 IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)9 Node (org.w3c.dom.Node)8 ArrayList (java.util.ArrayList)7 Variables (org.pentaho.di.core.variables.Variables)7 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)7 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)7 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)6 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)5 StringObjectId (org.pentaho.di.repository.StringObjectId)5