Rename invoke methods
This commit is contained in:
parent
ac9c497937
commit
3cdfa2fc0e
2 changed files with 21 additions and 21 deletions
|
@ -53,7 +53,7 @@ public class BoxFitterTest
|
||||||
"extralongword", 44
|
"extralongword", 44
|
||||||
);
|
);
|
||||||
wordMap.forEach((word, expectedSize) ->
|
wordMap.forEach((word, expectedSize) ->
|
||||||
assertThat(invoke(word))
|
assertThat(fit(word))
|
||||||
.as(word)
|
.as(word)
|
||||||
.isEqualTo(expectedSize));
|
.isEqualTo(expectedSize));
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class BoxFitterTest
|
||||||
longStringGenerator(196), 3
|
longStringGenerator(196), 3
|
||||||
);
|
);
|
||||||
wordMap.forEach((word, expectedSize) ->
|
wordMap.forEach((word, expectedSize) ->
|
||||||
assertThat(invoke(word))
|
assertThat(fit(word))
|
||||||
.as(word)
|
.as(word)
|
||||||
.isEqualTo(expectedSize));
|
.isEqualTo(expectedSize));
|
||||||
}
|
}
|
||||||
|
@ -85,18 +85,18 @@ public class BoxFitterTest
|
||||||
public void tooLongThrows() {
|
public void tooLongThrows() {
|
||||||
String longText = longStringGenerator(197);
|
String longText = longStringGenerator(197);
|
||||||
assertThatExceptionOfType(IllegalArgumentException.class)
|
assertThatExceptionOfType(IllegalArgumentException.class)
|
||||||
.isThrownBy(() -> invoke(longText));
|
.isThrownBy(() -> fit(longText));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Long text can be fitted down to a font size of 3")
|
@DisplayName("Long text can be fitted down to a font size of 3")
|
||||||
public void veryLongFits() {
|
public void veryLongFits() {
|
||||||
String longText = longStringGenerator(196);
|
String longText = longStringGenerator(196);
|
||||||
assertThatCode(() -> invoke(longText))
|
assertThatCode(() -> fit(longText))
|
||||||
.doesNotThrowAnyException();
|
.doesNotThrowAnyException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int invoke(String longText) {
|
private int fit(String longText) {
|
||||||
return boxFitter.fit(longText, fontFactory, graphics2D, box);
|
return boxFitter.fit(longText, fontFactory, graphics2D, box);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class BoxFitterTest
|
||||||
private Rectangle2D box = new Rectangle(imageSize, imageSize);
|
private Rectangle2D box = new Rectangle(imageSize, imageSize);
|
||||||
private List<Rectangle2D> boxes = Arrays.asList(box, box);
|
private List<Rectangle2D> boxes = Arrays.asList(box, box);
|
||||||
|
|
||||||
private int invoke(String longText) {
|
private int fit(String longText) {
|
||||||
return boxFitter.fit(longText, fontFactory, graphics2D, boxes);
|
return boxFitter.fit(longText, fontFactory, graphics2D, boxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ public class BoxFitterTest
|
||||||
@DisplayName("Text too long to fit single box - fits into two")
|
@DisplayName("Text too long to fit single box - fits into two")
|
||||||
public void tooLongThrows() {
|
public void tooLongThrows() {
|
||||||
String longText = longStringGenerator(197);
|
String longText = longStringGenerator(197);
|
||||||
int result = invoke(longText);
|
int result = fit(longText);
|
||||||
assertThat(result).isGreaterThan(3);
|
assertThat(result).isGreaterThan(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class TextLineWrapTest
|
||||||
|
|
||||||
private List<Rectangle2D> boxes = new ArrayList<>();
|
private List<Rectangle2D> boxes = new ArrayList<>();
|
||||||
|
|
||||||
private List<List<String>> invoke(String in) {
|
private List<List<String>> wrap(String in) {
|
||||||
return textLineWrap.wrap(in, font, graphics2D, boxes);
|
return textLineWrap.wrap(in, font, graphics2D, boxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,13 +146,13 @@ public class TextLineWrapTest
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Empty String give empty List")
|
@DisplayName("Empty String give empty List")
|
||||||
public void emptyStringEmptyList() {
|
public void emptyStringEmptyList() {
|
||||||
assertThat(invoke("")).containsExactly(Collections.emptyList());
|
assertThat(wrap("")).containsExactly(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Short string fits on one line")
|
@DisplayName("Short string fits on one line")
|
||||||
public void shortStringOnOneLine() {
|
public void shortStringOnOneLine() {
|
||||||
assertThat(invoke("x"))
|
assertThat(wrap("x"))
|
||||||
.containsExactly(Collections.singletonList("x"));
|
.containsExactly(Collections.singletonList("x"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ public class TextLineWrapTest
|
||||||
@DisplayName("Fits max 'words' per line on one line")
|
@DisplayName("Fits max 'words' per line on one line")
|
||||||
public void fitMaxWordsOneLine() {
|
public void fitMaxWordsOneLine() {
|
||||||
String input = words(wordsPerLine, WORD);
|
String input = words(wordsPerLine, WORD);
|
||||||
assertThat(invoke(input))
|
assertThat(wrap(input))
|
||||||
.containsExactly(Collections.singletonList(input));
|
.containsExactly(Collections.singletonList(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ public class TextLineWrapTest
|
||||||
@DisplayName("Wraps just over max 'words' per line onto two lines")
|
@DisplayName("Wraps just over max 'words' per line onto two lines")
|
||||||
public void wrapOneWordTooManyOntoTwoLines() {
|
public void wrapOneWordTooManyOntoTwoLines() {
|
||||||
String input = words(wordsPerLine + 1, WORD);
|
String input = words(wordsPerLine + 1, WORD);
|
||||||
assertThat(invoke(input)).containsExactly(Arrays.asList(
|
assertThat(wrap(input)).containsExactly(Arrays.asList(
|
||||||
words(wordsPerLine, WORD),
|
words(wordsPerLine, WORD),
|
||||||
WORD));
|
WORD));
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ public class TextLineWrapTest
|
||||||
public void longerStringOnThreeLines() {
|
public void longerStringOnThreeLines() {
|
||||||
String input = words(wordsPerLine + wordsPerLine + 1, WORD);
|
String input = words(wordsPerLine + wordsPerLine + 1, WORD);
|
||||||
String oneLinesWorthOfWords = words(wordsPerLine, WORD);
|
String oneLinesWorthOfWords = words(wordsPerLine, WORD);
|
||||||
assertThat(invoke(input)).containsExactly(Arrays.asList(
|
assertThat(wrap(input)).containsExactly(Arrays.asList(
|
||||||
oneLinesWorthOfWords,
|
oneLinesWorthOfWords,
|
||||||
oneLinesWorthOfWords,
|
oneLinesWorthOfWords,
|
||||||
WORD));
|
WORD));
|
||||||
|
@ -189,7 +189,7 @@ public class TextLineWrapTest
|
||||||
public void textFillsBox() {
|
public void textFillsBox() {
|
||||||
String lineOfWords = words(wordsPerLine, WORD);
|
String lineOfWords = words(wordsPerLine, WORD);
|
||||||
String words = words(linesPerBox, lineOfWords);
|
String words = words(linesPerBox, lineOfWords);
|
||||||
assertThat(invoke(words).get(0))
|
assertThat(wrap(words).get(0))
|
||||||
.hasSize(linesPerBox)
|
.hasSize(linesPerBox)
|
||||||
.allSatisfy(line ->
|
.allSatisfy(line ->
|
||||||
assertThat(line).isEqualTo(lineOfWords));
|
assertThat(line).isEqualTo(lineOfWords));
|
||||||
|
@ -220,7 +220,7 @@ public class TextLineWrapTest
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Empty String give empty List")
|
@DisplayName("Empty String give empty List")
|
||||||
public void emptyStringEmptyList() {
|
public void emptyStringEmptyList() {
|
||||||
assertThat(invoke("")).containsExactly(
|
assertThat(wrap("")).containsExactly(
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
Collections.emptyList());
|
Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ public class TextLineWrapTest
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Short string fits on one line")
|
@DisplayName("Short string fits on one line")
|
||||||
public void shortStringOnOneLine() {
|
public void shortStringOnOneLine() {
|
||||||
assertThat(invoke("x"))
|
assertThat(wrap("x"))
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
Collections.singletonList("x"),
|
Collections.singletonList("x"),
|
||||||
Collections.emptyList());
|
Collections.emptyList());
|
||||||
|
@ -238,7 +238,7 @@ public class TextLineWrapTest
|
||||||
@DisplayName("Fits max 'words' per line on one line")
|
@DisplayName("Fits max 'words' per line on one line")
|
||||||
public void fitMaxWordsOneLine() {
|
public void fitMaxWordsOneLine() {
|
||||||
String input = words(wordsPerLine, WORD);
|
String input = words(wordsPerLine, WORD);
|
||||||
assertThat(invoke(input))
|
assertThat(wrap(input))
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
Collections.singletonList(input),
|
Collections.singletonList(input),
|
||||||
Collections.emptyList() );
|
Collections.emptyList() );
|
||||||
|
@ -248,7 +248,7 @@ public class TextLineWrapTest
|
||||||
@DisplayName("Wraps just over max 'words' per line onto two lines")
|
@DisplayName("Wraps just over max 'words' per line onto two lines")
|
||||||
public void wrapOneWordTooManyOntoTwoLines() {
|
public void wrapOneWordTooManyOntoTwoLines() {
|
||||||
String input = words(wordsPerLine + 1, WORD);
|
String input = words(wordsPerLine + 1, WORD);
|
||||||
assertThat(invoke(input)).containsExactly(Arrays.asList(
|
assertThat(wrap(input)).containsExactly(Arrays.asList(
|
||||||
words(wordsPerLine, WORD),
|
words(wordsPerLine, WORD),
|
||||||
WORD),
|
WORD),
|
||||||
Collections.emptyList());
|
Collections.emptyList());
|
||||||
|
@ -259,7 +259,7 @@ public class TextLineWrapTest
|
||||||
public void longerStringOnThreeLines() {
|
public void longerStringOnThreeLines() {
|
||||||
String input = words(wordsPerLine + wordsPerLine + 1, WORD);
|
String input = words(wordsPerLine + wordsPerLine + 1, WORD);
|
||||||
String oneLinesWorthOfWords = words(wordsPerLine, WORD);
|
String oneLinesWorthOfWords = words(wordsPerLine, WORD);
|
||||||
assertThat(invoke(input)).containsExactly(Arrays.asList(
|
assertThat(wrap(input)).containsExactly(Arrays.asList(
|
||||||
oneLinesWorthOfWords,
|
oneLinesWorthOfWords,
|
||||||
oneLinesWorthOfWords,
|
oneLinesWorthOfWords,
|
||||||
WORD),
|
WORD),
|
||||||
|
@ -271,7 +271,7 @@ public class TextLineWrapTest
|
||||||
public void fitMaxLinesInFirstBox() {
|
public void fitMaxLinesInFirstBox() {
|
||||||
String oneLinesWorthOfWords = words(wordsPerLine, WORD);
|
String oneLinesWorthOfWords = words(wordsPerLine, WORD);
|
||||||
String input = words(linesPerBox, oneLinesWorthOfWords);
|
String input = words(linesPerBox, oneLinesWorthOfWords);
|
||||||
List<List<String>> result = invoke(input);
|
List<List<String>> result = wrap(input);
|
||||||
List<String> linesBoxOne = result.get(0);
|
List<String> linesBoxOne = result.get(0);
|
||||||
assertThat(linesBoxOne)
|
assertThat(linesBoxOne)
|
||||||
.hasSize(linesPerBox)
|
.hasSize(linesPerBox)
|
||||||
|
@ -285,7 +285,7 @@ public class TextLineWrapTest
|
||||||
public void overflowMaxPlusOneLinesIntoSecondBox() {
|
public void overflowMaxPlusOneLinesIntoSecondBox() {
|
||||||
String oneLinesWorthOfWords = words(wordsPerLine, WORD);
|
String oneLinesWorthOfWords = words(wordsPerLine, WORD);
|
||||||
String input = words(linesPerBox + 1, oneLinesWorthOfWords);
|
String input = words(linesPerBox + 1, oneLinesWorthOfWords);
|
||||||
List<List<String>> result = invoke(input);
|
List<List<String>> result = wrap(input);
|
||||||
List<String> linesBoxOne = result.get(0);
|
List<String> linesBoxOne = result.get(0);
|
||||||
assertThat(linesBoxOne)
|
assertThat(linesBoxOne)
|
||||||
.hasSize(linesPerBox)
|
.hasSize(linesPerBox)
|
||||||
|
|
Loading…
Reference in a new issue