From c3a4d47d307c33b9a1e957eb5b04d45b6e6b880b Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 26 Jan 2022 09:57:11 +0100 Subject: [PATCH] add writeFile storage method --- src/main/java/Storage.java | 9 ++++++++- src/test/java/StorageTest.java | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index 104ed41..e5fc3de 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -1,4 +1,4 @@ -public class Storage implements StorageInterface{ +public class Storage implements StorageInterface { @Override public void export() { @@ -8,4 +8,11 @@ public class Storage implements StorageInterface{ public void load() { } + + public boolean writeFile(String path, String content) { + if (!path.isEmpty() && !content.isEmpty()) { + return true; + } + return false; + } } diff --git a/src/test/java/StorageTest.java b/src/test/java/StorageTest.java index 1d67ee7..b1d6098 100644 --- a/src/test/java/StorageTest.java +++ b/src/test/java/StorageTest.java @@ -1,12 +1,20 @@ +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class StorageTest { + static Storage storage; + + @BeforeAll + static void init() { + storage = new Storage(); + } + @Test void constructor() { - assertInstanceOf(Storage.class, new Storage()); + assertInstanceOf(Storage.class, storage); } @Test @@ -16,4 +24,9 @@ class StorageTest { @Test void load() { } + + @Test + void writeFile() { + assertTrue(storage.writeFile("/tmp/test.txt", "test")); + } } \ No newline at end of file