Skip to content

Commit

Permalink
Fix Checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
lerxuan committed Nov 11, 2023
1 parent 94213cd commit de2f7db
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 58 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies {
}

shadowJar {
archiveFileName = 'addressbook.jar'
archiveFileName = 'ProjectPRO.jar'
}

defaultTasks 'clean', 'test'
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
import static seedu.address.logic.commands.DeleteGroupCommand.MESSAGE_DELETE_GROUP_SUCCESS;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalGroups.CS2103;
import static seedu.address.testutil.TypicalPersons.ALICE;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.function.Predicate;

import org.junit.jupiter.api.Test;

import javafx.collections.ObservableList;
import javafx.util.Pair;
import org.junit.jupiter.api.Test;
import seedu.address.commons.core.GuiSettings;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
Expand All @@ -28,10 +32,6 @@
import seedu.address.testutil.GroupBuilder;
import seedu.address.testutil.PersonBuilder;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.function.Predicate;

/**
* Contains integration tests (interaction with the Model) and unit tests for
* {@code DeleteCommand}.
Expand All @@ -51,7 +51,6 @@ public void execute_existingGroupWithNoMembers_deleteSuccessful() throws Excepti
commandResult.getFeedbackToUser());
ArrayList<Group> emptyGroupList = new ArrayList<>();
assertEquals(emptyGroupList, modelStub.groups); // checks group removed from contact list

}

@Test
Expand Down Expand Up @@ -82,24 +81,24 @@ public void execute_nonexistentGroup_throwsCommandException() {
Group nonexistentGroup = new GroupBuilder().build();
DeleteGroupCommand deleteGroupCommand =
new DeleteGroupCommand(nonexistentGroup.getGroupName());
DeleteGroupCommandTest.ModelStub modelStub
= new DeleteGroupCommandTest.ModelStubDeletingGroup();
DeleteGroupCommandTest.ModelStub modelStub =
new DeleteGroupCommandTest.ModelStubDeletingGroup();

assertThrows(CommandException.class, Messages.MESSAGE_NO_GROUP_WITH_NAME_FOUND,
() -> deleteGroupCommand.execute(modelStub));
assertThrows(CommandException.class,
Messages.MESSAGE_NO_GROUP_WITH_NAME_FOUND, () -> deleteGroupCommand.execute(modelStub));

// empty input
String emptyInput = "";
assertThrows(CommandException.class, Messages.MESSAGE_NO_GROUP_WITH_NAME_FOUND,
() -> new DeleteGroupCommand(emptyInput).execute(modelStub));
assertThrows(CommandException.class,
Messages.MESSAGE_NO_GROUP_WITH_NAME_FOUND, () -> new DeleteGroupCommand(emptyInput).execute(modelStub));
}

@Test
public void equals() {
Group CS2103 = new GroupBuilder().withName("CS2103").build();
Group CS2103T = new GroupBuilder().withName("CS2103T").build();
DeleteGroupCommand deleteCS2103Command = new DeleteGroupCommand(CS2103.getGroupName());
DeleteGroupCommand deleteCS2103TCommand = new DeleteGroupCommand(CS2103T.getGroupName());
Group cs2103 = new GroupBuilder().withName("CS2103").build();
Group cs2103T = new GroupBuilder().withName("CS2103T").build();
DeleteGroupCommand deleteCS2103Command = new DeleteGroupCommand(cs2103.getGroupName());
DeleteGroupCommand deleteCS2103TCommand = new DeleteGroupCommand(cs2103T.getGroupName());

// same object -> returns true
assertTrue(deleteCS2103Command.equals(deleteCS2103Command));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.ALICE;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.function.Predicate;

import org.junit.jupiter.api.Test;

import javafx.collections.ObservableList;
import javafx.util.Pair;
import org.junit.jupiter.api.Test;
import seedu.address.commons.core.GuiSettings;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
Expand All @@ -26,10 +31,6 @@
import seedu.address.model.person.Person;
import seedu.address.testutil.PersonBuilder;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.function.Predicate;

/**
* Contains integration tests (interaction with the Model) and unit tests for
* {@code DeleteCommand}.
Expand Down Expand Up @@ -76,16 +77,16 @@ public void execute_nonexistentPerson_throwsCommandException() {
Person nonexistentPerson = new PersonBuilder().build();
DeletePersonCommand deletePersonCommand =
new DeletePersonCommand(nonexistentPerson.getName().toString());
DeletePersonCommandTest.ModelStub modelStub
= new DeletePersonCommandTest.ModelStubDeletingPerson();
DeletePersonCommandTest.ModelStub modelStub =
new DeletePersonCommandTest.ModelStubDeletingPerson();

assertThrows(CommandException.class, Messages.MESSAGE_NO_PERSON_WITH_NAME_FOUND,
() -> deletePersonCommand.execute(modelStub));
assertThrows(CommandException.class,
Messages.MESSAGE_NO_PERSON_WITH_NAME_FOUND, () -> deletePersonCommand.execute(modelStub));

// empty input
String emptyInput = "";
assertThrows(CommandException.class, Messages.MESSAGE_NO_PERSON_WITH_NAME_FOUND,
() -> new DeletePersonCommand(emptyInput).execute(modelStub));
assertThrows(CommandException.class, Messages.MESSAGE_NO_PERSON_WITH_NAME_FOUND, () ->
new DeletePersonCommand(emptyInput).execute(modelStub));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

import java.util.Arrays;
import java.util.Collections;
import java.util.function.Predicate;

import org.junit.jupiter.api.Test;
Expand All @@ -18,7 +16,6 @@
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.model.group.Group;
import seedu.address.model.person.NameContainsKeywordsPredicate;
import seedu.address.model.person.Person;
import seedu.address.testutil.GroupBuilder;

Expand Down Expand Up @@ -57,16 +54,14 @@ public void execute_invalidGroup_failure() {

// empty input
String emptyInput = "";
assertThrows(CommandException.class, expectedMessage,
() -> new FindGroupCommand(emptyInput).execute(model));
assertThrows(CommandException.class, expectedMessage, () -> new FindGroupCommand(emptyInput).execute(model));

// nonexistent group
Group nonexistentGroup = new GroupBuilder().build();
FindGroupCommand findGroupCommand =
new FindGroupCommand(nonexistentGroup.getGroupName());

assertThrows(CommandException.class, expectedMessage,
() -> findGroupCommand.execute(model));
assertThrows(CommandException.class, expectedMessage, () -> findGroupCommand.execute(model));

assertEquals(expectedModel.getFilteredPersonList(), model.getFilteredPersonList());
}
Expand All @@ -92,4 +87,4 @@ public void toStringMethod() {
assertEquals(expected, findCS2100Command.toString());
}

}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package seedu.address.logic.commands;

import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

import org.junit.jupiter.api.Test;

import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;

import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

public class ListGroupCommandTest {
private Model model;
private Model expectedModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_CS;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_CS2103T;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE;
import static seedu.address.logic.commands.CommandTestUtil.VALID_GROUP_CS;
import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY;
Expand Down
33 changes: 16 additions & 17 deletions src/test/java/seedu/address/logic/parser/FindCommandParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
public class FindCommandParserTest {

private FindCommandParser parser = new FindCommandParser();
private String WHITESPACE = " ";

private String KEYWORDS_NO_WHITESPACES = WHITESPACE + PREFIX_NAME + "Amy Bob";
private String KEYWORDS_WITH_WHITESPACES = WHITESPACE + PREFIX_NAME + " \n Amy \n \t Bob \t";

private String KEYWORDS_NO_PREFIX = WHITESPACE + "Amy Bob";
private String whitespace = " ";
private String keywordsWithoutWhitespace = whitespace + PREFIX_NAME + "Amy Bob";
private String keywordsWithWhitespace = whitespace + PREFIX_NAME + " \n Amy \n \t Bob \t";
private String keywordsNoPrefix = whitespace + "Amy Bob";

@Test
public void parse_validArgs_returnsFindCommand() {
// valid command format for find person
assertParseSuccess(parser, PREAMBLE_WHITESPACE + KEYWORDS_NO_WHITESPACES,
new FindPersonCommand(new NameContainsKeywordsPredicate(Arrays.asList("Amy", "Bob")))); // no leading and trailing whitespaces
assertParseSuccess(parser, PREAMBLE_WHITESPACE + keywordsWithoutWhitespace,
new FindPersonCommand(new NameContainsKeywordsPredicate(
Arrays.asList("Amy", "Bob")))); // no leading and trailing whitespaces

assertParseSuccess(parser, PREAMBLE_WHITESPACE + KEYWORDS_WITH_WHITESPACES,
new FindPersonCommand(new NameContainsKeywordsPredicate(Arrays.asList("Amy", "Bob")))); // multiple whitespaces between keywords
assertParseSuccess(parser, PREAMBLE_WHITESPACE + keywordsWithWhitespace,
new FindPersonCommand(new NameContainsKeywordsPredicate(
Arrays.asList("Amy", "Bob")))); // multiple whitespaces between keywords

// valid command format for find group
assertParseSuccess(parser, NAME_DESC_CS,
Expand All @@ -51,7 +51,7 @@ public void parse_compulsoryFieldMissingPrefix_failure() {
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE));

// missing name prefix
assertParseFailure(parser, PREAMBLE_WHITESPACE + KEYWORDS_NO_PREFIX,
assertParseFailure(parser, PREAMBLE_WHITESPACE + keywordsNoPrefix,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE));

// missing group prefix
Expand All @@ -62,28 +62,27 @@ public void parse_compulsoryFieldMissingPrefix_failure() {
@Test
public void parse_repeatedNonTagValue_failure() {
// multiple name prefixes
assertParseFailure(parser, PREAMBLE_WHITESPACE + KEYWORDS_NO_WHITESPACES + KEYWORDS_WITH_WHITESPACES,
assertParseFailure(parser, PREAMBLE_WHITESPACE + keywordsWithoutWhitespace + keywordsWithWhitespace,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME));

// multiple group prefixes
assertParseFailure(parser, PREAMBLE_WHITESPACE + NAME_DESC_CS + NAME_DESC_CS2103T,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_GROUPTAG));

//multiple name and group prefixes
assertParseFailure(parser, PREAMBLE_WHITESPACE + KEYWORDS_NO_WHITESPACES + KEYWORDS_WITH_WHITESPACES
assertParseFailure(parser, PREAMBLE_WHITESPACE + keywordsWithoutWhitespace + keywordsWithWhitespace
+ NAME_DESC_CS + NAME_DESC_CS2103T,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_GROUPTAG));

// name and group
assertParseFailure(parser, PREAMBLE_WHITESPACE + KEYWORDS_NO_WHITESPACES + NAME_DESC_CS,
assertParseFailure(parser, PREAMBLE_WHITESPACE + keywordsWithoutWhitespace + NAME_DESC_CS,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_TWO_PARAMETERS));
}

@Test
public void parse_invalidValue_failure() {
// empty name for find person command
assertParseFailure(parser, PREAMBLE_WHITESPACE + WHITESPACE + PREFIX_NAME,
assertParseFailure(parser, PREAMBLE_WHITESPACE + whitespace + PREFIX_NAME,
FindCommand.MESSAGE_EMPTY_NAME);
}

}
}

0 comments on commit de2f7db

Please sign in to comment.