-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
author trangntt-016 <[email protected]> 1636566642 -0500 committer trangntt-016 <[email protected]> 1636567642 -0500 Squash all commits into one
- Loading branch information
1 parent
48fad5b
commit c5f1b96
Showing
19 changed files
with
2,076 additions
and
13 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
73 changes: 71 additions & 2 deletions
73
src/main/java/test/com/os/jssg/processor/HTMLProcessorTest.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 |
---|---|---|
@@ -1,12 +1,81 @@ | ||
package test.com.os.jssg.processor; | ||
|
||
import com.os.jssg.processor.HTMLProcessor; | ||
import com.os.jssg.utils.HTMLUtils; | ||
import org.junit.jupiter.api.Test; | ||
import test.com.os.jssg.TestUtils; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class HTMLProcessorTest { | ||
private HTMLProcessor processor = new HTMLProcessor(); | ||
private HTMLUtils utils = new HTMLUtils(); | ||
|
||
@Test | ||
void shouldCreateNewFileFromValidPathAndValidOutputPathAndValidLanguage() throws IOException { | ||
String inputPath = TestUtils.generateRandomInputPath(); | ||
|
||
String outputPath = TestUtils.generateOutputPath(); | ||
|
||
String language = "en"; | ||
|
||
// WHEN | ||
processor.convertToHTML(inputPath, outputPath, language); | ||
|
||
// THEN | ||
Path folderPath = Files.list(Paths.get("./src/main/resources/output")).findFirst().get(); | ||
|
||
assertThat(folderPath).exists().toString().endsWith(".html"); | ||
|
||
// clean directory after the test | ||
utils.cleanDirectory(Paths.get(outputPath)); | ||
} | ||
|
||
@Test | ||
void shouldCreateNoFilesFromInValidPathAndValidOutputPathAndValidLanguage() throws IOException { | ||
String inputPath = "invalid filepath"; | ||
|
||
String outputPath = TestUtils.generateOutputPath(); | ||
|
||
String language = "en"; | ||
|
||
// WHEN | ||
processor.convertToHTML(inputPath, outputPath, language); | ||
|
||
// THEN | ||
List<Path> filesPath= Files.list(Paths.get("./src/main/resources/output")).collect(Collectors.toList()); | ||
|
||
assertThat(filesPath).hasSize(0); | ||
|
||
// clean directory after the test | ||
utils.cleanDirectory(Paths.get(outputPath)); | ||
} | ||
|
||
@Test | ||
void shouldThrowNullPointerExceptionFromNullPath() { | ||
System.out.println("hi"); | ||
void shouldCreateNoFilesFromValidPathAndInvalidOutputPathAndValidLanguage() throws IOException { | ||
String inputPath = TestUtils.generateRandomInputPath(); | ||
|
||
String outputPath = "invalid output"; | ||
|
||
String language = "en"; | ||
|
||
// WHEN | ||
processor.convertToHTML(inputPath, outputPath, language); | ||
|
||
// THEN | ||
List<Path> filesPath= Files.list(Paths.get("./src/main/resources/output")).collect(Collectors.toList()); | ||
|
||
assertThat(filesPath).hasSize(0); | ||
|
||
// clean directory after the test | ||
utils.cleanDirectory(Paths.get(outputPath)); | ||
} | ||
|
||
} |
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
File renamed without changes.
Oops, something went wrong.