Polish
This commit is contained in:
@@ -26,7 +26,7 @@ import java.util.Locale;
|
||||
*/
|
||||
class DescriptionExtractor {
|
||||
|
||||
static final String NEW_LINE = System.getProperty("line.separator");
|
||||
private static final String NEW_LINE = System.getProperty("line.separator");
|
||||
|
||||
public String getShortDescription(String description) {
|
||||
if (description == null) {
|
||||
|
||||
@@ -27,41 +27,42 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
public class DescriptionExtractorTests {
|
||||
|
||||
private static final String NEW_LINE = System.getProperty("line.separator");
|
||||
|
||||
private DescriptionExtractor extractor = new DescriptionExtractor();
|
||||
|
||||
@Test
|
||||
public void extractShortDescription() {
|
||||
assertEquals("My short description.",
|
||||
this.extractor.getShortDescription("My short description. More stuff."));
|
||||
String description = this.extractor.getShortDescription("My short "
|
||||
+ "description. More stuff.");
|
||||
assertEquals("My short description.", description);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractShortDescriptionNewLineBeforeDot() {
|
||||
assertEquals("My short description.",
|
||||
this.extractor.getShortDescription("My short" + DescriptionExtractor.NEW_LINE +
|
||||
"description." + DescriptionExtractor.NEW_LINE + "More stuff."));
|
||||
String description = this.extractor.getShortDescription("My short" + NEW_LINE
|
||||
+ "description." + NEW_LINE + "More stuff.");
|
||||
assertEquals("My short description.", description);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractShortDescriptionNewLineBeforeDotWithSpaces() {
|
||||
assertEquals("My short description.",
|
||||
this.extractor
|
||||
.getShortDescription("My short "
|
||||
+ DescriptionExtractor.NEW_LINE + " description. "
|
||||
+ DescriptionExtractor.NEW_LINE + "More stuff."));
|
||||
String description = this.extractor.getShortDescription("My short " + NEW_LINE
|
||||
+ " description. " + NEW_LINE + "More stuff.");
|
||||
assertEquals("My short description.", description);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractShortDescriptionNoDot() {
|
||||
assertEquals("My short description",
|
||||
this.extractor.getShortDescription("My short description"));
|
||||
String description = this.extractor.getShortDescription("My short description");
|
||||
assertEquals("My short description", description);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractShortDescriptionNoDotMultipleLines() {
|
||||
assertEquals("My short description",
|
||||
this.extractor.getShortDescription("My short description "
|
||||
+ DescriptionExtractor.NEW_LINE + " More stuff"));
|
||||
String description = this.extractor.getShortDescription("My short description "
|
||||
+ NEW_LINE + " More stuff");
|
||||
assertEquals("My short description", description);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -35,7 +35,8 @@ class ExpressionTree extends ReflectionWrapper {
|
||||
|
||||
private final Class<?> methodInvocationTreeType = findClass("com.sun.source.tree.MethodInvocationTree");
|
||||
|
||||
private final Method methodInvocationArgumentsMethod = findMethod(this.methodInvocationTreeType, "getArguments");
|
||||
private final Method methodInvocationArgumentsMethod = findMethod(
|
||||
this.methodInvocationTreeType, "getArguments");
|
||||
|
||||
private final Class<?> newArrayTreeType = findClass("com.sun.source.tree.NewArrayTree");
|
||||
|
||||
@@ -59,7 +60,8 @@ class ExpressionTree extends ReflectionWrapper {
|
||||
|
||||
public Object getFactoryValue() throws Exception {
|
||||
if (this.methodInvocationTreeType.isAssignableFrom(getInstance().getClass())) {
|
||||
List<?> arguments = (List<?>) this.methodInvocationArgumentsMethod.invoke(getInstance());
|
||||
List<?> arguments = (List<?>) this.methodInvocationArgumentsMethod
|
||||
.invoke(getInstance());
|
||||
if (arguments.size() == 1) {
|
||||
return new ExpressionTree(arguments.get(0)).getLiteralValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user