Skip to content

Commit 1e65633

Browse files
PluiexoPluiexo
authored andcommitted
Merge branch 'branch-A-MoreTesting'
2 parents 0e1f2de + 7504c6b commit 1e65633

File tree

5 files changed

+91
-6
lines changed

5 files changed

+91
-6
lines changed

src/main/java/plato/storage/Storage.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ public TaskManager loadFile() throws PlatoException {
4545
throw new PlatoException("directoryError");
4646
}
4747
}
48-
assert filePath.contains(".txt") : "Loading invalid storage format";
48+
if (!filePath.contains("txt") || !filePath.contains("data")) {
49+
throw new PlatoException("loadError");
50+
}
51+
4952
File storage = new File(filePath);
5053
try {
5154
if (!storage.createNewFile()) {
@@ -60,6 +63,9 @@ public TaskManager loadFile() throws PlatoException {
6063
}
6164

6265
private void loadTasksFromFile(File file, TaskManager manager) throws IOException, PlatoException {
66+
67+
assert filePath.contains(".txt") : "Loading invalid storage format";
68+
6369
BufferedReader br = new BufferedReader(new FileReader(file));
6470
String next;
6571

src/main/java/plato/ui/DialogBox.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,7 @@ private void flip() {
6868
Collections.reverse(tmp);
6969
getChildren().setAll(tmp);
7070
setAlignment(Pos.TOP_LEFT);
71+
dialog.getStyleClass().clear();
72+
dialog.getStyleClass().add("dialogLabelPlato");
7173
}
7274
}

src/main/resources/style/style.css

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
/* For the dialog box window */
2+
/* Radius are top-left, top-right, bottom-right, and bottom-left corners, in that order. */
3+
/*Padding are in the order of top right bottom and left for java fx */
24
.dialogLabel{
35
-fx-border-radius: 20 20 20 20;
46
-fx-background-radius: 20 20 20 20;
5-
-fx-background-color: #2c242a;
7+
-fx-background-color: #3d549d;
68
-fx-background-padding: 100 200 0 0;
79
-fx-padding: 15 25 15 25;
810
-fx-background-insets: 0 0 0 0;
911
-fx-text-fill: white;
10-
-fx-effect: dropshadow(gaussian, rgba(45,36,42,0.8), 13, 0, 0, 0);
11-
/* top-left, top-right, bottom-right, and bottom-left corners, in that order. */
12-
/*Padding are in the order of top right bottom and left for java fx */
12+
-fx-effect: dropshadow(gaussian, rgba(62,84,158,0.8), 13, 0, 0, 0);
13+
1314
}
15+
16+
.dialogLabelPlato{
17+
-fx-border-radius: 20 20 20 20;
18+
-fx-background-radius: 20 20 20 20;
19+
-fx-background-color: #2c242a;
20+
-fx-background-padding: 100 200 0 0;
21+
-fx-padding: 15 25 15 25;
22+
-fx-background-insets: 0 0 0 0;
23+
-fx-text-fill: white;
24+
-fx-effect: dropshadow(gaussian, rgba(45,36,42,0.8), 13, 0, 0, 0);
25+
/* top-left, top-right, bottom-right, and bottom-left corners, in that order. */
26+
/*Padding are in the order of top right bottom and left for java fx */
27+
}
1428
.image{
1529
-fx-effect: dropshadow(gaussian, rgba(45,36,42,0.8), 13, 0, 0, 0);
1630
}
1731
/* For the main screen*/
1832
.mainWindow{
19-
-fx-background-color: #68abc4;
33+
-fx-background-color: #7187b0;
2034
}

src/test/java/plato/parser/ParserTest.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88

99
import plato.PlatoException;
1010
import plato.task.Deadline;
11+
import plato.task.Event;
1112
import plato.task.Task;
1213
import plato.task.TaskManager;
1314
import plato.task.Todo;
1415

1516

1617
class ParserTest {
1718
private static final String RESPONSE_ADD = "Got it. I've added this task:";
19+
private static final String RESPONSE_VIEW_DATES = "Here are the task scheduled on that date!!";
20+
private static final String RESPONSE_FIND = "Here are the matching tasks in your list";
1821

1922
@Test
2023
public void parse_todo() throws PlatoException {
@@ -42,5 +45,47 @@ public void parse_deadline() throws PlatoException {
4245
assertArrayEquals(testValues, Parser.parse("deadline math test /by 12-04-23 1800", testManager));
4346
}
4447

48+
@Test
49+
public void parse_event() throws PlatoException {
50+
TaskManager assertManager = new TaskManager();
51+
LocalDateTime from = LocalDateTime.of(2023, 4, 12, 18, 0);
52+
LocalDateTime by = LocalDateTime.of(2023, 4, 13, 15, 0);
53+
Task testItem = new Event("science test ", from, by);
54+
assertManager.addItem(testItem);
55+
String[] testValues = new String[3];
56+
testValues[0] = RESPONSE_ADD;
57+
testValues[1] = testItem.toString();
58+
testValues[2] = assertManager.numOfTask();
59+
TaskManager testManager = new TaskManager();
60+
assertArrayEquals(testValues, Parser.parse("event science test /from 12-04-23 1800 /to 1500 13/04/23",
61+
testManager));
62+
}
63+
64+
@Test
65+
public void parse_find() throws PlatoException {
66+
TaskManager assertManager = new TaskManager();
67+
Task testItem = new Deadline("math test ", LocalDateTime.of(2023, 4, 12, 18, 0));
68+
assertManager.addItem(testItem);
69+
String[] testValues = new String[2];
70+
testValues[0] = RESPONSE_FIND;
71+
testValues[1] = "1. " + testItem;
72+
TaskManager testManager = new TaskManager();
73+
testManager.addItem(testItem);
74+
assertArrayEquals(testValues, Parser.parse("find math", testManager));
75+
}
76+
77+
@Test
78+
public void parse_view() throws PlatoException {
79+
TaskManager assertManager = new TaskManager();
80+
Task testItem = new Deadline("math test ", LocalDateTime.of(2023, 4, 12, 18, 0));
81+
assertManager.addItem(testItem);
82+
String[] testValues = new String[2];
83+
testValues[0] = RESPONSE_VIEW_DATES;
84+
testValues[1] = "1. " + testItem;
85+
TaskManager testManager = new TaskManager();
86+
testManager.addItem(testItem);
87+
assertArrayEquals(testValues, Parser.parse("view 12-04-23", testManager));
88+
}
89+
4590
}
4691

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package plato.storage;
2+
3+
import static org.junit.jupiter.api.Assertions.assertThrows;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import plato.PlatoException;
8+
9+
10+
class StorageTest {
11+
@Test
12+
public void load_wrongFile_failure() {
13+
String filePath = "testFakePath";
14+
Storage store = new Storage(filePath);
15+
assertThrows(PlatoException.class, store::loadFile);
16+
}
17+
18+
}

0 commit comments

Comments
 (0)