Skip to content

Commit

Permalink
Fixed checkstyle issues with test files
Browse files Browse the repository at this point in the history
  • Loading branch information
AjeyAshok committed Nov 7, 2019
1 parent 1a8401e commit ecc95a9
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 54 deletions.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Sep 16 09:26:14 SGT 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 17 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
18 changes: 17 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
4 changes: 2 additions & 2 deletions savedWallet.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1000.0
out $250.0 /date 2019-11-07 /tags
out $100.0 /date 2019-11-07 /tags
in $100.0 /date 2019-11-07 /tags
out $100.0 /date 2019-11-07 /tags
in $100.0 /date 2019-11-07 /tags
77 changes: 37 additions & 40 deletions src/test/java/CommandGetSpendingByMonthTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,62 @@
public class CommandGetSpendingByMonthTest {
@Test
void execute() {
StorageManager storageManager = new StorageManager();

Receipt receipt1 = new Receipt(5.0);
receipt1.addTag("food");
receipt1.setDate(LocalDate.parse("2019-10-10"));
storageManager.getWallet().addReceipt(receipt1);

Receipt receipt2 = new Receipt(5.0);
receipt2.addTag("food");
receipt2.setDate(LocalDate.parse("2019-11-10"));
storageManager.getWallet().addReceipt(receipt2);


CommandGetSpendingByMonth c1 = new CommandGetSpendingByMonth("expendedmonth october /year 2019");
c1.execute(storageManager);
String ans1 = c1.getInfoCapsule().getOutputStr();

CommandGetSpendingByMonth c2 = new CommandGetSpendingByMonth("expendedmonth november /year 2019");
c2.execute(storageManager);
String ans2 = c2.getInfoCapsule().getOutputStr();

CommandGetSpendingByMonth c3 = new CommandGetSpendingByMonth("expendedmonth nov /year 2019");
c3.execute(storageManager);
String ans3 = c3.getInfoCapsule().getOutputStr();

CommandGetSpendingByMonth c4 = new CommandGetSpendingByMonth("expendedmonth november /year 209");
c4.execute(storageManager);
String ans4 = c4.getInfoCapsule().getOutputStr();
StorageManager storageManager = new StorageManager();

Receipt receipt1 = new Receipt(5.0);
receipt1.addTag("food");
receipt1.setDate(LocalDate.parse("2019-10-10"));
storageManager.getWallet().addReceipt(receipt1);

Receipt receipt2 = new Receipt(5.0);
receipt2.addTag("food");
receipt2.setDate(LocalDate.parse("2019-11-10"));
storageManager.getWallet().addReceipt(receipt2);

CommandGetSpendingByMonth c1 = new CommandGetSpendingByMonth("expendedmonth october /year 2019");
c1.execute(storageManager);
String ans1 = c1.getInfoCapsule().getOutputStr();
assertEquals("The total amount of money spent in october 2019 : $5.0\n", ans1);

CommandGetSpendingByMonth c2 = new CommandGetSpendingByMonth("expendedmonth november /year 2019");
c2.execute(storageManager);
String ans2 = c2.getInfoCapsule().getOutputStr();
assertEquals("The total amount of money spent in november 2019 : $5.0\n", ans2);

CommandGetSpendingByMonth c3 = new CommandGetSpendingByMonth("expendedmonth nov /year 2019");
c3.execute(storageManager);
String ans3 = c3.getInfoCapsule().getOutputStr();
assertEquals("Wrong month input. Check Spelling", ans3);

CommandGetSpendingByMonth c4 = new CommandGetSpendingByMonth("expendedmonth november /year 209");
c4.execute(storageManager);
String ans4 = c4.getInfoCapsule().getOutputStr();
assertEquals("Year input contains lesser/extra number of variables. "
+ "\nFORMAT : expendedmonth <month> /year <year>", ans4);

CommandGetSpendingByMonth c5 = new CommandGetSpendingByMonth("expendedmonth november /yea 2019");
c5.execute(storageManager);
String ans5 = c5.getInfoCapsule().getOutputStr();
assertEquals("Wrong format! FORMAT : expendedmonth <month> /year <year>", ans5);

CommandGetSpendingByMonth c6 = new CommandGetSpendingByMonth("expendedmonth november /year 1750");
c6.execute(storageManager);
String ans6 = c6.getInfoCapsule().getOutputStr();
assertEquals("Year is too far back into the past", ans6);

CommandGetSpendingByMonth c7 = new CommandGetSpendingByMonth("expendedmonth november /year 2750");
c7.execute(storageManager);
String ans7 = c7.getInfoCapsule().getOutputStr();
assertEquals("Future year entered is invalid!", ans7);

CommandGetSpendingByMonth c8 = new CommandGetSpendingByMonth("expendedmonth november /year");
c8.execute(storageManager);
String ans8 = c8.getInfoCapsule().getOutputStr();
assertEquals("No year input detected. FORMAT : expendedmonth <month> /year <year>", ans8);

CommandGetSpendingByMonth c9 = new CommandGetSpendingByMonth("expendedmonth /year 2019");
c9.execute(storageManager);
String ans9 = c9.getInfoCapsule().getOutputStr();

assertEquals("The total amount of money spent in october 2019 : $5.0\n", ans1);
assertEquals("The total amount of money spent in november 2019 : $5.0\n", ans2);
assertEquals("Wrong month input. Check Spelling", ans3);
assertEquals("Year input contains lesser/extra number of variables. "
+ "\nFORMAT : expendedmonth <month> /year <year>", ans4);
assertEquals("Wrong format! FORMAT : expendedmonth <month> /year <year>", ans5);
assertEquals("Year is too far back into the past", ans6);
assertEquals("Future year entered is invalid!", ans7);
assertEquals("No year input detected. FORMAT : expendedmonth <month> /year <year>", ans8);
assertEquals("No month input detected. FORMAT : expendedmonth <month> /year <year>", ans9);
assertEquals("No month input detected. FORMAT : expendedmonth <month> /year <year>", ans9);
}

}
20 changes: 13 additions & 7 deletions src/test/java/CommandGetSpendingByYearTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,40 @@ void execute() {
CommandGetSpendingByYear c1 = new CommandGetSpendingByYear("expendedyear 2019");
c1.execute(storageManager);
String ans1 = c1.getInfoCapsule().getOutputStr();
assertEquals("The total amount of money spent in 2019 : $10.0\n", ans1);

CommandGetSpendingByYear c2 = new CommandGetSpendingByYear("expendedyear");
c2.execute(storageManager);
String ans2 = c2.getInfoCapsule().getOutputStr();
assertEquals("No year input detected.\nFORMAT : expendedyear 2019\n", ans2);

CommandGetSpendingByYear c3 = new CommandGetSpendingByYear("expendedyear 201");
c3.execute(storageManager);
String ans3 = c3.getInfoCapsule().getOutputStr();
assertEquals("Year input contains lesser/extra number of variables.\n"
+ " FORMAT : expendedyear 2019\n", ans3);

CommandGetSpendingByYear c4 = new CommandGetSpendingByYear("expendedyear 2091");
c4.execute(storageManager);
String ans4 = c4.getInfoCapsule().getOutputStr();
assertEquals("Future year entered is invalid!" + "\n", ans4);

CommandGetSpendingByYear c5 = new CommandGetSpendingByYear("expendedyear 1750");
c5.execute(storageManager);
String ans5 = c5.getInfoCapsule().getOutputStr();
assertEquals("Year is too far back into the past" + "\n", ans5);

CommandGetSpendingByYear c6 = new CommandGetSpendingByYear("expendedyear abcd");
c6.execute(storageManager);
String ans6 = c6.getInfoCapsule().getOutputStr();

assertEquals("The total amount of money spent in 2019 : $10.0\n", ans1);
assertEquals("No year input detected.\nFORMAT : expendedyear 2019\n", ans2);
assertEquals("Year input contains lesser/extra number of variables.\n"
+ " FORMAT : expendedyear 2019\n", ans3);
assertEquals("Future year entered is invalid!" + "\n", ans4);
assertEquals("Year is too far back into the past" + "\n", ans5);
assertEquals("Year input is either a double or contains String values.\n"
+ "FORMAT : expendedyear 2019\n", ans6);







}
}
5 changes: 5 additions & 0 deletions src/test/java/ui/MainGuiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ public class MainGuiTest extends MainGui {
private String walletPath = "savedWallet.txt";
private MainWindow mainWindowController;

/**
* Tests the working of the GUI.
* @param taskPath is the path the leads to the task content
* @param walletPath is the path that leads to the wallet contents
*/
public void initialize(String taskPath, String walletPath) {
String[] args = {};
this.taskPath = taskPath;
Expand Down

0 comments on commit ecc95a9

Please sign in to comment.