From 9d5a01364890ed2cd8116eba5825291308edab61 Mon Sep 17 00:00:00 2001 From: RB9823 Date: Sun, 12 Nov 2023 00:09:57 +0800 Subject: [PATCH] Update Tag References --- .../address/logic/parser/ParserUtil.java | 18 +-------- .../address/logic/parser/ParserUtilTest.java | 38 ++----------------- 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index ff0c1227a36..5f60a85cd26 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -2,10 +2,6 @@ import static java.util.Objects.requireNonNull; -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; import seedu.address.logic.parser.exceptions.ParseException; @@ -148,7 +144,7 @@ public static Remark parseRemark(String remark) throws ParseException { * * @throws ParseException if the given {@code tag} is invalid. */ - public static RoomTypeTag parseTag(String tag) throws ParseException { + public static RoomTypeTag parseRoomTypeTag(String tag) throws ParseException { requireNonNull(tag); String trimmedTag = tag.trim(); if (!RoomTypeTag.isValidRoomTypeTagName(trimmedTag)) { @@ -156,16 +152,4 @@ public static RoomTypeTag parseTag(String tag) throws ParseException { } return new RoomTypeTag(trimmedTag); } - - /** - * Parses {@code Collection tags} into a {@code Set}. - */ - public static Set parseTags(Collection tags) throws ParseException { - requireNonNull(tags); - final Set tagSet = new HashSet<>(); - for (String tagName : tags) { - tagSet.add(parseTag(tagName)); - } - return tagSet; - } } diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index ce924638077..8b73df6e137 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -1,16 +1,10 @@ package seedu.address.logic.parser; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.parser.ParserUtil.MESSAGE_INVALID_INDEX; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; @@ -171,48 +165,24 @@ public void parseEmail_validValueWithWhitespace_returnsTrimmedEmail() throws Exc @Test public void parseTag_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseTag(null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseRoomTypeTag(null)); } @Test public void parseTag_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseTag(INVALID_TAG)); + assertThrows(ParseException.class, () -> ParserUtil.parseRoomTypeTag(INVALID_TAG)); } @Test public void parseTag_validValueWithoutWhitespace_returnsTag() throws Exception { RoomTypeTag expectedTag = new RoomTypeTag(VALID_TAG_1); - assertEquals(expectedTag, ParserUtil.parseTag(VALID_TAG_1)); + assertEquals(expectedTag, ParserUtil.parseRoomTypeTag(VALID_TAG_1)); } @Test public void parseTag_validValueWithWhitespace_returnsTrimmedTag() throws Exception { String tagWithWhitespace = WHITESPACE + VALID_TAG_1 + WHITESPACE; RoomTypeTag expectedTag = new RoomTypeTag(VALID_TAG_1); - assertEquals(expectedTag, ParserUtil.parseTag(tagWithWhitespace)); - } - - @Test - public void parseTags_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseTags(null)); - } - - @Test - public void parseTags_collectionWithInvalidTags_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, INVALID_TAG))); - } - - @Test - public void parseTags_emptyCollection_returnsEmptySet() throws Exception { - assertTrue(ParserUtil.parseTags(Collections.emptyList()).isEmpty()); - } - - @Test - public void parseTags_collectionWithValidTags_returnsTagSet() throws Exception { - Set actualTagSet = ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, VALID_TAG_2)); - Set expectedTagSet = new HashSet(Arrays.asList(new RoomTypeTag(VALID_TAG_1), - new RoomTypeTag(VALID_TAG_2))); - - assertEquals(expectedTagSet, actualTagSet); + assertEquals(expectedTag, ParserUtil.parseRoomTypeTag(tagWithWhitespace)); } }