PentahoResourceDoclet extends ResourceDoclet { public static boolean start( RootDoc root ) { final String outputPath = getOutputPath( root.options() ); final DocProcessorWrapper docProcessor = new DocProcessorWrapper(); final ResourceDocType result = new ResourceDocType(); final ClassDoc[] classes = root.classes(); for ( ClassDoc classDoc : classes ) { final ClassDocType classDocType = new ClassDocType(); AnnotationDesc[] annotationDescs = classDoc.annotations(); boolean toBeProcessed = false; if ( annotationDescs != null ) { for ( AnnotationDesc annotation : annotationDescs ) { if ( annotation.toString().contains( PATH_ANNOTATION ) ) { toBeProcessed = true; } } if ( !toBeProcessed ) { continue; } classDocType.setClassName( classDoc.qualifiedTypeName() ); classDocType.setCommentText( classDoc.commentText() ); docProcessor.processClassDoc( classDoc, classDocType ); for ( MethodDoc methodDoc : classDoc.methods() ) { final MethodDocType methodDocType = new MethodDocType(); annotationDescs = methodDoc.annotations(); toBeProcessed = false; if( annotationDescs != null ) { for ( AnnotationDesc annotation : annotationDescs ) { if ( annotation.toString().contains( PATH_ANNOTATION ) ) { toBeProcessed = true; } } if ( !toBeProcessed ) { continue; } methodDocType.setMethodName( methodDoc.name() ); methodDocType.setCommentText( generateComment( methodDoc ) ); docProcessor.processMethodDoc( methodDoc, methodDocType ); classDocType.getMethodDocs().add( methodDocType ); } } } result.getDocs().add( classDocType ); } try { final Class<?>[] clazzes = { result.getClass() }; final JAXBContext c = JAXBContext.newInstance( clazzes ); final Marshaller m = c.createMarshaller(); m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true ); final OutputStream out = new BufferedOutputStream( new FileOutputStream( outputPath ) ); final XMLSerializer serializer = getXMLSerializer( out ); m.marshal( result, serializer ); out.close(); } catch ( Exception e ) { return false; } return true; }  static boolean start( RootDoc root );  }
@Test public void testStart() { PentahoResourceDoclet.start( rootDoc ); String valueFromFile = readFromFile(); Assert.assertEquals( EXPECTED_WADL_FILE_CONTENT, valueFromFile ); }