Skip to content

Commit

Permalink
Merge pull request #274 from Siddardar/remove-Specific-Subject-Message
Browse files Browse the repository at this point in the history
Remove Level specific error
  • Loading branch information
EthanLoww authored Nov 11, 2024
2 parents 4766486 + 25c6f6a commit cb3a1e5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 38 deletions.
14 changes: 3 additions & 11 deletions src/main/java/seedu/address/logic/parser/TagCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import seedu.address.logic.commands.UpdateCommand.UpdateStudentDescriptor;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.student.Name;
import seedu.address.model.student.Subject;

/**
* Parses input arguments and creates a new TagCommand object
Expand Down Expand Up @@ -51,16 +50,9 @@ public TagCommand parse(String args) throws ParseException {
}

if (argMultiMap.getValue(PREFIX_SUBJECT).isPresent()) {
try {
editStudentTags.setSubjects(
ParserUtil.parseSubjects(
argMultiMap.getAllValues(PREFIX_SUBJECT)));
} catch (ParseException e) {
if (editStudentTags.getLevel().isPresent()) {
throw new ParseException(Subject.getValidSubjectMessage(editStudentTags.getLevel().get()));
}
throw new ParseException(e.getMessage());
}
editStudentTags.setSubjects(
ParserUtil.parseSubjects(
argMultiMap.getAllValues(PREFIX_SUBJECT)));
}

if (argMultiMap.getValue(PREFIX_SUBJECT).isEmpty()) {
Expand Down
16 changes: 2 additions & 14 deletions src/main/java/seedu/address/logic/parser/UpdateCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,9 @@ public UpdateCommand parse(String args) throws ParseException {
if (argMultimap.getValue(PREFIX_LEVEL).isPresent()) {
updateStudentDescriptor.setLevel(ParserUtil.parseLevel(argMultimap.getValue(PREFIX_LEVEL).get()));
}
if (argMultimap.getValue(PREFIX_SUBJECT).isPresent()) {
try {
updateStudentDescriptor.setSubjects(
ParserUtil.parseSubjects(
argMultimap.getAllValues(PREFIX_SUBJECT)));
} catch (ParseException e) {
if (updateStudentDescriptor.getLevel().isPresent()) {
throw new ParseException(Subject.getValidSubjectMessage(updateStudentDescriptor.getLevel().get()));
}

parseSubjectsForUpdate(argMultimap.getAllValues(PREFIX_SUBJECT))
.ifPresent(updateStudentDescriptor::setSubjects);
}
}

parseSubjectsForUpdate(argMultimap.getAllValues(PREFIX_SUBJECT))
.ifPresent(updateStudentDescriptor::setSubjects);
parseLessonTimesForUpdate(argMultimap.getAllValues(PREFIX_LESSON_TIME))
.ifPresent(updateStudentDescriptor::setLessonTimes);
if (!updateStudentDescriptor.isAnyFieldUpdated()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ public void parse_invalidValue_failure() {
assertParseFailure(parser, NAME_DESC_BOB + INVALID_LEVEL_DESC, Level.MESSAGE_CONSTRAINTS);
}

@Test
public void parse_validLevelInvalidSubject_failure() {
String command = " n/John Doe l/S2 NA s/Chem";

assertParseFailure(parser, command, Subject.getValidSubjectMessage(new Level("S2 NA")));
}

@Test
public void parse_invalidLevelInvalidSubject_failure() {
String command = " n/John Doe s/Chem";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,6 @@ public void parse_resetLessonTimes_success() {

assertParseSuccess(parser, userInput, expectedCommand);
}
@Test
public void parse_validLevelInvalidSubject_failure() {
String command = " John Doe l/S2 NA s/Chem";

assertParseFailure(parser, command, Subject.getValidSubjectMessage(new Level("S2 NA")));
}

@Test
public void parse_invalidLevelInvalidSubject_failure() {
Expand Down

0 comments on commit cb3a1e5

Please sign in to comment.