@Test public void shouldUnmarshallYamlIntoObjectTree_WhenYAMLValid_WithFileFailedToLoadAndPostSet() throws Exception { final String stubbedRequestFile = "../../very.big.soap.request.xml"; final String expectedPost = "{\"message\", \"Hello, this is HTTP request post\"}"; final String yaml = YAML_BUILDER .newStubbedRequest() .withMethodGet() .withUrl("/some/uri") .withFile(stubbedRequestFile) .withFoldedPost(expectedPost) .newStubbedResponse() .withLiteralBody("OK") .withStatus("201") .build(); final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(yaml); final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(0); final StubRequest actualRequest = actualHttpLifecycle.getRequest(); assertThat(actualRequest.getFile()).isEqualTo(new byte[] {}); assertThat(actualRequest.getPostBody()).isEqualTo(expectedPost); }
@Override public boolean equals(final Object o) { if (this == o) { return true; } else if (o instanceof StubRequest) { final StubRequest dataStoreRequest = (StubRequest) o; if (!urlsMatch(dataStoreRequest.url, url)) { return false; } if (!arraysIntersect(dataStoreRequest.getMethod(), getMethod())) { ANSITerminal.dump( String.format( "METHOD %s failed match for %s", dataStoreRequest.getMethod(), getMethod())); return false; } if (!postBodiesMatch(dataStoreRequest.getPostBody(), getPostBody())) { ANSITerminal.dump( String.format( "POST BODY %s failed match for %s", dataStoreRequest.getPostBody(), getPostBody())); return false; } if (!headersMatch(dataStoreRequest.getHeaders(), getHeaders())) { ANSITerminal.dump( String.format( "HEADERS %s failed match for %s", dataStoreRequest.getHeaders(), getHeaders())); return false; } if (!queriesMatch(dataStoreRequest.getQuery(), getQuery())) { ANSITerminal.dump( String.format("QUERY %s failed match for %s", dataStoreRequest.getQuery(), getQuery())); return false; } return true; } return false; }