Java Code Examples for org.pentaho.di.core.plugins.PluginRegistry#addPluginType()

The following examples show how to use org.pentaho.di.core.plugins.PluginRegistry#addPluginType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtensionPointHandlerTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void callExtensionPointTest() throws Exception {
  PluginMockInterface pluginInterface = mock( PluginMockInterface.class );
  when( pluginInterface.getName() ).thenReturn( TEST_NAME );
  when( pluginInterface.getMainType() ).thenReturn( (Class) ExtensionPointInterface.class );
  when( pluginInterface.getIds() ).thenReturn( new String[] {"testID"} );

  ExtensionPointInterface extensionPoint = mock( ExtensionPointInterface.class );
  when( pluginInterface.loadClass( ExtensionPointInterface.class ) ).thenReturn( extensionPoint );

  PluginRegistry.addPluginType( ExtensionPointPluginType.getInstance() );
  PluginRegistry.getInstance().registerPlugin( ExtensionPointPluginType.class, pluginInterface );

  final LogChannelInterface log = mock( LogChannelInterface.class );

  ExtensionPointHandler.callExtensionPoint( log, "noPoint", null );
  verify( extensionPoint, never() ).callExtensionPoint( any( LogChannelInterface.class ), any() );

  ExtensionPointHandler.callExtensionPoint( log, TEST_NAME, null );
  verify( extensionPoint, times( 1 ) ).callExtensionPoint( eq( log ), isNull() );
}
 
Example 2
Source File: SpoonStepsDelegateTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testDelStepsExtensionPointCancelDelete() throws Exception {
  PluginMockInterface pluginInterface = mock( PluginMockInterface.class );
  when( pluginInterface.getName() ).thenReturn( KettleExtensionPoint.TransBeforeDeleteSteps.id );
  when( pluginInterface.getMainType() ).thenReturn( (Class) ExtensionPointInterface.class );
  when( pluginInterface.getIds() ).thenReturn( new String[] { KettleExtensionPoint.TransBeforeDeleteSteps.id } );

  ExtensionPointInterface extensionPoint = mock( ExtensionPointInterface.class );
  when( pluginInterface.loadClass( ExtensionPointInterface.class ) ).thenReturn( extensionPoint );
  doThrow( KettleException.class ).when( extensionPoint )
      .callExtensionPoint( any( LogChannelInterface.class ), any( StepMeta[].class ) );

  PluginRegistry.addPluginType( ExtensionPointPluginType.getInstance() );
  PluginRegistry.getInstance().registerPlugin( ExtensionPointPluginType.class, pluginInterface );

  SpoonStepsDelegate delegate = mock( SpoonStepsDelegate.class );
  delegate.spoon = mock( Spoon.class );
  doCallRealMethod().when( delegate ).delSteps( any( TransMeta.class ), any( StepMeta[].class ) );

  TransMeta trans = mock( TransMeta.class );
  StepMeta[] steps = new StepMeta[] { mock( StepMeta.class ) };
  delegate.delSteps( trans, steps );

  verify( extensionPoint, times( 1 ) ).callExtensionPoint( any(), eq( steps ) );
}
 
Example 3
Source File: SalesforceConnectionTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpClass() throws KettleException {
  PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() );
  PluginRegistry.init();
  String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" );
  Encr.init( passwordEncoderPluginID );
}
 
Example 4
Source File: SafeStopTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() throws Exception {
  KettleClientEnvironment.init();
  PluginRegistry.addPluginType( StepPluginType.getInstance() );
  PluginRegistry.init();
  if ( !Props.isInitialized() ) {
    Props.init( 0 );
  }
}
 
Example 5
Source File: PanCommandExecutorTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * This method test a valid ktr and make sure the callExtensionPoint is never called, as this method is called
 * if the ktr fails in preparation step
 * @throws Throwable
 */
@Test
public void testNoTransformationFinishExtensionPointCalled() throws Throwable {
  PluginMockInterface pluginInterface = mock( PluginMockInterface.class );
  when( pluginInterface.getName() ).thenReturn( KettleExtensionPoint.TransformationFinish.id );
  when( pluginInterface.getMainType() ).thenReturn( (Class) ExtensionPointInterface.class );
  when( pluginInterface.getIds() ).thenReturn( new String[] { "extensionpointId" } );

  ExtensionPointInterface extensionPoint = mock( ExtensionPointInterface.class );
  when( pluginInterface.loadClass( ExtensionPointInterface.class ) ).thenReturn( extensionPoint );

  PluginRegistry.addPluginType( ExtensionPointPluginType.getInstance() );
  PluginRegistry.getInstance().registerPlugin( ExtensionPointPluginType.class, pluginInterface );

  // Execute a sample KTR
  String fullPath = getClass().getResource( SAMPLE_KTR ).getPath();
  Params params = mock( Params.class );

  when( params.getRepoName() ).thenReturn( "" );
  when( params.getLocalInitialDir() ).thenReturn( "" );
  when( params.getLocalFile() ).thenReturn( fullPath );
  when( params.getLocalJarFile() ).thenReturn( "" );
  when( params.getBase64Zip() ).thenReturn( "" );
  Trans trans = mockedPanCommandExecutor.loadTransFromFilesystem( "", fullPath, "", "" );

  PanCommandExecutor panCommandExecutor = new PanCommandExecutor( PanCommandExecutor.class );
  Result result = panCommandExecutor.execute( params );
  verify( extensionPoint, times( 0 ) ).callExtensionPoint( any( LogChannelInterface.class ), same( trans ) );
}
 
Example 6
Source File: ConstantIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() throws Exception {
  KettleClientEnvironment.init();
  PluginRegistry.addPluginType( StepPluginType.getInstance() );
  PluginRegistry.init();
  if ( !Props.isInitialized() ) {
    Props.init( 0 );
  }
}
 
Example 7
Source File: GaInputStepDialogTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException, KettlePluginException {
  PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() );
  PluginRegistry.init();

  GaData gaData = new GaData();
  headers = new ArrayList<>();
  headers.add( createColumnHeader( "DIMENSION", "ga:date", null ) );
  headers.add( createColumnHeader( "DIMENSION", "ga:daysSinceLastVisit", null ) );
  headers.add( createColumnHeader( "DIMENSION", "ga:visitLength", null ) );
  headers.add( createColumnHeader( "DIMENSION", "ga:visitCount", null ) );
  headers.add( createColumnHeader( "DIMENSION", "ga:latitude", null ) );
  headers.add( createColumnHeader( "DIMENSION", "ga:longitude", null ) );
  headers.add( createColumnHeader( "DIMENSION", "ga:other", null ) );

  headers.add( createColumnHeader( "METRIC", "currency", "currency" ) );
  headers.add( createColumnHeader( "METRIC", "float", "float" ) );
  headers.add( createColumnHeader( "METRIC", "percent", "percent" ) );
  headers.add( createColumnHeader( "METRIC", "us_currency", "us_currency" ) );
  headers.add( createColumnHeader( "METRIC", "time", "time" ) );
  headers.add( createColumnHeader( "METRIC", "integer", "integer" ) );
  headers.add( createColumnHeader( "METRIC", "other", "other" ) );

  gaData.setColumnHeaders( headers );

  gaData.setProfileInfo( new GaData.ProfileInfo() );

  List<List<String>> data = new ArrayList<>();
  data.add( new ArrayList<String>() );

  gaData.setRows( data );
  doReturn( gaData ).when( query ).execute();
  doReturn( tableItem ).when( table ).getItem( anyInt() );
  tableView.table = table;
  doReturn( tableView ).when( dialog ).getTableView();
  doCallRealMethod().when( dialog ).getFields();
  doReturn( query ).when( dialog ).getPreviewQuery();
  doReturn( mock( GaInputStepMeta.class ) ).when( dialog ).getInput();
}
 
Example 8
Source File: SalesforceInsertTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws KettleException {
  PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() );
  PluginRegistry.init();
  String passwordEncoderPluginID =
      Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" );
  Encr.init( passwordEncoderPluginID );
}
 
Example 9
Source File: JmsConsumerMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() throws Exception {
  KettleClientEnvironment.init();
  PluginRegistry.addPluginType( StepPluginType.getInstance() );
  PluginRegistry.init();
  if ( !Props.isInitialized() ) {
    Props.init( 0 );
  }
  StepPluginType.getInstance().handlePluginAnnotation(
    JmsConsumerMeta.class,
    JmsConsumerMeta.class.getAnnotation( org.pentaho.di.core.annotations.Step.class ),
    Collections.emptyList(), false, null );
}
 
Example 10
Source File: SalesforceInputMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws KettleException {
  PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() );
  PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() );
  PluginRegistry.init( true );
  String passwordEncoderPluginID =
    Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" );
  Encr.init( passwordEncoderPluginID );
}
 
Example 11
Source File: ValueMetaBaseTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws KettleException {
  PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() );
  PluginRegistry.addPluginType( DatabasePluginType.getInstance() );
  PluginRegistry.init();
  KettleLogStore.init();
}
 
Example 12
Source File: SalesforceDeleteMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws KettleException {
  PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() );
  PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() );
  PluginRegistry.init( true );
  String passwordEncoderPluginID =
    Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" );
  Encr.init( passwordEncoderPluginID );
}
 
Example 13
Source File: PGBulkLoaderMetaTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() );
  PluginRegistry.init( false );
}
 
Example 14
Source File: MySQLBulkLoaderTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Default conversion mask for Number column type should be calculated according to length and precision.
 * For example, for type NUMBER(6,3) conversion mask should be: " #000.000;-#000.000"
 */
@Test
public void testNumberFormatting() throws KettleException, IOException {
  PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() );
  PluginRegistry.init( false );

  MySQLBulkLoader loader;
  MySQLBulkLoaderData ld = new MySQLBulkLoaderData();
  MySQLBulkLoaderMeta lm = new MySQLBulkLoaderMeta();

  TransMeta transMeta = new TransMeta();
  transMeta.setName( "loader" );

  PluginRegistry plugReg = PluginRegistry.getInstance();

  String loaderPid = plugReg.getPluginId( StepPluginType.class, lm );
  StepMeta stepMeta = new StepMeta( loaderPid, "loader", lm );
  Trans trans = new Trans( transMeta );
  transMeta.addStep( stepMeta );
  trans.setRunning( true );

  loader = spy( new MySQLBulkLoader( stepMeta, ld, 1, transMeta, trans ) );

  RowMeta rm = new RowMeta();
  ValueMetaNumber vm = new ValueMetaNumber( "Test" );
  rm.addValueMeta( vm );
  RowMeta spyRowMeta = spy( new RowMeta() );
  when( spyRowMeta.getValueMeta( anyInt() ) ).thenReturn( vm );
  loader.setInputRowMeta( spyRowMeta );

  MySQLBulkLoaderMeta smi = new MySQLBulkLoaderMeta();
  smi.setFieldStream( new String[] { "Test" } );
  smi.setFieldFormatType( new int[] { MySQLBulkLoaderMeta.FIELD_FORMAT_TYPE_OK } );
  smi.setDatabaseMeta( mock( DatabaseMeta.class ) );

  ValueMetaNumber vmn = new ValueMetaNumber( "Test" );
  vmn.setLength( 6, 3 );

  MySQLBulkLoaderData sdi = new MySQLBulkLoaderData();
  sdi.keynrs = new int[1];
  sdi.keynrs[0] = 0;
  sdi.fifoStream = mock( OutputStream.class );
  sdi.bulkFormatMeta = new ValueMetaInterface[] { vmn };

  loader.init( smi, sdi );
  loader.first = false;

  when( loader.getRow() ).thenReturn( new Double[] { 1.023 } );
  loader.processRow( smi, sdi );
  verify( sdi.fifoStream, times( 1 ) ).write( " 001.023".getBytes() );
  assertEquals( " #000.000;-#000.000", vmn.getDecimalFormat().toPattern() );
}
 
Example 15
Source File: CompressionProviderFactoryTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  PluginRegistry.addPluginType( CompressionPluginType.getInstance() );
  PluginRegistry.init( false );
}
 
Example 16
Source File: GZIPCompressionOutputStreamTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  PluginRegistry.addPluginType( CompressionPluginType.getInstance() );
  PluginRegistry.init( false );
}
 
Example 17
Source File: DBCacheTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpClass() throws KettleException {
  PluginRegistry.addPluginType( ValueMetaPluginType.getInstance() );
  PluginRegistry.init();
}
 
Example 18
Source File: GZIPCompressionProviderTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  PluginRegistry.addPluginType( CompressionPluginType.getInstance() );
  PluginRegistry.init( false );
}
 
Example 19
Source File: TextFileOutputTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  PluginRegistry.addPluginType( CompressionPluginType.getInstance() );
  PluginRegistry.init( false );
}
 
Example 20
Source File: ZIPCompressionProviderTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  PluginRegistry.addPluginType( CompressionPluginType.getInstance() );
  PluginRegistry.init( false );
}