• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RowStepCollector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.pentaho.di.trans.RowStepCollector的典型用法代码示例。如果您正苦于以下问题:Java RowStepCollector类的具体用法?Java RowStepCollector怎么用?Java RowStepCollector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RowStepCollector类属于org.pentaho.di.trans包,在下文中一共展示了RowStepCollector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testProcessRow

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
@Test
public void testProcessRow() throws KettleException {
  AddDOMXMLHandler addXML = new AddDOMXMLHandler(
      stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0,
      stepMockHelper.transMeta, stepMockHelper.trans);
  Object[] row = new Object[] { "ROW_DATA" };
  addXML.setRow(row);
  addXML.init( stepMockHelper.initStepMetaInterface, stepMockHelper.initStepDataInterface );
  
  RowMetaInterface inputRowMeta = createInputRowMeta();

  addXML.setInputRowMeta(inputRowMeta);    
  
  RowStepCollector dummyRowCollector = new RowStepCollector();
  addXML.addRowListener(dummyRowCollector);
  
  assertTrue( addXML.processRow( stepMockHelper.initStepMetaInterface, stepMockHelper.processRowsStepDataInterface ) );
  assertTrue( addXML.getErrors() == 0 );
  assertTrue( addXML.getLinesWritten() > 0 );

  List<RowMetaAndData> resultRows = dummyRowCollector.getRowsWritten();
   
  Assert.assertEquals(ADDDOMXML_PROCESSROW_RESULT, DOMTestUtilities.toString((Document)resultRows.get(0).getData()[1]));
}
 
开发者ID:griddynamics,项目名称:xml-dom-kettle-etl-plugin,代码行数:25,代码来源:AddDOMXMLTest.java


示例2: subTransOutputIsAccessibleOutside

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
@Test
public void subTransOutputIsAccessibleOutside() throws Exception {
  TransExecutorMeta executorMeta = getExecutorMeta( transExecutor );
  executorMeta.setOutputRowsSourceStepMeta( dummy );

  Trans trans = createTrans( transMeta );
  RowStepCollector endRc = listenExecutor( trans );
  RowProducer rp = trans.addRowProducer( injector.getName(), 0 );

  trans.startThreads();

  RowMetaAndData testInput = new RowMetaAndData( createRowMetaForOneField(), SAMPLE_INPUT );
  rp.putRow( testInput.getRowMeta(), testInput.getData() );
  rp.finished();

  trans.waitUntilFinished();

  assertEquals( EXPECTED_SUBTRANS_OUTPUT_AMOUNT, endRc.getRowsWritten().size() );
  assertThat( asList( endRc.getRowsWritten().get( 0 ).getData() ),
    hasItem( (Object) EXPECTED_SUBTRANS_OUTPUT_PATTERN )
  );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:23,代码来源:TransExecutorIT.java


示例3: executorsInputIsStraightlyCopiedToOutput

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
@Test
public void executorsInputIsStraightlyCopiedToOutput() throws Exception {
  TransExecutorMeta executorMeta = getExecutorMeta( transExecutor );
  executorMeta.setExecutorsOutputStepMeta( dummy );

  Trans trans = createTrans( transMeta );
  RowStepCollector endRc = listenExecutor( trans );
  RowProducer rp = trans.addRowProducer( injector.getName(), 0 );

  trans.startThreads();

  RowMetaAndData testInput = new RowMetaAndData( createRowMetaForOneField(), SAMPLE_INPUT );
  rp.putRow( testInput.getRowMeta(), testInput.getData() );
  rp.finished();

  trans.waitUntilFinished();

  assertEquals( testInput.size(), endRc.getRowsWritten().size() );
  assertThat( asList( endRc.getRowsWritten().get( 0 ).getData() ),
    hasItem( (Object) SAMPLE_INPUT )
  );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:23,代码来源:TransExecutorIT.java


示例4: subTransExecutionStatisticsIsCollected

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
@Test
public void subTransExecutionStatisticsIsCollected() throws Exception {
  TransExecutorMeta executorMeta = getExecutorMeta( transExecutor );
  executorMeta.setExecutionTimeField( "time" );
  executorMeta.setExecutionResultTargetStepMeta( dummy );

  Trans trans = createTrans( transMeta );
  RowStepCollector endRc = listenExecutor( trans );
  RowProducer rp = trans.addRowProducer( injector.getName(), 0 );

  trans.startThreads();

  RowMetaAndData testInput = new RowMetaAndData( createRowMetaForOneField(), SAMPLE_INPUT );
  rp.putRow( testInput.getRowMeta(), testInput.getData() );
  rp.finished();

  trans.waitUntilFinished();

  assertFalse( endRc.getRowsWritten().isEmpty() );
  // execution time field
  assertNotNull( endRc.getRowsWritten().get( 0 ).getData()[ 0 ] );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:23,代码来源:TransExecutorIT.java


示例5: testValueNotExistedInCompare

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
 * Test compare table reference table is empty
 *
 * @throws IOException
 * @throws KettleException
 */
@Test
public void testValueNotExistedInCompare() throws IOException, KettleException {
  executeSqlPrecondition( "reference_only.sql" );

  TableCompareMeta meta = getTableCompareMeta();
  List<RowMetaAndData> inputData = new ArrayList<RowMetaAndData>();
  inputData.add( new RowMetaAndData( getRowMeta(), getData3() ) );

  TransMeta trMeta = TransTestFactory.generateTestTransformationError( null, meta, "junit" );
  Map<String, RowStepCollector> result = TransTestFactory
      .executeTestTransformationError( trMeta, "junit", inputData );

  List<RowMetaAndData> read = result.get( TransTestFactory.DUMMY_STEPNAME ).getRowsRead();
  List<RowMetaAndData> errors = result.get( TransTestFactory.ERROR_STEPNAME ).getRowsRead();

  RowMetaAndData row = read.get( 0 );
  Assert.assertEquals( "Errors reported", 4, row.getInteger( 8 ).intValue() );
  Assert.assertEquals( "Reference table row count", 4, row.getInteger( 9 ).intValue() );
  Assert.assertEquals( "Compare table row count", 0, row.getInteger( 10 ).intValue() );
  Assert.assertEquals( "Number of left joins errors", 4, row.getInteger( 11 ).intValue() );
  Assert.assertEquals( "Number of inner joins errors", 0, row.getInteger( 12 ).intValue() );
  Assert.assertEquals( "Number of right joins errors", 0, row.getInteger( 13 ).intValue() );

  Assert.assertEquals( "4 error rows passed to error output", 4, errors.size() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:32,代码来源:TableCompareIT.java


示例6: testProcessRow

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
private void testProcessRow(String doc1, String doc2,
    String goldenImageXML, String errMessage) throws Exception {
  ConcatFieldsHandler concatFields = new ConcatFieldsHandler(
      stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0,
      stepMockHelper.transMeta, stepMockHelper.trans);
  Object[] row = new Object[] { DOMTestUtilities.createTestDocument(doc1),
      DOMTestUtilities.createTestDocument(doc2) };
  String[] fieldNames = new String[] { "one", "two" };
  concatFields.setRow(row);
  RowMetaInterface inputRowMeta = mock(RowMetaInterface.class);
  when(inputRowMeta.clone()).thenReturn(inputRowMeta);
  when(inputRowMeta.size()).thenReturn(2);
  when(inputRowMeta.getFieldNames()).thenReturn(fieldNames);
  when(inputRowMeta.indexOfValue("Name")).thenReturn(0);
  when(inputRowMeta.indexOfValue("Surname")).thenReturn(1);
  when(stepMockHelper.processRowsStepMetaInterface.getOutputFields())
      .thenReturn(textFileFields);

  concatFields.setInputRowMeta(inputRowMeta);
  
  concatFields.init(stepMockHelper.processRowsStepMetaInterface,
      stepMockHelper.processRowsStepDataInterface);
  RowStepCollector dummyRowCollector = new RowStepCollector();
  concatFields.addRowListener(dummyRowCollector);
  concatFields.processRow(stepMockHelper.processRowsStepMetaInterface,
      stepMockHelper.processRowsStepDataInterface);
  List<RowMetaAndData> resultRows = dummyRowCollector.getRowsWritten();
   
  Assert.assertEquals(errMessage, goldenImageXML, DOMTestUtilities.toString((Document)resultRows.get(0).getData()[2]));

}
 
开发者ID:griddynamics,项目名称:xml-dom-kettle-etl-plugin,代码行数:32,代码来源:DOMConcatFieldsTest.java


示例7: createAndTestTrans

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
protected Trans createAndTestTrans( PluginRegistry registry, TransMeta transMeta, StepMeta inputStep,
    RowStepCollector rowStepCollector, String name, int limit ) throws KettleException {
  //
  // Create a dummy step
  //
  String dummyStepname = "dummy step";
  DummyTransMeta dm1 = new DummyTransMeta();

  String dummyPid1 = registry.getPluginId( StepPluginType.class, dm1 );
  StepMeta dummyStep1 = new StepMeta( dummyPid1, dummyStepname, dm1 );
  transMeta.addStep( dummyStep1 );

  TransHopMeta hi3 = new TransHopMeta( inputStep, dummyStep1 );
  transMeta.addTransHop( hi3 );

  // Now execute the transformation...
  Trans trans = new Trans( transMeta );

  trans.prepareExecution( null );

  StepInterface si = trans.getStepInterface( dummyStepname, 0 );
  si.addRowListener( rowStepCollector );

  RowProducer rp = trans.addRowProducer( inputStep.getName(), 0 );

  RowMeta rowMeta = new RowMeta();
  rowMeta.addValueMeta( new ValueMetaString( "pageSize" ) );
  rowMeta.addValueMeta( new ValueMetaString( "name" ) );
  rp.putRow( rowMeta, new Object[] { Integer.valueOf( limit ), name } );

  rp.finished();
  return trans;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:34,代码来源:RestInputIT.java


示例8: testRESTInput

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
@Test
public void testRESTInput() throws Exception {
  //
  // Create a new transformation...
  //
  TransMeta transMeta = new TransMeta();
  transMeta.setName( "restinput" );

  PluginRegistry registry = PluginRegistry.getInstance();

  StepMeta inputStep = createRestInputStep( transMeta, registry );

  RowStepCollector rowStepCollector = new RowStepCollector();
  final Trans trans = createAndTestTrans( registry, transMeta, inputStep, rowStepCollector, "limit", 5 );
  trans.startThreads();

  trans.waitUntilFinished();

  // Compare the results
  List<RowMetaAndData> resultRows = rowStepCollector.getRowsWritten();

  assertTrue( rowStepCollector.getRowsError().isEmpty() );
  assertEquals( 1, rowStepCollector.getRowsWritten().size() );

  final RowMetaAndData rowMetaAndData = resultRows.get( 0 );
  final RowMetaInterface rowMeta = rowMetaAndData.getRowMeta();

  final String[] fieldNames = rowMeta.getFieldNames();
  final Object[] data = rowMetaAndData.getData();

  assertEquals( "pageSize", fieldNames[0] );
  assertEquals( "name", fieldNames[1] );
  assertEquals( "result", fieldNames[2] );

  assertEquals( Integer.valueOf( 5 ), data[0] );
  assertEquals( "limit", data[1] );
  assertEquals( "limit:5", data[2] );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:39,代码来源:RestInputIT.java


示例9: testMissedReferenceLinesAreRepored

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
 * PDI-7255 - The table compare step reports incorrect record as missing
 *
 * @throws KettleException
 * @throws IOException
 */
@Test
public void testMissedReferenceLinesAreRepored() throws KettleException, IOException {
  // prepare database
  executeSqlPrecondition( "PDI-7255.sql" );

  TableCompareMeta meta = getTableCompareMeta();

  // prepare input date
  List<RowMetaAndData> inputData = new ArrayList<RowMetaAndData>();
  inputData.add( new RowMetaAndData( getRowMeta(), getData1() ) );

  // execute transformations
  TransMeta trMeta = TransTestFactory.generateTestTransformationError( null, meta, "junit" );
  Map<String, RowStepCollector> result = TransTestFactory
      .executeTestTransformationError( trMeta, "junit", inputData );

  // check the results
  List<RowMetaAndData> read = result.get( TransTestFactory.DUMMY_STEPNAME ).getRowsRead();
  Assert.assertTrue( "Step achieve comparsion data", read.size() == 1 );
  RowMetaAndData row = read.get( 0 );

  Assert.assertEquals( "Number of errors", 1, row.getInteger( 8 ).intValue() );
  Assert.assertEquals( "Reference table row count", 3, row.getInteger( 9 ).intValue() );
  Assert.assertEquals( "Compare table row count", 2, row.getInteger( 10 ).intValue() );

  Assert.assertEquals( "Number of left joins errors", 0, row.getInteger( 11 ).intValue() );
  Assert.assertEquals( "Number of inner joins errors", 0, row.getInteger( 12 ).intValue() );
  Assert.assertEquals( "Number of right joins errors", 1, row.getInteger( 13 ).intValue() );

  List<RowMetaAndData> errors = result.get( TransTestFactory.ERROR_STEPNAME ).getRowsRead();
  Assert.assertTrue( "One error output to negative step", errors.size() == 1 );
  row = errors.get( 0 );

  Assert.assertEquals( "Reported one missing key", "KEY1 = '2'", row.getString( ehlkd, null ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:42,代码来源:TableCompareIT.java


示例10: testComplexKeysComparsion

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
 * Test table compare test can handle complex keys comparison
 *
 * @throws IOException
 * @throws KettleException
 */
@Test
public void testComplexKeysComparsion() throws IOException, KettleException {
  executeSqlPrecondition( "complex_key_test.sql" );

  TableCompareMeta meta = getTableCompareMeta();
  List<RowMetaAndData> inputData = new ArrayList<RowMetaAndData>();
  inputData.add( new RowMetaAndData( getRowMeta(), getData2() ) );

  TransMeta trMeta = TransTestFactory.generateTestTransformationError( null, meta, "junit" );
  Map<String, RowStepCollector> result = TransTestFactory
      .executeTestTransformationError( trMeta, "junit", inputData );

  List<RowMetaAndData> read = result.get( TransTestFactory.DUMMY_STEPNAME ).getRowsRead();
  List<RowMetaAndData> errors = result.get( TransTestFactory.ERROR_STEPNAME ).getRowsRead();

  Assert.assertEquals( "One row passed to positive step", 1, read.size() );
  Assert.assertEquals( "Two rows passed to negative step", 2, errors.size() );

  // check positive step output
  RowMetaAndData row = read.get( 0 );

  Assert.assertEquals( "Number errors", 2, row.getInteger( 8 ).intValue() );
  Assert.assertEquals( "Reference table row count", 4, row.getInteger( 9 ).intValue() );
  Assert.assertEquals( "Compare table row count", 4, row.getInteger( 10 ).intValue() );

  Assert.assertEquals( "Number of left joins errors", 1, row.getInteger( 11 ).intValue() );
  Assert.assertEquals( "Number of inner joins errors", 0, row.getInteger( 12 ).intValue() );
  Assert.assertEquals( "Number of right joins errors", 1, row.getInteger( 13 ).intValue() );

  // check error step output
  row = errors.get( 0 );
  Assert.assertEquals( "error composite key is mentioned", "KEY1 = '2' and KEY2 = '1'", row.getString( 0, null ) );
  row = errors.get( 1 );
  Assert.assertEquals( "error composite key is mentioned", "KEY1 = '2' and KEY2 = '2'", row.getString( 0, null ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:42,代码来源:TableCompareIT.java


示例11: testValueNotExistsReference

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
 * Test compare table if reference table is empty
 *
 * @throws IOException
 * @throws KettleException
 */
@Test
public void testValueNotExistsReference() throws IOException, KettleException {
  executeSqlPrecondition( "compare_only.sql" );

  TableCompareMeta meta = getTableCompareMeta();
  List<RowMetaAndData> inputData = new ArrayList<RowMetaAndData>();
  inputData.add( new RowMetaAndData( getRowMeta(), getData3() ) );

  TransMeta trMeta = TransTestFactory.generateTestTransformationError( null, meta, "junit" );
  Map<String, RowStepCollector> result = TransTestFactory
      .executeTestTransformationError( trMeta, "junit", inputData );

  List<RowMetaAndData> read = result.get( TransTestFactory.DUMMY_STEPNAME ).getRowsRead();
  List<RowMetaAndData> errors = result.get( TransTestFactory.ERROR_STEPNAME ).getRowsRead();

  Assert.assertEquals( "One row passed to positive output", 1, read.size() );

  RowMetaAndData row = read.get( 0 );
  Assert.assertEquals( "Errors reported", 4, row.getInteger( 8 ).intValue() );
  Assert.assertEquals( "Reference table row count", 0, row.getInteger( 9 ).intValue() );
  Assert.assertEquals( "Compare table row count", 4, row.getInteger( 10 ).intValue() );
  Assert.assertEquals( "Number of left joins errors", 0, row.getInteger( 11 ).intValue() );
  Assert.assertEquals( "Number of inner joins errors", 0, row.getInteger( 12 ).intValue() );
  Assert.assertEquals( "Number of right joins errors", 4, row.getInteger( 13 ).intValue() );

  Assert.assertEquals( "4 error rows passed to error output", 4, errors.size() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:34,代码来源:TableCompareIT.java


示例12: testValueComparsion

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
 * Test that step reports value comparison errors
 *
 * @throws IOException
 * @throws KettleException
 */
@Test
public void testValueComparsion() throws IOException, KettleException {
  executeSqlPrecondition( "complex_key_test.sql" );

  TableCompareMeta meta = getTableCompareMeta();
  List<RowMetaAndData> inputData = new ArrayList<RowMetaAndData>();
  inputData.add( new RowMetaAndData( getRowMeta(), getData3() ) );

  TransMeta trMeta = TransTestFactory.generateTestTransformationError( null, meta, "junit" );
  Map<String, RowStepCollector> result = TransTestFactory
      .executeTestTransformationError( trMeta, "junit", inputData );

  List<RowMetaAndData> read = result.get( TransTestFactory.DUMMY_STEPNAME ).getRowsRead();
  List<RowMetaAndData> errors = result.get( TransTestFactory.ERROR_STEPNAME ).getRowsRead();

  Assert.assertEquals( "One row passed to positive output", 1, read.size() );
  Assert.assertEquals( "One row passed to negative output", 1, errors.size() );

  // check error is properly reported:
  RowMetaAndData row = read.get( 0 );

  Assert.assertEquals( "One errors reported", 1, row.getInteger( 8 ).intValue() );
  Assert.assertEquals( "Reference table row count", 4, row.getInteger( 9 ).intValue() );
  Assert.assertEquals( "Compare table row count", 4, row.getInteger( 10 ).intValue() );
  Assert.assertEquals( "Number of left joins errors", 0, row.getInteger( 11 ).intValue() );
  Assert.assertEquals( "Number of inner joins errors", 1, row.getInteger( 12 ).intValue() );
  Assert.assertEquals( "Number of right joins errors", 0, row.getInteger( 13 ).intValue() );

  row = errors.get( 0 );
  Assert.assertEquals( "Reported key for not match value", "KEY1 = '2'", row.getString( ehlkd, null ) );
  Assert.assertEquals( "Reported reference table value", "2", row.getString( ehlrvi, null ) );
  Assert.assertEquals( "Reported compare table value", "1", row.getString( ehlcvif, null ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:40,代码来源:TableCompareIT.java


示例13: testValueExcludeComparsion

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
 * Test that step can ignore excluded values during comparison
 *
 * @throws IOException
 * @throws KettleException
 */
@Test
public void testValueExcludeComparsion() throws IOException, KettleException {
  executeSqlPrecondition( "complex_key_test.sql" );

  TableCompareMeta meta = getTableCompareMeta();
  List<RowMetaAndData> inputData = new ArrayList<RowMetaAndData>();
  inputData.add( new RowMetaAndData( getRowMeta(), getData4() ) );

  TransMeta trMeta = TransTestFactory.generateTestTransformationError( null, meta, "junit" );
  Map<String, RowStepCollector> result = TransTestFactory
      .executeTestTransformationError( trMeta, "junit", inputData );

  List<RowMetaAndData> read = result.get( TransTestFactory.DUMMY_STEPNAME ).getRowsRead();
  List<RowMetaAndData> errors = result.get( TransTestFactory.ERROR_STEPNAME ).getRowsRead();

  Assert.assertEquals( "There is no errors reported", 0, errors.size() );

  RowMetaAndData row = read.get( 0 );

  Assert.assertEquals( "No errors reported", 0, row.getInteger( 8 ).intValue() );
  Assert.assertEquals( "Reference table row count", 4, row.getInteger( 9 ).intValue() );
  Assert.assertEquals( "Compare table row count", 4, row.getInteger( 10 ).intValue() );

  Assert.assertEquals( "Number of left joins errors", 0, row.getInteger( 11 ).intValue() );
  Assert.assertEquals( "Number of inner joins errors", 0, row.getInteger( 12 ).intValue() );
  Assert.assertEquals( "Number of right joins errors", 0, row.getInteger( 13 ).intValue() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:34,代码来源:TableCompareIT.java


示例14: test

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
 * Runs the transformation with the below input parameters
 * @param inputData JSON string
 * @param ignoreMissingPath boolean
 * @param defaultPathLeafToNull boolean
 * @return Transformation Results
 */
private List<RowMetaAndData> test(String inputData, boolean ignoreMissingPath, boolean defaultPathLeafToNull)
        throws Exception {
    KettleEnvironment.init();

    // Create a new transformation
    TransMeta transMeta = new TransMeta();
    transMeta.setName("testFastJsonInput");
    PluginRegistry registry = PluginRegistry.getInstance();

    // Create Injector
    String injectorStepName = "injector step";
    StepMeta injectorStep = TestUtilities.createInjectorStep(injectorStepName, registry);
    transMeta.addStep(injectorStep);

    // Create a FastJsonInput step
    String fastJsonInputName = "FastJsonInput step";
    StepMeta fastJsonInputStep = createFastJsonInputStep(fastJsonInputName, registry, ignoreMissingPath,
            defaultPathLeafToNull);
    transMeta.addStep(fastJsonInputStep);

    // TransHopMeta between injector step and FastJsonInput
    TransHopMeta injector_hop_fjis = new TransHopMeta(injectorStep, fastJsonInputStep);
    transMeta.addTransHop(injector_hop_fjis);

    // Create a dummy step
    String dummyStepName = "dummy step";
    StepMeta dummyStep = TestUtilities.createDummyStep(dummyStepName, registry);
    transMeta.addStep(dummyStep);

    // TransHopMeta between FastJsonInput and Dummy
    TransHopMeta fjis_hop_dummy = new TransHopMeta(fastJsonInputStep, dummyStep);
    transMeta.addTransHop(fjis_hop_dummy);

    // Execute the transformation
    Trans trans = new Trans(transMeta);
    trans.prepareExecution(null);

    // Create a row collector and add it to the dummy step interface
    StepInterface si = trans.getStepInterface(dummyStepName, 0);
    RowStepCollector dummyRowCollector = new RowStepCollector();
    si.addRowListener(dummyRowCollector);

    // Create a row producer
    RowProducer rowProducer = trans.addRowProducer(injectorStepName, 0);
    trans.startThreads();

    // create the rows
    List<RowMetaAndData> inputList = createInputData(inputData);
    for (RowMetaAndData rowMetaAndData : inputList) {
        rowProducer.putRow(rowMetaAndData.getRowMeta(), rowMetaAndData.getData());
    }
    rowProducer.finished();

    trans.waitUntilFinished();

    return dummyRowCollector.getRowsWritten();
}
 
开发者ID:etdube,项目名称:pdi-fastjsoninput-plugin,代码行数:65,代码来源:FastJsonInputTest.java


示例15: testInjector

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
* Test case for injector step... also a show case on how
* to use injector.
*/
  public void testInjector() throws Exception
  {
      EnvUtil.environmentInit();

      //
      // Create a new transformation...
      //
      TransMeta transMeta = new TransMeta();
      transMeta.setName("injectortest");
  	
      StepLoader steploader = StepLoader.getInstance();            

      // 
      // create an injector step...
      //
      String injectorStepname = "injector step";
      InjectorMeta im = new InjectorMeta();
      
      // Set the information of the injector.
              
      String injectorPid = steploader.getStepPluginID(im);
      StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
      transMeta.addStep(injectorStep);

      // 
      // Create a dummy step
      //
      String dummyStepname = "dummy step";            
      DummyTransMeta dm = new DummyTransMeta();

      String dummyPid = steploader.getStepPluginID(dm);
      StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
      transMeta.addStep(dummyStep);                              

      TransHopMeta hi = new TransHopMeta(injectorStep, dummyStep);
      transMeta.addTransHop(hi);
              
      // Now execute the transformation...
      Trans trans = new Trans(transMeta);

      trans.prepareExecution(null);
              
      StepInterface si = trans.getStepInterface(dummyStepname, 0);
      RowStepCollector rc = new RowStepCollector();
      si.addRowListener(rc);
      
      RowProducer rp = trans.addRowProducer(injectorStepname, 0);
      trans.startThreads();
      
      // add rows
      List<RowMetaAndData> inputList = createData();
      for (RowMetaAndData rm : inputList )
      {
      	rp.putRow(rm.getRowMeta(), rm.getData());
      }   
      rp.finished();

      trans.waitUntilFinished();   
      
      List<RowMetaAndData> resultRows = rc.getRowsWritten();
      checkRows(resultRows, inputList);
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:67,代码来源:InjectorTest.java


示例16: testCaseSensitiveNoPreviousSort

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
public void testCaseSensitiveNoPreviousSort() throws Exception
{
    EnvUtil.environmentInit();

    //
    // Create a new transformation...
    //
    TransMeta transMeta = new TransMeta();
    transMeta.setName("uniquerowstest");
	
    StepLoader steploader = StepLoader.getInstance();            

    // 
    // create an injector step...
    //
    String injectorStepname = "injector step";
    InjectorMeta im = new InjectorMeta();
    
    // Set the information of the injector.                
    String injectorPid = steploader.getStepPluginID(im);
    StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
    transMeta.addStep(injectorStep);

    // 
    // Create a unique rows step
    //
    String uniqueRowsStepname = "unique rows step";            
    UniqueRowsMeta urm = new UniqueRowsMeta();
    urm.setCompareFields(new String[] {"KEY"});
    urm.setCaseInsensitive(new boolean[] {false});

    String uniqueRowsStepPid = steploader.getStepPluginID(urm);
    StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
    transMeta.addStep(uniqueRowsStep);            

    transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));        
    
    // 
    // Create a dummy step
    //
    String dummyStepname = "dummy step";            
    DummyTransMeta dm = new DummyTransMeta();

    String dummyPid = steploader.getStepPluginID(dm);
    StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
    transMeta.addStep(dummyStep);                              

    transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));        
    
    // Now execute the transformation...
    Trans trans = new Trans(transMeta);

    trans.prepareExecution(null);
            
    StepInterface si = trans.getStepInterface(dummyStepname, 0);
    RowStepCollector dummyRc = new RowStepCollector();
    si.addRowListener(dummyRc);
    
    RowProducer rp = trans.addRowProducer(injectorStepname, 0);
    trans.startThreads();
    
    // add rows
    List<RowMetaAndData> inputList = createData();
    for ( RowMetaAndData rm : inputList )
    {
    	rp.putRow(rm.getRowMeta(), rm.getData());
    }   
    rp.finished();
 
    trans.waitUntilFinished();   
                                 
    List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
    checkRows(createResultDataCaseSensitiveNoPreviousSort(), resultRows);
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:75,代码来源:UniqueRowsTest.java


示例17: testCaseInsensitiveNoPreviousSort

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
public void testCaseInsensitiveNoPreviousSort() throws Exception
{
    EnvUtil.environmentInit();

    //
    // Create a new transformation...
    //
    TransMeta transMeta = new TransMeta();
    transMeta.setName("uniquerowstest");
    
    StepLoader steploader = StepLoader.getInstance();            

    // 
    // create an injector step...
    //
    String injectorStepname = "injector step";
    InjectorMeta im = new InjectorMeta();
    
    // Set the information of the injector.                
    String injectorPid = steploader.getStepPluginID(im);
    StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
    transMeta.addStep(injectorStep);

    // 
    // Create a unique rows step
    //
    String uniqueRowsStepname = "unique rows step";            
    UniqueRowsMeta urm = new UniqueRowsMeta();
    urm.setCompareFields(new String[] {"KEY"});
    urm.setCaseInsensitive(new boolean[] {true});

    String uniqueRowsStepPid = steploader.getStepPluginID(urm);
    StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
    transMeta.addStep(uniqueRowsStep);            

    transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));        
    
    // 
    // Create a dummy step
    //
    String dummyStepname = "dummy step";            
    DummyTransMeta dm = new DummyTransMeta();

    String dummyPid = steploader.getStepPluginID(dm);
    StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
    transMeta.addStep(dummyStep);                              

    transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));        
    
    // Now execute the transformation...
    Trans trans = new Trans(transMeta);

    trans.prepareExecution(null);
            
    StepInterface si = trans.getStepInterface(dummyStepname, 0);
    RowStepCollector dummyRc = new RowStepCollector();
    si.addRowListener(dummyRc);
    
    RowProducer rp = trans.addRowProducer(injectorStepname, 0);
    trans.startThreads();
    
    // add rows
    List<RowMetaAndData> inputList = createData();
    for ( RowMetaAndData rm : inputList )
    {
        rp.putRow(rm.getRowMeta(), rm.getData());
    }   
    rp.finished();
 
    trans.waitUntilFinished();   
                                 
    List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
    checkRows(createResultDataCaseInsensitiveNoPreviousSort(), resultRows);
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:75,代码来源:UniqueRowsTest.java


示例18: testRowGenerator

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
* Test case for Row Generator step.
*/
  public void testRowGenerator() throws Exception
  {
      EnvUtil.environmentInit();

      //
      // Create a new transformation...
      //
      TransMeta transMeta = new TransMeta();
      transMeta.setName("row generatortest");
  	
      StepLoader steploader = StepLoader.getInstance();            

      // 
      // create a row generator step...
      //
      String rowGeneratorStepname = "row generator step";
      RowGeneratorMeta rm = new RowGeneratorMeta();
      
      // Set the information of the row generator.                
      String rowGeneratorPid = steploader.getStepPluginID(rm);
      StepMeta rowGeneratorStep = new StepMeta(rowGeneratorPid, rowGeneratorStepname, (StepMetaInterface)rm);
      transMeta.addStep(rowGeneratorStep);
      
      //
      // Do the following specs 3 times.
      //
      String fieldName[]   = { "string", "boolean", "integer" };
      String type[]        = { "String", "Boolean", "Integer" };
      String value[]       = { "string_value", "true", "20"   };
      String fieldFormat[] = { "", "", ""  };
      String group[]       = { "", "", ""  };
      String decimal[]     = { "", "", ""  };
      int    intDummies[]  = { -1, -1, -1 };
              
      rm.setDefault();
      rm.setFieldName(fieldName);
      rm.setFieldType(type);
      rm.setValue(value);
      rm.setFieldLength(intDummies);
      rm.setFieldPrecision(intDummies);        
      rm.setRowLimit("3");
      rm.setFieldFormat(fieldFormat);
      rm.setGroup(group);
      rm.setDecimal(decimal);

      // 
      // Create a dummy step
      //
      String dummyStepname = "dummy step";            
      DummyTransMeta dm = new DummyTransMeta();

      String dummyPid = steploader.getStepPluginID(dm);
      StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
      transMeta.addStep(dummyStep);                              

      TransHopMeta hi = new TransHopMeta(rowGeneratorStep, dummyStep);
      transMeta.addTransHop(hi);
              
      // Now execute the transformation...
      Trans trans = new Trans(transMeta);

      trans.prepareExecution(null);
              
      StepInterface si = trans.getStepInterface(dummyStepname, 0);
      RowStepCollector rc = new RowStepCollector();
      si.addRowListener(rc);
      
      trans.startThreads();        
      trans.waitUntilFinished();   
      
      List<RowMetaAndData> checkList = createData();
      List<RowMetaAndData> resultRows = rc.getRowsWritten();
      checkRows(resultRows, checkList);
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:78,代码来源:RowGeneratorTest.java


示例19: testInfoStreams_single

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
/**
 * Tests that info steps are correctly identified via StepMetaInterface.getStepIOMeta()
 */
public void testInfoStreams_single() throws Exception {
  KettleEnvironment.init();
  PluginRegistry registry = PluginRegistry.getInstance();

  //
  // Create a new transformation with a row generator that feeds a Mapping (Sub-Transformation) Step
  //
  TransMeta transMeta = new TransMeta();
  transMeta.setName("Mapping Info Test"); //$NON-NLS-1$
  StepMeta rowGenerator = buildRowGeneratorStep(registry, "Generate Rows"); //$NON-NLS-1$
  transMeta.addStep(rowGenerator);

  String mappingName = "mapping"; //$NON-NLS-1$
  MappingMeta mappingMeta = new MappingMeta();
  mappingMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
  mappingMeta.setFileName("test/org/pentaho/di/trans/steps/mapping/subtrans.ktr"); //$NON-NLS-1$
  String mappingInputStepName = "input"; //$NON-NLS-1$
  mappingMeta
      .setInputMappings(Collections.singletonList(createMappingDef(rowGenerator.getName(), mappingInputStepName, "string", "a"))); //$NON-NLS-1$ //$NON-NLS-2$
  String mappingPid = registry.getPluginId(StepPluginType.class, mappingMeta);
  StepMeta mapping = new StepMeta(mappingPid, mappingName, mappingMeta);
  transMeta.addStep(mapping);

  TransHopMeta hopGeneratorToMapping = new TransHopMeta(rowGenerator, mapping);
  transMeta.addTransHop(hopGeneratorToMapping);

  Trans trans = new Trans(transMeta);
  trans.prepareExecution(null);

  // Mimic how a transformation is loaded and initialized from TransMeta.loadXML() or KettleDatabaseRepositoryTransDelegate.loadTransformation()
  // so the StepMeta references are wired up in the MappingMeta properly
  // (Copied from TransMeta.loadXML())
  for (int i = 0; i < transMeta.nrSteps(); i++) {
    StepMeta stepMeta = transMeta.getStep(i);
    StepMetaInterface sii = stepMeta.getStepMetaInterface();
    if (sii != null)
      sii.searchInfoAndTargetSteps(transMeta.getSteps());
  }

  // Verify the transformation was configured properly
  assertEquals("Transformation not initialized properly", 2, transMeta.nrSteps()); //$NON-NLS-1$

  StepMeta meta = transMeta.getStep(1);
  assertTrue("Transformation not initialized properly", meta.getStepMetaInterface() instanceof MappingMeta); //$NON-NLS-1$

  MappingMeta loadedMappingMeta = (MappingMeta) meta.getStepMetaInterface();
  assertEquals("Expected a single input mapping definition", 1, loadedMappingMeta.getInputMappings().size()); //$NON-NLS-1$

  StepIOMetaInterface ioMeta = loadedMappingMeta.getStepIOMeta();
  assertEquals("Expected a single Info Stream", 1, ioMeta.getInfoStreams().size()); //$NON-NLS-1$
  assertEquals("Expected a single Info Step", 1, loadedMappingMeta.getInfoSteps().length); //$NON-NLS-1$

  // Verify the transformation can be executed
  StepInterface si = trans.getStepInterface(mappingName, 0);
  RowStepCollector rc = new RowStepCollector();
  si.addRowListener(rc);

  trans.startThreads();
  trans.waitUntilFinished();

  assertEquals(1, rc.getRowsRead().size());
  assertEquals(1, rc.getRowsWritten().size());
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:67,代码来源:MappingTest.java


示例20: setUp

import org.pentaho.di.trans.RowStepCollector; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

	KettleEnvironment.init();

	/* SET UP TRANSFORMATION */

	// Create a new transformation...
	TransMeta transMeta = new TransMeta();
	transMeta.setName("insert/update test");

	// Add the database connections
	for (int i = 0; i < databasesXML.length; i++) {
		DatabaseMeta databaseMeta = new DatabaseMeta(databasesXML[i]);
		transMeta.addDatabase(databaseMeta);
	}

	DatabaseMeta dbInfo = transMeta.findDatabase("db" 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HExecutionEngine类代码示例发布时间:2022-05-22
下一篇:
Java LockTimeoutException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap