Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY1819S1#68 from CS2103-AY1819S1-W12-2/…
Browse files Browse the repository at this point in the history
…shaw_yeong_changes

add AnalyticsCommandTest and update UML Diagrams
  • Loading branch information
Aadit Kamat authored Oct 25, 2018
2 parents 880ff9e + 5eb2496 commit c6a8420
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 4 deletions.
3 changes: 0 additions & 3 deletions #.profile#

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ out/
allTest.sh
tokens/
!_reposense/config.json
#.profile#
Binary file modified docs/images/LogicClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/ModelClassBetterOopDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AnalyticsCommand extends Command {
+ "your financial status to view.\n"
+ "It will either generate your financial status base on all the list,\n"
+ "or generate to a certain date, base on the date you input."
+ "eg an or an dd/mm/yyyy";
+ "eg analytics or analytics dd/mm/yyyy";

public static final String MESSAGE_SUCCESS = "Financial status : SGD %.2f";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package seedu.address.logic.commands;

import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalTransactions.getUniqueFinancialDatabase;

import org.junit.Test;

import seedu.address.logic.CommandHistory;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.model.transaction.Deadline;


public class AnalyticsCommandTest {
private CommandHistory history = new CommandHistory();
private Model model = new ModelManager();
private Model expectedModel = new ModelManager();
private Model modelWithData = new ModelManager(getUniqueFinancialDatabase(), new UserPrefs());
private Model expectedModelWithData = new ModelManager(getUniqueFinancialDatabase(), new UserPrefs());


@Test
public void execute_emptyFinancialListWithNoDate() {
String expectedMessage = "Financial status : SGD 0.00";
AnalyticsCommand analyticsCommand = new AnalyticsCommand();
assertCommandSuccess(analyticsCommand, model, history, expectedMessage, expectedModel);
}

@Test
public void execute_emptyFinancialListWithDate_When_DatePassed_Then_TestWillFail() {
String date = "12/12/2020";
Deadline checkDate = new Deadline(date);
String expectedMessage = "Financial status : SGD 0.00";
AnalyticsCommand analyticsCommand = new AnalyticsCommand(checkDate);
assertCommandSuccess(analyticsCommand, model, history, expectedMessage, expectedModel);
}

@Test
public void execute_non_emptyFinancialListWithNoDate() {
String expectedMessage = "Financial status : SGD 188.10";
AnalyticsCommand analyticsCommand = new AnalyticsCommand();
assertCommandSuccess(analyticsCommand, modelWithData, history, expectedMessage, expectedModelWithData);
}

@Test
public void execute_non_emptyFinancialListWithDate_When_DatePassed_Then_TestWillFail() {
String date = "11/11/2018";
Deadline checkDate = new Deadline(date);
String expectedMessage = "Financial status : SGD 0.00";
AnalyticsCommand analyticsCommand = new AnalyticsCommand(checkDate);
assertCommandSuccess(analyticsCommand, modelWithData, history, expectedMessage, expectedModelWithData);
}

@Test
public void execute_non_emptyFinancialListWithDateTest2_When_DatePassed_Then_TestWillFail() {
String date = "12/11/2018";
Deadline checkDate = new Deadline(date);
String expectedMessage = "Financial status : SGD 85.00";
AnalyticsCommand analyticsCommand = new AnalyticsCommand(checkDate);
assertCommandSuccess(analyticsCommand, modelWithData, history, expectedMessage, expectedModelWithData);
}

@Test
public void execute_non_emptyFinancialListWithDateTest3_When_DatePassed_Then_TestWillFail() {
String date = "18/11/2018";
Deadline checkDate = new Deadline(date);
String expectedMessage = "Financial status : SGD 230.60";
AnalyticsCommand analyticsCommand = new AnalyticsCommand(checkDate);
assertCommandSuccess(analyticsCommand, modelWithData, history, expectedMessage, expectedModelWithData);
}

@Test
public void execute_non_emptyFinancialListWithDateTest4_When_DatePassed_Then_TestWillFail() {
String date = "12/12/2018";
Deadline checkDate = new Deadline(date);
String expectedMessage = "Financial status : SGD 188.10";
AnalyticsCommand analyticsCommand = new AnalyticsCommand(checkDate);
assertCommandSuccess(analyticsCommand, modelWithData, history, expectedMessage, expectedModelWithData);
}
}
4 changes: 4 additions & 0 deletions src/test/java/seedu/address/testutil/TypicalPersons.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class TypicalPersons {
.withEmail("[email protected]").withAddress("little india").build();
public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131")
.withEmail("[email protected]").withAddress("chicago ave").build();
public static final Person JACK = new PersonBuilder().withName("JACK lee").withPhone("8402424")
.withEmail("[email protected]").withAddress("chinatown").build();

// Manually added - Person's details found in {@code CommandTestUtil}
public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY)
Expand All @@ -58,6 +60,8 @@ public class TypicalPersons {
.withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND)
.build();



public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER

private TypicalPersons() {} // prevents instantiation
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/seedu/address/testutil/TypicalTransactions.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class TypicalTransactions {
public static final Transaction IDA_TRANSACTION = new TransactionBuilder().withPerson(TypicalPersons.IDA)
.withAmount("CNY 67.15")
.withType("Debt").build();
public static final Transaction JACK_TRANSACTION = new TransactionBuilder().withPerson(TypicalPersons.JACK)
.withAmount("SGD 42.50")
.withType("Debt")
.withDeadline("19/11/2018").build();

// Manually added - Person's details found in {@code CommandTestUtil}
public static final Transaction AMY_TRANSACTION = new TransactionBuilder().withPerson(TypicalPersons.AMY)
Expand All @@ -53,6 +57,7 @@ public class TypicalTransactions {
.withType("Loan")
.withDeadline("12/11/2018").build();


private TypicalTransactions() {} // prevents instantiation

/**
Expand All @@ -70,4 +75,20 @@ public static List<Transaction> getTypicalTransactions() {
return new ArrayList<>(Arrays.asList(ALICE_TRANSACTION, BENSON_TRANSACTION, CARL_TRANSACTION,
DANIEL_TRANSACTION, ELLE_TRANSACTION, FIONA_TRANSACTION, GEORGE_TRANSACTION));
}

/**
* Returns an {@code AddressBook} with all the unique persons.
*/
public static FinancialDatabase getUniqueFinancialDatabase() {
FinancialDatabase database = new FinancialDatabase();
for (Transaction transaction : getUniqueTransactions()) {
database.addTransaction(transaction);
}
return database;
}

public static List<Transaction> getUniqueTransactions() {
return new ArrayList<>(Arrays.asList(ALICE_TRANSACTION, AMY_TRANSACTION, BOB_TRANSACTION,
JACK_TRANSACTION));
}
}

0 comments on commit c6a8420

Please sign in to comment.