File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
src/test/java/dev/resms/util Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 5858
5959 <!-- Dependency versions -->
6060 <httpcore5 .version>5.3.4</httpcore5 .version>
61+ <junit .version>5.13.0</junit .version>
6162 <lombok .version>1.18.38</lombok .version>
6263 <moshi .version>1.15.2</moshi .version>
6364 </properties >
7980 <version >${lombok.version} </version >
8081 <scope >provided</scope >
8182 </dependency >
82-
83+ <dependency >
84+ <groupId >org.junit.jupiter</groupId >
85+ <artifactId >junit-jupiter-engine</artifactId >
86+ <version >${junit.version} </version >
87+ <scope >test</scope >
88+ </dependency >
8389 </dependencies >
8490
8591 <build >
Original file line number Diff line number Diff line change 1+ package dev .resms .util ;
2+
3+ import dev .resms .exception .ReSMSException ;
4+ import org .junit .jupiter .api .Test ;
5+
6+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
7+ import static org .junit .jupiter .api .Assertions .assertEquals ;
8+ import static org .junit .jupiter .api .Assertions .assertThrows ;
9+
10+ class ValidationUtilTest {
11+ @ Test
12+ void testValidatePhoneNumber_validNumber () {
13+ assertDoesNotThrow (() -> ValidationUtil .validatePhoneNumber ("+1234567890" ));
14+ }
15+
16+ @ Test
17+ void testValidatePhoneNumber_emptyNumber () {
18+ ReSMSException ex = assertThrows (ReSMSException .class , () -> ValidationUtil .validatePhoneNumber (" " ));
19+ assertEquals ("Phone number is required" , ex .getMessage ());
20+ }
21+
22+ @ Test
23+ void testValidatePhoneNumber_invalidFormat () {
24+ ReSMSException ex = assertThrows (ReSMSException .class ,
25+ () -> ValidationUtil .validatePhoneNumber ("123abc" ));
26+ assertEquals ("Invalid phone number format" , ex .getMessage ());
27+ }
28+
29+ @ Test
30+ void testValidateMessage_validMessage () {
31+ assertDoesNotThrow (() -> ValidationUtil .validateMessage ("Hello!" ));
32+ }
33+
34+ @ Test
35+ void testValidateMessage_empty () {
36+ ReSMSException ex = assertThrows (ReSMSException .class ,
37+ () -> ValidationUtil .validateMessage (" " ));
38+ assertEquals ("Message cannot be empty" , ex .getMessage ());
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments