| 232 | } |
| 233 | |
| 234 | @Test |
| 235 | void decodesSoap() throws Exception { |
| 236 | GetPrice mock = new GetPrice(); |
| 237 | mock.item = new Item(); |
| 238 | mock.item.value = "Apples"; |
| 239 | |
| 240 | String mockSoapEnvelop = |
| 241 | """ |
| 242 | <?xml version="1.0" encoding="UTF-8" ?>\ |
| 243 | <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">\ |
| 244 | <SOAP-ENV:Header/>\ |
| 245 | <SOAP-ENV:Body>\ |
| 246 | <GetPrice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://apihost/schema.xsd">\ |
| 247 | <Item>Apples</Item>\ |
| 248 | </GetPrice>\ |
| 249 | </SOAP-ENV:Body>\ |
| 250 | </SOAP-ENV:Envelope>\ |
| 251 | """; |
| 252 | |
| 253 | Response response = |
| 254 | Response.builder() |
| 255 | .status(200) |
| 256 | .reason("OK") |
| 257 | .request( |
| 258 | Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8)) |
| 259 | .headers(Collections.emptyMap()) |
| 260 | .body(mockSoapEnvelop, UTF_8) |
| 261 | .build(); |
| 262 | |
| 263 | SOAPDecoder decoder = new SOAPDecoder(new JAXBContextFactory.Builder().build()); |
| 264 | |
| 265 | assertThat(decoder.decode(response, GetPrice.class)).isEqualTo(mock); |
| 266 | } |
| 267 | |
| 268 | @Test |
| 269 | void decodesSoapWithSchemaOnEnvelope() throws Exception { |