forked from nus-cs2103-AY2122S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nus-cs2103-AY2122S1#85 from benedictchuajj/branch-…
…Increase-ViewTests Increase code coverage for view command related classes
- Loading branch information
Showing
6 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/seedu/address/model/person/ClientIdTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package seedu.address.model.person; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.testutil.Assert.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class ClientIdTest { | ||
|
||
@Test | ||
public void constructor_null_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new ClientId(null)); | ||
} | ||
|
||
@Test | ||
public void constructor_invalidCurrentPlan_throwsIllegalArgumentException() { | ||
String invalidClientId = " "; | ||
assertThrows(IllegalArgumentException.class, () -> new ClientId(invalidClientId)); | ||
} | ||
|
||
@Test | ||
public void isClientId() { | ||
// null input | ||
assertThrows(NullPointerException.class, () -> ClientId.isValidClientId(null)); | ||
|
||
// invalid client id | ||
assertFalse(ClientId.isValidClientId(" ")); // spaces only | ||
assertFalse(ClientId.isValidClientId("-1")); // negative int | ||
|
||
// valid client id | ||
assertTrue(ClientId.isValidClientId("0")); // zero | ||
assertTrue(ClientId.isValidClientId("12345")); // any positive int | ||
} | ||
|
||
@Test | ||
public void isEqual() { | ||
String input1 = "1"; | ||
String input2 = "2"; | ||
ClientId clientA = new ClientId(input1); | ||
ClientId clientB = new ClientId(input2); | ||
ClientId clientC = new ClientId(input1); | ||
|
||
// same value | ||
assertTrue(clientA.equals(clientA)); | ||
assertTrue(clientA.equals(clientC)); | ||
|
||
// different value | ||
assertFalse(clientA.equals(clientB)); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/test/java/seedu/address/model/person/PersonHasIdTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package seedu.address.model.person; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.testutil.PersonBuilder; | ||
|
||
public class PersonHasIdTest { | ||
|
||
@Test | ||
public void equals() { | ||
String input1 = "1"; | ||
String input2 = "2"; | ||
ClientId clientA = new ClientId(input1); | ||
ClientId clientB = new ClientId(input2); | ||
|
||
PersonHasId firstPredicate = new PersonHasId(clientA); | ||
PersonHasId secondPredicate = new PersonHasId(clientB); | ||
|
||
// same object -> returns true | ||
assertTrue(firstPredicate.equals(firstPredicate)); | ||
|
||
// same values -> returns true | ||
PersonHasId firstPredicateCopy = new PersonHasId(clientA); | ||
assertTrue(firstPredicate.equals(firstPredicateCopy)); | ||
|
||
// different types -> returns false | ||
assertFalse(firstPredicate.equals(1)); | ||
|
||
// null -> returns false | ||
assertFalse(firstPredicate.equals(null)); | ||
|
||
// different person -> returns false | ||
assertFalse(firstPredicate.equals(secondPredicate)); | ||
} | ||
|
||
@Test | ||
public void test_clientIdMatches_returnsTrue() { | ||
// Same client id | ||
PersonHasId predicate = new PersonHasId(new ClientId("1")); | ||
assertTrue(predicate.test(new PersonBuilder().withClientId("1").build())); | ||
} | ||
|
||
@Test | ||
public void test_clientIdMatches_returnsFalse() { | ||
// different client id | ||
PersonHasId predicate = new PersonHasId(new ClientId("0")); | ||
assertFalse(predicate.test(new PersonBuilder().withClientId("1").build())); | ||
} | ||
} |