Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2021S1#92 from GeNiaaz/fix-testcases-…
Browse files Browse the repository at this point in the history
…v1.2

Fix all testcases with non contextualised data
  • Loading branch information
lucastai98 committed Oct 11, 2020
2 parents 281a206 + 17840ab commit 4256d6c
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 181 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"projects": [ {
"name": "Valid Project",
"deadline": "9482424",
"deadline": "29-02-2020 00:00:00",
"repoUrl": "https://github.com/valid/valid.git",
"projectDescription": "4th street"
"projectDescription": "this project is valid",
"projectTagged": [ "urgent" ]
}, {
"name": "Project With Invalid Phone Field",
"name": "Project With Invalid deadline Field",
"deadline": "948asdf2424",
"email": "hans@example.com",
"projectDescription": "4th street"
"projectDescription": "4th street",
"projectTagged": [ "redundant" ]
} ]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"projects": [ {
"name": "Project with invalid name field: Ha!ns Mu@ster",
"deadline": "9482424",
"deadline": "32-42-32322 00:00",
"repoUrl": "https://github.con/valid/valid.git",
"projectDescription": "4th street"
"projectDescription": "inv@lid d3scription",
"projectTagged": [ "ss@$5v" ]
} ]
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"projects": [ {
"projectName": "Alice Pauline",
"projectName": "JuggerNought",
"deadline": "29-02-2020 00:00:00",
"repoUrl": "https://github.com/a/a.git",
"projectDescription": "123, Jurong West Ave 6, #08-111",
"projectTagged": [ "friends" ]
"projectDescription": "Advanced aerial robotics",
"projectTagged": [ "topsecret" ]
}, {
"projectName": "Alice Pauline",
"projectName": "JuggerNought",
"deadline": "29-02-2020 00:00:00",
"repoUrl": "https://github.com/a/a.git",
"projectDescription": "4th street",
"projectTagged": ["writeDG"]
"projectDescription": "Advanced aerial robotics",
"projectTagged": ["topsecret"]
} ]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"projects": [ {
"projectName": "Hans Muster",
"deadline": "29-02-2020 00:00:00",
"projectName": "invalid @ $% pr0j3ct",
"deadline": "29-02/020 00:00:00",
"repoUrl": "https://invalid.com/invalid/invalid",
"projectDescription": "4th street"
"projectDescription": "this is n0t v@lid",
"projectTagged": ["f@ulty"]
} ]
}
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
{
"_comment": "MainCatalogue save file which contains the same Project values as in TypicalProjects#getTypicalMainCatalogue()",
"projects" : [ {
"projectName" : "Alice Pauline",
"projectName" : "Apeakapp",
"deadline": "21-03-2020 00:00:00",
"repoUrl": "https://github.com/a/a.git",
"projectDescription" : "123, Jurong West Ave 6, #08-111",
"projectTagged" : [ "friends" ],
"projectDescription" : "An app for you to speak your mind",
"projectTagged" : [ "linguistics" ],
"occupied" : [ "Write DG", "Write user stories" ]
}, {
"projectName" : "Benson Meier",
"projectName" : "Brick No Meier",
"deadline": "21-03-2020 00:00:00",
"repoUrl": "https://github.com/b/b.git",
"projectDescription" : "311, Clementi Ave 2, #02-25",
"projectTagged" : [ "owesMoney", "friends" ],
"projectDescription" : "To destroy the brick and mortar",
"projectTagged" : [ "amazon", "evil" ],
"occupied" : [ "Practice presentation" ]
}, {
"projectName" : "Carl Kurz",
"projectName" : "Caractive",
"deadline": "21-03-2020 00:00:00",
"repoUrl": "https://github.com/c/c.git",
"projectDescription" : "wall street",
"projectTagged" : [ ],
"occupied" : [ "Read info pack" ]
"projectDescription" : "best car app for tesla",
"projectTagged" : [ "electric" ],
"occupied" : [ "Integrate with tesla" ]
}, {
"projectName" : "Daniel Meier",
"projectName" : "Dayum Snap",
"deadline": "21-03-2020 00:00:00",
"repoUrl": "https://github.com/d/d.git",
"projectDescription" : "10th street",
"projectTagged" : [ "friends" ],
"projectDescription" : "yet another stories app",
"projectTagged" : [ "instagram" , "snapchat" ],
"occupied" : [ ]
}, {
"projectName" : "Elle Meyer",
"projectName" : "Elfie save",
"deadline":"21-03-2020 00:00:00",
"repoUrl": "https://github.com/e/e.git",
"projectDescription" : "michegan ave",
"projectDescription" : "save elves from persecution",
"projectTagged" : [ ],
"occupied" : [ ]
}, {
"projectName" : "Fiona Kunz",
"projectName" : "Fans",
"deadline": "21-03-2020 00:00:00",
"repoUrl": "https://github.com/f/f.git",
"projectDescription" : "little tokyo",
"projectDescription" : "an app only for fans",
"projectTagged" : [ ],
"occupied" : [ ]
}, {
"projectName" : "George Best",
"projectName" : "Gerry Mander",
"deadline": "21-03-2020 00:00:00",
"repoUrl": "https://github.com/g/g.git",
"projectDescription" : "4th street",
"projectDescription" : "Call us to rig any election",
"projectTagged" : [ ],
"occupied" : [ ]
} ]
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static seedu.address.logic.commands.CommandTestUtil.PROJECT_NAME_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.REPOURL_DESC_A;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalProjects.AMY;
import static seedu.address.testutil.TypicalProjects.AI;

import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -81,7 +81,7 @@ public void execute_storageThrowsIoException_throwsCommandException() {
// Execute add command
String addCommand = AddCommand.COMMAND_WORD + PROJECT_NAME_DESC_AMY + DEADLINE_DESC_A + REPOURL_DESC_A
+ PROJECT_DESCRIPTION_DESC_AMY;
Project expectedProject = new ProjectBuilder(AMY).withTags().withTasks().build();
Project expectedProject = new ProjectBuilder(AI).withTags().withTasks().build();
ModelManager expectedModel = new ModelManager();
expectedModel.addProject(expectedProject);
String expectedMessage = LogicManager.FILE_OPS_ERROR_MESSAGE + DUMMY_IO_EXCEPTION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.commons.core.Messages.MESSAGE_PROJECTS_LISTED_OVERVIEW;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalProjects.CARL;
import static seedu.address.testutil.TypicalProjects.ELLE;
import static seedu.address.testutil.TypicalProjects.FIONA;
import static seedu.address.testutil.TypicalProjects.CARACTIVE;
import static seedu.address.testutil.TypicalProjects.ELFIE;
import static seedu.address.testutil.TypicalProjects.FANS;
import static seedu.address.testutil.TypicalProjects.getTypicalMainCatalogue;

import java.util.Arrays;
Expand Down Expand Up @@ -67,11 +67,11 @@ public void execute_zeroKeywords_noProjectFound() {
@Test
public void execute_multipleKeywords_multipleProjectsFound() {
String expectedMessage = String.format(MESSAGE_PROJECTS_LISTED_OVERVIEW, 3);
NameContainsKeywordsPredicate predicate = preparePredicate("Kurz Elle Kunz");
NameContainsKeywordsPredicate predicate = preparePredicate("Caractive Elfie Fans");
FindCommand command = new FindCommand(predicate);
expectedModel.updateFilteredProjectList(predicate);
assertCommandSuccess(command, model, expectedMessage, expectedModel);
assertEquals(Arrays.asList(CARL, ELLE, FIONA), model.getFilteredProjectList());
assertEquals(Arrays.asList(CARACTIVE, ELFIE, FANS), model.getFilteredProjectList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_TASK_MODEL;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.address.testutil.TypicalProjects.AMY;
import static seedu.address.testutil.TypicalProjects.BOB;
import static seedu.address.testutil.TypicalProjects.AI;
import static seedu.address.testutil.TypicalProjects.BOT;

import org.junit.jupiter.api.Test;

Expand All @@ -49,7 +49,7 @@ public class AddCommandParserTest {

@Test
public void parse_allFieldsPresent_success() {
Project expectedProject = new ProjectBuilder(BOB).withTags(VALID_PROJECT_TAG_FIEND).withTasks(
Project expectedProject = new ProjectBuilder(BOT).withTags(VALID_PROJECT_TAG_FIEND).withTasks(
VALID_PROJECT_TAG_DG).build();

// whitespace only preamble
Expand Down Expand Up @@ -79,7 +79,7 @@ public void parse_allFieldsPresent_success() {
+ TASK_DESC_DG, new AddCommand(expectedProject));

// multiple project tags - all accepted
Project expectedProjectMultipleTags = new ProjectBuilder(BOB).withTags(VALID_PROJECT_TAG_FIEND,
Project expectedProjectMultipleTags = new ProjectBuilder(BOT).withTags(VALID_PROJECT_TAG_FIEND,
VALID_PROJECT_TAG_HANG)
.build();
assertParseSuccess(parser, PROJECT_NAME_DESC_BOB + DEADLINE_DESC_B + REPOURL_DESC_B
Expand All @@ -88,7 +88,7 @@ public void parse_allFieldsPresent_success() {
expectedProjectMultipleTags));

// multiple tasks - all accepted
Project expectedProjectMultipleTasks = new ProjectBuilder(BOB).withTasks(VALID_PROJECT_TAG_DG, VALID_TASK_MODEL)
Project expectedProjectMultipleTasks = new ProjectBuilder(BOT).withTasks(VALID_PROJECT_TAG_DG, VALID_TASK_MODEL)
.build();
assertParseSuccess(parser, PROJECT_NAME_DESC_BOB + DEADLINE_DESC_B + REPOURL_DESC_B
+ PROJECT_DESCRIPTION_DESC_BOB
Expand All @@ -99,7 +99,7 @@ public void parse_allFieldsPresent_success() {
@Test
public void parse_optionalFieldsMissing_success() {
// zero tags
Project expectedProject = new ProjectBuilder(AMY).withTags().build();
Project expectedProject = new ProjectBuilder(AI).withTags().build();
assertParseSuccess(parser, PROJECT_NAME_DESC_AMY + DEADLINE_DESC_A + REPOURL_DESC_A
+ PROJECT_DESCRIPTION_DESC_AMY
+ TASK_DESC_DG + TASK_DESC_MODEL, new AddCommand(expectedProject));
Expand Down
35 changes: 19 additions & 16 deletions src/test/java/seedu/address/model/MainCatalogueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_TAG_DG;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_TAG_HANG;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalProjects.ALICE;
import static seedu.address.testutil.TypicalProjects.APEAKAPP;
import static seedu.address.testutil.TypicalProjects.getTypicalMainCatalogue;

import java.util.Arrays;
Expand Down Expand Up @@ -51,11 +51,12 @@ public void resetData_withValidReadOnlyMainCatalogue_replacesData() {
@Test
public void resetData_withDuplicateProjects_throwsDuplicateProjectException() {
// Two projects with the same identity fields
Project editedAlice = new ProjectBuilder(ALICE).withProjectDescription(VALID_PROJECT_DESCRIPTION_BOT).withTags(
Project editedAlice = new ProjectBuilder(APEAKAPP).withProjectDescription(
VALID_PROJECT_DESCRIPTION_BOT).withTags(
VALID_PROJECT_TAG_HANG)
.withTasks(VALID_PROJECT_TAG_DG)
.build();
List<Project> newProjects = Arrays.asList(ALICE, editedAlice);
List<Project> newProjects = Arrays.asList(APEAKAPP, editedAlice);
MainCatalogueStub newData = new MainCatalogueStub(newProjects);

assertThrows(DuplicateProjectException.class, () -> mainCatalogue.resetData(newData));
Expand All @@ -68,19 +69,21 @@ public void hasProject_nullProject_throwsNullPointerException() {

@Test
public void hasProject_projectNotInMainCatalogue_returnsFalse() {
assertFalse(mainCatalogue.hasProject(ALICE));
assertFalse(
mainCatalogue.hasProject(APEAKAPP));
}

@Test
public void hasProject_projectInMainCatalogue_returnsTrue() {
mainCatalogue.addProject(ALICE);
assertTrue(mainCatalogue.hasProject(ALICE));
mainCatalogue.addProject(APEAKAPP);
assertTrue(mainCatalogue.hasProject(APEAKAPP));
}

@Test
public void hasProject_projectWithSameIdentityFieldsInMainCatalogue_returnsTrue() {
mainCatalogue.addProject(ALICE);
Project editedAlice = new ProjectBuilder(ALICE).withProjectDescription(VALID_PROJECT_DESCRIPTION_BOT).withTags(
mainCatalogue.addProject(APEAKAPP);
Project editedAlice = new ProjectBuilder(APEAKAPP).withProjectDescription(
VALID_PROJECT_DESCRIPTION_BOT).withTags(
VALID_PROJECT_TAG_HANG)
.withTasks(VALID_PROJECT_TAG_DG)
.build();
Expand All @@ -95,8 +98,8 @@ public void getProjectList_modifyList_throwsUnsupportedOperationException() {
@Test
public void enterQuit_correctScope_success() {
try {
mainCatalogue.addProject(ALICE);
mainCatalogue.enter(ALICE);
mainCatalogue.addProject(APEAKAPP);
mainCatalogue.enter(APEAKAPP);
mainCatalogue.quit();
} catch (Exception e) {
fail();
Expand All @@ -105,17 +108,17 @@ public void enterQuit_correctScope_success() {

@Test
public void enterQuit_incorrectScope_throwInvalidScopeException() {
mainCatalogue.addProject(ALICE);
mainCatalogue.addProject(APEAKAPP);
try {
mainCatalogue.quit();
} catch (InvalidScopeException e) {
assertEquals(new InvalidScopeException(Status.PROJECT, Status.CATALOGUE), e);
} catch (Exception e) {
fail();
}
mainCatalogue.enter(ALICE);
mainCatalogue.enter(APEAKAPP);
try {
mainCatalogue.enter(ALICE);
mainCatalogue.enter(APEAKAPP);
} catch (InvalidScopeException e) {
assertEquals(new InvalidScopeException(Status.CATALOGUE, Status.PROJECT), e);
} catch (Exception e) {
Expand All @@ -125,13 +128,13 @@ public void enterQuit_incorrectScope_throwInvalidScopeException() {

@Test
public void enter_nonExistingProject_throwProjectNotFoundException() {
assertThrows(ProjectNotFoundException.class, () -> mainCatalogue.enter(ALICE));
assertThrows(ProjectNotFoundException.class, () -> mainCatalogue.enter(APEAKAPP));
}

@Test
public void enter_sameButNotEqualProject_success() {
mainCatalogue.addProject(ALICE);
Project adapted = new ProjectBuilder(ALICE).withTags().build();
mainCatalogue.addProject(APEAKAPP);
Project adapted = new ProjectBuilder(APEAKAPP).withTags().build();
try {
mainCatalogue.enter(adapted);
} catch (Exception e) {
Expand Down
Loading

0 comments on commit 4256d6c

Please sign in to comment.