Skip to content

Commit b138325

Browse files
Remove AssertJ in favor of plain JUnit5
1 parent 3cb1048 commit b138325

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

src/test/java/org/jabref/logic/layout/format/MarkdownFormatterTest.java

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import org.junit.jupiter.api.BeforeEach;
44
import org.junit.jupiter.api.Test;
55

6-
import static org.assertj.core.api.Assertions.assertThat;
7-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertFalse;
8+
import static org.junit.jupiter.api.Assertions.assertThrows;
9+
import static org.junit.jupiter.api.Assertions.assertTrue;
810

911
class MarkdownFormatterTest {
1012

@@ -17,44 +19,48 @@ void setUp() {
1719

1820
@Test
1921
void formatWhenFormattingPlainTextThenReturnsTextWrappedInParagraph() {
20-
assertThat(markdownFormatter.format("Hello World")).isEqualTo("<p>Hello World</p>");
22+
assertEquals("<p>Hello World</p>", markdownFormatter.format("Hello World"));
2123
}
2224

2325
@Test
2426
void formatWhenFormattingComplexMarkupThenReturnsOnlyOneLine() {
2527
String source = "Markup\n\n* list item one\n* list item 2\n\n rest";
26-
assertThat(markdownFormatter.format(source))
27-
.contains("Markup<br />")
28-
.contains("<li>list item one</li>")
29-
.contains("<li>list item 2</li>")
30-
.contains("> rest")
31-
.doesNotContain("\n");
28+
29+
String actual = markdownFormatter.format(source);
30+
31+
// Only test relevant bits and ignore possible whitespace introduced by html-renderer
32+
assertTrue(actual.contains("Markup<br />"));
33+
assertTrue(actual.contains("<li>list item one</li>"));
34+
assertTrue(actual.contains("<li>list item 2</li>"));
35+
assertTrue(actual.contains("> rest"));
36+
assertFalse(actual.contains("\n"));
3237
}
3338

3439
@Test
3540
void formatWhenFormattingEmptyStringThenReturnsEmptyString() {
36-
assertThat(markdownFormatter.format("")).isEqualTo("");
41+
assertEquals("", markdownFormatter.format(""));
3742
}
3843

3944
@Test
4045
void formatWhenFormattingNullThenThrowsException() {
41-
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> markdownFormatter.format(null))
42-
.withMessageContaining("Field Text should not be null, when handed to formatter")
43-
.withNoCause();
46+
Exception exception = assertThrows(NullPointerException.class, () -> markdownFormatter.format(null));
47+
assertEquals("Field Text should not be null, when handed to formatter", exception.getMessage());
4448
}
4549

4650
@Test
4751
void formatWhenMarkupContainingStrikethroughThenContainsMatchingDel() {
48-
assertThat(markdownFormatter.format("a ~~b~~ b")).contains("<del>b</del>");
52+
// Only test strikethrough extension
53+
assertTrue(markdownFormatter.format("a ~~b~~ b").contains("<del>b</del>"));
4954
}
5055

5156
@Test
5257
void formatWhenMarkupContainingTaskListThenContainsFormattedTaskList() {
53-
assertThat(markdownFormatter.format("Some text\n" +
58+
String actual = markdownFormatter.format("Some text\n" +
5459
"* [ ] open task\n" +
5560
"* [x] closed task\n\n" +
56-
"some other text"))
57-
.contains("<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"disabled\" readonly=\"readonly\" />&nbsp;open task</li>")
58-
.contains("<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"checked\" disabled=\"disabled\" readonly=\"readonly\" />&nbsp;closed task</li>");
61+
"some other text");
62+
// Only test list items
63+
assertTrue(actual.contains("<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled=\"disabled\" readonly=\"readonly\" />&nbsp;open task</li>"));
64+
assertTrue(actual.contains("<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" checked=\"checked\" disabled=\"disabled\" readonly=\"readonly\" />&nbsp;closed task</li>"));
5965
}
6066
}

0 commit comments

Comments
 (0)