Skip to content

Commit

Permalink
Add Assert test
Browse files Browse the repository at this point in the history
  • Loading branch information
yanlings committed Mar 23, 2023
1 parent 340a0ed commit 789cd2c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ src/main/resources/docs/
/out/
/*.iml


# Storage/log files
/data/
/config.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
ObservableList<Employee> lastShownList = model.getFilteredEmployeeList();

if (!EmployeeId.isValidNumber(employeeId.toString())) {
if (!EmployeeId.isValidEmployeeId(employeeId.toString())) {
throw new CommandException(Messages.MESSAGE_INVALID_EMPLOYEE_DISPLAYED_INDEX);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Index parseIndex(String oneBasedIndex) throws ParseException {
*/
public static EmployeeId parseEmployeeId(String employeeId) throws ParseException {
String trimmedEmployeeId = employeeId.trim();
if (!EmployeeId.isValidNumber(trimmedEmployeeId)) {
if (!EmployeeId.isValidEmployeeId(trimmedEmployeeId)) {
throw new ParseException(MESSAGE_INVALID_EMPLOYEE_ID);
}
return new EmployeeId(trimmedEmployeeId);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/model/employee/EmployeeId.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ public EmployeeId() {
*/
public EmployeeId(String id) {
requireNonNull(id);
checkArgument(isValidNumber(id));
checkArgument(isValidEmployeeId(id));
this.value = String.valueOf(Integer.parseInt(id));
}


/**
* Returns true if a given string is a valid number, and can possibly be an employee ID.
*/
public static boolean isValidNumber(String test) {
/*public static boolean isValidNumber(String test) {
return test.matches(VALIDATION_REGEX);
}
}*/


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.testutil.TypicalEmployeeIds.EMPLOYEE_ID_ONE;
import static seedu.address.testutil.TypicalEmployeeIds.EMPLOYEE_ID_TWO;
import static seedu.address.testutil.TypicalEmployeeIds.*;
import static seedu.address.testutil.TypicalEmployees.getTypicalExecutiveProDb;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -65,6 +64,7 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() {
public void equals() {
DeleteCommand deleteFirstCommand = new DeleteCommand(EMPLOYEE_ID_ONE);
DeleteCommand deleteSecondCommand = new DeleteCommand(EMPLOYEE_ID_TWO);
DeleteCommand deleteThirdCommand = new DeleteCommand(EMPLOYEE_ID_THREE);

// same object -> returns true
assertTrue(deleteFirstCommand.equals(deleteFirstCommand));
Expand All @@ -81,6 +81,8 @@ public void equals() {

// different employee -> returns false
assertFalse(deleteFirstCommand.equals(deleteSecondCommand));
assertFalse(deleteThirdCommand.equals(deleteSecondCommand));

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public void parse_validArgs_returnsDeleteCommand() {
public void parse_invalidArgs_throwsParseException() {
assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
public class TypicalEmployeeIds {
public static final EmployeeId EMPLOYEE_ID_ONE = new EmployeeId("1");
public static final EmployeeId EMPLOYEE_ID_TWO = new EmployeeId("2");
public static final EmployeeId EMPLOYEE_ID_THREE = new EmployeeId("3");
}

0 comments on commit 789cd2c

Please sign in to comment.