This commit is contained in:
Phillip Webb
2015-07-14 22:17:52 -07:00
parent 68d875bdc6
commit f0f5f78e25
17 changed files with 69 additions and 58 deletions

View File

@@ -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) {

View File

@@ -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

View File

@@ -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();
}