Skip to content

Commit

Permalink
Fixed wiremock#1684 - Add (Old)RemoveStubMappingTask acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrolfr committed Oct 16, 2022
1 parent a84fcfb commit d6ed558
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,29 @@ public void jsonResponseWithObjectValue() {
assertThat(response.content(), containsString("\"Json From Object\""));
}

@Test
public void removesASingleStubMapping() {
final UUID id = UUID.randomUUID();
stubFor(get("/stub-to-remove").withId(id).willReturn(aResponse()));

assertThat(testClient.get("/stub-to-remove").statusCode(), is(200));

StubMapping stub = wireMockServer.getSingleStubMapping(id);
wireMockServer.removeStubMapping(stub);
assertThat(testClient.get("/stub-to-remove").statusCode(), is(404));
}

@Test
public void removesASingleStubMappingById() {
final UUID id = UUID.randomUUID();
stubFor(get("/stub-to-remove-by-id").withId(id).willReturn(aResponse()));

assertThat(testClient.get("/stub-to-remove-by-id").statusCode(), is(200));

wireMockServer.removeStubMapping(id);
assertThat(testClient.get("/stub-to-remove-by-id").statusCode(), is(404));
}

private int getStatusCodeUsingJavaUrlConnection(String url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("GET");
Expand Down

0 comments on commit d6ed558

Please sign in to comment.