-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[T4A6][T13-B1] Hong Bangwu #1653
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package seedu.addressbook.data.tag; | ||
|
||
import seedu.addressbook.data.person.Name; | ||
import seedu.addressbook.data.person.Person; | ||
|
||
public class Tagging { | ||
|
||
Name name; | ||
Tag tag; | ||
//isValid tells us whether the tag is still available after the change occurred. | ||
boolean isValid; | ||
|
||
/* | ||
* object will be initialised whenever a tag is added or removed. the method called to do so will provide a reference to | ||
* the tag object, the person object, as well as whether the affected tag's validity to the person. | ||
*/ | ||
public Tagging(Tag tagAffected, Person person, boolean validity) { | ||
name = person.getName(); | ||
isValid = validity; | ||
tag = tagAffected; | ||
} | ||
|
||
public String outputTaggings() { | ||
String output = ""; | ||
if (isValid) { | ||
output += "+ "; | ||
} else output += "- "; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. coding standard violation here 👎
|
||
|
||
output += name.toString(); | ||
output += tag.toString(); | ||
|
||
return output; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package seedu.addressbook.parser; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Test; | ||
|
||
import seedu.addressbook.data.person.Name; | ||
import seedu.addressbook.common.Utils; | ||
import seedu.addressbook.data.exception.IllegalValueException; | ||
import seedu.addressbook.data.person.*; | ||
|
||
public class UtilsTest { | ||
|
||
@Test | ||
public void isAnyNullTest() { | ||
Utils Util = new Utils(); | ||
Name name = null; | ||
|
||
//test case 1: return true for a name that is actually a null | ||
assertTrue(Utils.isAnyNull(name)); | ||
} | ||
|
||
@Test | ||
public void isAnyNullTest1() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test name should have 3 parts |
||
try { | ||
Utils Util = new Utils(); | ||
Name name2 = new Name("Andy Tan"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. going further you can consider moving all the steps necessary for the test to run (or preconditions) to a set up method before beginning the tests; correspondingly can put all the tear down in a method after the tests. |
||
Name name3 = new Name("Joshua Soh"); | ||
|
||
//test case 2: return false if no nulls among objects passed in | ||
assertFalse(Utils.isAnyNull(name2, name3)); | ||
|
||
} catch (IllegalValueException e) { | ||
} | ||
} | ||
|
||
@Test | ||
public void isAnyNullTest2() { | ||
try { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in general, no need to |
||
Utils Util = new Utils(); | ||
Name name = null; | ||
Name name2 = new Name("Andy Tan"); | ||
Name name3 = new Name("Joshua Soh"); | ||
|
||
//test case 3: return true if one of the name object is actually null | ||
assertTrue(Utils.isAnyNull(name, name2, name3)); | ||
|
||
} catch (IllegalValueException e) { | ||
} | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Tagging association should identify a person and a tag, assume the application allows different people with same name, by just using name here, you wouldn't know which person was tagged with the given tag, no? what is a better way?