@Test
public void should_UpdateStubbedRequest_WhenSuccessfulPutMade_ToAdminPortalRootWithValidIndexURI() throws Exception {
final String requestUrl = String.format("%s%s", ADMIN_URL, "/0");
HttpRequest httpGetRequest = HttpUtils.constructHttpRequest(HttpMethods.GET, requestUrl);
HttpResponse httpGetResponse = httpGetRequest.execute();
String getResponseContent = httpGetResponse.parseAsString().trim();
assertThat(HttpStatus.OK_200).isEqualTo(httpGetResponse.getStatusCode());
assertThat(getResponseContent).containsOnlyOnce("request");
assertThat(getResponseContent).containsOnlyOnce("url: ^/resources/asn/");
assertThat(getResponseContent).containsOnlyOnce("response");
assertThat(getResponseContent).containsOnlyOnce("content-type: application/json");
final String yamlToUpdate = new YamlBuilder()
.newStubbedRequest()
.withUrl("^/resources/something/new")
.withMethodGet()
.withQuery("someKey", "someValue")
.newStubbedResponse()
.withHeaderContentType("application/xml")
.withLiteralBody("OK")
.withStatus("201")
.build();
final HttpRequest httpPutRequest = HttpUtils.constructHttpRequest(HttpMethods.PUT, requestUrl, yamlToUpdate);
final HttpResponse httpPutResponse = httpPutRequest.execute();
final String putResponseContent = httpPutResponse.parseAsString().trim();
final String putResponseLocationHeader = httpPutResponse.getHeaders().getLocation();
assertThat(HttpStatus.OK_200).isEqualTo(httpGetResponse.getStatusCode());
assertThat(putResponseLocationHeader).isEqualTo("^/resources/something/new?someKey=someValue");