210 210 | let params = crate::config::endpoint::Params::builder().build().map_err(|err| {
|
211 211 | ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
|
212 212 | })?;
|
213 213 | cfg.interceptor_state()
|
214 214 | .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
|
215 215 | ::std::result::Result::Ok(())
|
216 216 | }
|
217 217 | }
|
218 218 | #[allow(unreachable_code, unused_variables)]
|
219 219 | #[cfg(test)]
|
220 - | mod greeting_with_errors_request_test {
|
220 + | mod greeting_with_errors_test {
|
221 + |
|
221 222 | /// Ensures that operations with errors successfully know how to deserialize the successful response
|
222 223 | /// Test ID: QueryGreetingWithErrors
|
223 224 | #[::tokio::test]
|
224 - | #[allow(unused_mut)]
|
225 + | #[::tracing_test::traced_test]
|
225 226 | async fn query_greeting_with_errors_response() {
|
226 227 | let expected_output = crate::operation::greeting_with_errors::GreetingWithErrorsOutput::builder()
|
227 228 | .set_greeting(::std::option::Option::Some("Hello".to_owned()))
|
228 229 | .build();
|
229 230 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http::response::Builder::new()
|
230 231 | .header("Content-Type", "text/xml")
|
231 232 | .status(200)
|
232 233 | .body(::aws_smithy_types::body::SdkBody::from("<GreetingWithErrorsResponse xmlns=\"https://example.com/\">\n <GreetingWithErrorsResult>\n <greeting>Hello</greeting>\n </GreetingWithErrorsResult>\n</GreetingWithErrorsResponse>\n"))
|
233 234 | .unwrap()
|
234 235 | ).unwrap();
|
235 236 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
236 237 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
237 238 |
|
238 239 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
239 240 | let config = op.config().expect("the operation has config");
|
240 241 | let de = config
|
241 242 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
242 243 | .expect("the config must have a deserializer");
|
243 244 |
|
244 245 | let parsed = de.deserialize_streaming(&mut http_response);
|
245 246 | let parsed = parsed.unwrap_or_else(|| {
|
246 247 | let http_response =
|
247 248 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
248 249 | de.deserialize_nonstreaming(&http_response)
|
249 250 | });
|
250 251 | let parsed = parsed
|
251 252 | .expect("should be successful response")
|
252 253 | .downcast::<crate::operation::greeting_with_errors::GreetingWithErrorsOutput>()
|
253 254 | .unwrap();
|
254 255 | ::pretty_assertions::assert_eq!(parsed.greeting, expected_output.greeting, "Unexpected value for `greeting`");
|
255 256 | }
|
256 257 | /// Parses simple XML errors
|
257 258 | /// Test ID: QueryInvalidGreetingError
|
258 259 | #[::tokio::test]
|
259 - | #[allow(unused_mut)]
|
260 + | #[::tracing_test::traced_test]
|
260 261 | async fn query_invalid_greeting_error_response() {
|
261 262 | let expected_output = crate::types::error::InvalidGreeting::builder()
|
262 263 | .set_message(::std::option::Option::Some("Hi".to_owned()))
|
263 264 | .build();
|
264 265 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http::response::Builder::new()
|
265 266 | .header("Content-Type", "text/xml")
|
266 267 | .status(400)
|
267 268 | .body(::aws_smithy_types::body::SdkBody::from("<ErrorResponse>\n <Error>\n <Type>Sender</Type>\n <Code>InvalidGreeting</Code>\n <Message>Hi</Message>\n </Error>\n <RequestId>foo-id</RequestId>\n</ErrorResponse>\n"))
|
268 269 | .unwrap()
|
269 270 | ).unwrap();
|
270 271 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
271 272 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
272 273 |
|
273 274 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
274 275 | let config = op.config().expect("the operation has config");
|
275 276 | let de = config
|
276 277 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
277 278 | .expect("the config must have a deserializer");
|
278 279 |
|
279 280 | let parsed = de.deserialize_streaming(&mut http_response);
|
280 281 | let parsed = parsed.unwrap_or_else(|| {
|
281 282 | let http_response =
|
282 283 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
283 284 | de.deserialize_nonstreaming(&http_response)
|
284 285 | });
|
285 286 | let parsed = parsed.expect_err("should be error response");
|
286 287 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
287 288 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
288 289 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::InvalidGreeting(parsed) = parsed {
|
289 290 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
290 291 | } else {
|
291 292 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
292 293 | }
|
293 294 | }
|
294 295 | /// Test ID: QueryComplexError
|
295 296 | #[::tokio::test]
|
296 - | #[allow(unused_mut)]
|
297 + | #[::tracing_test::traced_test]
|
297 298 | async fn query_complex_error_response() {
|
298 299 | let expected_output = crate::types::error::ComplexError::builder()
|
299 300 | .set_top_level(::std::option::Option::Some("Top level".to_owned()))
|
300 301 | .set_nested(::std::option::Option::Some(
|
301 302 | crate::types::ComplexNestedErrorData::builder()
|
302 303 | .set_foo(::std::option::Option::Some("bar".to_owned()))
|
303 304 | .build(),
|
304 305 | ))
|
305 306 | .build();
|
306 307 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http::response::Builder::new()
|
307 308 | .header("Content-Type", "text/xml")
|
308 309 | .status(400)
|
309 310 | .body(::aws_smithy_types::body::SdkBody::from("<ErrorResponse>\n <Error>\n <Type>Sender</Type>\n <Code>ComplexError</Code>\n <TopLevel>Top level</TopLevel>\n <Nested>\n <Foo>bar</Foo>\n </Nested>\n </Error>\n <RequestId>foo-id</RequestId>\n</ErrorResponse>\n"))
|
310 311 | .unwrap()
|
311 312 | ).unwrap();
|
312 313 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
313 314 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
314 315 |
|
315 316 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
316 317 | let config = op.config().expect("the operation has config");
|
317 318 | let de = config
|
318 319 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
319 320 | .expect("the config must have a deserializer");
|
320 321 |
|
321 322 | let parsed = de.deserialize_streaming(&mut http_response);
|
322 323 | let parsed = parsed.unwrap_or_else(|| {
|
323 324 | let http_response =
|
324 325 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
325 326 | de.deserialize_nonstreaming(&http_response)
|
326 327 | });
|
327 328 | let parsed = parsed.expect_err("should be error response");
|
328 329 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
329 330 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
330 331 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::ComplexError(parsed) = parsed {
|
331 332 | ::pretty_assertions::assert_eq!(parsed.top_level, expected_output.top_level, "Unexpected value for `top_level`");
|
332 333 | ::pretty_assertions::assert_eq!(parsed.nested, expected_output.nested, "Unexpected value for `nested`");
|
333 334 | } else {
|
334 335 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
335 336 | }
|
336 337 | }
|
337 338 | /// Parses customized XML errors
|
338 339 | /// Test ID: QueryCustomizedError
|
339 340 | #[::tokio::test]
|
340 - | #[allow(unused_mut)]
|
341 + | #[::tracing_test::traced_test]
|
341 342 | async fn query_customized_error_response() {
|
342 343 | let expected_output = crate::types::error::CustomCodeError::builder()
|
343 344 | .set_message(::std::option::Option::Some("Hi".to_owned()))
|
344 345 | .build();
|
345 346 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http::response::Builder::new()
|
346 347 | .header("Content-Type", "text/xml")
|
347 348 | .status(402)
|
348 349 | .body(::aws_smithy_types::body::SdkBody::from("<ErrorResponse>\n <Error>\n <Type>Sender</Type>\n <Code>Customized</Code>\n <Message>Hi</Message>\n </Error>\n <RequestId>foo-id</RequestId>\n</ErrorResponse>\n"))
|
349 350 | .unwrap()
|
350 351 | ).unwrap();
|