File tree Expand file tree Collapse file tree
main/java/com/meilisearch/sdk/http
test/java/com/meilisearch/sdk/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ public URLBuilder(String rootRoute) {
2121 }
2222
2323 public URLBuilder addSubroute (String route ) {
24+ if (route == null || route .isEmpty ()) {
25+ throw new IllegalArgumentException ("route segment must not be null or empty" );
26+ }
2427 routes .append ("/" );
2528 routes .append (route );
2629 return this ;
Original file line number Diff line number Diff line change 55import static org .hamcrest .Matchers .is ;
66import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
77import static org .junit .jupiter .api .Assertions .assertEquals ;
8+ import static org .junit .jupiter .api .Assertions .assertThrows ;
89
910import java .text .SimpleDateFormat ;
1011import java .util .Date ;
@@ -32,6 +33,14 @@ void addSubrouteWithMultipleRoutes() {
3233 assertThat (classToTest .getRoutes ().toString (), is (equalTo ("/route1/route2/route3/route4" )));
3334 }
3435
36+ @ Test
37+ void addSubrouteWithNullOrEmptyRoute () {
38+ assertThat (
39+ assertThrows (IllegalArgumentException .class , () -> classToTest .addSubroute ("" ))
40+ .getMessage (),
41+ is (equalTo ("route segment must not be null or empty" )));
42+ }
43+
3544 @ Test
3645 void addParameterStringInt () {
3746 classToTest .addParameter ("parameter1" , 1 );
You can’t perform that action at this time.
0 commit comments