From 654a5e4bd2866cdb847b5c16067d30724f447d96 Mon Sep 17 00:00:00 2001 From: Photogrammer Date: Fri, 16 Aug 2024 10:33:08 +0900 Subject: [PATCH] =?UTF-8?q?test:=20TimeSlotvalueOfEnumString=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/enums/TimeSlotTest.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 server/src/test/java/com/talkka/server/common/enums/TimeSlotTest.java diff --git a/server/src/test/java/com/talkka/server/common/enums/TimeSlotTest.java b/server/src/test/java/com/talkka/server/common/enums/TimeSlotTest.java new file mode 100644 index 00000000..75b42868 --- /dev/null +++ b/server/src/test/java/com/talkka/server/common/enums/TimeSlotTest.java @@ -0,0 +1,40 @@ +package com.talkka.server.common.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import com.talkka.server.common.exception.enums.InvalidTimeSlotEnumException; + +class TimeSlotTest { + + @ParameterizedTest + @ValueSource(strings = {"T_00_00", "T_00_30", "T_01_00", "T_01_30", "T_02_00", "T_02_30", "T_03_00", "T_03_30", + "T_04_00", "T_04_30", "T_05_00", "T_05_30", "T_06_00", "T_06_30", "T_07_00", "T_07_30", "T_08_00", "T_08_30", + "T_09_00", "T_09_30", "T_10_00", "T_10_30", "T_11_00", "T_11_30", "T_12_00", "T_12_30", "T_13_00", "T_13_30", + "T_14_00", "T_14_30", "T_15_00", "T_15_30", "T_16_00", "T_16_30", "T_17_00", "T_17_30", "T_18_00", "T_18_30", + "T_19_00", "T_19_30", "T_20_00", "T_20_30", "T_21_00", "T_21_30", "T_22_00", "T_22_30", "T_23_00", "T_23_30"}) + @DisplayName("ENUM 문자열과 일치하면 ENUM을 생성한다.") + void valueOfEnumString(String timeSlot) { + // given + // when + TimeSlot actual = TimeSlot.valueOf(timeSlot); + // then + assertNotNull(actual); + } + + @ParameterizedTest + @ValueSource(strings = { + "T_00_01", "T_00_31", "T_01_01", "T_01_31", "T_02_01", "T_02_31", "T_03_01", "T_03_31", + "test", "00:00", "00:30", "01:00", "01:30", "02:00", "02:30", "03:00", "03:30", + }) + @DisplayName("ENUM 문자열과 일치하지 않으면 예외를 발생시킨다.") + void valueOfEnumStringNotMatch(String timeSlot) { + // given + // when + // then + assertThrows(InvalidTimeSlotEnumException.class, () -> TimeSlot.valueOfEnumString(timeSlot)); + } +} \ No newline at end of file