Search in sources :

Example 6 with ParameterGeneration

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"));
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) Test(org.junit.Test)

Example 7 with ParameterGeneration

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));
        }
    }
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) StepMeta(org.pentaho.di.trans.step.StepMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta)

Example 8 with ParameterGeneration

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();
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

Example 9 with ParameterGeneration

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");
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

Example 10 with ParameterGeneration

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;
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Aggregations

ParameterGeneration (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration)13 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)10 Test (org.junit.Test)6 XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)2 BaseMessages.getString (org.pentaho.di.i18n.BaseMessages.getString)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 TableInputMeta (org.pentaho.di.trans.steps.tableinput.TableInputMeta)1 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)1