예제 #1
0
 @Test
 public void testJavaDocParsing() throws Exception {
   String text = "/** Text */ public class MyClass{}";
   JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, text);
   JavaDocSource<JavaClassSource> javaDoc = javaClass.getJavaDoc();
   Assert.assertNotNull(javaDoc);
   Assert.assertEquals("Text", javaDoc.getText());
   Assert.assertTrue(javaDoc.getTagNames().isEmpty());
 }
예제 #2
0
 @Test
 public void testJavaDocParsingTags() throws Exception {
   String text = "/** Do Something\n*@author George Gastaldi*/ public class MyClass{}";
   JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, text);
   JavaDocSource<JavaClassSource> javaDoc = javaClass.getJavaDoc();
   Assert.assertNotNull(javaDoc);
   Assert.assertEquals("Do Something", javaDoc.getText());
   Assert.assertEquals(1, javaDoc.getTagNames().size());
   JavaDocTag authorTag = javaDoc.getTags("@author").get(0);
   Assert.assertEquals("@author", authorTag.getName());
   Assert.assertEquals("George Gastaldi", authorTag.getValue());
 }
예제 #3
0
 @Test
 public void testJavaDocMultiLineShouldNotConcatenateWords() throws Exception {
   String text =
       "/**"
           + LINE_SEPARATOR
           + "* The country where this currency is used mostly. This field is just for"
           + LINE_SEPARATOR
           + "* informational purposes and have no effect on any processing."
           + LINE_SEPARATOR
           + "*/"
           + LINE_SEPARATOR
           + "public class MyClass{}";
   JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, text);
   JavaDocSource<JavaClassSource> javaDoc = javaClass.getJavaDoc();
   String expected =
       "The country where this currency is used mostly. This field is just for informational purposes and have no effect on any processing.";
   Assert.assertEquals(expected, javaDoc.getFullText());
 }
예제 #4
0
 @Test
 public void testJavaDocEnumConstant() throws Exception {
   String text =
       "public enum MyEnum {"
           + "/**"
           + LINE_SEPARATOR
           + " * Do Something"
           + LINE_SEPARATOR
           + " * @author George Gastaldi"
           + LINE_SEPARATOR
           + " */"
           + LINE_SEPARATOR
           + ""
           + "MY_CONSTANT;}";
   JavaEnumSource javaEnum = Roaster.parse(JavaEnumSource.class, text);
   Assert.assertFalse(javaEnum.hasJavaDoc());
   EnumConstantSource enumConstant = javaEnum.getEnumConstant("MY_CONSTANT");
   Assert.assertTrue(enumConstant.hasJavaDoc());
   JavaDocSource<EnumConstantSource> javaDoc = enumConstant.getJavaDoc();
   String expected = "Do Something" + LINE_SEPARATOR + "@author George Gastaldi";
   Assert.assertEquals(expected, javaDoc.getFullText());
 }
예제 #5
0
 @Test
 public void testJavaDocGetFullText() throws Exception {
   String text =
       "/**"
           + LINE_SEPARATOR
           + " * Do Something"
           + LINE_SEPARATOR
           + " * @author George Gastaldi"
           + LINE_SEPARATOR
           + " */"
           + LINE_SEPARATOR
           + "public class MyClass"
           + LINE_SEPARATOR
           + "{"
           + LINE_SEPARATOR
           + "}";
   JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, text);
   Assert.assertTrue(javaClass.hasJavaDoc());
   JavaDocSource<JavaClassSource> javaDoc = javaClass.getJavaDoc();
   String expected = "Do Something" + LINE_SEPARATOR + "@author George Gastaldi";
   Assert.assertEquals(expected, javaDoc.getFullText());
 }
예제 #6
0
 @Test
 public void testJavaDocSetFullText() throws Exception {
   String expected =
       "/**"
           + LINE_SEPARATOR
           + " * Do Something"
           + LINE_SEPARATOR
           + " * "
           + LINE_SEPARATOR
           + " * @author George Gastaldi"
           + LINE_SEPARATOR
           + " */"
           + LINE_SEPARATOR
           + "public class MyClass {"
           + LINE_SEPARATOR
           + "}";
   JavaClassSource javaClass =
       Roaster.create(JavaClassSource.class).setPublic().setName("MyClass");
   Assert.assertFalse(javaClass.hasJavaDoc());
   JavaDocSource<JavaClassSource> javaDoc = javaClass.getJavaDoc();
   javaDoc.setFullText("Do Something" + LINE_SEPARATOR + "* @author George Gastaldi");
   Assert.assertEquals(expected, javaClass.toString());
 }