### Question:
InterPluginBroker { public static void run( Map<String, Object> params, OutputStream out ) throws Exception { IPluginCall cdeRenderer = getCdeRenderer(); if ( cdeRenderer == null ) { logger.error( "No InterPluginCall found for CDE Renderer." ); return; } CallParameters parameters = new CallParameters(); for ( String key : params.keySet() ) { String value = params.get( key ).toString(); parameters.put( key, value ); } String response = cdeRenderer.call( parameters.getParameters() ); PluginIOUtils.writeOutAndFlush( out, response ); }  static void run( Map<String, Object> params, OutputStream out );  }### Answer:
@Test @PrepareForTest( { PluginEnvironment.class, InterPluginBroker.class } ) public void testRunWithConfiguredValues() throws Exception { String beanID = "configured-bean-id"; String beanMethod = "configured-bean-method"; String pluginCallResult = "Test with configured values."; PluginEnvironment environmentMock = mock( PluginEnvironment.class ); doReturn( mockPluginSettings( beanID, beanMethod ) ).when( environmentMock ) .getPluginSettings(); doReturn( mockPluginCall( true, pluginCallResult ) ).when( environmentMock ) .getPluginCall( anyString(), eq( beanID ), eq( beanMethod ) ); when( PluginEnvironment.env() ).thenReturn( environmentMock ); ByteArrayOutputStream out = new ByteArrayOutputStream(); InterPluginBroker.run( new HashMap<>(), out ); assertEquals( out.toString(), pluginCallResult ); }
@Test @PrepareForTest( { PluginEnvironment.class, InterPluginBroker.class } ) public void testRunWithLatestBeanId() throws Exception { String pluginCallResult = "Test with the latest bean id."; PluginEnvironment environmentMock = mock( PluginEnvironment.class ); doReturn( mockPluginSettings( null, null ) ).when( environmentMock ).getPluginSettings(); doReturn( mockPluginCall( false, null ) ).when( environmentMock ) .getPluginCall( anyString(), eq( "" ), eq( "" ) ); doReturn( mockPluginCall( true, pluginCallResult ) ).when( environmentMock ) .getPluginCall( anyString(), eq( CDE_RENDER_API_BEAN_ID ), eq( CDE_RENDER_API_RENDER_METHOD ) ); when( PluginEnvironment.env() ).thenReturn( environmentMock ); ByteArrayOutputStream out = new ByteArrayOutputStream(); InterPluginBroker.run( new HashMap<>(), out ); assertEquals( out.toString(), pluginCallResult ); }
@Test @PrepareForTest( { PluginEnvironment.class, InterPluginBroker.class } ) public void testRunWithLegacyBeanId() throws Exception { String pluginCallResult = "Test with legacy bean id."; PluginEnvironment environmentMock = mock( PluginEnvironment.class ); doReturn( mockPluginSettings( null, null ) ).when( environmentMock ).getPluginSettings(); doReturn( mockPluginCall( false, null ) ).when( environmentMock ) .getPluginCall( anyString(), eq( "" ), eq( "" ) ); doReturn( mockPluginCall( false, null ) ).when( environmentMock ) .getPluginCall( anyString(), eq( CDE_RENDER_API_BEAN_ID ), eq( CDE_RENDER_API_RENDER_METHOD ) ); doReturn( mockPluginCall( true, pluginCallResult ) ).when( environmentMock ) .getPluginCall( anyString(), eq( CDE_RENDER_API_LEGACY_BEAN_ID ), eq( CDE_RENDER_API_RENDER_METHOD ) ); when( PluginEnvironment.env() ).thenReturn( environmentMock ); ByteArrayOutputStream out = new ByteArrayOutputStream(); InterPluginBroker.run( new HashMap<>(), out ); assertEquals( out.toString(), pluginCallResult ); }