1+ /*
2+ * Copyright 2024-2024 the original author or authors.
3+ */
4+
5+ package io .modelcontextprotocol .util ;
6+
7+ import org .junit .jupiter .api .Test ;
8+
9+ import java .util .List ;
10+
11+ import static org .junit .jupiter .api .Assertions .*;
12+
13+ class AssertTests {
14+
15+ @ Test
16+ void testCollectionNotEmpty () {
17+ IllegalArgumentException e1 = assertThrows (IllegalArgumentException .class ,
18+ () -> Assert .notEmpty (null , "collection is null" ));
19+ assertEquals ("collection is null" , e1 .getMessage ());
20+
21+ IllegalArgumentException e2 = assertThrows (IllegalArgumentException .class ,
22+ () -> Assert .notEmpty (List .of (), "collection is empty" ));
23+ assertEquals ("collection is empty" , e2 .getMessage ());
24+
25+ assertDoesNotThrow (() -> Assert .notEmpty (List .of ("test" ), "collection is not empty" ));
26+ }
27+
28+ @ Test
29+ void testObjectNotNull () {
30+ IllegalArgumentException e = assertThrows (IllegalArgumentException .class ,
31+ () -> Assert .notNull (null , "object is null" ));
32+ assertEquals ("object is null" , e .getMessage ());
33+
34+ assertDoesNotThrow (() -> Assert .notNull ("test" , "object is not null" ));
35+ }
36+
37+ @ Test
38+ void testStringHasText () {
39+ IllegalArgumentException e = assertThrows (IllegalArgumentException .class ,
40+ () -> Assert .hasText (null , "string is null" ));
41+ assertEquals ("string is null" , e .getMessage ());
42+
43+ assertDoesNotThrow (() -> Assert .hasText ("test" , "string is not empty" ));
44+ }
45+
46+ }
0 commit comments