@@ -56,18 +56,25 @@ void testNoServiceBindingLoadingThrows() {
5656 assertThatThrownBy (resolver ::getDestination ).isSameAs (exception );
5757 }
5858
59+ private record DestinationTestCase (String givenBasePath , String expectedBasePath ) {}
60+
5961 @ Test
6062 void testFromCustomBaseDestination () {
61- var destination = DefaultHttpDestination .builder ("https://api.ai.sap" ).build ();
62- assertThat (DestinationResolver .fromCustomBaseDestination (destination ).getUri ())
63- .hasToString ("https://api.ai.sap/v2/" );
64-
65- destination = DefaultHttpDestination .builder ("https://api.ai.sap/" ).build ();
66- assertThat (DestinationResolver .fromCustomBaseDestination (destination ).getUri ())
67- .hasToString ("https://api.ai.sap/v2/" );
68-
69- destination = DefaultHttpDestination .builder ("https://api.ai.sap/foo" ).build ();
70- assertThat (DestinationResolver .fromCustomBaseDestination (destination ).getUri ())
71- .hasToString ("https://api.ai.sap/foo" );
63+ var testCases =
64+ new DestinationTestCase [] {
65+ new DestinationTestCase ("" , "/v2/" ),
66+ new DestinationTestCase ("/" , "/v2/" ),
67+ new DestinationTestCase ("/foo" , "/foo/" ),
68+ new DestinationTestCase ("/foo/" , "/foo/" )
69+ };
70+ for (var testCase : testCases ) {
71+ var url = "https://api.ai.sap" + testCase .givenBasePath ;
72+ var destination = DefaultHttpDestination .builder (url ).build ();
73+ assertThat (DestinationResolver .fromCustomBaseDestination (destination ).getUri ().getPath ())
74+ .describedAs (
75+ "Expecting given base path %s to resolve to %s" ,
76+ testCase .givenBasePath , testCase .expectedBasePath )
77+ .hasToString (testCase .expectedBasePath );
78+ }
7279 }
7380}
0 commit comments