HadoopExitMeta extends BaseStepMeta implements StepMetaInterface { @Override public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info ) { CheckResult cr; if ( prev == null || prev.size() == 0 ) { cr = new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( PKG, HADOOP_EXIT_META_CHECK_RESULT_NO_DATA_STREAM ), stepinfo ); remarks.add( cr ); } else { List<String> fieldnames = Arrays.asList( prev.getFieldNames() ); HadoopExitMeta stepMeta = (HadoopExitMeta) stepinfo.getStepMetaInterface(); if ( ( stepMeta.getOutKeyFieldname() == null ) || stepMeta.getOutValueFieldname() == null ) { cr = new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( PKG, HADOOP_EXIT_META_CHECK_RESULT_NO_SPECIFIED_FIELDS, prev.size() + "" ), stepinfo ); remarks.add( cr ); } else { if ( fieldnames.contains( stepMeta.getOutKeyFieldname() ) && fieldnames.contains( stepMeta.getOutValueFieldname() ) ) { cr = new CheckResult( CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString( PKG, HADOOP_EXIT_META_CHECK_RESULT_STEP_RECEVING_DATA, prev.size() + "" ), stepinfo ); remarks.add( cr ); } else { cr = new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( PKG, HADOOP_EXIT_META_CHECK_RESULT_NOT_RECEVING_SPECIFIED_FIELDS, prev.size() + "" ), stepinfo ); remarks.add( cr ); } } } } HadoopExitMeta(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); @Override String getXML(); Object clone(); @Override void setDefault(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep,
      VariableSpace space ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo, RowMetaInterface prev,
      String[] input, String[] output, RowMetaInterface info ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
      Trans trans ); StepDataInterface getStepData(); String getOutKeyFieldname(); void setOutKeyFieldname( String arg ); String getOutValueFieldname(); void setOutValueFieldname( String arg ); @Override String getDialogClassName(); static final String ERROR_INVALID_KEY_FIELD; static final String ERROR_INVALID_VALUE_FIELD; static final String OUT_KEY; static final String OUT_VALUE; static final String HADOOP_EXIT_META_CHECK_RESULT_NO_DATA_STREAM; static final String HADOOP_EXIT_META_CHECK_RESULT_NO_SPECIFIED_FIELDS; static final String HADOOP_EXIT_META_CHECK_RESULT_STEP_RECEVING_DATA; static final String HADOOP_EXIT_META_CHECK_RESULT_NOT_RECEVING_SPECIFIED_FIELDS; static Class<?> PKG; static final String DIALOG_NAME; static String OUT_KEY_FIELDNAME; static String OUT_VALUE_FIELDNAME; }
@Test public void testCheckNoDataStream() { List<CheckResultInterface> remarks = new ArrayList<>(); StepMeta stepinfo = mock( StepMeta.class ); hadoopExitMeta.check( remarks, null, stepinfo, null, null, null, null ); assertSingleRemark( remarks, CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( HadoopExitMeta.PKG, HadoopExitMeta.HADOOP_EXIT_META_CHECK_RESULT_NO_DATA_STREAM ), stepinfo ); }
@Test public void testCheckEmptyDataStream() { List<CheckResultInterface> remarks = new ArrayList<>(); StepMeta stepinfo = mock( StepMeta.class ); RowMetaInterface prev = mock( RowMetaInterface.class ); when( prev.size() ).thenReturn( 0 ); hadoopExitMeta.check( remarks, null, stepinfo, prev, null, null, null ); assertSingleRemark( remarks, CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( HadoopExitMeta.PKG, HadoopExitMeta.HADOOP_EXIT_META_CHECK_RESULT_NO_DATA_STREAM ), stepinfo ); }
@Test public void testCheckNoSpecifiedFieldsNullOutKeyFieldName() { List<CheckResultInterface> remarks = new ArrayList<>(); StepMeta stepinfo = mock( StepMeta.class ); when( stepinfo.getStepMetaInterface() ).thenReturn( hadoopExitMeta ); RowMetaInterface prev = mock( RowMetaInterface.class ); when( prev.size() ).thenReturn( 1 ); when( prev.getFieldNames() ).thenReturn( new String[ 0 ] ); hadoopExitMeta.check( remarks, null, stepinfo, prev, null, null, null ); assertSingleRemark( remarks, CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( HadoopExitMeta.PKG, HadoopExitMeta.HADOOP_EXIT_META_CHECK_RESULT_NO_SPECIFIED_FIELDS, prev.size() + "" ), stepinfo ); }