/*
* Pentaho Data Integration
*
* Copyright (C) 2002-2015 by Pentaho : http://www.pentaho.com
*
* **************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pentaho.di.core.extension;
import org.junit.Test;
import org.pentaho.di.core.logging.LogChannelInterface;
import org.pentaho.di.core.plugins.PluginRegistry;
import static org.mockito.Mockito.*;
public class ExtensionPointHandlerTest {
public static final String TEST_NAME = "testName";
@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() );
}
}