Skip to content

Commit

Permalink
Merge pull request #100 from choaticman/branch-dylan-update-test-cases-2
Browse files Browse the repository at this point in the history
Add InternshipApplication tests
  • Loading branch information
ZweZeya authored Oct 17, 2024
2 parents cc37cb7 + 8a5e9a7 commit 700886c
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public class ClearCommand extends Command<InternshipApplication> {

public static final String COMMAND_WORD = "/c";
public static final String COMMAND_WORD = "/clear";
public static final String MESSAGE_SUCCESS = "HireMe has been cleared!";


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
public class HelpCommand extends Command {

public static final String COMMAND_WORD = "help";
public static final String COMMAND_WORD = "/help";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows program usage instructions.\n"
+ "Example: " + COMMAND_WORD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Email {
public Email(String email) {
requireNonNull(email);
checkArgument(EmailValidator.of().validate(email), MESSAGE_CONSTRAINTS);
this.value = email;
this.value = email.trim();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Name {
public Name(String name) {
requireNonNull(name);
checkArgument(NameValidator.of().validate(name), MESSAGE_CONSTRAINTS);
this.value = name;
this.value = name.trim();
}

/**
Expand Down Expand Up @@ -66,7 +66,7 @@ public boolean equals(Object other) {
}

Name otherName = (Name) other;
return value.equals(otherName.value);
return value.equalsIgnoreCase(otherName.value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Role {
public Role(String role) {
requireNonNull(role);
checkArgument(RoleValidator.of().validate(role), MESSAGE_CONSTRAINTS);
this.value = role;
this.value = role.trim();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package seedu.address.model.internshipapplication;

import org.junit.jupiter.api.Test;
import seedu.address.testutil.InternshipApplicationBuilder;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.VALID_COMPANY_EMAIL_BOFA;
import static seedu.address.logic.commands.CommandTestUtil.VALID_COMPANY_NAME_BOFA;
import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE_BOFA;
import static seedu.address.logic.commands.CommandTestUtil.VALID_ROLE_BOFA;
import static seedu.address.testutil.TypicalInternshipApplications.APPLE;
import static seedu.address.testutil.TypicalInternshipApplications.BOFA;

public class InternshipApplicationTest {

@Test
public void isSame() {
// same object -> returns true
assertTrue(APPLE.isSame(APPLE));

// null -> returns false
assertFalse(APPLE.isSame(null));

// same name, all other attributes different -> returns false
InternshipApplication editedApple = new InternshipApplicationBuilder(APPLE).withRole(VALID_ROLE_BOFA)
.withDate(VALID_DATE_BOFA).build();
assertFalse(APPLE.isSame(editedApple));

// different name, all other attributes same -> returns false
editedApple = new InternshipApplicationBuilder(APPLE).withName(VALID_COMPANY_NAME_BOFA).build();
assertFalse(APPLE.isSame(editedApple));

// name differs in case, all other attributes same -> returns true
InternshipApplication editedBofa = new InternshipApplicationBuilder(BOFA).withName(VALID_COMPANY_NAME_BOFA
.toLowerCase()).build();
assertTrue(BOFA.isSame(editedBofa));

// name has trailing spaces, all other attributes same -> returns true
String nameWithTrailingSpaces = VALID_COMPANY_NAME_BOFA + " ";
editedBofa = new InternshipApplicationBuilder(BOFA).withName(nameWithTrailingSpaces).build();
assertTrue(BOFA.isSame(editedBofa));
}

@Test
public void equals() {
// same values -> returns true
InternshipApplication appleCopy = new InternshipApplicationBuilder(APPLE).build();
assertTrue(APPLE.equals(appleCopy));

// same object -> returns true
assertTrue(APPLE.equals(APPLE));

// null -> returns false
assertFalse(APPLE.equals(null));

// different type -> returns false
assertFalse(APPLE.equals(5));

// different person -> returns false
assertFalse(APPLE.equals(BOFA));

// different company name -> returns false
InternshipApplication editedApple = new InternshipApplicationBuilder(APPLE).withName(VALID_COMPANY_NAME_BOFA).build();
assertFalse(APPLE.equals(editedApple));

// different role -> returns false
editedApple = new InternshipApplicationBuilder(APPLE).withRole(VALID_ROLE_BOFA).build();
assertFalse(APPLE.equals(editedApple));

// different email -> returns false
editedApple = new InternshipApplicationBuilder(APPLE).withEmail(VALID_COMPANY_EMAIL_BOFA).build();
assertFalse(APPLE.equals(editedApple));

// different date -> returns false
editedApple = new InternshipApplicationBuilder(APPLE).withDate("02/01/24").build();
assertFalse(APPLE.equals(editedApple));
}

@Test
public void toStringMethod() {
String expected = InternshipApplication.class.getCanonicalName() + "{Company="
+ APPLE.getCompany() + ", Date of Application="
+ APPLE.getDateOfApplication() + ", Role=" + APPLE.getRole() + "}";
assertEquals(expected, APPLE.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public InternshipApplicationBuilder withEmail(String email) {
* Sets the {@code CompanyName} of the {@code InternshipApplication} that we are building.
*/
public InternshipApplicationBuilder withName(String name) {
this.company = new Company(this.company.getEmail(), new Name(name));
this.company = new Company(this.company.getEmail(), new Name(name.trim()));
return this;
}

Expand Down

0 comments on commit 700886c

Please sign in to comment.