builder.addSource( new StringReader( content ) );
JavaClass[] classes = builder.getClasses();
JavaClass clazz = classes[0];
JavaMethod javaMethod = clazz.getMethods()[0];
String javadoc =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "extractOriginalJavadoc", new Class[] {
String.class, AbstractJavaEntity.class }, new Object[] { content, javaMethod } );
assertEquals( " /**" + EOL +
" *" + EOL +
" * Dummy" + EOL +
" *" + EOL +
" * Method." + EOL +
" *" + EOL +
" * @param args not" + EOL +
" *" + EOL +
" * null" + EOL +
" * @param i non negative" + EOL +
" * @param object could" + EOL +
" * be" + EOL +
" * null" + EOL +
" * @return a" + EOL +
" * String" + EOL +
" *" + EOL +
" * @throws Exception if" + EOL +
" * any" + EOL +
" *" + EOL +
" */", javadoc );
String javadocContent =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "extractOriginalJavadocContent",
new Class[] { String.class, AbstractJavaEntity.class }, new Object[] {
content, javaMethod } );
assertEquals( " *" + EOL +
" * Dummy" + EOL +
" *" + EOL +
" * Method." + EOL +
" *" + EOL +
" * @param args not" + EOL +
" *" + EOL +
" * null" + EOL +
" * @param i non negative" + EOL +
" * @param object could" + EOL +
" * be" + EOL +
" * null" + EOL +
" * @return a" + EOL +
" * String" + EOL +
" *" + EOL +
" * @throws Exception if" + EOL +
" * any" + EOL +
" *", javadocContent );
String withoutEmptyJavadocLines =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
new Class[] { String.class }, new Object[] { javadocContent } );
assertTrue( withoutEmptyJavadocLines.endsWith( "any" ) );
String methodJavadoc =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "getJavadocComment", new Class[] {
String.class, AbstractJavaEntity.class }, new Object[] { content, javaMethod } );
assertEquals( " *" + EOL +
" * Dummy" + EOL +
" *" + EOL +
" * Method." + EOL +
" *", methodJavadoc );
withoutEmptyJavadocLines =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
new Class[] { String.class }, new Object[] { methodJavadoc } );
assertTrue( withoutEmptyJavadocLines.endsWith( "Method." ) );
assertEquals( 5, javaMethod.getTags().length );
AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo();
setVariableValueToObject( mojoInstance, "fixTagsSplitted", new String[] { "all" } );
DocletTag tag = javaMethod.getTags()[0];
String tagJavadoc =
(String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
javaMethod, tag } );
assertEquals( " * @param args not" + EOL +
" *" + EOL +
" * null", tagJavadoc );
withoutEmptyJavadocLines =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
new Class[] { String.class }, new Object[] { tagJavadoc } );
assertTrue( withoutEmptyJavadocLines.endsWith( "null" ) );
tag = javaMethod.getTags()[1];
tagJavadoc =
(String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
javaMethod, tag } );
assertEquals( " * @param i non negative", tagJavadoc );
withoutEmptyJavadocLines =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
new Class[] { String.class }, new Object[] { tagJavadoc } );
assertTrue( withoutEmptyJavadocLines.endsWith( "negative" ) );
tag = javaMethod.getTags()[2];
tagJavadoc =
(String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
javaMethod, tag } );
assertEquals( " * @param object could" + EOL +
" * be" + EOL +
" * null", tagJavadoc );
withoutEmptyJavadocLines =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
new Class[] { String.class }, new Object[] { tagJavadoc } );
assertTrue( withoutEmptyJavadocLines.endsWith( "null" ) );
tag = javaMethod.getTags()[3];
tagJavadoc =
(String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
javaMethod, tag } );
assertEquals( " * @return a" + EOL +
" * String" + EOL +
" *", tagJavadoc );
withoutEmptyJavadocLines =
(String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
new Class[] { String.class }, new Object[] { tagJavadoc } );
assertTrue( withoutEmptyJavadocLines.endsWith( "String" ) );
tag = javaMethod.getTags()[4];
tagJavadoc =
(String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
javaMethod, tag } );
assertEquals( " * @throws Exception if" + EOL +