-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases for BlurbMarkdownParser
- Loading branch information
1 parent
3e6ec16
commit c5cbd37
Showing
16 changed files
with
158 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/test/java/reposense/parser/BlurbMarkdownParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package reposense.parser; | ||
|
||
import static reposense.util.TestUtil.loadResource; | ||
|
||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import reposense.parser.exceptions.InvalidMarkdownException; | ||
|
||
public class BlurbMarkdownParserTest { | ||
private static final Path EMPTY_BLURB_TESTER = loadResource(BlurbMarkdownParserTest.class, | ||
"BlurbMarkdownParserTest/empty_blurbs.md"); | ||
private static final Path MALFORMED_URL_TESTER = loadResource(BlurbMarkdownParserTest.class, | ||
"BlurbMarkdownParserTest/malformed_url_blurb.md"); | ||
private static final Path MALFORMED_DELIMITER_TESTER = loadResource(BlurbMarkdownParserTest.class, | ||
"BlurbMarkdownParserTest/malformed_delimiter_blurb.md"); | ||
private static final Path MULTILINE_BLURB_TESTER = loadResource(BlurbMarkdownParserTest.class, | ||
"BlurbMarkdownParserTest/multiline_blurb.md"); | ||
private static final Path MULTIPLE_BLURB_TESTER = loadResource(BlurbMarkdownParser.class, | ||
"BlurbMarkdownParserTest/multiple_blurbs.md"); | ||
|
||
@Test | ||
public void parse_emptyBlurbTest_throwsException() { | ||
Assertions.assertThrows( | ||
InvalidMarkdownException.class, () -> new BlurbMarkdownParser(EMPTY_BLURB_TESTER).parse() | ||
); | ||
} | ||
|
||
@Test | ||
public void parse_malformedUrlBlurbTest_throwsException() { | ||
Assertions.assertThrows( | ||
InvalidMarkdownException.class, () -> new BlurbMarkdownParser(MALFORMED_URL_TESTER).parse() | ||
); | ||
} | ||
|
||
@Test | ||
public void parse_malformedDelimiterBlurbTest_success() throws Exception { | ||
BlurbMarkdownParser bmp = new BlurbMarkdownParser(MALFORMED_DELIMITER_TESTER); | ||
Map<String, String> bm = bmp.parse().getAllMappings(); | ||
Assertions.assertTrue(bm.containsKey("https://github.com/reposense/testrepo-Alpha/tree/master")); | ||
Assertions.assertEquals( | ||
bm.get("https://github.com/reposense/testrepo-Alpha/tree/master"), | ||
"Master branch of testrepo-Alpha\n" | ||
+ "<!--repo--bunchofcharacters that don't count>\n" | ||
+ "https://github.com/reposense/testrepo-Alpha/tree/master\n" | ||
+ "Master branch of testrepo-Alpha\n" | ||
+ "<!--repo - this is not legal and will be captured as part of the text -->" | ||
); | ||
} | ||
|
||
@Test | ||
public void parse_multilineBlurbTest_success() throws Exception { | ||
BlurbMarkdownParser bmp = new BlurbMarkdownParser(MULTILINE_BLURB_TESTER); | ||
Map<String, String> bm = bmp.parse().getAllMappings(); | ||
Assertions.assertTrue(bm.containsKey("https://github.com/reposense/testrepo-Alpha/tree/master")); | ||
Assertions.assertEquals( | ||
bm.get("https://github.com/reposense/testrepo-Alpha/tree/master"), | ||
"Master branch of testrepo-Alpha\n" | ||
+ "A\n" | ||
+ "long\n" | ||
+ "line\n" | ||
+ "of\n" | ||
+ "description\n" | ||
+ "of\n" | ||
+ "testrepo\n" | ||
+ "Alpha" | ||
); | ||
} | ||
|
||
@Test | ||
public void parse_multipleBlurbTest_success() throws Exception { | ||
BlurbMarkdownParser bmp = new BlurbMarkdownParser(MULTIPLE_BLURB_TESTER); | ||
Map<String, String> bm = bmp.parse().getAllMappings(); | ||
Assertions.assertTrue(bm.keySet().containsAll( | ||
List.of("https://github.com/reposense/testrepo-Alpha/tree/master", | ||
"https://github.com/reposense/testrepo-Beta/tree/master", | ||
"https://github.com/reposense/testrepo-Gamma/tree/master", | ||
"https://github.com/reposense/testrepo-Sigma/tree/master") | ||
)); | ||
Assertions.assertEquals( | ||
bm.get("https://github.com/reposense/testrepo-Alpha/tree/master"), | ||
"Master branch of testrepo-Alpha" | ||
); | ||
Assertions.assertEquals( | ||
bm.get("https://github.com/reposense/testrepo-Beta/tree/master"), | ||
"Master branch of testrepo-Beta" | ||
); | ||
Assertions.assertEquals( | ||
bm.get("https://github.com/reposense/testrepo-Gamma/tree/master"), | ||
"Master branch of testrepo-Gamma" | ||
); | ||
Assertions.assertEquals( | ||
bm.get("https://github.com/reposense/testrepo-Sigma/tree/master"), | ||
"Master branch of testrepo-Sigma" | ||
); | ||
} | ||
} |
Empty file.
7 changes: 7 additions & 0 deletions
7
src/test/resources/BlurbMarkdownParserTest/malformed_delimiter_blurb.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
https://github.com/reposense/testrepo-Alpha/tree/master | ||
Master branch of testrepo-Alpha | ||
<!--repo--bunchofcharacters that don't count> | ||
https://github.com/reposense/testrepo-Alpha/tree/master | ||
Master branch of testrepo-Alpha | ||
<!--repo - this is not legal and will be captured as part of the text --> | ||
<!--repo-->but this is legal and will be ignored |
2 changes: 2 additions & 0 deletions
2
src/test/resources/BlurbMarkdownParserTest/malformed_url_blurb.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
://github/reposense/testrepo-Alp | ||
Malformed URL Test |
10 changes: 10 additions & 0 deletions
10
src/test/resources/BlurbMarkdownParserTest/multiline_blurb.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
https://github.com/reposense/testrepo-Alpha/tree/master | ||
Master branch of testrepo-Alpha | ||
A | ||
long | ||
line | ||
of | ||
description | ||
of | ||
testrepo | ||
Alpha |
12 changes: 12 additions & 0 deletions
12
src/test/resources/BlurbMarkdownParserTest/multiple_blurbs.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
https://github.com/reposense/testrepo-Alpha/tree/master | ||
Master branch of testrepo-Alpha | ||
<!--repo--> | ||
https://github.com/reposense/testrepo-Beta/tree/master | ||
Master branch of testrepo-Beta | ||
<!--repo--> | ||
https://github.com/reposense/testrepo-Gamma/tree/master | ||
Master branch of testrepo-Gamma | ||
<!--repo--> | ||
https://github.com/reposense/testrepo-Sigma/tree/master | ||
Master branch of testrepo-Sigma | ||
<!--repo--> |