Search in sources :

Example 6 with OptimizationImpactInfo

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

the class MongodbInputParameterGenerationTest method testPreviewWithConversionFailure.

@Test
public void testPreviewWithConversionFailure() throws KettleException {
    when(mongodbPredicate.asFilterCriteria()).thenThrow(new PushDownOptimizationException("FAILURE"));
    OptimizationImpactInfo impact = preview(condition, parameterGeneration, stepInterface);
    assertThat(impact.getStepName(), equalTo(MOCK_STEPNAME));
    assertThat(impact.getQueryBeforeOptimization(), equalTo(TEST_JSON_QUERY));
    assertFalse(impact.isModified());
    assertThat(impact.getErrorMsg(), containsString("FAILURE"));
}
Also used : OptimizationImpactInfo(org.pentaho.di.trans.dataservice.optimization.OptimizationImpactInfo) PushDownOptimizationException(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationException) Test(org.junit.Test)

Example 7 with OptimizationImpactInfo

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

the class ParameterPushdownTest method testPreview.

@Test
public void testPreview() throws Exception {
    query("WHERE ARTIST = 'The Rolling Stones' AND ALBUM = 'Let it Bleed' ");
    when(transMeta.getParameterDefault(anyString())).thenReturn("<default>");
    OptimizationImpactInfo preview = parameterPushdown.preview(executor, optimizationMeta);
    assertThat(preview.getErrorMsg(), emptyOrNullString());
    assertThat(preview.isModified(), is(true));
    assertThat(preview.getQueryBeforeOptimization(), equalTo("ARTIST_FIELD = <default>\n" + "ALBUM_FIELD = <default>\n" + "LIVE_FIELD = <default>"));
    assertThat(preview.getQueryAfterOptimization(), equalTo("ARTIST_FIELD = artist: \"The Rolling Stones\",\n" + "ALBUM_FIELD = album: \"Let it Bleed\",\n" + "LIVE_FIELD = <default>"));
}
Also used : OptimizationImpactInfo(org.pentaho.di.trans.dataservice.optimization.OptimizationImpactInfo) Test(org.junit.Test)

Example 8 with OptimizationImpactInfo

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

the class DataServiceTestModel method getOptimizationImpactDescription.

public String getOptimizationImpactDescription() {
    StringBuilder builder = new StringBuilder();
    builder.append("\n");
    if (optimizationImpact.size() == 0) {
        builder.append("[No Push Down Optimizations Defined]\n");
    }
    for (OptimizationImpactInfo info : optimizationImpact) {
        builder.append(info.getDescription());
        builder.append("\n- - - - - - - - - - - - - - - - - - - - - -\n\n");
    }
    return builder.toString();
}
Also used : OptimizationImpactInfo(org.pentaho.di.trans.dataservice.optimization.OptimizationImpactInfo)

Example 9 with OptimizationImpactInfo

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

the class MongodbInputParameterGenerationTest method testQueryBeforeOptimizationWithConversionFailure.

@Test
public void testQueryBeforeOptimizationWithConversionFailure() throws KettleException {
    when(mongodbPredicate.asFilterCriteria()).thenThrow(new PushDownOptimizationException("FAILURE"));
    OptimizationImpactInfo impact = preview(condition, parameterGeneration, stepInterface);
    assertThat(impact.getQueryBeforeOptimization(), equalTo(TEST_JSON_QUERY));
}
Also used : OptimizationImpactInfo(org.pentaho.di.trans.dataservice.optimization.OptimizationImpactInfo) PushDownOptimizationException(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationException) Test(org.junit.Test)

Example 10 with OptimizationImpactInfo

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

the class MongodbInputParameterGenerationTest method testPreviewWithoutModification.

@Test
public void testPreviewWithoutModification() {
    when(parameterGeneration.getParameterName()).thenReturn("DifferentParamName");
    when(parameterGeneration.setQueryParameter(TEST_JSON_QUERY, "mockedFilter")).thenReturn(TEST_JSON_QUERY);
    OptimizationImpactInfo impact = preview(condition, parameterGeneration, stepInterface);
    assertThat(impact.getStepName(), equalTo(MOCK_STEPNAME));
    assertThat(impact.getQueryBeforeOptimization(), equalTo(TEST_JSON_QUERY));
    assertThat(impact.getQueryAfterOptimization(), equalTo(""));
    assertFalse(impact.isModified());
    assertThat(impact.getErrorMsg(), equalTo(""));
}
Also used : OptimizationImpactInfo(org.pentaho.di.trans.dataservice.optimization.OptimizationImpactInfo) Test(org.junit.Test)

Aggregations

OptimizationImpactInfo (org.pentaho.di.trans.dataservice.optimization.OptimizationImpactInfo)14 Test (org.junit.Test)9 PushDownOptimizationException (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationException)3 Condition (org.pentaho.di.core.Condition)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)1 Matchers.anyString (org.mockito.Matchers.anyString)1 KettleException (org.pentaho.di.core.exception.KettleException)1 DuplicateParamException (org.pentaho.di.core.parameters.DuplicateParamException)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 SQL (org.pentaho.di.core.sql.SQL)1 SQLCondition (org.pentaho.di.core.sql.SQLCondition)1 TransMeta (org.pentaho.di.trans.TransMeta)1 ParameterGenerationTest.newCondition (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGenerationTest.newCondition)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 TableInputMeta (org.pentaho.di.trans.steps.tableinput.TableInputMeta)1