@Test public void shouldUnmarshallYamlIntoObjectTree_WhenYAMLValid_WithOneSequenceResponse() throws Exception { final String sequenceResponseHeaderKey = "content-type"; final String sequenceResponseHeaderValue = "application/json"; final String sequenceResponseStatus = "200"; final String sequenceResponseBody = "OK"; final String yaml = YAML_BUILDER .newStubbedRequest() .withMethodPut() .withUrl("/invoice") .newStubbedResponse() .withSequenceResponseStatus(sequenceResponseStatus) .withSequenceResponseHeaders(sequenceResponseHeaderKey, sequenceResponseHeaderValue) .withSequenceResponseLiteralBody(sequenceResponseBody) .build(); final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(yaml); final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(0); final StubResponse actualResponse = actualHttpLifecycle.getResponse(true); final MapEntry sequenceHeaderEntry = MapEntry.entry(sequenceResponseHeaderKey, sequenceResponseHeaderValue); assertThat(actualResponse).isInstanceOf(StubResponse.class); assertThat(actualResponse.getHeaders()).contains(sequenceHeaderEntry); assertThat(actualResponse.getStatus()).isEqualTo(sequenceResponseStatus); assertThat(actualResponse.getBody()).isEqualTo(sequenceResponseBody); }
@Test public void shouldUnmarshallYamlIntoObjectTree_WhenYAMLValid_WithLiteralBody() throws Exception { final String stubbedResponseBody = "This is a sentence"; final String yaml = YAML_BUILDER .newStubbedRequest() .withMethodGet() .withUrl("/some/uri") .newStubbedResponse() .withLiteralBody(stubbedResponseBody) .build(); final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(yaml); final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(0); final StubResponse actualResponse = actualHttpLifecycle.getResponse(true); assertThat(actualResponse.getBody()).isEqualTo(stubbedResponseBody); }