diff --git a/build.gradle b/build.gradle
index 21ddcdb4a6..950f41505a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,6 +2,11 @@ plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.1.2'
+ id 'checkstyle'
+}
+
+checkstyle {
+ toolVersion = '10.2'
}
repositories {
@@ -46,7 +51,7 @@ application {
}
shadowJar {
- archiveBaseName = "AdamV0.5"
+ archiveBaseName = "AdamV0.6"
archiveClassifier = null
dependsOn("distZip", "distTar")
}
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000000..eb761a9b9a
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,434 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml
new file mode 100644
index 0000000000..39efb6e4ac
--- /dev/null
+++ b/config/checkstyle/suppressions.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
diff --git a/src/main/java/adam/Adam.java b/src/main/java/adam/Adam.java
index e0d44d4483..accc23eb3c 100644
--- a/src/main/java/adam/Adam.java
+++ b/src/main/java/adam/Adam.java
@@ -2,13 +2,10 @@
import java.util.ArrayList;
-import javafx.scene.Scene;
-import javafx.scene.image.Image;
-
import adam.command.Command;
import adam.exception.AdamException;
-import adam.tasks.Task;
-
+import javafx.scene.Scene;
+import javafx.scene.image.Image;
/**
* This is the main java class that contains instructions to create the chatbot Tasks.Task manager Adam.Adam.
*/
@@ -29,7 +26,7 @@ public Adam() {
try {
list = new TaskList(storage.read());
} catch (AdamException e) {
- list = new TaskList(new ArrayList());
+ list = new TaskList(new ArrayList<>());
}
}
diff --git a/src/main/java/adam/DialogBox.java b/src/main/java/adam/DialogBox.java
index 85b205c27b..bb878c5e88 100644
--- a/src/main/java/adam/DialogBox.java
+++ b/src/main/java/adam/DialogBox.java
@@ -58,4 +58,4 @@ public static DialogBox getAdamDialog(String text, Image img) {
db.flip();
return db;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/adam/Main.java b/src/main/java/adam/Main.java
index c46b61c454..00d0227e22 100644
--- a/src/main/java/adam/Main.java
+++ b/src/main/java/adam/Main.java
@@ -29,4 +29,4 @@ public void start(Stage stage) {
e.printStackTrace();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/adam/MainWindow.java b/src/main/java/adam/MainWindow.java
index 6ad9722813..7e20de9ff5 100644
--- a/src/main/java/adam/MainWindow.java
+++ b/src/main/java/adam/MainWindow.java
@@ -39,7 +39,7 @@ public void setAdam(Adam d) {
*/
public void greet() {
dialogContainer.getChildren().addAll(
- DialogBox.getAdamDialog(adam.getGreeting(),adamImage)
+ DialogBox.getAdamDialog(adam.getGreeting(), adamImage)
);
}
@@ -57,11 +57,11 @@ private void handleUserInput() {
String response = adam.getResponse(input);
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
- DialogBox.getAdamDialog(response,adamImage)
+ DialogBox.getAdamDialog(response, adamImage)
);
userInput.clear();
- if(!adam.running()){
+ if (!adam.running()) {
System.exit(0);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/adam/Parser.java b/src/main/java/adam/Parser.java
index 446ac507fd..746c041652 100644
--- a/src/main/java/adam/Parser.java
+++ b/src/main/java/adam/Parser.java
@@ -1,10 +1,10 @@
package adam;
-import adam.command.Command;
import adam.command.AddCommand;
+import adam.command.Command;
+import adam.command.EditCommand;
import adam.command.FindCommand;
import adam.command.SingleCommand;
-import adam.command.EditCommand;
import adam.exception.AdamException;
/**
@@ -28,7 +28,7 @@ public static String getParams(String[] tokens, String input) {
* @return Command object.
*/
public static Command parse(String input) {
- Command command ;
+ Command command;
String[] tokens = input.split(" ");
switch (tokens[0]) {
case "bye":
@@ -50,7 +50,7 @@ public static Command parse(String input) {
command = new FindCommand(tokens, getParams(tokens, input), tokens[0]);
break;
default:
- throw new AdamException();
+ throw new AdamException();
}
return command;
}
diff --git a/src/main/java/adam/Storage.java b/src/main/java/adam/Storage.java
index b807e08c33..2bf58c8cdd 100644
--- a/src/main/java/adam/Storage.java
+++ b/src/main/java/adam/Storage.java
@@ -1,6 +1,11 @@
package adam;
-import java.io.*;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
import adam.exception.NoFileException;
@@ -13,7 +18,6 @@ public class Storage {
private String home = System.getProperty("user.home");
private java.nio.file.Path path = java.nio.file.Paths.get(home, "Digimon.txt");
- boolean directoryExists = java.nio.file.Files.exists(path);
/**
* Returns an Arraylist of tasks object that is used to save tasks.
diff --git a/src/main/java/adam/TaskList.java b/src/main/java/adam/TaskList.java
index 61158122c5..59c1ebc969 100644
--- a/src/main/java/adam/TaskList.java
+++ b/src/main/java/adam/TaskList.java
@@ -32,7 +32,7 @@ public TaskList(ArrayList list) {
*
* @return String message saying whixh item was deleted.
*/
- public String deleteTask( String[] tokens) {
+ public String deleteTask(String[] tokens) {
if (tokens.length != 2) {
throw new NumberException();
}
@@ -91,10 +91,10 @@ public String addEvent(String text, String from, String to) {
* Lists all the existing tasks inside the task list as a String.
*/
public String list() {
- String sentence = ui.list() + "\n";
+ String sentence = ui.list() + "\n";
int count = 1;
for (Task item: tasks) {
- String task = count + ". " + item.toString()+" | ";
+ String task = count + ". " + item.toString() + " | ";
sentence = sentence + task;
count++;
}
@@ -173,7 +173,7 @@ public String bye() {
*
* @param storage Storage Object.
*/
- public void save (Storage storage) {
+ public void save(Storage storage) {
storage.write(tasks);
}
@@ -196,9 +196,9 @@ public String find(String item) {
ArrayList matches = new ArrayList<>();
int count = 1;
for (Task task : tasks) {
- if (task.search(item)) {
- matches.add(task);
- }
+ if (task.search(item)) {
+ matches.add(task);
+ }
}
if (matches.size() == 0) {
return ui.apologize();
@@ -220,7 +220,7 @@ public String find(String item) {
* @return String message saying which item was tagged what it was tagged with.
*/
public String tagTask(String[] tokens) {
- if(tokens.length < 3) {
+ if (tokens.length < 3) {
throw new NoTagException();
}
if (!tokens[1].matches("[0-9]+")) {
@@ -234,7 +234,7 @@ public String tagTask(String[] tokens) {
throw new OutOfBoundException();
}
String description = "";
- for(int i = 2 ; i < tokens.length; i++) {
+ for (int i = 2; i < tokens.length; i++) {
description = tokens[i] + " ";
}
Task curr = tasks.get(number - 1);
diff --git a/src/main/java/adam/Ui.java b/src/main/java/adam/Ui.java
index 529b793ce2..d33b0d5237 100644
--- a/src/main/java/adam/Ui.java
+++ b/src/main/java/adam/Ui.java
@@ -23,7 +23,7 @@ public String readInput() {
* Returns a String of a welcome message at the start of the program.
*/
public String welcome() {
- return "What's up I am Adam\n" + "so like what do you want?";
+ return "What's up I am Adam\n" + "so like what do you want?";
}
/**
@@ -42,19 +42,19 @@ public String getAmount(int size) {
* @param size Size of the list.
*/
public String delete(Task curr, int size) {
- return "I have removed the Task, so just make up your mind next time:\n" + curr.toString() +
- "\n" + getAmount(size);
+ return "I have removed the Task, so just make up your mind next time:\n" + curr.toString()
+ + "\n" + getAmount(size);
}
/**
- *Returns a message whenever you add a todo Task to your list as a String.
+ * Returns a message whenever you add a todo Task to your list as a String.
*
* @param curr Current Task.
* @param size Size of the list.
*/
public String addTodo(Task curr, int size) {
- return "I added this todo to the list of endless work you have:\n" + curr.toString() +
- "\n" + getAmount(size);
+ return "I added this todo to the list of endless work you have:\n" + curr.toString()
+ + "\n" + getAmount(size);
}
/**
@@ -64,8 +64,8 @@ public String addTodo(Task curr, int size) {
* @param size Size of the list.
*/
public String addEvent(Task curr, int size) {
- return "I added this event to your list, congrats on having a life outside of work:" + curr.toString() +
- "\n" + getAmount(size);
+ return "I added this event to your list, congrats on having a life outside of work:" + curr.toString()
+ + "\n" + getAmount(size);
}
/**
@@ -75,8 +75,8 @@ public String addEvent(Task curr, int size) {
* @param size Size of the list.
*/
public String addDeadline(Task curr, int size) {
- return "I have added this deadline to the list, good " +
- "luck on remembering it one day before deadline:\n" + curr.toString() + "\n" + getAmount(size);
+ return "I have added this deadline to the list, good "
+ + "luck on remembering it one day before deadline:\n" + curr.toString() + "\n" + getAmount(size);
}
/**
@@ -97,8 +97,8 @@ public String bye() {
* Returns a String message to indicate that you have completed a Task.
*/
public String mark() {
- return "Congrats on getting one step closer to achieving true happines," +
- " I have marked this task as complete";
+ return "Congrats on getting one step closer to achieving true happines,"
+ + " I have marked this task as complete";
}
/**
@@ -137,6 +137,6 @@ public String search() {
* @param item String of the tag.
*/
public String tag(String item) {
- return "I have tagged this task as " + item;
+ return "I have tagged this task as " + item;
}
}
diff --git a/src/main/java/adam/command/AddCommand.java b/src/main/java/adam/command/AddCommand.java
index 48358642b4..77f3d93483 100644
--- a/src/main/java/adam/command/AddCommand.java
+++ b/src/main/java/adam/command/AddCommand.java
@@ -54,7 +54,7 @@ public String checkDeadline(TaskList tasks) {
} catch (DateTimeParseException e) {
throw new DateException();
}
- return tasks.addDeadline(by[0], by[1]);
+ return tasks.addDeadline(by[0], by[1]);
}
/**
@@ -102,7 +102,7 @@ public String checkEvent(TaskList tasks) {
* @param ui Ui that is used to print messages.
*/
@Override
- public String execute(TaskList tasks, Storage storage, Ui ui){
+ public String execute(TaskList tasks, Storage storage, Ui ui) {
int length = tasks.getSize();
String respond = "Something went wrong";
if (tokens.length == 1) {
diff --git a/src/main/java/adam/command/Command.java b/src/main/java/adam/command/Command.java
index 4fe5c61dbd..24d6026927 100644
--- a/src/main/java/adam/command/Command.java
+++ b/src/main/java/adam/command/Command.java
@@ -1,8 +1,9 @@
package adam.command;
+
import adam.Storage;
-import adam.Ui;
import adam.TaskList;
+import adam.Ui;
/**
* This interface is used to give a building block for all class that implements the Command interface.
diff --git a/src/main/java/adam/command/EditCommand.java b/src/main/java/adam/command/EditCommand.java
index 8152f4a7a5..0b1aa563c5 100644
--- a/src/main/java/adam/command/EditCommand.java
+++ b/src/main/java/adam/command/EditCommand.java
@@ -19,7 +19,7 @@ public class EditCommand implements Command {
* @param text The specific command from the parser.
*/
public EditCommand(String[] tokens, String text) {
- this.tokens = tokens;
+ this.tokens = tokens;
this.text = text;
}
diff --git a/src/main/java/adam/command/FindCommand.java b/src/main/java/adam/command/FindCommand.java
index 9bb07a1464..83b915c46e 100644
--- a/src/main/java/adam/command/FindCommand.java
+++ b/src/main/java/adam/command/FindCommand.java
@@ -8,7 +8,7 @@
/**
* This class is used to call the find method if the user input is correct.
*/
-public class FindCommand implements Command{
+public class FindCommand implements Command {
private String[] tokens;
private String item;
private String input;
@@ -20,7 +20,7 @@ public class FindCommand implements Command{
* @param item String after the command.
* @param input String of the command.
*/
- public FindCommand(String[]tokens, String item, String input) {
+ public FindCommand(String[]tokens, String item, String input) {
this.tokens = tokens;
this.item = item;
this.input = input;
diff --git a/src/main/java/adam/command/SingleCommand.java b/src/main/java/adam/command/SingleCommand.java
index d1b4313d0f..4842dcb292 100644
--- a/src/main/java/adam/command/SingleCommand.java
+++ b/src/main/java/adam/command/SingleCommand.java
@@ -1,9 +1,10 @@
package adam.command;
import adam.Storage;
-import adam.Ui;
import adam.TaskList;
+import adam.Ui;
import adam.exception.OneWordException;
+
/**
* This class is used to call either the list or bye methods
*/
@@ -30,7 +31,7 @@ public SingleCommand(String[] tokens, String input) {
* @param ui Ui that is used to print messages.
*/
@Override
- public String execute(TaskList tasks, Storage storage, Ui ui){
+ public String execute(TaskList tasks, Storage storage, Ui ui) {
String respond = "Something went wrong";
if (tokens.length > 1) {
throw new OneWordException();
diff --git a/src/main/java/adam/exception/AdamException.java b/src/main/java/adam/exception/AdamException.java
index d247dd4e87..a67dbb920a 100644
--- a/src/main/java/adam/exception/AdamException.java
+++ b/src/main/java/adam/exception/AdamException.java
@@ -3,7 +3,7 @@
/**
* This Exception is a subclass of a RunTimeException and is used when an unidentified user input was entered.
*/
-public class AdamException extends RuntimeException{
+public class AdamException extends RuntimeException {
/**
* Returns an error String message.
diff --git a/src/main/java/adam/exception/FindException.java b/src/main/java/adam/exception/FindException.java
index 1cf3718b38..25a9993d82 100644
--- a/src/main/java/adam/exception/FindException.java
+++ b/src/main/java/adam/exception/FindException.java
@@ -3,7 +3,7 @@
/**
* This exception is thrown when user inputs find without specifying anything.
*/
-public class FindException extends AdamException{
+public class FindException extends AdamException {
@Override
public String getInfo() {
return "OOPS!!! You need to add a word that you are trying to find";
diff --git a/src/main/java/adam/exception/NoFileException.java b/src/main/java/adam/exception/NoFileException.java
index b356db1564..df07ad61b7 100644
--- a/src/main/java/adam/exception/NoFileException.java
+++ b/src/main/java/adam/exception/NoFileException.java
@@ -3,7 +3,7 @@
/**
* This exception is thrown when user tries access a file that doesn't exist.
*/
-public class NoFileException extends AdamException{
+public class NoFileException extends AdamException {
@Override
public String getInfo() {
return "OOPS!!! This file doesn't exist";
diff --git a/src/main/java/adam/exception/NoTagException.java b/src/main/java/adam/exception/NoTagException.java
index 3b3433cd55..8958aa628f 100644
--- a/src/main/java/adam/exception/NoTagException.java
+++ b/src/main/java/adam/exception/NoTagException.java
@@ -3,7 +3,7 @@
/**
* This exception is thrown when user tries to tag a task without a tag description.
*/
-public class NoTagException extends AdamException{
+public class NoTagException extends AdamException {
@Override
public String getInfo() {
return "OOPS!!! You need to add a tag to this task";
diff --git a/src/main/java/adam/tasks/Deadline.java b/src/main/java/adam/tasks/Deadline.java
index 3ba99282c9..c9f8502b4f 100644
--- a/src/main/java/adam/tasks/Deadline.java
+++ b/src/main/java/adam/tasks/Deadline.java
@@ -22,6 +22,6 @@ public Deadline(String text, String by) {
}
@Override
public String toString() {
- return "[D]" + super.toString() + " (by: " + by.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ return "[D]" + super.toString() + " (by: " + by.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
}
}
diff --git a/src/main/java/adam/tasks/Task.java b/src/main/java/adam/tasks/Task.java
index e4f93ffaed..d1aacd5c28 100644
--- a/src/main/java/adam/tasks/Task.java
+++ b/src/main/java/adam/tasks/Task.java
@@ -36,7 +36,7 @@ public String getTag() {
*/
@Override
public String toString() {
- if(item.equals("")) {
+ if (item.equals("")) {
return "[" + getStatusIcon() + "] " + this.description;
}
return "[" + getStatusIcon() + "] " + this.description + getTag();
@@ -62,7 +62,7 @@ public void markAsDone() {
/**
* Unmarks the task as incomplete.
*/
- public void unmarkAsDone(){
+ public void unmarkAsDone() {
this.isDone = false;
System.out.println(this.toString());
}
diff --git a/src/test/java/adam/ParserTest.java b/src/test/java/adam/ParserTest.java
index 08f99d7e17..e1b0d88455 100644
--- a/src/test/java/adam/ParserTest.java
+++ b/src/test/java/adam/ParserTest.java
@@ -1,28 +1,30 @@
package adam;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
-import adam.exception.AdamException;
import org.junit.jupiter.api.Test;
+import adam.exception.AdamException;
+
public class ParserTest {
@Test
public void parse_randomInput_exceptionThrown() {
- try{
+ try {
Parser.parse("bla");
fail();
} catch (AdamException e) {
- assertEquals("OOPS!!! I don't know what this means",e.getInfo());
+ assertEquals("OOPS!!! I don't know what this means", e.getInfo());
}
}
@Test
public void parse_noInput_exceptionThrown() {
- try{
+ try {
Parser.parse("");
fail();
} catch (AdamException e) {
- assertEquals("OOPS!!! I don't know what this means",e.getInfo());
+ assertEquals("OOPS!!! I don't know what this means", e.getInfo());
}
}
}
diff --git a/src/test/java/adam/command/AddCommandTest.java b/src/test/java/adam/command/AddCommandTest.java
index eaa60f9006..17c661ec1e 100644
--- a/src/test/java/adam/command/AddCommandTest.java
+++ b/src/test/java/adam/command/AddCommandTest.java
@@ -1,20 +1,22 @@
package adam.command;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.Test;
+
import adam.Storage;
import adam.TaskList;
import adam.Ui;
import adam.exception.AdamException;
import adam.tasks.Task;
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.util.ArrayList;
public class AddCommandTest {
- Ui ui = new Ui();
- Storage storage = new Storage();
- TaskList task = new TaskList(new ArrayList());
+ private Ui ui = new Ui();
+ private Storage storage = new Storage();
+ private TaskList task = new TaskList(new ArrayList());
@Test
public void executeDeadline_noDescription_exceptionThrown() {
String li = "deadline";
@@ -22,7 +24,7 @@ public void executeDeadline_noDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
assertEquals("OOPS!!! You need to add a description to these tasks", e.getInfo());
@@ -36,10 +38,10 @@ public void executeDeadline_noCommand_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
- assertEquals( "OOPS!!! You need to add one /by command to indicate by when deadline is", e.getInfo());
+ assertEquals("OOPS!!! You need to add one /by command to indicate by when deadline is", e.getInfo());
}
}
@Test
@@ -49,10 +51,10 @@ public void executeDeadline_noDescriptionWithCommands_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
- assertEquals( "OOPS!!! You need to add a description to these tasks", e.getInfo());
+ assertEquals("OOPS!!! You need to add a description to these tasks", e.getInfo());
}
}
@Test
@@ -62,10 +64,10 @@ public void executeDeadline_wrongDates_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
- assertEquals( "OOPS!!! you need the date to be in a yyyy-mm-dd format", e.getInfo());
+ assertEquals("OOPS!!! you need the date to be in a yyyy-mm-dd format", e.getInfo());
}
}
@@ -76,10 +78,10 @@ public void executeEvent_wrongDates_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
- assertEquals( "OOPS!!! you need the date to be in a yyyy-mm-dd format", e.getInfo());
+ assertEquals("OOPS!!! you need the date to be in a yyyy-mm-dd format", e.getInfo());
}
}
@@ -90,10 +92,10 @@ public void executeEvent_noDescriptionWithCommands_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
- assertEquals( "OOPS!!! You need to add a description to these tasks", e.getInfo());
+ assertEquals("OOPS!!! You need to add a description to these tasks", e.getInfo());
}
}
@@ -104,10 +106,10 @@ public void executeEvent_noCommand_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
- assertEquals( "OOPS!!! You need to add one /from and one /to command", e.getInfo());
+ assertEquals("OOPS!!! You need to add one /from and one /to command", e.getInfo());
}
}
@@ -118,7 +120,7 @@ public void executeEvent_noDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
assertEquals("OOPS!!! You need to add a description to these tasks", e.getInfo());
@@ -132,7 +134,7 @@ public void executeTodo_noDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new AddCommand(tokens,item,tokens[0]).execute(task,storage,ui);
+ new AddCommand(tokens, item, tokens[0]).execute(task, storage, ui);
fail();
} catch (AdamException e) {
assertEquals("OOPS!!! You need to add a description to these tasks", e.getInfo());
diff --git a/src/test/java/adam/command/EditCommandTest.java b/src/test/java/adam/command/EditCommandTest.java
index 68983ceb95..96e30d2a75 100644
--- a/src/test/java/adam/command/EditCommandTest.java
+++ b/src/test/java/adam/command/EditCommandTest.java
@@ -1,19 +1,21 @@
package adam.command;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.Test;
+
import adam.Storage;
import adam.TaskList;
import adam.Ui;
import adam.exception.AdamException;
import adam.tasks.Task;
-import org.junit.jupiter.api.Test;
-import java.util.ArrayList;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
public class EditCommandTest {
- Ui ui = new Ui();
- Storage storage = new Storage();
- TaskList task = new TaskList(new ArrayList());
+ private Ui ui = new Ui();
+ private Storage storage = new Storage();
+ private TaskList task = new TaskList(new ArrayList());
@Test
public void executeMark_noDescription_exceptionThrown() {
@@ -22,7 +24,7 @@ public void executeMark_noDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}
@@ -35,7 +37,7 @@ public void executeMark_outOfBound_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! The number you put in is more than the current item in your list", e.getInfo());
}
@@ -48,7 +50,7 @@ public void executeUnmark_outOfBound_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! The number you put in is more than the current item in your list", e.getInfo());
}
@@ -61,7 +63,7 @@ public void executeDelete_outOfBound_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! The number you put in is more than the current item in your list", e.getInfo());
}
@@ -74,7 +76,7 @@ public void executeMark_wrongDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}
@@ -87,7 +89,7 @@ public void executeMark_multipleDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}
@@ -100,7 +102,7 @@ public void executeUnmark_multipleDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}
@@ -112,7 +114,7 @@ public void executeUnmark_wrongDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}
@@ -124,7 +126,7 @@ public void executeUnmark_noDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}
@@ -137,7 +139,7 @@ public void executeDelete_noDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}
@@ -149,7 +151,7 @@ public void executeDelete_wrongDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}
@@ -161,7 +163,7 @@ public void executeDelete_multipleDescription_exceptionThrown() {
int length = tokens[0].length();
String item = li.substring(length, li.length());
try {
- new EditCommand(tokens,item).execute(task,storage,ui);
+ new EditCommand(tokens, item).execute(task, storage, ui);
} catch (AdamException e) {
assertEquals("OOPS!!! You need to follow this command by a number", e.getInfo());
}