|
|
@@ -6,8 +6,6 @@ import java.io.IOException;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
|
|
|
public class FileConverterTest {
|
|
|
|
|
|
@@ -37,45 +35,28 @@ public class FileConverterTest {
|
|
|
deleteFile(filePath);
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
- void testConvertToUpperCase() throws IOException {
|
|
|
- convertFileAndAssert(
|
|
|
- Paths.get("src/main/resources/oneFile.txt"),
|
|
|
- "test\nprzykladowy tekst malymi literami\n12345\nabcdef\n",
|
|
|
- "TEST\nPRZYKLADOWY TEKST MALYMI LITERAMI\n12345\nABCDEF\n"
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
@Test
|
|
|
void testConvertEmpty() throws IOException {
|
|
|
convertFileAndAssert(
|
|
|
- Paths.get("src/main/resources/empty.txt"),
|
|
|
+ Paths.get("target/test-classes/empty.txt"),
|
|
|
"",
|
|
|
""
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void testConvertManyFilesToUpperCase() throws IOException {
|
|
|
- List<Path> testFiles = Arrays.asList(
|
|
|
- Paths.get("src/main/resources/testFile1.txt"),
|
|
|
- Paths.get("src/main/resources/testFile2.txt"),
|
|
|
- Paths.get("src/main/resources/testFile3.txt")
|
|
|
+ void testConvertSimpleFileToUpperCase() throws IOException {
|
|
|
+ convertFileAndAssert(
|
|
|
+ Paths.get("target/test-classes/testFile1.txt"),
|
|
|
+ "to jest test\n",
|
|
|
+ "TO JEST TEST\n"
|
|
|
);
|
|
|
-
|
|
|
- for (Path filePath : testFiles) {
|
|
|
- convertFileAndAssert(
|
|
|
- filePath,
|
|
|
- "To plik testowy",
|
|
|
- "TO PLIK TESTOWY\n"
|
|
|
- );
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void testConvertDigitsOnly() throws IOException {
|
|
|
convertFileAndAssert(
|
|
|
- Paths.get("src/main/resources/digits.txt"),
|
|
|
+ Paths.get("target/test-classes/digits.txt"),
|
|
|
"1234567890\n0987654321\n",
|
|
|
"1234567890\n0987654321\n"
|
|
|
);
|
|
|
@@ -84,15 +65,26 @@ public class FileConverterTest {
|
|
|
@Test
|
|
|
void testConvertSpecialCharacters() throws IOException {
|
|
|
convertFileAndAssert(
|
|
|
- Paths.get("src/main/resources/specialChars.txt"),
|
|
|
+ Paths.get("target/test-classes/specialChars.txt"),
|
|
|
"@#$%^&*()_+[]{}|;:',.<>/?\n-=~`\n",
|
|
|
"@#$%^&*()_+[]{}|;:',.<>/?\n-=~`\n"
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testConvertToUpperCase() throws IOException {
|
|
|
+ convertFileAndAssert(
|
|
|
+ Paths.get("target/test-classes/oneFile.txt"),
|
|
|
+ "test\nprzykladowy tekst malymi literami\n12345\nabcdef\n$@#\n",
|
|
|
+ "TEST\nPRZYKLADOWY TEKST MALYMI LITERAMI\n12345\nABCDEF\n$@#\n"
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Test
|
|
|
void testConvertNonExistentFile() {
|
|
|
- Path nonExistentFilePath = Paths.get("src/main/resources/nonExistentFile.txt");
|
|
|
+ Path nonExistentFilePath = Paths.get("target/test-classes/nonExistentFile.txt");
|
|
|
|
|
|
FileConverter converter = new FileConverter();
|
|
|
|