|
@@ -29,29 +29,30 @@ public class FileConverterTest {
|
|
|
assertEquals(expectedContent, actualContent);
|
|
assertEquals(expectedContent, actualContent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Test
|
|
|
|
|
- void testConvertToUpperCase() throws IOException {
|
|
|
|
|
- Path filePath = Paths.get("src/main/resources/oneFile.txt");
|
|
|
|
|
- createFileWithContent(filePath, "test\nprzykladowy tekst malymi literami\n12345\nabcdef\n");
|
|
|
|
|
- String expectedContent = "TEST\nPRZYKLADOWY TEKST MALYMI LITERAMI\n12345\nABCDEF\n";
|
|
|
|
|
-
|
|
|
|
|
|
|
+ private void convertFileAndAssert(Path filePath, String content, String expectedContent) throws IOException {
|
|
|
|
|
+ createFileWithContent(filePath, content);
|
|
|
FileConverter converter = new FileConverter();
|
|
FileConverter converter = new FileConverter();
|
|
|
converter.convertToUpperCase(filePath.toString());
|
|
converter.convertToUpperCase(filePath.toString());
|
|
|
-
|
|
|
|
|
assertFileContent(filePath, expectedContent);
|
|
assertFileContent(filePath, expectedContent);
|
|
|
deleteFile(filePath);
|
|
deleteFile(filePath);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
- void testConvertEmpty() throws IOException {
|
|
|
|
|
- Path emptyFilePath = Paths.get("src/main/resources/empty.txt");
|
|
|
|
|
- createFileWithContent(emptyFilePath, "");
|
|
|
|
|
-
|
|
|
|
|
- FileConverter converter = new FileConverter();
|
|
|
|
|
- converter.convertToUpperCase(emptyFilePath.toString());
|
|
|
|
|
|
|
+ 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"
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- assertFileContent(emptyFilePath, "");
|
|
|
|
|
- deleteFile(emptyFilePath);
|
|
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void testConvertEmpty() throws IOException {
|
|
|
|
|
+ convertFileAndAssert(
|
|
|
|
|
+ Paths.get("src/main/resources/empty.txt"),
|
|
|
|
|
+ "",
|
|
|
|
|
+ ""
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -63,40 +64,30 @@ public class FileConverterTest {
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
for (Path filePath : testFiles) {
|
|
for (Path filePath : testFiles) {
|
|
|
- createFileWithContent(filePath, "To plik testowy");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- FileConverter converter = new FileConverter();
|
|
|
|
|
-
|
|
|
|
|
- for (Path filePath : testFiles) {
|
|
|
|
|
- converter.convertToUpperCase(filePath.toString());
|
|
|
|
|
- assertFileContent(filePath, "TO PLIK TESTOWY\n");
|
|
|
|
|
- deleteFile(filePath);
|
|
|
|
|
|
|
+ convertFileAndAssert(
|
|
|
|
|
+ filePath,
|
|
|
|
|
+ "To plik testowy",
|
|
|
|
|
+ "TO PLIK TESTOWY\n"
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
void testConvertDigitsOnly() throws IOException {
|
|
void testConvertDigitsOnly() throws IOException {
|
|
|
- Path digitsFilePath = Paths.get("src/main/resources/digits.txt");
|
|
|
|
|
- createFileWithContent(digitsFilePath, "1234567890\n0987654321\n");
|
|
|
|
|
-
|
|
|
|
|
- FileConverter converter = new FileConverter();
|
|
|
|
|
- converter.convertToUpperCase(digitsFilePath.toString());
|
|
|
|
|
-
|
|
|
|
|
- assertFileContent(digitsFilePath, "1234567890\n0987654321\n");
|
|
|
|
|
- deleteFile(digitsFilePath);
|
|
|
|
|
|
|
+ convertFileAndAssert(
|
|
|
|
|
+ Paths.get("src/main/resources/digits.txt"),
|
|
|
|
|
+ "1234567890\n0987654321\n",
|
|
|
|
|
+ "1234567890\n0987654321\n"
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
void testConvertSpecialCharacters() throws IOException {
|
|
void testConvertSpecialCharacters() throws IOException {
|
|
|
- Path specialCharactersFilePath = Paths.get("src/main/resources/specialChars.txt");
|
|
|
|
|
- createFileWithContent(specialCharactersFilePath, "@#$%^&*()_+[]{}|;:',.<>/?\n-=~`\n");
|
|
|
|
|
-
|
|
|
|
|
- FileConverter converter = new FileConverter();
|
|
|
|
|
- converter.convertToUpperCase(specialCharactersFilePath.toString());
|
|
|
|
|
-
|
|
|
|
|
- assertFileContent(specialCharactersFilePath, "@#$%^&*()_+[]{}|;:',.<>/?\n-=~`\n");
|
|
|
|
|
- deleteFile(specialCharactersFilePath);
|
|
|
|
|
|
|
+ convertFileAndAssert(
|
|
|
|
|
+ Paths.get("src/main/resources/specialChars.txt"),
|
|
|
|
|
+ "@#$%^&*()_+[]{}|;:',.<>/?\n-=~`\n",
|
|
|
|
|
+ "@#$%^&*()_+[]{}|;:',.<>/?\n-=~`\n"
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -114,5 +105,4 @@ public class FileConverterTest {
|
|
|
|
|
|
|
|
assertTrue(actualMessage.contains(expectedMessage));
|
|
assertTrue(actualMessage.contains(expectedMessage));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|