List<StubHttpLifecycle> beforeResetHttpCycles = stubbedDataManager.getStubHttpLifecycles();
assertThat(beforeResetHttpCycles.size()).isEqualTo(1);
for (int resourceId = 0; resourceId < beforeResetHttpCycles.size(); resourceId++) {
final StubHttpLifecycle cycle = beforeResetHttpCycles.get(resourceId);
final List<StubResponse> allResponses = cycle.getAllResponses();
for (int sequence = 0; sequence < allResponses.size(); sequence++) {
final StubResponse sequenceStubResponse = allResponses.get(sequence);
assertThat(sequenceStubResponse.getHeaders()).containsKey(StubResponse.STUBBY_RESOURCE_ID_HEADER);
assertThat(sequenceStubResponse.getHeaders().get(StubResponse.STUBBY_RESOURCE_ID_HEADER)).isEqualTo(String.valueOf(resourceId));
}
}
final String cycleTwo = YAML_BUILDER
.newStubbedRequest()
.withMethodPut()
.withUrl("/invoice")
.newStubbedResponse()
.withSequenceResponseStatus("200")
.withSequenceResponseHeaders("headerOne", "valueOne")
.withSequenceResponseLiteralBody("BodyContent")
.withSequenceResponseStatus("200")
.withSequenceResponseHeaders("headerTwo", "valueTwo")
.withSequenceResponseLiteralBody("BodyContentTwo")
.build();
final String cycleThree = YAML_BUILDER.newStubbedRequest()
.withMethodGet()
.withUrl("/some/uri/2")
.withQuery("paramName2", "paramValue2")
.newStubbedResponse()
.withStatus("201")
.build();
final List<StubHttpLifecycle> stubHttpLifecycles = new YamlParser().parse(".", String.format("%s%s%s", cycleTwo, BR, cycleThree));
stubbedDataManager.resetStubHttpLifecycles(stubHttpLifecycles);
List<StubHttpLifecycle> afterResetHttpCycles = stubbedDataManager.getStubHttpLifecycles();
assertThat(afterResetHttpCycles.size()).isEqualTo(2);
for (int resourceId = 0; resourceId < afterResetHttpCycles.size(); resourceId++) {
final StubHttpLifecycle cycle = afterResetHttpCycles.get(resourceId);
final List<StubResponse> allResponses = cycle.getAllResponses();
for (int sequence = 0; sequence < allResponses.size(); sequence++) {
final StubResponse sequenceStubResponse = allResponses.get(sequence);
assertThat(sequenceStubResponse.getHeaders()).containsKey(StubResponse.STUBBY_RESOURCE_ID_HEADER);
assertThat(sequenceStubResponse.getHeaders().get(StubResponse.STUBBY_RESOURCE_ID_HEADER)).isEqualTo(String.valueOf(resourceId));