@@ -83,33 +83,45 @@ void setupEach() {
83
83
84
84
RestClient .Builder createBuilder () {
85
85
return RestClient .builder ()
86
+ .baseUrl ("https://example.com/base" )
86
87
.messageConverters (converters -> converters .add (0 , this .converter ))
87
88
.requestFactory (this .requestFactory )
88
89
.observationRegistry (this .observationRegistry );
89
90
}
90
91
91
92
@ Test
92
93
void shouldContributeTemplateWhenUriVariables () throws Exception {
93
- mockSentRequest (GET , "https://example.com/hotels/42/bookings/21" );
94
+ mockSentRequest (GET , "https://example.com/base/ hotels/42/bookings/21" );
94
95
mockResponseStatus (HttpStatus .OK );
95
96
96
- client .get ().uri ("https://example.com /hotels/{hotel}/bookings/{booking}" , "42" , "21" )
97
+ client .get ().uri ("/hotels/{hotel}/bookings/{booking}" , "42" , "21" )
97
98
.retrieve ().toBodilessEntity ();
98
99
99
- assertThatHttpObservation ().hasLowCardinalityKeyValue ("uri" , "/hotels/{hotel}/bookings/{booking}" );
100
+ assertThatHttpObservation ().hasLowCardinalityKeyValue ("uri" , "/base/ hotels/{hotel}/bookings/{booking}" );
100
101
}
101
102
102
103
@ Test
103
104
void shouldContributeTemplateWhenMap () throws Exception {
104
- mockSentRequest (GET , "https://example.com/hotels/42/bookings/21" );
105
+ mockSentRequest (GET , "https://example.com/base/ hotels/42/bookings/21" );
105
106
mockResponseStatus (HttpStatus .OK );
106
107
107
108
Map <String , String > vars = Map .of ("hotel" , "42" , "booking" , "21" );
108
109
109
- client .get ().uri ("https://example.com /hotels/{hotel}/bookings/{booking}" , vars )
110
+ client .get ().uri ("/hotels/{hotel}/bookings/{booking}" , vars )
110
111
.retrieve ().toBodilessEntity ();
111
112
112
- assertThatHttpObservation ().hasLowCardinalityKeyValue ("uri" , "/hotels/{hotel}/bookings/{booking}" );
113
+ assertThatHttpObservation ().hasLowCardinalityKeyValue ("uri" , "/base/hotels/{hotel}/bookings/{booking}" );
114
+ }
115
+
116
+ @ Test
117
+ void shouldContributeTemplateWhenFunction () throws Exception {
118
+ mockSentRequest (GET , "https://example.com/base/hotels/42/bookings/21" );
119
+ mockResponseStatus (HttpStatus .OK );
120
+
121
+ client .get ().uri ("/hotels/{hotel}/bookings/{booking}" , builder -> builder .build ("42" , "21" ))
122
+ .retrieve ().toBodilessEntity ();
123
+
124
+ assertThatHttpObservation ().hasLowCardinalityKeyValue ("uri" , "/base/hotels/{hotel}/bookings/{booking}" );
113
125
}
114
126
115
127
@ Test
0 commit comments