Skip to content

Commit 83e72b3

Browse files
committed
Update test cases
1 parent 4a9b391 commit 83e72b3

7 files changed

Lines changed: 120 additions & 57 deletions

File tree

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ repositories {
1010
}
1111

1212
dependencies {
13+
implementation 'org.junit.jupiter:junit-jupiter:5.4.2'
14+
implementation 'org.junit.jupiter:junit-jupiter:5.4.2'
15+
implementation 'org.junit.jupiter:junit-jupiter:5.4.2'
16+
implementation 'org.junit.jupiter:junit-jupiter:5.4.2'
1317
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0'
1418
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0'
1519

@@ -49,7 +53,7 @@ application {
4953

5054
shadowJar {
5155
archiveBaseName = "Bob"
52-
archiveClassifier = "v1.1"
56+
archiveClassifier = "v1.0"
5357
}
5458

5559
checkstyle {

docs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ e.g. in `todo NAME`, `NAME` is a parameter which can be used as `todo eat`.
3030
* Extraneous parameters for commands that do not take in parameters (such as `list` and `bye`) will be ignored.
3131
e.g. if the command specifies `list 2`, it will be interpreted as `list`.
3232

33+
### Getting a list of commands: `help`
34+
List commands that Bob can take in.
35+
36+
Format: `help`
37+
3338
### Adding a todo task: `todo`
3439
Adds a new todo task to the chatbox.
3540

src/main/java/bob/command/Command.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ public enum Command {
1919
HELP {
2020
@Override
2121
public String executeCommand(String userInput, TaskList taskList, Storage storage) {
22-
return "You can add a new task using the following commands: \n" +
23-
"todo NAME_OF_TASK\n" +
24-
"event NAME_OF_EVENT /at: YYYY-MM-DD HHMM\n" +
25-
"deadline NAME_OF_DEADLINE /by: YYYY-MM-DD HHMM\n" +
26-
"\nYou can see the whole list of tasks using: list\n" +
27-
"\nTo search for a specific task: find KEYWORDS\n" +
28-
"\nTo add a reminder for a task:\n" +
29-
"remind INDEX /on: YYYY-MM-DD HHMM\n" +
30-
"\nTo mark a task as done: done INDEX\n" +
31-
"\nTo delete a task: delete INDEX\n" +
32-
"\nTo exit the app: bye";
22+
return "You can add a new task using the following commands: \n"
23+
+ "todo NAME_OF_TASK\n"
24+
+ "event NAME_OF_EVENT /at: YYYY-MM-DD HHMM\n"
25+
+ "deadline NAME_OF_DEADLINE /by: YYYY-MM-DD HHMM\n"
26+
+ "\nYou can see the whole list of tasks using: list\n"
27+
+ "\nTo search for a specific task: find KEYWORDS\n"
28+
+ "\nTo add a reminder for a task:\n"
29+
+ "remind INDEX /on: YYYY-MM-DD HHMM\n"
30+
+ "\nTo mark a task as done: done INDEX\n"
31+
+ "\nTo delete a task: delete INDEX\n"
32+
+ "\nTo exit the app: bye";
3333
}
3434
},
3535
REMIND {

src/test/java/ParserTest.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import java.time.format.DateTimeFormatter;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import bob.BobException;
8+
import bob.processor.Parser;
9+
10+
public class ParserTest {
11+
12+
@Test
13+
public void parseName_validName() throws BobException {
14+
Parser parser = new Parser();
15+
String expected = "eat and sleep";
16+
String parsedTodoName = parser.parseName("todo eat and sleep");
17+
assertEquals(expected, parsedTodoName);
18+
19+
String parsedEventName = parser.parseName("event eat and sleep /at: 2pm");
20+
assertEquals(expected, parsedEventName);
21+
22+
String parsedDeadlineName = parser.parseName("deadline eat and sleep /by: 9pm");
23+
assertEquals(expected, parsedDeadlineName);
24+
}
25+
26+
@Test
27+
public void parseDateTime_eventDateTime_validDateTime() throws BobException {
28+
Parser parser = new Parser();
29+
30+
String userInput = "event eat and sleep /at: 2021-11-02 0200";
31+
String taskType = "event";
32+
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd MMM yyyy h:mm a");
33+
String actualParsedDateTime = parser.parseDateTime(userInput, taskType).format(dateFormatter);
34+
String expectedParsedDateTime = "02 Nov 2021 2:00 AM";
35+
assertEquals(actualParsedDateTime, expectedParsedDateTime);
36+
}
37+
38+
@Test
39+
public void parseDateTime_deadlineDateTime_validDateTime() throws BobException {
40+
Parser parser = new Parser();
41+
42+
String userInput = "deadline eat and sleep /by: 2021-11-02 2359";
43+
String taskType = "deadline";
44+
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd MMM yyyy h:mm a");
45+
String actualParsedDateTime = parser.parseDateTime(userInput, taskType).format(dateFormatter);
46+
String expectedParsedDateTime = "02 Nov 2021 11:59 PM";
47+
assertEquals(actualParsedDateTime, expectedParsedDateTime);
48+
}
49+
@Test
50+
public void parseDateTime_remindDateTime_validDateTime() throws BobException {
51+
Parser parser = new Parser();
52+
53+
String userInput = "remind 1 /on: 2021-04-13 1400";
54+
String taskType = "remind";
55+
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd MMM yyyy h:mm a");
56+
String actualParsedDateTime = parser.parseDateTime(userInput, taskType).format(dateFormatter);
57+
String expectedParsedDateTime = "13 Apr 2021 2:00 PM";
58+
assertEquals(actualParsedDateTime, expectedParsedDateTime);
59+
}
60+
61+
62+
}

src/test/java/UiTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import bob.BobException;
6+
import bob.command.Command;
7+
import bob.processor.Storage;
8+
import bob.task.TaskList;
9+
10+
public class UiTest {
11+
12+
@Test
13+
public void respondToCommand_validHelpCommand_correctResponse() throws BobException {
14+
String userInput = "help";
15+
Storage storage = new Storage("data/tasks.txt");
16+
TaskList taskList;
17+
try {
18+
taskList = storage.load();
19+
} catch (BobException e) {
20+
taskList = new TaskList();
21+
}
22+
23+
String expectedResponse = "You can add a new task using the following commands: \n"
24+
+ "todo NAME_OF_TASK\n"
25+
+ "event NAME_OF_EVENT /at: YYYY-MM-DD HHMM\n"
26+
+ "deadline NAME_OF_DEADLINE /by: YYYY-MM-DD HHMM\n"
27+
+ "\nYou can see the whole list of tasks using: list\n"
28+
+ "\nTo search for a specific task: find KEYWORDS\n"
29+
+ "\nTo add a reminder for a task:\n"
30+
+ "remind INDEX /on: YYYY-MM-DD HHMM\n"
31+
+ "\nTo mark a task as done: done INDEX\n"
32+
+ "\nTo delete a task: delete INDEX\n"
33+
+ "\nTo exit the app: bye";
34+
String actualResponse = Command.HELP.executeCommand(userInput, taskList, storage);
35+
assertEquals(expectedResponse, actualResponse);
36+
}
37+
}

text-ui-test/java/ParserTest.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

text-ui-test/java/StorageTest.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)