Skip to content

Commit

Permalink
Merge pull request #333 from jessteoxizhi/master
Browse files Browse the repository at this point in the history
PPP and checkstyle
  • Loading branch information
mononokehime14 authored Nov 11, 2019
2 parents 00fefe1 + 16ad239 commit a9f0972
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 135 deletions.
Empty file removed GazeeeboLogger.log.lck
Empty file.
20 changes: 0 additions & 20 deletions Save.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
D|ND|yearly assignment|by: 2020-01-01 01:01:01
E|ND|party|at: 2019-11-09 12:00:00-14:00:00
E|ND|project meeting|at: 2019-01-13 08:00:00-13:00:00
E|ND|meeting friend|at: 2019-01-13 15:00:00-16:00:00
E|ND|welfare pack collection|at: 2019-01-13 16:30:00-17:30:00
E|ND|internship fair|at: 2019-01-13 18:00:00-20:30:00
D|ND|project submission|by: 2019-01-13 23:59:59
D|ND|PPP|by: 2019-01-13 23:59:59
D|ND|UG|by: 2019-01-13 23:59:59
D|ND|DG|by: 2019-01-13 23:59:59
D|ND|jar file submission|by: 2019-01-13 23:59:59
D|ND|update github page|by: 2019-01-13 23:59:59
E|ND|lunch with parents|at: 2019-01-12 12:00:00-13:00:00
E|ND|consultation|at: 2019-01-11 14:00:00-14:30:00
P|ND|watch cg2028 webcast|2019-01-10 and 2019-01-14
P|ND|do geh1036 tutorial|2019-01-09 and 2019-01-13
P|ND|polish my blade|2019-01-07 and 2019-01-09
P|ND|cut hair|2019-01-06 and 2019-01-07
P|ND|buy new chair|2019-01-05 and 2019-01-08
P|ND|clean room|2019-01-06 and 2019-01-10

Binary file modified docs/team/jessteoxizhi.pdf
Binary file not shown.
22 changes: 22 additions & 0 deletions src/main/resources/NoteDaily.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
2019-10-12
1
testing note
2020-09-11
2
note 1
note 2
2019-08-11
1
updated note
2019-11-09
10
will receive chocolate hahaha
jiayou for this busy day
today is a holiday
made a new friend today :)
managed meet mum
went to botanic gardens
saw a new species of bird
took photo of a rare bird
ai ya! failed to photograph a pretty butterfly
found a pretty pebble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@@author jessteoxizhi

package PlacesCommandTest;
package placestest;

import gazeeebo.ui.Ui;
import gazeeebo.commands.places.AddPlacesCommand;
Expand Down Expand Up @@ -59,3 +59,4 @@ void testAddWrongPlacesCommand() {
assertEquals("Please input add command in the correct format\r\n", output.toString());
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@@author jessteoxizhi

package PlacesCommandTest;
package placestest;

import gazeeebo.ui.Ui;
import gazeeebo.commands.places.DeletePlacesCommand;
Expand Down Expand Up @@ -71,3 +71,4 @@ void testDeleteWrongFormatPlacesCommand() throws IOException {
assertEquals("Please input delete command in the correct format\r\n", output.toString());
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@@author jessteoxizhi

package PlacesCommandTest;
package placestest;

import gazeeebo.ui.Ui;
import gazeeebo.commands.places.FindPlacesCommand;
Expand Down Expand Up @@ -37,7 +37,7 @@ void restoreStream() {
}

/**
* test find places command
* test find places command.
* @throws IOException exception when there is an error reading the command
*/

Expand All @@ -53,3 +53,4 @@ void testFindPlacesCommand() throws IOException {
+ "------------------------------------------\n", output.toString());
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@@author jessteoxizhi

package PlacesCommandTest;
package placestest;

import gazeeebo.ui.Ui;
import gazeeebo.commands.places.ListPlacesCommand;
Expand Down Expand Up @@ -38,7 +38,7 @@ void restoreStream() {

/**
* test list command.
* @throws IOException
* @throws IOException Exception when file cannot be read
*/

@Test
Expand All @@ -57,3 +57,4 @@ void testListPlacesCommand() throws IOException {
+ "------------------------------------------\n", output.toString());
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@@author jessteoxizhi

package PlacesCommandTest;
package placestest;

import gazeeebo.storage.TriviaStorage;
import gazeeebo.triviamanager.TriviaManager;
Expand All @@ -21,7 +21,7 @@
import java.util.Stack;
import static org.junit.jupiter.api.Assertions.assertEquals;

class PlacesCommandParserTest {
class PlacesParserTest {
private ByteArrayOutputStream output = new ByteArrayOutputStream();
private PrintStream mine = new PrintStream(output);
private PrintStream original = System.out;
Expand Down Expand Up @@ -80,3 +80,4 @@ void testPlaceCommand() throws IOException, ParseException, DukeException {
+ "\r\n",output.toString());
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@@author jessteoxizhi

package PlacesCommandTest;
package placestest;

import gazeeebo.ui.Ui;
import gazeeebo.commands.places.UndoPlacesCommand;
Expand All @@ -14,7 +14,12 @@
import java.io.IOException;
import java.io.PrintStream;
import java.text.ParseException;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.Stack;



import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down
85 changes: 42 additions & 43 deletions src/test/java/studyAssistTest/deleteModuleCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class deleteModuleCommandTest {
class deleteModuleCommandTest {
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final PrintStream originalOut = System.out;

Expand All @@ -32,19 +32,19 @@ public void setUpStreams() {
public void restoreStreams() {
System.setOut(originalOut);
}

@Test
void deleteModule_emptyException() throws IOException {
Storage storage = new Storage();
Ui ui = new Ui();
StudyAssistPageStorage studyAssistPageStorage = new StudyAssistPageStorage();
StudyPlannerCommand StudyPlan = new StudyPlannerCommand(studyAssistPageStorage);
StudyPlannerCommand studyPlan = new StudyPlannerCommand(studyAssistPageStorage);
Stack<ArrayList<ArrayList<String>>> oldStudyPlan = new Stack<>();
oldStudyPlan.push(StudyPlan.StudyPlan);
oldStudyPlan.push(studyPlan.StudyPlan);
ui.fullCommand = "delete";
try {
new DeleteModuleCommand().execute(StudyPlan,studyAssistPageStorage,ui,oldStudyPlan);
// fail();
} catch (DukeException e){
new DeleteModuleCommand().execute(studyPlan,studyAssistPageStorage,ui,oldStudyPlan);
} catch (DukeException e) {
assertEquals("Please follow the correct input format~",e.getMessage());
}
}
Expand All @@ -54,105 +54,104 @@ void deleteModule_wrongModuleException() throws IOException {
Storage storage = new Storage();
Ui ui = new Ui();
StudyAssistPageStorage studyAssistPageStorage = new StudyAssistPageStorage();
StudyPlannerCommand StudyPlan = new StudyPlannerCommand(studyAssistPageStorage);
StudyPlannerCommand studyPlan = new StudyPlannerCommand(studyAssistPageStorage);
Stack<ArrayList<ArrayList<String>>> oldStudyPlan = new Stack<>();
oldStudyPlan.push(StudyPlan.StudyPlan);
oldStudyPlan.push(studyPlan.StudyPlan);
ui.fullCommand = "delete CD1234 from 5";
try {
new DeleteModuleCommand().execute(StudyPlan,studyAssistPageStorage,ui,oldStudyPlan);
// fail();
} catch (DukeException e){
new DeleteModuleCommand().execute(studyPlan,studyAssistPageStorage,ui,oldStudyPlan);
} catch (DukeException e) {
assertEquals("We currently do not have this module.",e.getMessage());
}
}

@Test
void addModule_wrongSemesterException() throws IOException {
Storage storage = new Storage();
Ui ui = new Ui();
StudyAssistPageStorage studyAssistPageStorage = new StudyAssistPageStorage();
StudyPlannerCommand StudyPlan = new StudyPlannerCommand(studyAssistPageStorage);
StudyPlannerCommand studyPlan = new StudyPlannerCommand(studyAssistPageStorage);
Stack<ArrayList<ArrayList<String>>> oldStudyPlan = new Stack<>();
oldStudyPlan.push(StudyPlan.StudyPlan);
oldStudyPlan.push(studyPlan.StudyPlan);
ui.fullCommand = "delete CS2040C from 9";
try {
new DeleteModuleCommand().execute(StudyPlan,studyAssistPageStorage,ui,oldStudyPlan);
// fail();
} catch (DukeException | IOException e){
new DeleteModuleCommand().execute(studyPlan,studyAssistPageStorage,ui,oldStudyPlan);
} catch (DukeException | IOException e) {
assertEquals("Please input correct Semester number.",e.getMessage());
}
}

@Test
void addModule_wrongFormatException() throws IOException {
Storage storage = new Storage();
Ui ui = new Ui();
StudyAssistPageStorage studyAssistPageStorage = new StudyAssistPageStorage();
StudyPlannerCommand StudyPlan = new StudyPlannerCommand(studyAssistPageStorage);
StudyPlannerCommand studyPlan = new StudyPlannerCommand(studyAssistPageStorage);
Stack<ArrayList<ArrayList<String>>> oldStudyPlan = new Stack<>();
oldStudyPlan.push(StudyPlan.StudyPlan);
oldStudyPlan.push(studyPlan.StudyPlan);
ui.fullCommand = "delete CS2040C from";
try {
new DeleteModuleCommand().execute(StudyPlan,studyAssistPageStorage,ui,oldStudyPlan);
// fail();
} catch (DukeException | IOException e){
new DeleteModuleCommand().execute(studyPlan,studyAssistPageStorage,ui,oldStudyPlan);
} catch (DukeException | IOException e) {
assertEquals("Please follow the correct input format~",e.getMessage());
}
}

@Test
void addModule_not_existModuleException() throws IOException {
Storage storage = new Storage();
Ui ui = new Ui();
StudyAssistPageStorage studyAssistPageStorage = new StudyAssistPageStorage();
StudyPlannerCommand StudyPlan = new StudyPlannerCommand(studyAssistPageStorage);
StudyPlannerCommand studyPlan = new StudyPlannerCommand(studyAssistPageStorage);
Stack<ArrayList<ArrayList<String>>> oldStudyPlan = new Stack<>();
oldStudyPlan.push(StudyPlan.StudyPlan);
oldStudyPlan.push(studyPlan.StudyPlan);
ui.fullCommand = "delete CS3230 sem 5";
try {
new DeleteModuleCommand().execute(StudyPlan,studyAssistPageStorage,ui,oldStudyPlan);
// fail();
} catch (DukeException | IOException e){
new DeleteModuleCommand().execute(studyPlan,studyAssistPageStorage,ui,oldStudyPlan);
} catch (DukeException | IOException e) {
assertEquals("This module is not inside the study plan",e.getMessage());
}
}

@Test
void deleteModuleTest() throws IOException {
Storage storage = new Storage();
Ui ui = new Ui();
StudyAssistPageStorage studyAssistPageStorage = new StudyAssistPageStorage();
StudyPlannerCommand StudyPlan = new StudyPlannerCommand(studyAssistPageStorage);
StudyPlannerCommand studyPlan = new StudyPlannerCommand(studyAssistPageStorage);
Stack<ArrayList<ArrayList<String>>> oldStudyPlan = new Stack<>();
oldStudyPlan.push(StudyPlan.StudyPlan);
oldStudyPlan.push(studyPlan.StudyPlan);
ui.fullCommand = "delete CS2040C from 5";
String ModuleCode = "CS2040C";
int Semester = Integer.parseInt(ui.fullCommand.split(" ")[3]) - 1;
String moduleCode = "CS2040C";
int semester = Integer.parseInt(ui.fullCommand.split(" ")[3]) - 1;
boolean flag = false;
int semester_number = -1;
for(int i=0;i<StudyPlan.StudyPlan.size()&& !flag;i++){
if(StudyPlan.StudyPlan.get(i).contains(ModuleCode)) {
for (int i = 0;i < studyPlan.StudyPlan.size() && !flag;i++) {
if (studyPlan.StudyPlan.get(i).contains(moduleCode)) {
flag = true;
semester_number = i;
}
}
if(!flag){
if (!flag) {
try {
new DeleteModuleCommand().execute(StudyPlan, studyAssistPageStorage, ui,oldStudyPlan);
// fail();
new DeleteModuleCommand().execute(studyPlan, studyAssistPageStorage, ui,oldStudyPlan);
} catch (DukeException | IOException e) {
assertEquals("This module is not inside the study plan", e.getMessage());
}
}else if(flag && semester_number != Semester){
} else if (flag && semester_number != semester) {
try {
new DeleteModuleCommand().execute(StudyPlan, studyAssistPageStorage, ui, oldStudyPlan);
// fail();
new DeleteModuleCommand().execute(studyPlan, studyAssistPageStorage, ui, oldStudyPlan);
} catch (DukeException | IOException e) {
assertEquals("This module is not in Sem "+(Semester+1)+" but inside Sem "+(semester_number+1), e.getMessage());
assertEquals("This module is not in Sem " + (semester + 1) + " but inside Sem "
+ (semester_number + 1), e.getMessage());
}

}else {
} else {
try {
new DeleteModuleCommand().execute(StudyPlan, studyAssistPageStorage, ui,oldStudyPlan);
// fail();
new DeleteModuleCommand().execute(studyPlan, studyAssistPageStorage, ui,oldStudyPlan);
} catch (DukeException | IOException e) {
assertEquals("This module " + ModuleCode + " has been successfully deleted from Sem" + 5+".", e.getMessage());
assertEquals("This module " + moduleCode + " has been successfully deleted from Sem" + 5
+ ".", e.getMessage());
}
}
}
Expand Down
Loading

0 comments on commit a9f0972

Please sign in to comment.