Skip to content

Commit

Permalink
Edit to pass checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Lin-Shuang-Shuang committed Mar 5, 2024
1 parent 761dd61 commit d574a2a
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 159 deletions.
6 changes: 0 additions & 6 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,7 @@ public CommandResult execute(Model model) throws CommandException {
*/
private static Person createEditedPerson(Person personToEdit, EditPersonDescriptor editPersonDescriptor) {
assert personToEdit != null;

Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName());
// Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone());
// Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail());
// Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
// Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());

return new Person(updatedName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ public class AddProjectCommandParser implements Parser<AddProjectCommand> {
* @throws ParseException if the user input does not conform the expected format
*/
public AddProjectCommand parse(String args) throws ParseException {

String projectName = args;

Name name = ParserUtil.parseName(projectName);

// Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));

Person person = new Person(name);

return new AddProjectCommand(person);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class AddressBookParser {
/**
* Used for initial separation of command word and args.
*/
private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?<commandWord>[^\\s]+\\s[^\\s]+)(?<arguments>.*)");
private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile(
"(?<commandWord>[^\\s]+\\s[^\\s]+)(?<arguments>.*)");
private static final Logger logger = LogsCenter.getLogger(AddressBookParser.class);

/**
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;

import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.model.tag.Tag;

/**
* Represents a Person in the address book.
Expand All @@ -19,8 +15,6 @@ public class Person {
// Identity fields
private final Name name;

// private final Set<Tag> tags = new HashSet<>();

/**
* Every field must be present and not null.
*/
Expand All @@ -34,13 +28,6 @@ public Name getName() {
}


// /**
// * Returns an immutable tag set, which throws {@code UnsupportedOperationException}
// * if modification is attempted.
// */
// public Set<Tag> getTags() {
// return Collections.unmodifiableSet(tags);
// }

/**
* Returns true if both persons have the same name.
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.tag.Tag;

/**
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package seedu.address.storage;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.tag.Tag;

/**
Expand Down Expand Up @@ -45,9 +39,6 @@ public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone
*/
public JsonAdaptedPerson(Person source) {
name = source.getName().fullName;
// tags.addAll(source.getTags().stream()
// .map(JsonAdaptedTag::new)
// .collect(Collectors.toList()));
}

/**
Expand All @@ -68,8 +59,6 @@ public Person toModelType() throws IllegalValueException {
throw new IllegalValueException(Name.MESSAGE_CONSTRAINTS);
}
final Name modelName = new Name(name);

// final Set<Tag> modelTags = new HashSet<>(personTags);
return new Person(modelName);
}

Expand Down
5 changes: 0 additions & 5 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package seedu.address.ui;

import java.util.Comparator;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
Expand Down Expand Up @@ -49,8 +47,5 @@ public PersonCard(Person person, int displayedIndex) {
this.person = person;
id.setText(displayedIndex + ". ");
name.setText(person.getName().fullName);
// person.getTags().stream()
// .sorted(Comparator.comparing(tag -> tag.tagName))
// .forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public void execute_duplicatePerson_throwsCommandException() {
AddProjectCommand addProjectCommand = new AddProjectCommand(validPerson);
ModelStub modelStub = new ModelStubWithPerson(validPerson);

assertThrows(CommandException.class, AddProjectCommand.MESSAGE_DUPLICATE_PERSON, () -> addProjectCommand.execute(modelStub));
assertThrows(CommandException.class, AddProjectCommand.MESSAGE_DUPLICATE_PERSON, () ->
addProjectCommand.execute(modelStub));
}

@Test
Expand Down
13 changes: 0 additions & 13 deletions src/test/java/seedu/address/model/person/PersonTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package seedu.address.model.person;

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_ADDRESS_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.BOB;

Expand All @@ -18,11 +16,6 @@

public class PersonTest {

@Test
public void asObservableList_modifyList_throwsUnsupportedOperationException() {
Person person = new PersonBuilder().build();
assertThrows(UnsupportedOperationException.class, () -> person.getTags().remove(0));
}

@Test
public void isSamePerson() {
Expand Down Expand Up @@ -90,10 +83,4 @@ public void equals() {
assertFalse(ALICE.equals(editedAlice));
}

@Test
public void toStringMethod() {
String expected = Person.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone()
+ ", email=" + ALICE.getEmail() + ", address=" + ALICE.getAddress() + ", tags=" + ALICE.getTags() + "}";
assertEquals(expected, ALICE.toString());
}
}
85 changes: 1 addition & 84 deletions src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
package seedu.address.storage;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static seedu.address.storage.JsonAdaptedPerson.MISSING_FIELD_MESSAGE_FORMAT;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.BENSON;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.junit.jupiter.api.Test;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;

public class JsonAdaptedPersonTest {
private static final String INVALID_NAME = "R@chel";
Expand All @@ -25,86 +14,14 @@ public class JsonAdaptedPersonTest {
private static final String INVALID_TAG = "#friend";

private static final String VALID_NAME = BENSON.getName().toString();
private static final String VALID_PHONE = BENSON.getPhone().toString();
private static final String VALID_EMAIL = BENSON.getEmail().toString();
private static final String VALID_ADDRESS = BENSON.getAddress().toString();
private static final List<JsonAdaptedTag> VALID_TAGS = BENSON.getTags().stream()
.map(JsonAdaptedTag::new)
.collect(Collectors.toList());


@Test
public void toModelType_validPersonDetails_returnsPerson() throws Exception {
JsonAdaptedPerson person = new JsonAdaptedPerson(BENSON);
assertEquals(BENSON, person.toModelType());
}

@Test
public void toModelType_invalidName_throwsIllegalValueException() {
JsonAdaptedPerson person =
new JsonAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS);
String expectedMessage = Name.MESSAGE_CONSTRAINTS;
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_nullName_throwsIllegalValueException() {
JsonAdaptedPerson person = new JsonAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName());
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_invalidPhone_throwsIllegalValueException() {
JsonAdaptedPerson person =
new JsonAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS);
String expectedMessage = Phone.MESSAGE_CONSTRAINTS;
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_nullPhone_throwsIllegalValueException() {
JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName());
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_invalidEmail_throwsIllegalValueException() {
JsonAdaptedPerson person =
new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_TAGS);
String expectedMessage = Email.MESSAGE_CONSTRAINTS;
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_nullEmail_throwsIllegalValueException() {
JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_TAGS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName());
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_invalidAddress_throwsIllegalValueException() {
JsonAdaptedPerson person =
new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_TAGS);
String expectedMessage = Address.MESSAGE_CONSTRAINTS;
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_nullAddress_throwsIllegalValueException() {
JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_TAGS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName());
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_invalidTags_throwsIllegalValueException() {
List<JsonAdaptedTag> invalidTags = new ArrayList<>(VALID_TAGS);
invalidTags.add(new JsonAdaptedTag(INVALID_TAG));
JsonAdaptedPerson person =
new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags);
assertThrows(IllegalValueException.class, person::toModelType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) {
*/
public EditPersonDescriptorBuilder(Person person) {
descriptor = new EditPersonDescriptor();
descriptor.setName(person.getName());
descriptor.setPhone(person.getPhone());
descriptor.setEmail(person.getEmail());
descriptor.setAddress(person.getAddress());
descriptor.setTags(person.getTags());
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/seedu/address/testutil/PersonBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public PersonBuilder() {
*/
public PersonBuilder(Person personToCopy) {
name = personToCopy.getName();
phone = personToCopy.getPhone();
email = personToCopy.getEmail();
address = personToCopy.getAddress();
tags = new HashSet<>(personToCopy.getTags());
}

/**
Expand Down Expand Up @@ -90,7 +86,7 @@ public PersonBuilder withEmail(String email) {
}

public Person build() {
return new Person(name, phone, email, address, tags);
return new Person(name);
}

}
6 changes: 0 additions & 6 deletions src/test/java/seedu/address/testutil/PersonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public static String getAddCommand(Person person) {
public static String getPersonDetails(Person person) {
StringBuilder sb = new StringBuilder();
sb.append(PREFIX_NAME + person.getName().fullName + " ");
sb.append(PREFIX_PHONE + person.getPhone().value + " ");
sb.append(PREFIX_EMAIL + person.getEmail().value + " ");
sb.append(PREFIX_ADDRESS + person.getAddress().value + " ");
person.getTags().stream().forEach(
s -> sb.append(PREFIX_TAG + s.tagName + " ")
);
return sb.toString();
}

Expand Down

0 comments on commit d574a2a

Please sign in to comment.