Skip to content

Commit

Permalink
fix checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kappaccinoh committed Mar 20, 2024
1 parent a00c4f8 commit 091ae99
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 43 deletions.
1 change: 0 additions & 1 deletion src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import seedu.address.logic.parser.Prefix;
import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
import seedu.address.model.person.Person;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import seedu.address.model.Model;
import seedu.address.model.appointment.AppointmentContainsPatientPredicate;


/**
* Represents a command for querying appointments for a specific patient.
* The command searches for appointments of patients whose NRICs/names contain any of the specified keywords
* (case-insensitive) and displays them as a list with index numbers.
*/
public class QueryPatientAppointmentCommand extends Command {
public static final String COMMAND_WORD = "appforpatient";

Expand All @@ -19,14 +23,17 @@ public class QueryPatientAppointmentCommand extends Command {

private final AppointmentContainsPatientPredicate predicate;

public QueryPatientAppointmentCommand(AppointmentContainsPatientPredicate predicate) { this.predicate = predicate; }
public QueryPatientAppointmentCommand(AppointmentContainsPatientPredicate predicate) {
this.predicate = predicate;
}

@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredAppointmentList(predicate);
return new CommandResult(
String.format(Messages.MESSAGE_APPOINTMENTS_LISTED_OVERVIEW, model.getFilteredAppointmentList().size()));
String.format(Messages.MESSAGE_APPOINTMENTS_LISTED_OVERVIEW,
model.getFilteredAppointmentList().size()));
}

@Override
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@
import java.util.regex.Pattern;

import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.*;
import seedu.address.logic.commands.AddAppointmentCommand;
import seedu.address.logic.commands.AddDoctorCommand;
import seedu.address.logic.commands.AddPatientCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.DeleteAppointmentCommand;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.ExitCommand;
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.QueryDoctorCommand;
import seedu.address.logic.commands.QueryPatientAppointmentCommand;
import seedu.address.logic.commands.QueryPatientCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Arrays;

import seedu.address.logic.commands.QueryPatientAppointmentCommand;
import seedu.address.logic.commands.QueryPatientCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.appointment.AppointmentContainsPatientPredicate;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package seedu.address.model.appointment;

import seedu.address.commons.util.StringUtil;
import seedu.address.commons.util.ToStringBuilder;

import java.util.List;
import java.util.function.Predicate;

import seedu.address.commons.util.StringUtil;
import seedu.address.commons.util.ToStringBuilder;

/**
* Represents a Predicate used to test if an Appointment contains specified patient keywords.
*/
public class AppointmentContainsPatientPredicate implements Predicate<Appointment> {
private final List<String> keywords;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package seedu.address.logic.commands;

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.Messages.MESSAGE_APPOINTMENTS_LISTED_OVERVIEW;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalAppointments.APPOINTMENT_4;
import static seedu.address.testutil.TypicalAppointments.getTypicalAddressBook;

import java.util.Arrays;
import java.util.Collections;

import org.junit.jupiter.api.Test;

import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.model.appointment.AppointmentContainsPatientPredicate;
import seedu.address.model.person.NameContainsKeywordsPredicate;

import java.util.Arrays;
import java.util.Collections;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static seedu.address.logic.Messages.MESSAGE_APPOINTMENTS_LISTED_OVERVIEW;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalAppointments.*;

public class QueryPatientAppointmentCommandTest {
private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs());
Expand Down Expand Up @@ -62,13 +65,7 @@ public void execute_singleKeyword_singleAppointmentFound() {
String expectedMessage = String.format(MESSAGE_APPOINTMENTS_LISTED_OVERVIEW, 1);
AppointmentContainsPatientPredicate predicate = preparePredicate("S8734985A");
QueryPatientAppointmentCommand command = new QueryPatientAppointmentCommand(predicate);

System.out.println(expectedModel.getFilteredAppointmentList());

expectedModel.updateFilteredAppointmentList(predicate);

System.out.println(expectedModel.getFilteredAppointmentList());

assertCommandSuccess(command, model, expectedMessage, expectedModel);
assertEquals(Arrays.asList(APPOINTMENT_4), model.getFilteredAppointmentList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@

import org.junit.jupiter.api.Test;

import seedu.address.logic.commands.*;
import seedu.address.logic.commands.AddAppointmentCommand;
import seedu.address.logic.commands.AddDoctorCommand;
import seedu.address.logic.commands.AddPatientCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.DeleteAppointmentCommand;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.EditCommand.EditPersonDescriptor;
import seedu.address.logic.commands.ExitCommand;
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.QueryDoctorCommand;
import seedu.address.logic.commands.QueryPatientAppointmentCommand;
import seedu.address.logic.commands.QueryPatientCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.appointment.Appointment;
import seedu.address.model.appointment.AppointmentContainsPatientPredicate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package seedu.address.logic.parser;

import org.junit.jupiter.api.Test;
import seedu.address.logic.commands.QueryPatientAppointmentCommand;
import seedu.address.logic.commands.QueryPatientCommand;
import seedu.address.model.appointment.AppointmentContainsPatientPredicate;
import seedu.address.model.person.PatientNameContainsKeywordsPredicate;

import java.util.Arrays;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;

import java.util.Arrays;

import org.junit.jupiter.api.Test;

import seedu.address.logic.commands.QueryPatientAppointmentCommand;
import seedu.address.model.appointment.AppointmentContainsPatientPredicate;

public class QueryPatientAppointmentCommandParserTest {
private QueryPatientAppointmentCommandParser parser = new QueryPatientAppointmentCommandParser();

@Test
public void parse_emptyArg_throwsParseException() {
assertParseFailure(parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT,
QueryPatientCommand.MESSAGE_USAGE));
QueryPatientAppointmentCommand.MESSAGE_USAGE));
}

@Test
public void parse_validArgs_returnsQueryCommand() {
// no leading and trailing whitespaces
QueryPatientAppointmentCommand expectedQueryCommand =
new QueryPatientAppointmentCommand(new AppointmentContainsPatientPredicate(Arrays.asList("Alice", "Bob")));
new QueryPatientAppointmentCommand(new AppointmentContainsPatientPredicate(
Arrays.asList("Alice", "Bob")));
assertParseSuccess(parser, "Alice Bob", expectedQueryCommand);

// multiple whitespaces between keywords
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package seedu.address.model.appointment;

import org.junit.jupiter.api.Test;
import seedu.address.model.person.*;
import seedu.address.testutil.AppointmentBuilder;
import seedu.address.testutil.PatientBuilder;
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.testutil.TypicalAppointments.APPOINTMENT_1;
import static seedu.address.testutil.TypicalAppointments.APPOINTMENT_4;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;
import static seedu.address.testutil.TypicalAppointments.*;
import org.junit.jupiter.api.Test;

public class AppointmentContainsPatientPredicateTest {
@Test
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/seedu/address/testutil/TypicalAppointments.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package seedu.address.testutil;

import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.BENSON;
import static seedu.address.testutil.TypicalPersons.BROWN;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -9,8 +13,6 @@
import seedu.address.model.person.Doctor;
import seedu.address.model.person.Patient;

import static seedu.address.testutil.TypicalPersons.*;

/**
* A utility class containing a list of {@code Appointments } objects to be used in tests.
*/
Expand Down

0 comments on commit 091ae99

Please sign in to comment.