コード例 #1
0
  @Test
  public void testStepShouldProcessError_WhenMappingTransHasError() throws KettleException {

    // Set Up TransMock to return the error
    int errorCount = 1;
    when(stepMockHelper.trans.getErrors()).thenReturn(errorCount);

    // The step has been already finished
    when(stepMockHelper.trans.isFinished()).thenReturn(Boolean.TRUE);
    // The step was started
    simpleMpData.wasStarted = true;

    smp =
        new SimpleMapping(
            stepMockHelper.stepMeta,
            stepMockHelper.stepDataInterface,
            0,
            stepMockHelper.transMeta,
            stepMockHelper.trans);
    smp.init(stepMockHelper.initStepMetaInterface, simpleMpData);

    smp.dispose(stepMockHelper.processRowsStepMetaInterface, simpleMpData);
    verify(stepMockHelper.trans, times(1)).isFinished();
    verify(stepMockHelper.trans, never()).waitUntilFinished();
    verify(stepMockHelper.trans, never()).addActiveSubTransformation(anyString(), any(Trans.class));
    verify(stepMockHelper.trans, never()).removeActiveSubTransformation(anyString());
    verify(stepMockHelper.trans, never()).getActiveSubTransformation(anyString());
    verify(stepMockHelper.trans, times(1)).getErrors();
    assertTrue("The step contains the errors", smp.getErrors() == errorCount);
  }
コード例 #2
0
 @Override
 public void setMetadata(ResultSet result, ResultSetMetaData metadata) throws SQLException {
   super.setMetadata(result, metadata);
   // take care of the attributes
   for (Attribute attr : getDimensionIndex().getAttributes()) {
     SimpleMapping s = getMapping(attr.getId().getAttributeId());
     s.setMetadata(result, metadata);
   }
 }
コード例 #3
0
  @Test
  public void testStepSetUpAsWasStarted_AtProcessingFirstRow() throws KettleException {

    smp =
        new SimpleMapping(
            stepMockHelper.stepMeta,
            stepMockHelper.stepDataInterface,
            0,
            stepMockHelper.transMeta,
            stepMockHelper.trans);
    smp.init(stepMockHelper.initStepMetaInterface, stepMockHelper.initStepDataInterface);
    smp.getInputRowSets().add(stepMockHelper.getMockInputRowSet(new Object[] {}));
    assertTrue("The step is processing in first", smp.first);
    assertTrue(smp.processRow(stepMockHelper.processRowsStepMetaInterface, simpleMpData));
    assertFalse("The step is processing not in first", smp.first);
    assertTrue("The step was started", smp.getData().wasStarted);
  }
コード例 #4
0
  @Test
  public void testStepShouldStopProcessingInput_IfUnderlyingTransitionIsStopped() throws Exception {

    MappingInput mappingInput = mock(MappingInput.class);
    when(mappingInput.getStepname()).thenReturn(MAPPING_INPUT_STEP_NAME);
    stepMockHelper.processRowsStepDataInterface.mappingInput = mappingInput;

    RowProducer rowProducer = mock(RowProducer.class);
    when(rowProducer.putRow(any(RowMetaInterface.class), any(Object[].class), anyBoolean()))
        .thenReturn(true);

    StepInterface stepInterface = mock(StepInterface.class);

    Trans mappingTrans = mock(Trans.class);
    when(mappingTrans.addRowProducer(anyString(), anyInt())).thenReturn(rowProducer);
    when(mappingTrans.findStepInterface(anyString(), anyInt())).thenReturn(stepInterface);
    when(mappingTrans.isFinishedOrStopped()).thenReturn(Boolean.FALSE).thenReturn(Boolean.TRUE);
    stepMockHelper.processRowsStepDataInterface.mappingTrans = mappingTrans;

    MappingOutput mappingOutput = mock(MappingOutput.class);
    when(mappingOutput.getStepname()).thenReturn(MAPPING_OUTPUT_STEP_NAME);
    stepMockHelper.processRowsStepDataInterface.mappingOutput = mappingOutput;

    smp =
        new SimpleMapping(
            stepMockHelper.stepMeta,
            stepMockHelper.stepDataInterface,
            0,
            stepMockHelper.transMeta,
            stepMockHelper.trans);
    smp.init(stepMockHelper.initStepMetaInterface, simpleMpData);
    smp.getInputRowSets().add(stepMockHelper.getMockInputRowSet(new Object[] {}));
    smp.getInputRowSets().add(stepMockHelper.getMockInputRowSet(new Object[] {}));

    assertTrue(
        smp.processRow(
            stepMockHelper.processRowsStepMetaInterface,
            stepMockHelper.processRowsStepDataInterface));
    assertFalse(
        smp.processRow(
            stepMockHelper.processRowsStepMetaInterface,
            stepMockHelper.processRowsStepDataInterface));
  }