Search in sources :

Example 16 with PushDownOptimizationMeta

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

the class ParameterGenerationControllerTest method testEditParameter.

@Test
public void testEditParameter() throws Exception {
    PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
    ParameterGeneration parameterGeneration = new ParameterGeneration(factory);
    parameterGeneration.setParameterName("parameterName");
    setSelected(meta, parameterGeneration);
    mockPromptBox("newParameterName", XulDialogCallback.Status.ACCEPT);
    controller.editParameter();
    assertThat(parameterGeneration.getParameterName(), equalTo("newParameterName"));
    verify(model).setSelectedParameter("newParameterName");
    verify(model).updateParameterMap();
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

Example 17 with PushDownOptimizationMeta

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

the class ParameterGenerationControllerTest method testRunAutoGenerate.

@Test
public void testRunAutoGenerate() throws Exception {
    DataServiceModel dataServiceModel = mock(DataServiceModel.class);
    when(model.getDialogModel()).thenReturn(dataServiceModel);
    AutoParameterGenerationService parameterGenerationService = mock(AutoParameterGenerationService.class);
    when(factory.createAutoOptimizationService()).thenReturn(parameterGenerationService);
    DataServiceMeta dataServiceMeta = mock(DataServiceMeta.class);
    when(dataServiceModel.getDataService()).thenReturn(dataServiceMeta);
    List<PushDownOptimizationMeta> generatedOptimizations = ImmutableList.of(mock(PushDownOptimizationMeta.class));
    when(parameterGenerationService.apply(dataServiceMeta)).thenReturn(generatedOptimizations);
    when(dataServiceModel.addAll(generatedOptimizations)).thenReturn(true);
    controller.runAutoGenerate();
    verify(dataServiceModel).addAll(generatedOptimizations);
    verify(model).updateParameterMap();
    verify(messageBox).open();
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) DataServiceModel(org.pentaho.di.trans.dataservice.ui.model.DataServiceModel) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) AutoParameterGenerationService(org.pentaho.di.trans.dataservice.optimization.paramgen.AutoParameterGenerationService) Test(org.junit.Test)

Example 18 with PushDownOptimizationMeta

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

the class ParameterGenerationControllerTest method testEditParameterFailure.

@Test
public void testEditParameterFailure() throws Exception {
    PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
    ParameterGeneration parameterGeneration = new ParameterGeneration(factory);
    parameterGeneration.setParameterName("parameterName");
    setSelected(meta, parameterGeneration);
    mockPromptBox("newParameterName", XulDialogCallback.Status.CANCEL);
    controller.editParameter();
    mockPromptBox("parameterName", XulDialogCallback.Status.ACCEPT);
    controller.editParameter();
    mockPromptBox("", XulDialogCallback.Status.ACCEPT);
    controller.editParameter();
    mockPromptBox("newParameterName", XulDialogCallback.Status.ACCEPT);
    when(model.getParameterMap()).thenReturn(ImmutableMap.of("parameterName", meta, "newParameterName", mock(PushDownOptimizationMeta.class)));
    controller.editParameter();
    assertThat(parameterGeneration.getParameterName(), equalTo("parameterName"));
    verify(model, never()).updateParameterMap();
    verify(messageBox, times(2)).setIcon(SWT.ICON_WARNING);
    verify(messageBox, times(2)).open();
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

Example 19 with PushDownOptimizationMeta

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

the class ParameterGenerationControllerTest method testRemoveParameter.

@Test
public void testRemoveParameter() throws Exception {
    PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
    ParameterGeneration parameterGeneration = new ParameterGeneration(factory);
    parameterGeneration.setParameterName("parameterName");
    setSelected(meta, parameterGeneration);
    when(messageBox.open()).thenReturn(SWT.NO);
    controller.removeParameter();
    verify(model, never()).remove(any(PushDownOptimizationMeta.class));
    when(messageBox.open()).thenReturn(SWT.YES);
    controller.removeParameter();
    verify(model).setSelectedParameter(null);
    verify(model).remove(meta);
    verify(messageBox, times(2)).setIcon(SWT.ICON_QUESTION);
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

Example 20 with PushDownOptimizationMeta

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

the class ParameterPushdownTest method setUp.

@Before
public void setUp() throws Exception {
    optimizationMeta = new PushDownOptimizationMeta();
    optimizationMeta.setType(parameterPushdown);
    optimizationMeta.setStepName("OUTPUT");
    dataService = new DataServiceMeta(transMeta);
    dataService.setStepname("OUTPUT");
    dataService.getPushDownOptimizationMeta().add(optimizationMeta);
    parameterPushdown.createDefinition().setFieldName("ARTIST").setParameter("ARTIST_FIELD").setFormat("artist: \"%s\",");
    parameterPushdown.createDefinition().setFieldName("ALBUM").setParameter("ALBUM_FIELD").setFormat("album: \"%s\",");
    parameterPushdown.createDefinition().setFieldName("LIVE").setParameter("LIVE_FIELD");
    when(executor.getServiceTransMeta()).thenReturn(transMeta);
    when(executor.getParameters()).thenReturn(parameters = Maps.newHashMap());
    rowMeta = new RowMeta();
    rowMeta.addValueMeta(new ValueMetaString("ARTIST"));
    rowMeta.addValueMeta(new ValueMetaString("ALBUM"));
    rowMeta.addValueMeta(new ValueMetaBoolean("LIVE"));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) RowMeta(org.pentaho.di.core.row.RowMeta) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) Before(org.junit.Before)

Aggregations

PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)41 Test (org.junit.Test)23 ParameterGeneration (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration)10 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)8 SQL (org.pentaho.di.core.sql.SQL)7 IMetaStore (org.pentaho.metastore.api.IMetaStore)7 Matchers.anyString (org.mockito.Matchers.anyString)5 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 DataOutputStream (java.io.DataOutputStream)3 Set (java.util.Set)3 RowProducer (org.pentaho.di.trans.RowProducer)3 PushDownType (org.pentaho.di.trans.dataservice.optimization.PushDownType)3 DataServiceModel (org.pentaho.di.trans.dataservice.ui.model.DataServiceModel)3 XulException (org.pentaho.ui.xul.XulException)3 Shell (org.eclipse.swt.widgets.Shell)2 Before (org.junit.Before)2 InOrder (org.mockito.InOrder)2 KettleException (org.pentaho.di.core.exception.KettleException)2