@Test
public void supportsResetOfAllScenariosState() {
StubMapping firstGetMapping = new StubMapping(
new RequestPattern(GET, "/scenario/resource"),
new ResponseDefinition(204, "Desired content"));
firstGetMapping.setScenarioName("TestScenario");
firstGetMapping.setRequiredScenarioState(STARTED);
mappings.addMapping(firstGetMapping);
StubMapping putMapping = new StubMapping(
new RequestPattern(PUT, "/scenario/resource"),
new ResponseDefinition(204, ""));
putMapping.setScenarioName("TestScenario");
putMapping.setRequiredScenarioState(STARTED);
putMapping.setNewScenarioState("Modified");
mappings.addMapping(putMapping);
mappings.serveFor(
aRequest(context, "put /scenario/resource")
.withMethod(PUT).withUrl("/scenario/resource").build());
ResponseDefinition response =
mappings.serveFor(
aRequest(context, "1st get /scenario/resource")
.withMethod(GET).withUrl("/scenario/resource").build());
assertThat(response.wasConfigured(), is(false));
mappings.resetScenarios();
response =
mappings.serveFor(
aRequest(context, "2nd get /scenario/resource")
.withMethod(GET).withUrl("/scenario/resource").build());
assertThat(response.getBody(), is("Desired content"));
}