259 264 | .expect("the config must have a deserializer");
|
260 265 |
|
261 266 | let parsed = de.deserialize_streaming(&mut http_response);
|
262 267 | let parsed = parsed.unwrap_or_else(|| {
|
263 268 | let http_response = http_response.map(|body| {
|
264 269 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
265 270 | body.bytes().unwrap(),
|
266 271 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
267 272 | )))
|
268 273 | });
|
269 - | de.deserialize_nonstreaming(&http_response)
|
274 + | // Build a config bag with the protocol for schema-based deserialization
|
275 + | #[allow(unused_mut)]
|
276 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
277 + |
|
278 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
270 279 | });
|
271 280 | let parsed = parsed
|
272 281 | .expect("should be successful response")
|
273 282 | .downcast::<crate::operation::greeting_with_errors::GreetingWithErrorsOutput>()
|
274 283 | .unwrap();
|
275 284 | ::pretty_assertions::assert_eq!(parsed.greeting, expected_output.greeting, "Unexpected value for `greeting`");
|
276 285 | }
|
277 286 |
|
278 287 | /// Parses simple XML errors
|
279 288 | /// Test ID: QueryInvalidGreetingError
|
280 289 | #[::tokio::test]
|
281 290 | #[::tracing_test::traced_test]
|
282 291 | async fn query_invalid_greeting_error_response() {
|
283 292 | let expected_output = crate::types::error::InvalidGreeting::builder()
|
284 293 | .set_message(::std::option::Option::Some("Hi".to_owned()))
|
285 294 | .build();
|
286 295 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
287 296 | .header("Content-Type", "text/xml")
|
288 297 | .status(400)
|
289 298 | .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"))
|
290 299 | .unwrap()
|
291 300 | ).unwrap();
|
292 301 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
293 302 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
294 303 |
|
295 304 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
296 305 | let config = op.config().expect("the operation has config");
|
297 306 | let de = config
|
298 307 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
299 308 | .expect("the config must have a deserializer");
|
300 309 |
|
301 310 | let parsed = de.deserialize_streaming(&mut http_response);
|
302 311 | let parsed = parsed.unwrap_or_else(|| {
|
303 312 | let http_response = http_response.map(|body| {
|
304 313 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
305 314 | body.bytes().unwrap(),
|
306 315 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
307 316 | )))
|
308 317 | });
|
309 - | de.deserialize_nonstreaming(&http_response)
|
318 + | // Build a config bag with the protocol for schema-based deserialization
|
319 + | #[allow(unused_mut)]
|
320 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
321 + |
|
322 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
310 323 | });
|
311 324 | let parsed = parsed.expect_err("should be error response");
|
312 325 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
313 326 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
314 327 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::InvalidGreeting(parsed) = parsed {
|
315 328 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
316 329 | } else {
|
317 330 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
318 331 | }
|
319 332 | }
|
320 333 | /// Test ID: QueryComplexError
|
321 334 | #[::tokio::test]
|
322 335 | #[::tracing_test::traced_test]
|
323 336 | async fn query_complex_error_response() {
|
324 337 | let expected_output = crate::types::error::ComplexError::builder()
|
325 338 | .set_top_level(::std::option::Option::Some("Top level".to_owned()))
|
326 339 | .set_nested(::std::option::Option::Some(
|
327 340 | crate::types::ComplexNestedErrorData::builder()
|
328 341 | .set_foo(::std::option::Option::Some("bar".to_owned()))
|
329 342 | .build(),
|
330 343 | ))
|
331 344 | .build();
|
332 345 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
333 346 | .header("Content-Type", "text/xml")
|
334 347 | .status(400)
|
335 348 | .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"))
|
336 349 | .unwrap()
|
337 350 | ).unwrap();
|
338 351 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
339 352 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
340 353 |
|
341 354 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
342 355 | let config = op.config().expect("the operation has config");
|
343 356 | let de = config
|
344 357 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
345 358 | .expect("the config must have a deserializer");
|
346 359 |
|
347 360 | let parsed = de.deserialize_streaming(&mut http_response);
|
348 361 | let parsed = parsed.unwrap_or_else(|| {
|
349 362 | let http_response = http_response.map(|body| {
|
350 363 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
351 364 | body.bytes().unwrap(),
|
352 365 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
353 366 | )))
|
354 367 | });
|
355 - | de.deserialize_nonstreaming(&http_response)
|
368 + | // Build a config bag with the protocol for schema-based deserialization
|
369 + | #[allow(unused_mut)]
|
370 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
371 + |
|
372 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
356 373 | });
|
357 374 | let parsed = parsed.expect_err("should be error response");
|
358 375 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
359 376 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
360 377 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::ComplexError(parsed) = parsed {
|
361 378 | ::pretty_assertions::assert_eq!(parsed.top_level, expected_output.top_level, "Unexpected value for `top_level`");
|
362 379 | ::pretty_assertions::assert_eq!(parsed.nested, expected_output.nested, "Unexpected value for `nested`");
|
363 380 | } else {
|
364 381 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
365 382 | }
|
366 383 | }
|
367 384 |
|
368 385 | /// Parses customized XML errors
|
369 386 | /// Test ID: QueryCustomizedError
|
370 387 | #[::tokio::test]
|
371 388 | #[::tracing_test::traced_test]
|
372 389 | async fn query_customized_error_response() {
|
373 390 | let expected_output = crate::types::error::CustomCodeError::builder()
|
374 391 | .set_message(::std::option::Option::Some("Hi".to_owned()))
|
375 392 | .build();
|
376 393 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
377 394 | .header("Content-Type", "text/xml")
|
378 395 | .status(402)
|
379 396 | .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"))
|
380 397 | .unwrap()
|
381 398 | ).unwrap();
|
382 399 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
383 400 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
384 401 |
|
385 402 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
386 403 | let config = op.config().expect("the operation has config");
|
387 404 | let de = config
|
388 405 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
389 406 | .expect("the config must have a deserializer");
|
390 407 |
|
391 408 | let parsed = de.deserialize_streaming(&mut http_response);
|
392 409 | let parsed = parsed.unwrap_or_else(|| {
|
393 410 | let http_response = http_response.map(|body| {
|
394 411 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
395 412 | body.bytes().unwrap(),
|
396 413 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
397 414 | )))
|
398 415 | });
|
399 - | de.deserialize_nonstreaming(&http_response)
|
416 + | // Build a config bag with the protocol for schema-based deserialization
|
417 + | #[allow(unused_mut)]
|
418 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
419 + |
|
420 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
400 421 | });
|
401 422 | let parsed = parsed.expect_err("should be error response");
|
402 423 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
403 424 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
404 425 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::CustomCodeError(parsed) = parsed {
|
405 426 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
406 427 | } else {
|
407 428 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
408 429 | }
|
409 430 | }
|