Skip to content

Commit 04bf607

Browse files
Merge pull request #92 from vijay-shankaranand/add-event-testcases
Add Event Command test cases
2 parents b8e6402 + 6de1300 commit 04bf607

File tree

62 files changed

+1042
-354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1042
-354
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ run {
7070
}
7171

7272
shadowJar {
73-
archiveFileName = 'addressbook.jar'
73+
archiveFileName = 'jobfestgo.jar'
7474
}
7575

7676
defaultTasks 'clean', 'test'

docs/tutorials/RemovingFields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ IntelliJ IDEA provides a refactoring tool that can identify *most* parts of a re
3131

3232
### Assisted refactoring
3333

34-
The `address` field in `Person` is actually an instance of the `seedu.address.model.person.Address` class. Since removing the `Address` class will break the application, we start by identifying `Address`'s usages. This allows us to see code that depends on `Address` to function properly and edit them on a case-by-case basis. Right-click the `Address` class and select `Refactor` \> `Safe Delete` through the menu.
34+
The `address` field in `Person` is actually an instance of the `seedu.address.model.address.Address` class. Since removing the `Address` class will break the application, we start by identifying `Address`'s usages. This allows us to see code that depends on `Address` to function properly and edit them on a case-by-case basis. Right-click the `Address` class and select `Refactor` \> `Safe Delete` through the menu.
3535
* :bulb: To make things simpler, you can unselect the options `Search in comments and strings` and `Search for text occurrences`
3636

3737
![Usages detected](../images/remove/UnsafeDelete.png)

src/main/java/seedu/address/logic/commands/event/LinkCommand.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
import seedu.address.logic.commands.exceptions.CommandException;
1313
import seedu.address.model.Model;
1414
import seedu.address.model.event.Event;
15-
import seedu.address.model.event.EventName;
1615
import seedu.address.model.event.exceptions.EventNotFoundException;
17-
import seedu.address.model.person.Name;
16+
import seedu.address.model.name.Name;
1817
import seedu.address.model.person.Person;
1918
import seedu.address.model.person.exceptions.PersonNotFoundException;
2019

@@ -39,13 +38,13 @@ public class LinkCommand extends Command {
3938
+ "Please add it in first.";
4039
public static final String MESSAGE_LINKED_CONTACT = "The contact: %1$s is already linked to the event: %2$s";
4140

42-
private final EventName eventNameToLink;
41+
private final Name eventNameToLink;
4342
private final Set<Name> contactNameListToLink;
4443

4544
/**
4645
* Creates a LinkCommand to link the person specified by the name to the event specified by the name.
4746
*/
48-
public LinkCommand(EventName eventNameToLink, Set<Name> contactNameListToLink) {
47+
public LinkCommand(Name eventNameToLink, Set<Name> contactNameListToLink) {
4948
this.eventNameToLink = eventNameToLink;
5049
this.contactNameListToLink = contactNameListToLink;
5150
}

src/main/java/seedu/address/logic/commands/person/EditCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import seedu.address.logic.commands.CommandResult;
2424
import seedu.address.logic.commands.exceptions.CommandException;
2525
import seedu.address.model.Model;
26-
import seedu.address.model.person.Address;
26+
import seedu.address.model.address.Address;
27+
import seedu.address.model.name.Name;
2728
import seedu.address.model.person.Email;
28-
import seedu.address.model.person.Name;
2929
import seedu.address.model.person.Person;
3030
import seedu.address.model.person.Phone;
3131
import seedu.address.model.tag.Tag;

src/main/java/seedu/address/logic/commands/person/FindCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import seedu.address.logic.commands.Command;
88
import seedu.address.logic.commands.CommandResult;
99
import seedu.address.model.Model;
10-
import seedu.address.model.person.NameContainsKeywordsPredicate;
10+
import seedu.address.model.name.NameContainsKeywordsPredicate;
1111

1212
/**
1313
* Finds and lists all persons in address book whose name contains any of the argument keywords.

src/main/java/seedu/address/logic/commands/task/AddTaskCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import seedu.address.model.Model;
1515
import seedu.address.model.date.Date;
1616
import seedu.address.model.event.Event;
17-
import seedu.address.model.event.EventName;
1817
import seedu.address.model.event.exceptions.EventNotFoundException;
18+
import seedu.address.model.name.Name;
1919
import seedu.address.model.task.Task;
2020
import seedu.address.model.task.TaskDescription;
2121

@@ -39,13 +39,13 @@ public class AddTaskCommand extends Command {
3939
public static final String MESSAGE_DUPLICATE_TASK = "This task already exists in the event";
4040
private final TaskDescription taskDescription;
4141
private final Date taskDeadline;
42-
private final EventName associatedEventName;
42+
private final Name associatedEventName;
4343
private Task taskToAdd;
4444

4545
/**
4646
* Creates an AddTaskCommand to add the specified {@code Task}
4747
*/
48-
public AddTaskCommand(TaskDescription taskDescription, Date taskDeadline, EventName associatedEvent) {
48+
public AddTaskCommand(TaskDescription taskDescription, Date taskDeadline, Name associatedEvent) {
4949
requireAllNonNull(taskDescription, taskDeadline, associatedEvent);
5050
this.taskDescription = taskDescription;
5151
this.taskDeadline = taskDeadline;

src/main/java/seedu/address/logic/parser/ParserUtil.java

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
import seedu.address.commons.core.index.Index;
1010
import seedu.address.commons.util.StringUtil;
1111
import seedu.address.logic.parser.exceptions.ParseException;
12+
import seedu.address.model.address.Address;
1213
import seedu.address.model.date.Date;
13-
import seedu.address.model.event.EventAddress;
14-
import seedu.address.model.event.EventName;
15-
import seedu.address.model.person.Address;
14+
import seedu.address.model.name.Name;
1615
import seedu.address.model.person.Email;
17-
import seedu.address.model.person.Name;
1816
import seedu.address.model.person.Phone;
1917
import seedu.address.model.tag.Tag;
2018
import seedu.address.model.task.TaskDescription;
@@ -127,25 +125,10 @@ public static Set<Tag> parseTags(Collection<String> tags) throws ParseException
127125
}
128126

129127
/**
130-
* Parses a {@code String eventName} into an {@code EventName}.
128+
* Parses a {@code String Date} into an {@code Date}.
131129
* Leading and trailing whitespaces will be trimmed.
132130
*
133-
* @throws ParseException if the given {@code eventName} is invalid.
134-
*/
135-
public static EventName parseEventName(String eventName) throws ParseException {
136-
requireNonNull(eventName);
137-
String trimmedEventName = eventName.trim();
138-
if (!EventName.isValidName(trimmedEventName)) {
139-
throw new ParseException(EventName.MESSAGE_CONSTRAINTS);
140-
}
141-
return new EventName(trimmedEventName);
142-
}
143-
144-
/**
145-
* Parses a {@code String eventDate} into an {@code EventDate}.
146-
* Leading and trailing whitespaces will be trimmed.
147-
*
148-
* @throws ParseException if the given {@code eventDate} is invalid.
131+
* @throws ParseException if the given {@code Date} is invalid.
149132
*/
150133
public static Date parseDate(String eventDate) throws ParseException {
151134
requireNonNull(eventDate);
@@ -156,20 +139,6 @@ public static Date parseDate(String eventDate) throws ParseException {
156139
return new Date(trimmedEventDate);
157140
}
158141

159-
/**
160-
* Parses a {@code String eventAddress} into an {@code EventAddress}.
161-
* Leading and trailing whitespaces will be trimmed.
162-
*
163-
* @throws ParseException if the given {@code eventAddress} is invalid.
164-
*/
165-
public static EventAddress parseEventAddress(String eventAddress) throws ParseException {
166-
requireNonNull(eventAddress);
167-
String trimmedEventAddress = eventAddress.trim();
168-
if (!EventAddress.isValidAddress(trimmedEventAddress)) {
169-
throw new ParseException(EventAddress.MESSAGE_CONSTRAINTS);
170-
}
171-
return new EventAddress(trimmedEventAddress);
172-
}
173142

174143
/**
175144
* Parses {@code Collection<String> contactNames} into a {@code Set<Name>}.
@@ -198,5 +167,4 @@ public static TaskDescription parseTaskDescription(String taskDescription) throw
198167
return new TaskDescription(trimmedTaskDescription);
199168
}
200169

201-
202170
}

src/main/java/seedu/address/logic/parser/event/AddEventCommandParser.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
import seedu.address.logic.parser.ParserUtil;
1717
import seedu.address.logic.parser.Prefix;
1818
import seedu.address.logic.parser.exceptions.ParseException;
19+
import seedu.address.model.address.Address;
1920
import seedu.address.model.date.Date;
2021
import seedu.address.model.event.Event;
21-
import seedu.address.model.event.EventAddress;
22-
import seedu.address.model.event.EventName;
22+
import seedu.address.model.name.Name;
2323
import seedu.address.model.person.Person;
2424
import seedu.address.model.task.Task;
2525

@@ -42,9 +42,11 @@ public AddEventCommand parse(String args) throws ParseException {
4242
}
4343

4444
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_DATE, PREFIX_ADDRESS);
45-
EventName name = ParserUtil.parseEventName(argMultimap.getValue(PREFIX_NAME).get());
45+
46+
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
4647
Date date = ParserUtil.parseDate(argMultimap.getValue(PREFIX_DATE).get());
47-
EventAddress address = ParserUtil.parseEventAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
48+
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
49+
4850
Set<Person> contacts = new HashSet<>();
4951
Set<Task> tasks = new HashSet<>();
5052

src/main/java/seedu/address/logic/parser/event/LinkCommandParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
import seedu.address.logic.parser.ParserUtil;
1515
import seedu.address.logic.parser.Prefix;
1616
import seedu.address.logic.parser.exceptions.ParseException;
17-
import seedu.address.model.event.EventName;
18-
import seedu.address.model.person.Name;
17+
import seedu.address.model.name.Name;
1918

2019
/**
2120
* Parses input arguments and creates a new LinkCommand object
@@ -37,10 +36,10 @@ public LinkCommand parse(String args) throws ParseException {
3736
}
3837

3938
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_EVENT);
40-
EventName eventName = ParserUtil.parseEventName(argMultimap.getValue(PREFIX_EVENT).get());
39+
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_EVENT).get());
4140
Set<Name> contactNameList = ParserUtil.parseContactNames(argMultimap.getAllValues(PREFIX_CONTACT));
4241

43-
return new LinkCommand(eventName, contactNameList);
42+
return new LinkCommand(name, contactNameList);
4443
}
4544

4645
/**

src/main/java/seedu/address/logic/parser/person/AddCommandParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import seedu.address.logic.parser.ParserUtil;
1818
import seedu.address.logic.parser.Prefix;
1919
import seedu.address.logic.parser.exceptions.ParseException;
20-
import seedu.address.model.person.Address;
20+
import seedu.address.model.address.Address;
21+
import seedu.address.model.name.Name;
2122
import seedu.address.model.person.Email;
22-
import seedu.address.model.person.Name;
2323
import seedu.address.model.person.Person;
2424
import seedu.address.model.person.Phone;
2525
import seedu.address.model.tag.Tag;

0 commit comments

Comments
 (0)