diff --git a/testing-modules/mocks/src/test/java/com/baeldung/jimf/FileRepositoryUnitTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jimf/FileRepositoryUnitTest.java index 3cfb49e14f..0564b2a52b 100644 --- a/testing-modules/mocks/src/test/java/com/baeldung/jimf/FileRepositoryUnitTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jimf/FileRepositoryUnitTest.java @@ -26,7 +26,7 @@ class FileRepositoryUnitTest implements FileTestProvider { @DisplayName("Should create a file on a file system") @MethodSource("provideFileSystem") void shouldCreateFile(final FileSystem fileSystem) throws Exception { - final String fileName = "test.txt"; + final String fileName = "newFile.txt"; final Path pathToStore = fileSystem.getPath(""); fileRepository.create(pathToStore, fileName); @@ -38,10 +38,10 @@ class FileRepositoryUnitTest implements FileTestProvider { @DisplayName("Should read the content of the file") @MethodSource("provideFileSystem") void shouldReadFileContent_thenReturnIt(final FileSystem fileSystem) throws Exception { - final Path pathToStore = fileSystem.getPath(RESOURCE_FILE_NAME); - Files.copy(getResourceFilePath(), pathToStore); + final Path resourceFilePath = fileSystem.getPath(RESOURCE_FILE_NAME); + Files.copy(getResourceFilePath(), resourceFilePath); - final String content = fileRepository.read(pathToStore); + final String content = fileRepository.read(resourceFilePath); assertEquals(FILE_CONTENT, content); } @@ -50,25 +50,25 @@ class FileRepositoryUnitTest implements FileTestProvider { @DisplayName("Should update content of the file") @MethodSource("provideFileSystem") void shouldUpdateContentOfTheFile(final FileSystem fileSystem) throws Exception { - final Path pathToStore = fileSystem.getPath(RESOURCE_FILE_NAME); - Files.copy(getResourceFilePath(), pathToStore); - final String newContent = "NEW_CONTENT"; + final Path resourceFilePath = fileSystem.getPath(RESOURCE_FILE_NAME); + Files.copy(getResourceFilePath(), resourceFilePath); + final String newContent = "I'm updating you."; - final String content = fileRepository.update(pathToStore, newContent); + final String content = fileRepository.update(resourceFilePath, newContent); assertEquals(newContent, content); - assertEquals(newContent, fileRepository.read(pathToStore)); + assertEquals(newContent, fileRepository.read(resourceFilePath)); } @ParameterizedTest @DisplayName("Should update delete file") @MethodSource("provideFileSystem") void shouldDeleteFile(final FileSystem fileSystem) throws Exception { - final Path pathToStore = fileSystem.getPath(RESOURCE_FILE_NAME); - Files.copy(getResourceFilePath(), pathToStore); + final Path resourceFilePath = fileSystem.getPath(RESOURCE_FILE_NAME); + Files.copy(getResourceFilePath(), resourceFilePath); - fileRepository.delete(pathToStore); + fileRepository.delete(resourceFilePath); - assertFalse(Files.exists(pathToStore)); + assertFalse(Files.exists(resourceFilePath)); } } \ No newline at end of file diff --git a/testing-modules/mocks/src/test/java/com/baeldung/jimf/FileTestProvider.java b/testing-modules/mocks/src/test/java/com/baeldung/jimf/FileTestProvider.java index 9144a0b65f..5893e5b925 100644 --- a/testing-modules/mocks/src/test/java/com/baeldung/jimf/FileTestProvider.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jimf/FileTestProvider.java @@ -4,7 +4,7 @@ import java.nio.file.Path; import java.nio.file.Paths; public interface FileTestProvider { - String FILE_CONTENT = "BAELDUNG"; + String FILE_CONTENT = "I'm the file content."; String RESOURCE_FILE_NAME = "fileRepositoryRead.txt"; default Path getResourceFilePath() { diff --git a/testing-modules/mocks/src/test/resources/fileRepositoryRead.txt b/testing-modules/mocks/src/test/resources/fileRepositoryRead.txt index 7c2239aab9..b63f63cdd6 100644 --- a/testing-modules/mocks/src/test/resources/fileRepositoryRead.txt +++ b/testing-modules/mocks/src/test/resources/fileRepositoryRead.txt @@ -1 +1 @@ -BAELDUNG \ No newline at end of file +I'm the file content. \ No newline at end of file