Search in sources :

Example 46 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class TransientResolverTest method testBuildStreamingTransient.

@Test
public void testBuildStreamingTransient() throws Exception {
    RepositoryDirectoryInterface directory = mock(RepositoryDirectoryInterface.class);
    when(root.findDirectory("\\path\\to")).thenReturn(directory);
    when(repository.getTransformationID("name", directory)).thenReturn(objectId);
    when(repository.loadTransformation(objectId, null)).thenReturn(transMeta);
    String transientId = TransientResolver.buildTransient("\\path\\to\\name", "streaming:data_service");
    String[] parts = transientResolver.splitTransient(transientId);
    assertEquals(parts.length, 2);
    DataServiceMeta dataServiceMeta = transientResolver.getDataService(transientId);
    assertEquals(dataServiceMeta.getStepname(), "data_service");
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) Test(org.junit.Test)

Example 47 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class TransientResolverTest method testGetLocalDataService.

@Test
public void testGetLocalDataService() throws Exception {
    File localFolder = temporaryFolder.newFolder("local");
    File localFile = new File(localFolder, "name.ktr");
    Files.write(transMeta.getXML().getBytes(StandardCharsets.UTF_8), localFile);
    String transientId = TransientResolver.buildTransient(localFile.getPath(), "data_service");
    when(repository.getTransformationID(any(), eq(root))).thenThrow(new KettleException());
    DataServiceMeta dataServiceMeta = transientResolver.getDataService(transientId);
    assertNotNull(dataServiceMeta);
    assertThat(dataServiceMeta.getStepname(), is("data_service"));
    assertFalse(dataServiceMeta.isUserDefined());
    assertThat(dataServiceMeta, hasServiceCacheOptimization());
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) File(java.io.File) Test(org.junit.Test)

Example 48 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class TransientResolverTest method testBuildLocalTransient.

@Test
public void testBuildLocalTransient() throws Exception {
    String transientId = TransientResolver.buildTransient("/path/to/file.ktr", "local:OUTPUT");
    String[] parts = transientResolver.splitTransient(transientId);
    assertEquals(parts.length, 2);
    DataServiceMeta dataServiceMeta = transientResolver.getDataService(transientId);
    assertEquals(dataServiceMeta.getStepname(), "OUTPUT");
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) Test(org.junit.Test)

Example 49 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceMetaStoreUtilTest method createDataService.

@Override
protected DataServiceMeta createDataService(String dataServiceName, TransMeta transMeta) {
    DataServiceMeta dataService = super.createDataService(dataServiceName, transMeta);
    PushDownOptimizationMeta optimization = new PushDownOptimizationMeta();
    optimization.setName(OPTIMIZATION);
    optimization.setStepName(OPTIMIZED_STEP);
    TestOptimization optimizationType = new TestOptimization();
    optimizationType.setValue(OPTIMIZATION_VALUE);
    optimization.setType(optimizationType);
    dataService.setPushDownOptimizationMeta(Lists.newArrayList(optimization));
    return dataService;
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Example 50 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRemapStepChooserDialogControllerTest method testRemap.

@Test
public void testRemap() throws Exception {
    DataServiceRemapStepChooserModel model = mock(DataServiceRemapStepChooserModel.class);
    DataServiceMeta dataService = mock(DataServiceMeta.class);
    List<String> stepNames = Arrays.asList("step1", "step2");
    DataServiceDelegate delegate = mock(DataServiceDelegate.class);
    SwtDialog dialog = mock(SwtDialog.class);
    when(model.getServiceStep()).thenReturn("step2");
    doNothing().doThrow(Exception.class).when(delegate).save(any(DataServiceMeta.class));
    DataServiceRemapStepChooserDialogController controller = spy(new DataServiceRemapStepChooserDialogController(model, dataService, stepNames, delegate));
    doReturn(dialog).when(controller).getDialog();
    controller.remap();
    verify(dataService).setStepname("step2");
    verify(delegate).save(same(dataService));
    Assert.assertEquals(DataServiceRemapStepChooserDialog.Action.REMAP, controller.getAction());
    controller.remap();
    verify(delegate).showError(anyString(), anyString());
    Assert.assertEquals(DataServiceRemapStepChooserDialog.Action.CANCEL, controller.getAction());
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) DataServiceRemapStepChooserModel(org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel) DataServiceDelegate(org.pentaho.di.trans.dataservice.ui.DataServiceDelegate) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)52 Test (org.junit.Test)29 TransMeta (org.pentaho.di.trans.TransMeta)16 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)9 KettleException (org.pentaho.di.core.exception.KettleException)8 DataServiceContext (org.pentaho.di.trans.dataservice.DataServiceContext)6 DataServiceDelegate (org.pentaho.di.trans.dataservice.ui.DataServiceDelegate)6 StepMeta (org.pentaho.di.trans.step.StepMeta)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Before (org.junit.Before)4 RowMeta (org.pentaho.di.core.row.RowMeta)4 DataServiceResolver (org.pentaho.di.trans.dataservice.resolvers.DataServiceResolver)4 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)4 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)4 MetastoreLocator (org.pentaho.osgi.metastore.locator.api.MetastoreLocator)4 ModelAnnotationGroup (org.pentaho.agilebi.modeler.models.annotations.ModelAnnotationGroup)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 File (java.io.File)2 IOException (java.io.IOException)2 URL (java.net.URL)2