use of org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration in project pdi-dataservice-server-plugin by pentaho.
the class ParameterGenerationModelTest method testGetMappings.
@Test
public void testGetMappings() throws Exception {
ParameterGeneration parameterGeneration = (ParameterGeneration) createParameterGeneration("parameter").getType();
parameterGeneration.createFieldMapping("source", "target");
model.updateParameterMap();
assertThat(model.getMappings(), empty());
model.setSelectedParameter("parameter");
ImmutableList<SourceTargetAdapter> mappings = model.getMappings();
assertThat(mappings, hasSize(greaterThan(1)));
assertThat(mappings.get(0), allOf(hasProperty("sourceFieldName", is("source")), hasProperty("targetFieldName", is("target"))));
assertThat(mappings.subList(1, mappings.size()), everyItem(hasProperty("defined", is(false))));
verify(changeSupport).firePropertyChange("mappings", ImmutableList.of(), mappings);
SourceTargetAdapter sourceTargetAdapter = mappings.get(1);
sourceTargetAdapter.setSourceFieldName("secondSource");
sourceTargetAdapter.setTargetFieldName("secondTarget");
assertThat(parameterGeneration.getFieldMappings().get(1).getSourceFieldName(), is("secondSource"));
assertThat(parameterGeneration.getFieldMappings().get(1).getTargetFieldName(), is("secondTarget"));
}
use of org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration in project pdi-dataservice-server-plugin by pentaho.
the class TableInputValidation method checkMissingDefinedParam.
private void checkMissingDefinedParam(CheckStepsExtension checkStepExtension, DataServiceMeta dataServiceMeta) {
StepMeta checkedStepMeta = checkStepExtension.getStepMetas()[0];
TableInputMeta tableInputMeta = (TableInputMeta) checkedStepMeta.getStepMetaInterface();
for (ParameterGeneration paramGen : getParameterGenerationsForStep(dataServiceMeta, checkedStepMeta.getName())) {
if (Const.isEmpty(tableInputMeta.getSQL()) || !tableInputMeta.getSQL().contains(paramGen.getParameterName())) {
checkStepExtension.getRemarks().add(warn(BaseMessages.getString(PKG, "TableInputValidation.MissingDefinedParam.Message", checkedStepMeta.getName(), paramGen.getParameterName()), checkedStepMeta));
}
}
}
use of org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration in project pdi-dataservice-server-plugin by pentaho.
the class ParameterGenerationControllerTest method testAddParameterFailure.
@Test
public void testAddParameterFailure() throws Exception {
when(factory.createPushDown()).thenReturn(new ParameterGeneration(factory));
when(model.getParameterMap()).thenReturn(ImmutableMap.<String, PushDownOptimizationMeta>of());
when(stepList.getSelectedItem()).thenReturn("Default Step");
mockPromptBox("parameterName", XulDialogCallback.Status.CANCEL);
controller.addParameter();
mockPromptBox("", XulDialogCallback.Status.ACCEPT);
controller.addParameter();
mockPromptBox("parameterName", XulDialogCallback.Status.ACCEPT);
when(model.getParameterMap()).thenReturn(ImmutableMap.of("parameterName", mock(PushDownOptimizationMeta.class)));
controller.addParameter();
verify(model, never()).add(any(PushDownOptimizationMeta.class));
verify(messageBox, times(2)).setIcon(SWT.ICON_WARNING);
verify(messageBox, times(2)).open();
}
use of org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration in project pdi-dataservice-server-plugin by pentaho.
the class ParameterGenerationControllerTest method testAddParameter.
@Test
public void testAddParameter() throws Exception {
ParameterGeneration parameterGeneration = new ParameterGeneration(factory);
when(factory.createPushDown()).thenReturn(parameterGeneration);
when(model.getParameterMap()).thenReturn(ImmutableMap.<String, PushDownOptimizationMeta>of());
when(stepList.getSelectedItem()).thenReturn("Default Step");
mockPromptBox("parameterName", XulDialogCallback.Status.ACCEPT);
controller.addParameter();
ArgumentCaptor<PushDownOptimizationMeta> optMetaCaptor = ArgumentCaptor.forClass(PushDownOptimizationMeta.class);
verify(model).add(optMetaCaptor.capture());
PushDownOptimizationMeta pushDownOptimizationMeta = optMetaCaptor.getValue();
assertThat(pushDownOptimizationMeta, allOf(hasProperty("type", sameInstance(parameterGeneration)), hasProperty("enabled", is(true)), hasProperty("stepName", is("Default Step"))));
assertThat(parameterGeneration.getParameterName(), equalTo("parameterName"));
verify(model).setSelectedParameter("parameterName");
}
use of org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration in project pdi-dataservice-server-plugin by pentaho.
the class ParameterGenerationModelTest method createParameterGeneration.
private PushDownOptimizationMeta createParameterGeneration(String parameterName) {
PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
ParameterGeneration parameterGeneration = new ParameterGeneration(factory);
meta.setType(parameterGeneration);
parameterGeneration.setParameterName(parameterName);
optimizations.add(meta);
return meta;
}
Aggregations