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();
}
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();
}
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();
}
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);
}
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"));
}
Aggregations