-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mudaafi <[email protected]>
- Loading branch information
Showing
11 changed files
with
121 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ui; | ||
|
||
import executor.command.CommandTrackTag; | ||
import org.junit.jupiter.api.Test; | ||
import storage.StorageManager; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class CommandTrackTagTest { | ||
@Test | ||
void executeTest() { | ||
StorageManager store = new StorageManager(); | ||
CommandTrackTag emptyArg = new CommandTrackTag("Track"); | ||
emptyArg.execute(store); | ||
assertEquals(emptyArg.getInfoCapsule().getUiCode(), UiCode.ERROR); | ||
assertEquals(emptyArg.getInfoCapsule().getOutputStr(), "Please enter a tag to track"); | ||
|
||
ArrayList<String> tags = new ArrayList<>(); | ||
tags.add("food"); | ||
store.getWallet().addReceipt(new Receipt(100.0, LocalDate.now(), tags)); | ||
store.getWallet().addReceipt(new Receipt(100.0, LocalDate.now(), tags)); | ||
CommandTrackTag correctArg = new CommandTrackTag("Track food"); | ||
correctArg.execute(store); | ||
assertEquals(correctArg.getInfoCapsule().getUiCode(), UiCode.TOAST); | ||
assertEquals(correctArg.getInfoCapsule().getOutputStr(), "Tracking tags: food"); | ||
|
||
CommandTrackTag multipleArgs = new CommandTrackTag("Track food dating"); | ||
multipleArgs.execute(store); | ||
assertEquals(multipleArgs.getInfoCapsule().getUiCode(), UiCode.TOAST); | ||
assertEquals(multipleArgs.getInfoCapsule().getOutputStr(), "Tracking tags: food dating"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ui; | ||
|
||
import duke.exception.DukeException; | ||
import executor.command.CommandUntrackTag; | ||
import org.junit.jupiter.api.Test; | ||
import storage.StorageManager; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class CommandUntrackTagTest { | ||
@Test | ||
void executeTest() { | ||
StorageManager store = new StorageManager(); | ||
CommandUntrackTag emptyArg = new CommandUntrackTag("Untrack"); | ||
emptyArg.execute(store); | ||
assertEquals(UiCode.ERROR, emptyArg.getInfoCapsule().getUiCode()); | ||
assertEquals("Please enter a tag to untrack", emptyArg.getInfoCapsule().getOutputStr()); | ||
|
||
try { | ||
ArrayList<String> tags = new ArrayList<>(); | ||
tags.add("food"); | ||
store.getWallet().addReceipt(new Receipt(100.0, LocalDate.now(), tags)); | ||
tags.remove("food"); | ||
store.getWallet().addReceipt(new Receipt(100.0, LocalDate.now(), tags)); | ||
store.getWallet().getReceipts().addFolder("food"); | ||
} catch (DukeException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
CommandUntrackTag correctUntrack = new CommandUntrackTag("Untrack food"); | ||
correctUntrack.execute(store); | ||
assertEquals("Untracked tags: food", correctUntrack.getInfoCapsule().getOutputStr()); | ||
assertEquals(UiCode.TOAST, correctUntrack.getInfoCapsule().getUiCode()); | ||
|
||
// Removing a non-existent tracking tag | ||
CommandUntrackTag notTracked = new CommandUntrackTag("Untrack food"); | ||
notTracked.execute(store); | ||
assertEquals(notTracked.getInfoCapsule().getUiCode(), UiCode.ERROR); | ||
assertEquals("<food> is not being tracked!\nIf you wish to track this tag, try TRACK <tag>.", | ||
notTracked.getInfoCapsule().getOutputStr()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters