Skip to content

Commit

Permalink
Edit: edit test case for addDeadline and addEvent command + minor edi…
Browse files Browse the repository at this point in the history
…t on conversion from date to data string
  • Loading branch information
Jnjy committed Feb 5, 2023
1 parent 8dce343 commit bc554a5
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
8 changes: 5 additions & 3 deletions data/duke.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
D | 0 | return book | 2020-06-12 2311
E | 0 | project meeting | 2020-06-12 2311 | 2021-11-12 2311
E | 0 | project meeting | 2020-06-12 2311 | 2020-06-12 2311
T | 1 | join sports club
E | 1 | test | 2020-08-15 2311 | 2021-12-12 2311
T | 0 | test
T | 0 | nth
T | 0 | what
T | 0 | 2101
T | 0 | ma2001
D | 0 | this | 2021-12-12 2011
E | 0 | this | 2021-12-12 2011 | 2021-12-12 2011
D | 0 | this | 2021-11-11 2311
E | 0 | that | 2021-11-11 2311 | 2021-11-11 2311
2 changes: 1 addition & 1 deletion src/main/java/duke/exception/InvalidDateTimeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public class InvalidDateTimeException extends DukeException {
public InvalidDateTimeException() {
super("Please insert your date using the format, YYYY-MM-DD (e.g. 2000-01-01)");
super("Please insert your date using the format, YYYY-MM-DD (e.g. 2000-01-01 2311)");
}
}
4 changes: 3 additions & 1 deletion src/main/java/duke/task/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public Deadline(String task, LocalDateTime dueDate) {

@Override
public String toData() {
String[] dateTime = this.dueDate.toString().split("T");
String dueDateData = dateTime[0] + " " + dateTime[1].replace(":", "");
String status = this.completed ? "1" : "0";
return "D | " + status + " | " + this.task + " | " + this.dueDate;
return "D | " + status + " | " + this.task + " | " + dueDateData;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/duke/task/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ public Event(String task, LocalDateTime from, LocalDateTime to) {

@Override
public String toData() {
String[] fromDate = this.from.toString().split("T");
String fromDateData = fromDate[0] + " " + fromDate[1].replace(":", "");
String[] toDate = this.from.toString().split("T");
String toDateData = toDate[0] + " " + toDate[1].replace(":", "");
String status = this.completed ? "1" : "0";
return "E | " + status + " | " + this.task + " | " + this.from + " | " + this.to;
return "E | " + status + " | " + this.task + " | " + fromDateData + " | " + toDateData;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/command/AddDeadlineCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public void init() {

@Test
public void deadlineTest() {
Command addDeadlineTest = new AddDeadlineCommand("deadline test /by 2023-01-29");
Command addDeadlineTest = new AddDeadlineCommand("deadline test /by 2023-01-29 2311");
addDeadlineTest.execute(tasks);
String expected = "[D][ ] test (by: Jan 29 2023)";
String expected = "[D][ ] test (by: Jan 29 2023, 11:11PM)";
assertEquals(expected, tasks.getTask(0).toString());
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/command/AddEventCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public void init() {

@Test
public void eventTest() {
Command addEventTest = new AddEventCommand("event testing /from 2023-01-27 /to 2023-01-29");
Command addEventTest = new AddEventCommand("event testing /from 2023-01-27 2311 /to 2023-01-29 2311");
addEventTest.execute(tasks);
String expected = "[E][ ] testing (from: Jan 27 2023 to: Jan 29 2023)";
String expected = "[E][ ] testing (from: Jan 27 2023, 11:11PM to: Jan 29 2023, 11:11PM)";
assertEquals(expected, tasks.getTask(0).toString());
}
}
8 changes: 4 additions & 4 deletions src/test/java/duke/task/DeadlineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
public class DeadlineTest {
@Test
public void testDeadlineString() {
Deadline deadline = new Deadline("test", DateTimeParser.parse("2023-01-30"));
String expected = "[D][ ] test (by: Jan 30 2023)";
Deadline deadline = new Deadline("test", DateTimeParser.parse("2023-01-30 2311"));
String expected = "[D][ ] test (by: Jan 30 2023, 11:11PM)";
assertEquals(expected, deadline.toString());
}

@Test
public void testDeadlineData() {
Deadline deadline = new Deadline("test", DateTimeParser.parse("2023-01-30"));
String expected = "D | 0 | test | 2023-01-30";
Deadline deadline = new Deadline("test", DateTimeParser.parse("2023-01-30 2311"));
String expected = "D | 0 | test | 2023-01-30 2311";
assertEquals(expected, deadline.toData());
}
}

0 comments on commit bc554a5

Please sign in to comment.