PentahoWadlGeneratorConfig extends WadlGeneratorConfig { protected WadlGeneratorConfigDescriptionBuilder getBuilder( String plugin ) { List<IWadlDocumentResource> resourceReferences = getWadlDocumentResources(); InputStream is = null; try { for ( IWadlDocumentResource wadlDocumentResource : resourceReferences ) { if ( plugin == null && !wadlDocumentResource.isFromPlugin() ) { is = wadlDocumentResource.getResourceAsStream(); break; } else if ( wadlDocumentResource.isFromPlugin() && wadlDocumentResource.getPluginId().equals( plugin ) ) { is = wadlDocumentResource.getResourceAsStream(); break; } } } catch ( IOException e ) { e.printStackTrace(); } if ( is != null ) { return generator( WadlGeneratorResourceDocSupport.class ).prop( "resourceDocStream", is ); } return null; }  @Override List<WadlGeneratorDescription> configure();  }
@Test public void testGetBuilder() throws Exception { List<IWadlDocumentResource> list = new ArrayList<IWadlDocumentResource>(); IWadlDocumentResource documentResource1 = mock( IWadlDocumentResource.class ), documentResource2 = mock( IWadlDocumentResource.class ), documentResource3 = mock( IWadlDocumentResource.class ); list.add( documentResource1 ); list.add( documentResource2 ); list.add( documentResource3 ); doReturn( false ).when( documentResource1 ).isFromPlugin(); doReturn( true ).when( documentResource2 ).isFromPlugin(); doReturn( true ).when( documentResource3 ).isFromPlugin(); doReturn( "" ).when( documentResource1 ).getPluginId(); doReturn( "reporting" ).when( documentResource2 ).getPluginId(); doReturn( "data-access" ).when( documentResource3 ).getPluginId(); doReturn( mock( InputStream.class ) ).when( documentResource1 ).getResourceAsStream(); doReturn( mock( InputStream.class ) ).when( documentResource2 ).getResourceAsStream(); doThrow( new IOException() ).when( documentResource3 ).getResourceAsStream(); doReturn( list ).when( spyConfig ).getWadlDocumentResources(); assertNotNull( spyConfig.getBuilder( null ) ); assertNotNull( spyConfig.getBuilder( "reporting" ) ); assertNull( spyConfig.getBuilder( "data-access" ) ); doThrow( new IOException() ).when( documentResource1 ).getResourceAsStream(); assertNull( spyConfig.getBuilder( null ) ); }