|
| 1 | +/* |
| 2 | + * Copyright (C) 2024 The Project Lombok Authors. |
| 3 | + * |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | + * of this software and associated documentation files (the "Software"), to deal |
| 6 | + * in the Software without restriction, including without limitation the rights |
| 7 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 | + * copies of the Software, and to permit persons to whom the Software is |
| 9 | + * furnished to do so, subject to the following conditions: |
| 10 | + * |
| 11 | + * The above copyright notice and this permission notice shall be included in |
| 12 | + * all copies or substantial portions of the Software. |
| 13 | + * |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 20 | + * THE SOFTWARE. |
| 21 | + */ |
| 22 | +package lombok.eclipse.misc; |
| 23 | + |
| 24 | +import static org.junit.Assert.assertEquals; |
| 25 | + |
| 26 | +import org.eclipse.jdt.core.ICompilationUnit; |
| 27 | +import org.eclipse.jdt.core.IJavaElement; |
| 28 | +import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2; |
| 29 | +import org.junit.Rule; |
| 30 | +import org.junit.Test; |
| 31 | +import org.junit.runner.RunWith; |
| 32 | + |
| 33 | +import lombok.eclipse.EclipseRunner; |
| 34 | +import lombok.eclipse.SetupSingleFileTest; |
| 35 | + |
| 36 | +@RunWith(EclipseRunner.class) |
| 37 | +public class JavadocTest { |
| 38 | + |
| 39 | + @Rule |
| 40 | + public SetupSingleFileTest setup = new SetupSingleFileTest(); |
| 41 | + |
| 42 | + @Test |
| 43 | + public void getterSetter() throws Exception { |
| 44 | + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Javadoc.java"); |
| 45 | + |
| 46 | + IJavaElement getterInvocation = cu.codeSelect(306, 0)[0]; |
| 47 | + String getterHtmlContent = JavadocContentAccess2.getHTMLContent(getterInvocation, true); |
| 48 | + assertEquals("Getter section<dl><dt>Returns:</dt><dd> Sky is blue3</dd></dl>", getterHtmlContent); |
| 49 | + |
| 50 | + IJavaElement setterInvocation = cu.codeSelect(320, 0)[0]; |
| 51 | + String setterHtmlContent = JavadocContentAccess2.getHTMLContent(setterInvocation, true); |
| 52 | + assertEquals("Setter section<dl><dt>Parameters:</dt><dd><b>fieldName</b> Hello, World3</dd><dd><b>field</b> </dd></dl>", setterHtmlContent); |
| 53 | + } |
| 54 | +} |
0 commit comments