StepValidationExtensionPointPlugin implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface log, Object o ) throws KettleException { if ( !validInputs( o, log ) ) { return; } CheckStepsExtension checkStepExtension = (CheckStepsExtension) o; TransMeta transMeta = checkStepExtension.getTransMeta(); for ( StepValidation stepValidation : getStepValidations() ) { StepMeta stepMeta = checkStepExtension.getStepMetas()[0]; if ( stepValidation.supportsStep( stepMeta, log ) ) { DataServiceMeta dataServiceMeta = metaStoreUtil.getDataServiceByStepName( transMeta, stepMeta.getName() ); if ( dataServiceMeta == null ) { return; } stepValidation.checkStep( checkStepExtension, dataServiceMeta, log ); } } } StepValidationExtensionPointPlugin( DataServiceContext context ); @Override void callExtensionPoint( LogChannelInterface log, Object o ); List<StepValidation> getStepValidations(); void setStepValidations( List<StepValidation> stepValidations );  }
@Test public void testCallStepValidations() throws Exception { when( stepValidation.supportsStep( stepMeta, log ) ).thenReturn( true, false ); extensionPointPlugin.callExtensionPoint( log, spiedCheckStepExtension ); extensionPointPlugin.callExtensionPoint( log, spiedCheckStepExtension ); verify( stepValidation ).checkStep( spiedCheckStepExtension, dataServiceMeta, log ); }
@Test public void testCallExtensionPointInvalidObjType() throws Exception { extensionPointPlugin.callExtensionPoint( log, "FooBar" ); verify( log ).logError( any( String.class ) ); }
@Test public void testCallExtensionPointWrongNumSteps() throws Exception { when( spiedCheckStepExtension.getStepMetas() ) .thenReturn( new StepMeta[ 5 ] ); extensionPointPlugin.callExtensionPoint( log, spiedCheckStepExtension ); verify( log ).logError( any( String.class ) ); }