From 64869bdb701fcc60125b0b456da9f1e381092af6 Mon Sep 17 00:00:00 2001 From: junhyeong0411 Date: Wed, 18 Oct 2023 23:12:45 +0900 Subject: [PATCH] Test Storage --- .../java/seedu/duke/flashcard/FlashcardComponent.java | 6 ++++++ src/main/java/seedu/duke/flashcard/FlashcardStorage.java | 7 +++++++ src/test/java/seedu/duke/DukeTest.java | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/src/main/java/seedu/duke/flashcard/FlashcardComponent.java b/src/main/java/seedu/duke/flashcard/FlashcardComponent.java index ef6d8a124d..e37135afb2 100644 --- a/src/main/java/seedu/duke/flashcard/FlashcardComponent.java +++ b/src/main/java/seedu/duke/flashcard/FlashcardComponent.java @@ -37,6 +37,12 @@ public FlashcardComponent(ArrayList flashcards) { ui = new FlashcardUi(flashcardList); } + //@@author junhyeong0411 + public FlashcardStorage getStorage(){ + return this.storage; + } + + //@@author wendelinwemhoener public boolean isResponsible(String input) { FlashcardCommand command = parser.parseInput(input); diff --git a/src/main/java/seedu/duke/flashcard/FlashcardStorage.java b/src/main/java/seedu/duke/flashcard/FlashcardStorage.java index 2143b6a705..3800827000 100644 --- a/src/main/java/seedu/duke/flashcard/FlashcardStorage.java +++ b/src/main/java/seedu/duke/flashcard/FlashcardStorage.java @@ -24,6 +24,11 @@ public FlashcardStorage(String path){ } + public boolean isStorageAvailable(){ + File f = new File(this.path); + return f.exists(); + } + /** * load a flash card from certain format * Tokens includes attributes of Flashcard @@ -99,4 +104,6 @@ public void saveFlashcards(ArrayList flashcardList) { + + } diff --git a/src/test/java/seedu/duke/DukeTest.java b/src/test/java/seedu/duke/DukeTest.java index 2b935b8383..c229ccdb5f 100644 --- a/src/test/java/seedu/duke/DukeTest.java +++ b/src/test/java/seedu/duke/DukeTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; import seedu.duke.flashcard.FlashcardComponent; +import seedu.duke.flashcard.FlashcardStorage; import java.util.ArrayList; @@ -34,6 +35,14 @@ public void testFlashcardComponent_isResponsible_responsible() { assertTrue(flashcardComponent.isResponsible("list flashcards")); } + @Test + public void testFlashcardStorage_isAvailable(){ + FlashcardComponent flashcardComponent = new FlashcardComponent( + new ArrayList<>()); + FlashcardStorage storage = flashcardComponent.getStorage(); + assertTrue(storage.isStorageAvailable()); + } + @Test public void testCalendar() { assertTrue(true);