Search in sources :

Example 1 with CubeOutputMeta

use of org.pentaho.di.trans.steps.cubeoutput.CubeOutputMeta in project pentaho-kettle by pentaho.

the class CubeInputStepIntIT method testPDI12897.

@Test
public void testPDI12897() throws KettleException, IOException {
    File tempOutputFile = File.createTempFile("testPDI11374", ".cube");
    tempOutputFile.deleteOnExit();
    String stepName = "Cube Output";
    CubeOutputMeta meta = new CubeOutputMeta();
    meta.setDefault();
    meta.setFilename(tempOutputFile.getAbsolutePath());
    TransMeta transMeta = TransTestFactory.generateTestTransformation(null, meta, stepName);
    List<RowMetaAndData> inputList = getSampleData();
    TransTestFactory.executeTestTransformation(transMeta, TransTestFactory.INJECTOR_STEPNAME, stepName, TransTestFactory.DUMMY_STEPNAME, inputList);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException ignored) {
    // Continue
    }
    // Now, check the result
    Variables varSpace = new Variables();
    varSpace.setVariable("ROWS", "2");
    String checkStepName = "Cube Input";
    CubeInputMeta inputMeta = new CubeInputMeta();
    inputMeta.setFilename(tempOutputFile.getAbsolutePath());
    inputMeta.setRowLimit("${ROWS}");
    transMeta = TransTestFactory.generateTestTransformation(varSpace, inputMeta, checkStepName);
    // Remove the Injector hop, as it's not needed for this transformation
    TransHopMeta injectHop = transMeta.findTransHop(transMeta.findStep(TransTestFactory.INJECTOR_STEPNAME), transMeta.findStep(stepName));
    transMeta.removeTransHop(transMeta.indexOfTransHop(injectHop));
    inputList = new ArrayList<RowMetaAndData>();
    List<RowMetaAndData> result = TransTestFactory.executeTestTransformation(transMeta, TransTestFactory.INJECTOR_STEPNAME, stepName, TransTestFactory.DUMMY_STEPNAME, inputList);
    assertNotNull(result);
    assertEquals(2, result.size());
    assertEquals(1, result.get(0).getRowMeta().size());
    assertEquals(ValueMetaInterface.TYPE_STRING, result.get(0).getValueMeta(0).getType());
    assertEquals("col1", result.get(0).getValueMeta(0).getName());
    assertEquals("data1", result.get(0).getString(0, "fail"));
    assertEquals("data2", result.get(1).getString(0, "fail"));
}
Also used : Variables(org.pentaho.di.core.variables.Variables) CubeOutputMeta(org.pentaho.di.trans.steps.cubeoutput.CubeOutputMeta) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) TransMeta(org.pentaho.di.trans.TransMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) TransHopMeta(org.pentaho.di.trans.TransHopMeta) File(java.io.File) Test(org.junit.Test)

Example 2 with CubeOutputMeta

use of org.pentaho.di.trans.steps.cubeoutput.CubeOutputMeta in project pentaho-kettle by pentaho.

the class CubeInputStepIntIT method testNoLimit.

@Test
public void testNoLimit() throws KettleException, IOException {
    File tempOutputFile = File.createTempFile("testNoLimit", ".cube");
    tempOutputFile.deleteOnExit();
    String stepName = "Cube Output";
    CubeOutputMeta meta = new CubeOutputMeta();
    meta.setDefault();
    meta.setFilename(tempOutputFile.getAbsolutePath());
    TransMeta transMeta = TransTestFactory.generateTestTransformation(null, meta, stepName);
    List<RowMetaAndData> inputList = getSampleData();
    TransTestFactory.executeTestTransformation(transMeta, TransTestFactory.INJECTOR_STEPNAME, stepName, TransTestFactory.DUMMY_STEPNAME, inputList);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException ignored) {
    // Continue
    }
    // Now, check the result
    String checkStepName = "Cube Input";
    CubeInputMeta inputMeta = new CubeInputMeta();
    inputMeta.setFilename(tempOutputFile.getAbsolutePath());
    transMeta = TransTestFactory.generateTestTransformation(null, inputMeta, checkStepName);
    // Remove the Injector hop, as it's not needed for this transformation
    TransHopMeta injectHop = transMeta.findTransHop(transMeta.findStep(TransTestFactory.INJECTOR_STEPNAME), transMeta.findStep(stepName));
    transMeta.removeTransHop(transMeta.indexOfTransHop(injectHop));
    inputList = new ArrayList<RowMetaAndData>();
    List<RowMetaAndData> result = TransTestFactory.executeTestTransformation(transMeta, TransTestFactory.INJECTOR_STEPNAME, stepName, TransTestFactory.DUMMY_STEPNAME, inputList);
    assertNotNull(result);
    assertEquals(5, result.size());
    assertEquals(1, result.get(0).getRowMeta().size());
    assertEquals(ValueMetaInterface.TYPE_STRING, result.get(0).getValueMeta(0).getType());
    assertEquals("col1", result.get(0).getValueMeta(0).getName());
    assertEquals("data1", result.get(0).getString(0, "fail"));
    assertEquals("data2", result.get(1).getString(0, "fail"));
    assertEquals("data3", result.get(2).getString(0, "fail"));
    assertEquals("data4", result.get(3).getString(0, "fail"));
    assertEquals("data5", result.get(4).getString(0, "fail"));
}
Also used : CubeOutputMeta(org.pentaho.di.trans.steps.cubeoutput.CubeOutputMeta) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) TransMeta(org.pentaho.di.trans.TransMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) TransHopMeta(org.pentaho.di.trans.TransHopMeta) File(java.io.File) Test(org.junit.Test)

Example 3 with CubeOutputMeta

use of org.pentaho.di.trans.steps.cubeoutput.CubeOutputMeta in project pentaho-kettle by pentaho.

the class CubeInputStepIntIT method testNumericLimit.

@Test
public void testNumericLimit() throws KettleException, IOException {
    File tempOutputFile = File.createTempFile("testNumericLimit", ".cube");
    tempOutputFile.deleteOnExit();
    String stepName = "Cube Output";
    CubeOutputMeta meta = new CubeOutputMeta();
    meta.setDefault();
    meta.setFilename(tempOutputFile.getAbsolutePath());
    TransMeta transMeta = TransTestFactory.generateTestTransformation(null, meta, stepName);
    List<RowMetaAndData> inputList = getSampleData();
    TransTestFactory.executeTestTransformation(transMeta, TransTestFactory.INJECTOR_STEPNAME, stepName, TransTestFactory.DUMMY_STEPNAME, inputList);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException ignored) {
    // Continue
    }
    // Now, check the result
    String checkStepName = "Cube Input";
    CubeInputMeta inputMeta = new CubeInputMeta();
    inputMeta.setFilename(tempOutputFile.getAbsolutePath());
    inputMeta.setRowLimit("3");
    transMeta = TransTestFactory.generateTestTransformation(null, inputMeta, checkStepName);
    // Remove the Injector hop, as it's not needed for this transformation
    TransHopMeta injectHop = transMeta.findTransHop(transMeta.findStep(TransTestFactory.INJECTOR_STEPNAME), transMeta.findStep(stepName));
    transMeta.removeTransHop(transMeta.indexOfTransHop(injectHop));
    inputList = new ArrayList<RowMetaAndData>();
    List<RowMetaAndData> result = TransTestFactory.executeTestTransformation(transMeta, TransTestFactory.INJECTOR_STEPNAME, stepName, TransTestFactory.DUMMY_STEPNAME, inputList);
    assertNotNull(result);
    assertEquals(3, result.size());
    assertEquals(1, result.get(0).getRowMeta().size());
    assertEquals(ValueMetaInterface.TYPE_STRING, result.get(0).getValueMeta(0).getType());
    assertEquals("col1", result.get(0).getValueMeta(0).getName());
    assertEquals("data1", result.get(0).getString(0, "fail"));
    assertEquals("data2", result.get(1).getString(0, "fail"));
    assertEquals("data3", result.get(2).getString(0, "fail"));
}
Also used : CubeOutputMeta(org.pentaho.di.trans.steps.cubeoutput.CubeOutputMeta) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) TransMeta(org.pentaho.di.trans.TransMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) TransHopMeta(org.pentaho.di.trans.TransHopMeta) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)3 Test (org.junit.Test)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 TransHopMeta (org.pentaho.di.trans.TransHopMeta)3 TransMeta (org.pentaho.di.trans.TransMeta)3 CubeOutputMeta (org.pentaho.di.trans.steps.cubeoutput.CubeOutputMeta)3 Variables (org.pentaho.di.core.variables.Variables)1