@Override public Object answer( InvocationOnMock invocation ) throws Throwable { if ( ( (CheckResultInterface) invocation.getArguments()[0] ).getType() != CheckResultInterface.TYPE_RESULT_OK ) { TestCase.fail( "We've got validation error" ); } return null; } } ).when( validationResults ).add( any( CheckResultInterface.class ) );
if ( show_successful_results || cr.getType() != CheckResultInterface.TYPE_RESULT_OK ) { TableItem ti = new TableItem( wFields.table, SWT.NONE ); ti.setText( 1, "<global>" ); ti.setText( 2, cr.getType() + " - " + cr.getTypeDesc() ); ti.setText( 3, cr.getText() ); switch ( cr.getType() ) { case CheckResultInterface.TYPE_RESULT_OK: col = green;
private static int getCheckResultErrorCount( List<CheckResultInterface> remarks ) { return remarks.stream() .filter( p -> p.getType() == CheckResultInterface.TYPE_RESULT_ERROR ) .collect( Collectors.toList() ).size(); }
@Override public boolean init( StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface ) { boolean isInitalized = super.init( stepMetaInterface, stepDataInterface ); BaseSerializingMeta serializingMeta = (BaseSerializingMeta) stepMetaInterface; meta = (MQTTProducerMeta) serializingMeta.withVariables( this ); // handle variable substitution up-front List<CheckResultInterface> remarks = new ArrayList<>(); meta.check( remarks, getTransMeta(), meta.getParentStepMeta(), null, null, null, null, //these parameters are not used inside the method variables, getRepository(), getMetaStore() ); boolean errorsPresent = remarks.stream().filter( result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR ) .peek( result -> logError( result.getText() ) ) .count() > 0; return !errorsPresent && isInitalized; }
@Override public boolean init( StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface ) { boolean isInitalized = super.init( stepMetaInterface, stepDataInterface ); meta = ( (JmsProducerMeta) ( (BaseSerializingMeta) stepMetaInterface ).withVariables( this ) ); List<CheckResultInterface> remarks = new ArrayList<>(); meta.check( remarks, getTransMeta(), meta.getParentStepMeta(), null, null, null, null, //these parameters are not used inside the method variables, getRepository(), getMetaStore() ); boolean errorsPresent = remarks.stream().filter( result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR ) .peek( result -> logError( result.getText() ) ) .count() > 0; if ( errorsPresent ) { return false; } return isInitalized; }
@Test public void testTransWithOneStepIsConsideredUsed() throws Exception { TransMeta transMeta = new TransMeta( getClass().getResource( "one-step-trans.ktr" ).getPath() ); assertEquals( 1, transMeta.getUsedSteps().size() ); Repository rep = mock( Repository.class ); ProgressMonitorListener monitor = mock( ProgressMonitorListener.class ); List<CheckResultInterface> remarks = new ArrayList<>(); IMetaStore metaStore = mock( IMetaStore.class ); transMeta.checkSteps( remarks, false, monitor, new Variables(), rep, metaStore ); assertEquals( 4, remarks.size() ); for ( CheckResultInterface remark : remarks ) { assertEquals( CheckResultInterface.TYPE_RESULT_OK, remark.getType() ); } }
@Test public void testCheckInputRowsBothNonEmpty() throws KettleStepException { when( transMeta.getPrevStepFields( REFERENCE_STEP_NAME ) ).thenReturn( generateRowMeta10Strings() ); when( transMeta.getPrevStepFields( COMPARISON_STEP_NAME ) ).thenReturn( generateRowMeta10Strings() ); meta.check( remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0], (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null ); assertNotNull( remarks ); assertTrue( remarks.size() >= 2 ); assertEquals( remarks.get( 1 ).getType(), CheckResultInterface.TYPE_RESULT_OK ); }
@Test public void testCheckInputRowsDifferentRowMetaTypes() throws KettleStepException { when( transMeta.getPrevStepFields( REFERENCE_STEP_NAME ) ).thenReturn( generateRowMeta10MixedTypes() ); when( transMeta.getPrevStepFields( COMPARISON_STEP_NAME ) ).thenReturn( generateRowMeta10Strings() ); meta.check( remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0], (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null ); assertNotNull( remarks ); assertTrue( remarks.size() >= 2 ); assertEquals( remarks.get( 1 ).getType(), CheckResultInterface.TYPE_RESULT_ERROR ); } }
@Test public void testCheckInputRowsBothEmpty() throws KettleStepException { when( transMeta.getPrevStepFields( REFERENCE_STEP_NAME ) ).thenReturn( generateRowMetaEmpty() ); when( transMeta.getPrevStepFields( COMPARISON_STEP_NAME ) ).thenReturn( generateRowMetaEmpty() ); meta.check( remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0], (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null ); assertNotNull( remarks ); assertTrue( remarks.size() >= 2 ); assertEquals( remarks.get( 1 ).getType(), CheckResultInterface.TYPE_RESULT_OK ); }
@Test public void testCheckInputRowsEmptyAndNonEmpty() throws KettleStepException { when( transMeta.getPrevStepFields( REFERENCE_STEP_NAME ) ).thenReturn( generateRowMetaEmpty() ); when( transMeta.getPrevStepFields( COMPARISON_STEP_NAME ) ).thenReturn( generateRowMeta10Strings() ); meta.check( remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0], (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null ); assertNotNull( remarks ); assertTrue( remarks.size() >= 2 ); assertEquals( remarks.get( 1 ).getType(), CheckResultInterface.TYPE_RESULT_ERROR ); }
@Test public void testCheckErrorsOnNaN() { List<CheckResultInterface> remarks = new ArrayList<>(); meta.setBatchDuration( "blah" ); meta.setBatchSize( "blah" ); meta.check( remarks, null, null, null, null, null, null, new Variables(), null, null ); assertEquals( 2, remarks.size() ); assertEquals( CheckResultInterface.TYPE_RESULT_ERROR, remarks.get( 0 ).getType() ); assertEquals( "The \"Duration\" field is using a non-numeric value. Please set a numeric value.", remarks.get( 0 ).getText() ); assertEquals( CheckResultInterface.TYPE_RESULT_ERROR, remarks.get( 1 ).getType() ); assertEquals( "The \"Number of records\" field is using a non-numeric value. Please set a numeric value.", remarks.get( 1 ).getText() ); }
remarks.stream().filter( result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR ) .peek( result -> logError( result.getText() ) ) .count() > 0;
StringBuilder message = new StringBuilder(); for ( CheckResultInterface remark : remarks ) { if ( remark.getType() == CheckResultInterface.TYPE_RESULT_ERROR ) { message.append( message.toString() ).append( Const.CR );