Skip to content

Commit

Permalink
fix checktsyle in some classes in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kailash201 committed Nov 10, 2023
1 parent 99900c5 commit a57e763
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 186 deletions.
3 changes: 0 additions & 3 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.StringUtil;
Expand All @@ -19,7 +17,6 @@
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
import seedu.address.model.tag.Tag;

/**
* Contains utility methods used for parsing strings in the various *Parser classes.
Expand Down
95 changes: 50 additions & 45 deletions src/test/java/seedu/address/logic/commands/AddTimeCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static seedu.address.testutil.Assert.assertThrows;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.function.Predicate;

import org.junit.jupiter.api.Test;

import javafx.collections.ObservableList;
import javafx.util.Pair;
import seedu.address.commons.core.GuiSettings;
Expand Down Expand Up @@ -52,7 +55,7 @@ public void execute_personDoesNotExit_throwException() {
}

@Test
public void execute_AddSingleTimeToPerson_addSuccessful() {
public void execute_addSingleTimeToPerson_addSuccessful() {
Person validPerson = new PersonBuilder().build();
ModelStubWithPerson modelStub = new ModelStubWithPerson(validPerson);
TimeInterval timeInterval = new TimeIntervalBuilder().build();
Expand All @@ -73,17 +76,17 @@ public void execute_AddSingleTimeToPerson_addSuccessful() {
}

@Test
public void execute_AddMultipleTimeWithNoOverlapToPerson_addSuccessful_addMsg() {
public void execute_addMultipleTimeWithNoOverlapToPerson_addSuccessfulAddMsg() {
Person validPerson = new PersonBuilder().build();
ModelStubWithPerson modelStub = new ModelStubWithPerson(validPerson);
ArrayList<TimeInterval> timeIntervalArrayList = new ArrayList<>();
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalOneNoOverlap);
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalTwoNoOverlap);
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalThreeNoOverlap);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_ONE_NO_OVERLAP);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_TWO_NO_OVERLAP);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP);

String status = "These times have been added:\n" + TypicalTimeIntervals.timeIntervalOneNoOverlap.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalTwoNoOverlap.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalThreeNoOverlap.toString()
String status = "These times have been added:\n" + TypicalTimeIntervals.TIME_INTERVAL_ONE_NO_OVERLAP.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_TWO_NO_OVERLAP.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP.toString()
+ "\n";

try {
Expand All @@ -92,26 +95,27 @@ public void execute_AddMultipleTimeWithNoOverlapToPerson_addSuccessful_addMsg()
assertEquals(String.format(AddTimeCommand.MESSAGE_SUCCESS + status, Messages.format(validPerson.getName())),
commandResult.getFeedbackToUser());

assertEquals("\n" + TypicalTimeIntervals.timeIntervalOneNoOverlap.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalTwoNoOverlap.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalThreeNoOverlap.toString(),
assertEquals("\n" + TypicalTimeIntervals.TIME_INTERVAL_ONE_NO_OVERLAP.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_TWO_NO_OVERLAP.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP.toString(),
modelStub.personList.get(0).getTime().toString());
} catch (CommandException e) {
fail();
}
}

@Test
public void execute_AddMultipleTimeToPersonWithOneExistingOverlappingTime_addUnSuccessful_clashMsg() {
Person validPerson = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.timeIntervalTwoOverlapA).build();
public void execute_addMultipleTimeToPersonWithOneExistingOverlappingTime_addUnSuccessfulClashMsg() {
Person validPerson = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A)
.build();
ModelStubWithPerson modelStub = new ModelStubWithPerson(validPerson);
ArrayList<TimeInterval> timeIntervalArrayList = new ArrayList<>();
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalOneOverlapA);
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalThreeOverlapA);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_THREE_OVERLAP_A);

String status = "There is a clash in these input timings with your existing timings:\n"
+ TypicalTimeIntervals.timeIntervalOneOverlapA.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalThreeOverlapA.toString()
+ TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_THREE_OVERLAP_A.toString()
+ "\n";

try {
Expand All @@ -120,25 +124,26 @@ public void execute_AddMultipleTimeToPersonWithOneExistingOverlappingTime_addUnS
assertEquals(String.format(AddTimeCommand.MESSAGE_SUCCESS + status, Messages.format(validPerson.getName())),
commandResult.getFeedbackToUser());

assertEquals("\n" + TypicalTimeIntervals.timeIntervalTwoOverlapA.toString(),
assertEquals("\n" + TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A.toString(),
modelStub.personList.get(0).getTime().toString());
} catch (CommandException e) {
fail();
}
}

@Test
public void execute_AddMultipleTimeToPersonWithOneExistingOverlappingTime_addHalfSuccessful_clashAndAddMsg() {
Person validPerson = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.timeIntervalTwoOverlapA).build();
public void execute_addMultipleTimeToPersonWithOneExistingOverlappingTime_addHalfSuccessfulClashAndAddMsg() {
Person validPerson = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A)
.build();
ModelStubWithPerson modelStub = new ModelStubWithPerson(validPerson);
ArrayList<TimeInterval> timeIntervalArrayList = new ArrayList<>();
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalOneOverlapA);
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalThreeNoOverlap);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP);

String status = "There is a clash in these input timings with your existing timings:\n"
+ TypicalTimeIntervals.timeIntervalOneOverlapA.toString()
+ TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A.toString()
+ "\n" + "These times have been added:"
+ "\n" + TypicalTimeIntervals.timeIntervalThreeNoOverlap.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP.toString()
+ "\n";

try {
Expand All @@ -147,26 +152,26 @@ public void execute_AddMultipleTimeToPersonWithOneExistingOverlappingTime_addHal
assertEquals(String.format(AddTimeCommand.MESSAGE_SUCCESS + status, Messages.format(validPerson.getName())),
commandResult.getFeedbackToUser());

assertEquals("\n" + TypicalTimeIntervals.timeIntervalTwoOverlapA.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalThreeNoOverlap.toString(),
assertEquals("\n" + TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP.toString(),
modelStub.personList.get(0).getTime().toString());
} catch (CommandException e) {
fail();
}
}

@Test
public void execute_AddMultipleTimeToPersonWithTwoExistingOverlappingTime_addUnSuccessful_clashMsg() {
Person validPerson = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.timeIntervalOneOverlapA)
.withTimeInterval(TypicalTimeIntervals.timeIntervalFourOverlapA).build();
public void execute_addMultipleTimeToPersonWithTwoExistingOverlappingTime_addUnSuccessfulClashMsg() {
Person validPerson = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A)
.withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_FOUR_OVERLAP_A).build();
ModelStubWithPerson modelStub = new ModelStubWithPerson(validPerson);
ArrayList<TimeInterval> timeIntervalArrayList = new ArrayList<>();
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalTwoOverlapA);
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalFiveOverlapA);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_FIVE_OVERLAP_A);

String status = "There is a clash in these input timings with your existing timings:\n"
+ TypicalTimeIntervals.timeIntervalTwoOverlapA.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalFiveOverlapA.toString()
+ TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_FIVE_OVERLAP_A.toString()
+ "\n";

try {
Expand All @@ -175,27 +180,27 @@ public void execute_AddMultipleTimeToPersonWithTwoExistingOverlappingTime_addUnS
assertEquals(String.format(AddTimeCommand.MESSAGE_SUCCESS + status, Messages.format(validPerson.getName())),
commandResult.getFeedbackToUser());

assertEquals("\n" + TypicalTimeIntervals.timeIntervalOneOverlapA.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalFourOverlapA.toString(),
assertEquals("\n" + TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_FOUR_OVERLAP_A.toString(),
modelStub.personList.get(0).getTime().toString());
} catch (CommandException e) {
fail();
}
}

@Test
public void execute_AddMultipleTimeToPersonWithTwoExistingOverlappingTime_addHalfSuccessful_clashAndAddMsg() {
Person validPerson = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.timeIntervalOneOverlapA)
.withTimeInterval(TypicalTimeIntervals.timeIntervalFourOverlapA).build();
public void execute_addMultipleTimeToPersonWithTwoExistingOverlappingTime_addHalfSuccessfulClashAndAddMsg() {
Person validPerson = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A)
.withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_FOUR_OVERLAP_A).build();
ModelStubWithPerson modelStub = new ModelStubWithPerson(validPerson);
ArrayList<TimeInterval> timeIntervalArrayList = new ArrayList<>();
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalTwoOverlapA);
timeIntervalArrayList.add(TypicalTimeIntervals.timeIntervalThreeNoOverlap);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A);
timeIntervalArrayList.add(TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP);

String status = "There is a clash in these input timings with your existing timings:\n"
+ TypicalTimeIntervals.timeIntervalTwoOverlapA.toString()
+ TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A.toString()
+ "\n" + "These times have been added:"
+ "\n" + TypicalTimeIntervals.timeIntervalThreeNoOverlap.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP.toString()
+ "\n";

try {
Expand All @@ -204,9 +209,9 @@ public void execute_AddMultipleTimeToPersonWithTwoExistingOverlappingTime_addHal
assertEquals(String.format(AddTimeCommand.MESSAGE_SUCCESS + status, Messages.format(validPerson.getName())),
commandResult.getFeedbackToUser());

assertEquals("\n" + TypicalTimeIntervals.timeIntervalOneOverlapA.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalFourOverlapA.toString()
+ "\n" + TypicalTimeIntervals.timeIntervalThreeNoOverlap.toString(),
assertEquals("\n" + TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_FOUR_OVERLAP_A.toString()
+ "\n" + TypicalTimeIntervals.TIME_INTERVAL_THREE_NO_OVERLAP.toString(),
modelStub.personList.get(0).getTime().toString());
} catch (CommandException e) {
fail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void parse_allFieldsPresent_success() {
Person expectedPerson = new PersonBuilder(BOB).build();

// whitespace only preamble
9(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB
assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB
+ GROUP_DESC_BOB, new AddCommand(expectedPerson));


Expand Down
Loading

0 comments on commit a57e763

Please sign in to comment.