use of com.thoughtworks.qdox.model.JavaClass in project maven-plugins by apache.
the class AbstractFixJavadocMojoTest method testReplaceLinkTags_spacesAfterMethod.
public void testReplaceLinkTags_spacesAfterMethod() throws Throwable {
String comment = "/** {@link ConnectException#getMessage() } */";
AbstractInheritableJavaEntity entity = spy(new PrivateAbstractInheritableJavaEntity());
JavaClass clazz = mock(JavaClass.class);
when(entity.getParentClass()).thenReturn(clazz);
when(clazz.resolveType("ConnectException")).thenReturn("java.net.ConnectException");
String newComment = (String) PrivateAccessor.invoke(AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] { String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity });
assertEquals("/** {@link java.net.ConnectException#getMessage()} */", newComment);
}
use of com.thoughtworks.qdox.model.JavaClass in project maven-plugins by apache.
the class AbstractFixJavadocMojoTest method testReplaceLinkTags_spacesAfterLinkTag.
public void testReplaceLinkTags_spacesAfterLinkTag() throws Throwable {
String comment = "/** {@link ConnectException} */";
AbstractInheritableJavaEntity entity = spy(new PrivateAbstractInheritableJavaEntity());
JavaClass clazz = mock(JavaClass.class);
when(entity.getParentClass()).thenReturn(clazz);
when(clazz.resolveType("ConnectException")).thenReturn("java.net.ConnectException");
String newComment = (String) PrivateAccessor.invoke(AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] { String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity });
assertEquals("/** {@link java.net.ConnectException} */", newComment);
}
use of com.thoughtworks.qdox.model.JavaClass in project maven-plugins by apache.
the class AbstractFixJavadocMojoTest method testReplaceLinkTags_missingEndBrace.
public void testReplaceLinkTags_missingEndBrace() throws Throwable {
String comment = "/** {@link ConnectException */";
AbstractInheritableJavaEntity entity = spy(new PrivateAbstractInheritableJavaEntity());
JavaClass clazz = mock(JavaClass.class);
when(entity.getParentClass()).thenReturn(clazz);
when(clazz.resolveType("ConnectException")).thenReturn("java.net.ConnectException");
String newComment = (String) PrivateAccessor.invoke(AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] { String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity });
assertEquals("/** {@link ConnectException */", newComment);
}
use of com.thoughtworks.qdox.model.JavaClass in project maven-plugins by apache.
the class FixJavadocMojoTest method testJavadocComment.
/**
* @throws Throwable if any
*/
public void testJavadocComment() throws Throwable {
String content = "/**" + EOL + " * Dummy Class." + EOL + " */" + EOL + "public class DummyClass" + EOL + "{" + EOL + " /**" + 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 + " */" + EOL + " public static String dummyMethod( String[] args, int i, Object object )" + EOL + " throws Exception" + EOL + " {" + EOL + " return null;" + EOL + " }" + EOL + "}";
JavaDocBuilder builder = new JavaDocBuilder();
builder.setEncoding("UTF-8");
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 + " * any" + EOL + " *", tagJavadoc);
withoutEmptyJavadocLines = (String) PrivateAccessor.invoke(AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines", new Class[] { String.class }, new Object[] { tagJavadoc });
assertTrue(withoutEmptyJavadocLines.endsWith("any"));
}
use of com.thoughtworks.qdox.model.JavaClass in project maven-plugins by apache.
the class AbstractFixJavadocMojoTest method testReplaceLinkTags_spacesAfterClassName.
public void testReplaceLinkTags_spacesAfterClassName() throws Throwable {
String comment = "/** {@link ConnectException } */";
AbstractInheritableJavaEntity entity = spy(new PrivateAbstractInheritableJavaEntity());
JavaClass clazz = mock(JavaClass.class);
when(entity.getParentClass()).thenReturn(clazz);
when(clazz.resolveType("ConnectException")).thenReturn("java.net.ConnectException");
String newComment = (String) PrivateAccessor.invoke(AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] { String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity });
assertEquals("/** {@link java.net.ConnectException} */", newComment);
}
Aggregations