Skip to content

Commit

Permalink
Fix checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
seox123 committed Oct 17, 2022
1 parent 04db0f8 commit cb0b828
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 90 deletions.
6 changes: 3 additions & 3 deletions src/test/java/seedu/waddle/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static seedu.waddle.commons.core.Messages.MESSAGE_INVALID_ITINERARY_DISPLAYED_INDEX;
import static seedu.waddle.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND;
import static seedu.waddle.logic.commands.CommandTestUtil.NAME_DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.COUNTRY_DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.START_DATE_DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.END_DATE_DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.NAME_DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.PEOPLE_DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.START_DATE_DESC_SUMMER;
import static seedu.waddle.testutil.Assert.assertThrows;
import static seedu.waddle.testutil.TypicalItineraries.SUMMER;

Expand All @@ -28,8 +28,8 @@
import seedu.waddle.model.ReadOnlyWaddle;
import seedu.waddle.model.UserPrefs;
import seedu.waddle.model.itinerary.Itinerary;
import seedu.waddle.storage.JsonWaddleStorage;
import seedu.waddle.storage.JsonUserPrefsStorage;
import seedu.waddle.storage.JsonWaddleStorage;
import seedu.waddle.storage.StorageManager;
import seedu.waddle.testutil.ItineraryBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public void execute_duplicateItinerary_throwsCommandException() {
AddCommand addCommand = new AddCommand(validItinerary);
ModelStub modelStub = new ModelStubWithItinerary(validItinerary);

assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_ITINERARY, () -> addCommand.execute(modelStub));
assertThrows(CommandException.class,
AddCommand.MESSAGE_DUPLICATE_ITINERARY, () -> addCommand.execute(modelStub));
}

@Test
Expand Down
10 changes: 9 additions & 1 deletion src/test/java/seedu/waddle/logic/commands/EditCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.waddle.logic.commands.CommandTestUtil.*;
import static seedu.waddle.logic.commands.CommandTestUtil.DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.DESC_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_COUNTRY_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_NAME_TEST;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_NAME_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_PEOPLE_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.waddle.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.waddle.logic.commands.CommandTestUtil.showItineraryAtIndex;
import static seedu.waddle.testutil.TypicalIndexes.INDEX_FIRST_ITINERARY;
import static seedu.waddle.testutil.TypicalIndexes.INDEX_SECOND_ITINERARY;
import static seedu.waddle.testutil.TypicalItineraries.getTypicalWaddle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.waddle.logic.commands.CommandTestUtil.*;
import static seedu.waddle.logic.commands.CommandTestUtil.DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.DESC_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_COUNTRY_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_END_DATE_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_NAME_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_PEOPLE_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_START_DATE_WINTER;

import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -30,7 +36,8 @@ public void equals() {
assertFalse(DESC_SUMMER.equals(DESC_WINTER));

// different name -> returns false
EditItineraryDescriptor editedSummer = new EditItineraryDescriptorBuilder(DESC_SUMMER).withName(VALID_NAME_WINTER).build();
EditItineraryDescriptor editedSummer =
new EditItineraryDescriptorBuilder(DESC_SUMMER).withName(VALID_NAME_WINTER).build();
assertFalse(DESC_SUMMER.equals(editedSummer));

// different country -> returns false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import static seedu.waddle.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.waddle.testutil.TypicalItineraries.AUTUMN;
import static seedu.waddle.testutil.TypicalItineraries.SPRING;
import static seedu.waddle.testutil.TypicalItineraries.SUMMER;
import static seedu.waddle.testutil.TypicalItineraries.WINTER;
import static seedu.waddle.testutil.TypicalItineraries.getTypicalWaddle;

import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import static seedu.waddle.logic.commands.CommandTestUtil.showItineraryAtIndex;
import static seedu.waddle.testutil.TypicalIndexes.INDEX_FIRST_ITINERARY;
import static seedu.waddle.testutil.TypicalItineraries.getTypicalWaddle;
import static seedu.waddle.testutil.TypicalItineraries.SUMMER;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import seedu.waddle.model.Model;
import seedu.waddle.model.ModelManager;
import seedu.waddle.model.UserPrefs;
import seedu.waddle.model.Waddle;

/**
* Contains integration tests (interaction with the Model) and unit tests for ListCommand.
Expand Down
21 changes: 5 additions & 16 deletions src/test/java/seedu/waddle/logic/parser/AddCommandParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
import static seedu.waddle.logic.commands.CommandTestUtil.PEOPLE_DESC_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.PREAMBLE_NON_EMPTY;
import static seedu.waddle.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE;
import static seedu.waddle.logic.commands.CommandTestUtil.START_DATE_DESC_SUMMER;
import static seedu.waddle.logic.commands.CommandTestUtil.START_DATE_DESC_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_COUNTRY_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_END_DATE_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_NAME_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_START_DATE_WINTER;
import static seedu.waddle.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.waddle.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.waddle.testutil.TypicalItineraries.SUMMER;
import static seedu.waddle.testutil.TypicalItineraries.WINTER;

import org.junit.jupiter.api.Test;
Expand All @@ -46,17 +44,17 @@ public void parse_allFieldsPresent_success() {

// whitespace only preamble
assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_WINTER + COUNTRY_DESC_WINTER
+ START_DATE_DESC_WINTER + END_DATE_DESC_WINTER + PEOPLE_DESC_WINTER,
+ START_DATE_DESC_WINTER + END_DATE_DESC_WINTER + PEOPLE_DESC_WINTER,
new AddCommand(expectedItinerary));

// multiple names - last name accepted
assertParseSuccess(parser, NAME_DESC_SUMMER + NAME_DESC_WINTER + COUNTRY_DESC_WINTER
+ START_DATE_DESC_WINTER + END_DATE_DESC_WINTER + PEOPLE_DESC_WINTER,
+ START_DATE_DESC_WINTER + END_DATE_DESC_WINTER + PEOPLE_DESC_WINTER,
new AddCommand(expectedItinerary));

// multiple country - last country accepted
assertParseSuccess(parser, NAME_DESC_WINTER + COUNTRY_DESC_SUMMER + COUNTRY_DESC_WINTER
+ START_DATE_DESC_WINTER + END_DATE_DESC_WINTER + PEOPLE_DESC_WINTER,
+ START_DATE_DESC_WINTER + END_DATE_DESC_WINTER + PEOPLE_DESC_WINTER,
new AddCommand(expectedItinerary));

// multiple people - last people accepted
Expand All @@ -66,25 +64,16 @@ public void parse_allFieldsPresent_success() {

// multiple end date - last address accepted
assertParseSuccess(parser, NAME_DESC_WINTER + COUNTRY_DESC_WINTER + START_DATE_DESC_WINTER
+ END_DATE_DESC_SUMMER + END_DATE_DESC_WINTER + PEOPLE_DESC_WINTER,
+ END_DATE_DESC_SUMMER + END_DATE_DESC_WINTER + PEOPLE_DESC_WINTER,
new AddCommand(expectedItinerary));

// multiple tags - all accepted
Itinerary expectedItineraryMultipleTags = new ItineraryBuilder(WINTER).build();
assertParseSuccess(parser, NAME_DESC_WINTER + COUNTRY_DESC_WINTER + START_DATE_DESC_WINTER
+ END_DATE_DESC_WINTER + PEOPLE_DESC_SUMMER + PEOPLE_DESC_WINTER,
+ END_DATE_DESC_WINTER + PEOPLE_DESC_SUMMER + PEOPLE_DESC_WINTER,
new AddCommand(expectedItineraryMultipleTags));
}

//TODO: currently no optional fields
// @Test
// public void parse_optionalFieldsMissing_success() {
// // zero tags
// Itinerary expectedItinerary = new ItineraryBuilder(SUMMER).build();
// assertParseSuccess(parser, NAME_DESC_SUMMER + COUNTRY_DESC_SUMMER + START_DATE_DESC_SUMMER
// + END_DATE_DESC_SUMMER, new AddCommand(expectedItinerary));
// }

@Test
public void parse_compulsoryFieldMissing_failure() {
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import static seedu.waddle.logic.parser.CliSyntax.PREFIX_PEOPLE;
import static seedu.waddle.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.waddle.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.waddle.testutil.TypicalIndexes.*;
import static seedu.waddle.testutil.TypicalIndexes.INDEX_FIRST_ITINERARY;
import static seedu.waddle.testutil.TypicalIndexes.INDEX_SECOND_ITINERARY;
import static seedu.waddle.testutil.TypicalIndexes.INDEX_THIRD_ITINERARY;

import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -186,8 +188,8 @@ public void parse_invalidValueFollowedByValidValue_success() {
// no other valid values specified
Index targetIndex = INDEX_FIRST_ITINERARY;
String userInput = targetIndex.getOneBased() + INVALID_COUNTRY_DESC + COUNTRY_DESC_WINTER;
EditItineraryDescriptor descriptor = new EditItineraryDescriptorBuilder().
withCountry(VALID_COUNTRY_WINTER).build();
EditItineraryDescriptor descriptor = new EditItineraryDescriptorBuilder()
.withCountry(VALID_COUNTRY_WINTER).build();
EditCommand expectedCommand = new EditCommand(targetIndex, descriptor);
assertParseSuccess(parser, userInput, expectedCommand);

Expand Down
25 changes: 0 additions & 25 deletions src/test/java/seedu/waddle/logic/parser/ParserUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,29 +164,4 @@ public void parsePeople_validValueWithWhitespace_returnsTrimmedPeople() throws E
People expectedPeople = new People(VALID_PEOPLE);
assertEquals(expectedPeople, ParserUtil.parsePeople(tagWithWhitespace));
}

/* Tags different from People //TODO
@Test
public void parsePeoples_null_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> ParserUtil.parsePeople(null));
}
@Test
public void parsePeople_collectionWithInvalidPeoples_throwsParseException() {
assertThrows(ParseException.class, () -> ParserUtil.parsePeople(Arrays.asList(VALID_TAG_1, INVALID_TAG)));
}
@Test
public void parsePeople_emptyCollection_returnsEmptySet() throws Exception {
assertTrue(ParserUtil.parsePeople(Collections.emptyList()).isEmpty());
}
@Test
public void parsePeoples_collectionWithValidPeoples_returnsPeopleSet() throws Exception {
Set<People> actualPeopleSet = ParserUtil.parsePeoples(Arrays.asList(VALID_TAG_1, VALID_TAG_2));
Set<People> expectedPeopleSet = new HashSet<People>(Arrays.asList(new People(VALID_TAG_1), new People(VALID_TAG_2)));
assertEquals(expectedPeopleSet, actualPeopleSet);
}
*/
}
6 changes: 4 additions & 2 deletions src/test/java/seedu/waddle/logic/parser/WaddleParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public void parseCommand_edit() throws Exception {
Itinerary itinerary = new ItineraryBuilder().build();
EditItineraryDescriptor descriptor = new EditItineraryDescriptorBuilder(itinerary).build();
EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " "
+ INDEX_FIRST_ITINERARY.getOneBased() + " " + ItineraryUtil.getEditItineraryDescriptorDetails(descriptor));
+ INDEX_FIRST_ITINERARY.getOneBased() + " "
+ ItineraryUtil.getEditItineraryDescriptorDetails(descriptor));
assertEquals(new EditCommand(INDEX_FIRST_ITINERARY, descriptor), command);
}

Expand Down Expand Up @@ -96,6 +97,7 @@ public void parseCommand_unrecognisedInput_throwsParseException() {

@Test
public void parseCommand_unknownCommand_throwsParseException() {
assertThrows(ParseException.class, MESSAGE_UNKNOWN_COMMAND, () -> parser.parseCommand("unknownCommand"));
assertThrows(ParseException.class, MESSAGE_UNKNOWN_COMMAND, ()
-> parser.parseCommand("unknownCommand"));
}
}
6 changes: 2 additions & 4 deletions src/test/java/seedu/waddle/model/ModelManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
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.waddle.model.Model.PREDICATE_SHOW_ALL_PERSONS;
import static seedu.waddle.model.Model.PREDICATE_SHOW_ALL_ITINERARIES;
import static seedu.waddle.testutil.Assert.assertThrows;
import static seedu.waddle.testutil.TypicalItineraries.AUTUMN;
import static seedu.waddle.testutil.TypicalItineraries.SPRING;
import static seedu.waddle.testutil.TypicalItineraries.SUMMER;
import static seedu.waddle.testutil.TypicalItineraries.WINTER;

import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -124,7 +122,7 @@ public void equals() {
assertFalse(modelManager.equals(new ModelManager(waddle, userPrefs)));

// resets modelManager to initial state for upcoming tests
// modelManager.updateFilteredItineraryList(PREDICATE_SHOW_ALL_PERSONS);
modelManager.updateFilteredItineraryList(PREDICATE_SHOW_ALL_ITINERARIES);

// different userPrefs -> returns false
UserPrefs differentUserPrefs = new UserPrefs();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/seedu/waddle/model/WaddleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class WaddleTest {

@Test
public void constructor() {
assertEquals(Collections.emptyList(), waddle.getItineraryList());}
assertEquals(Collections.emptyList(), waddle.getItineraryList());
}

@Test
public void resetData_null_throwsNullPointerException() {
Expand Down
9 changes: 4 additions & 5 deletions src/test/java/seedu/waddle/model/itinerary/ItineraryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_COUNTRY_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_START_DATE_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_NAME_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_END_DATE_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_NAME_WINTER;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_PEOPLE_WINTER;
import static seedu.waddle.testutil.Assert.assertThrows;
import static seedu.waddle.logic.commands.CommandTestUtil.VALID_START_DATE_WINTER;
import static seedu.waddle.testutil.TypicalItineraries.SUMMER;
import static seedu.waddle.testutil.TypicalItineraries.WINTER;

import org.junit.jupiter.api.Test;

import seedu.waddle.model.item.Item;
import seedu.waddle.testutil.ItineraryBuilder;

public class ItineraryTest {
Expand All @@ -27,7 +25,8 @@ public void isSameItinerary() {
assertFalse(SUMMER.isSameItinerary(null));

// same name, all other attributes different -> returns true
Itinerary editedSummer = new ItineraryBuilder(SUMMER).withCountry(VALID_COUNTRY_WINTER).withStartDate(VALID_START_DATE_WINTER)
Itinerary editedSummer = new ItineraryBuilder(SUMMER)
.withCountry(VALID_COUNTRY_WINTER).withStartDate(VALID_START_DATE_WINTER)
.withEndDate(VALID_END_DATE_WINTER).withPeople(VALID_PEOPLE_WINTER).build();
assertTrue(SUMMER.isSameItinerary(editedSummer));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void equals() {
@Test
public void test_nameContainsKeywords_returnsTrue() {
// One keyword
NameContainsKeywordsPredicate predicate = new NameContainsKeywordsPredicate(Collections.singletonList("Summer"));
NameContainsKeywordsPredicate predicate =
new NameContainsKeywordsPredicate(Collections.singletonList("Summer"));
assertTrue(predicate.test(new ItineraryBuilder().withName("Summer Winter").build()));

// Multiple keywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ public void setItinerary_list_replacesOwnListWithProvidedList() {
@Test
public void setItinerary_listWithDuplicateItinerary_throwsDuplicateItineraryException() {
List<Itinerary> listWithDuplicateItinerary = Arrays.asList(SUMMER, SUMMER);
assertThrows(DuplicateItineraryException.class,
() -> uniqueItineraryList.setItineraries(listWithDuplicateItinerary));
assertThrows(DuplicateItineraryException.class, ()
-> uniqueItineraryList.setItineraries(listWithDuplicateItinerary));
}

@Test
Expand Down
Loading

0 comments on commit cb0b828

Please sign in to comment.