Skip to content

Commit

Permalink
Merge branch 'master' into StringUtils_replace
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Peshin committed Mar 6, 2024
2 parents 00efbab + b773056 commit 92bc595
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ dependencies {

testImplementation "org.hamcrest:hamcrest-core:2.2"
testImplementation "org.hamcrest:hamcrest-library:2.2"
testImplementation 'org.mockito:mockito-core:5.10.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.10.0'
testImplementation 'org.mockito:mockito-core:5.11.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.11.0'
testImplementation "net.javacrumbs.json-unit:json-unit:$versions.jsonUnit"
testImplementation "org.skyscreamer:jsonassert:1.2.3"
testImplementation 'com.toomuchcoding.jsonassert:jsonassert:0.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ public void removeStub(MappingBuilder mappingBuilder) {
public void removeStub(StubMapping stubMapping) {
client.removeStubMapping(stubMapping);
}
@Override
public void removeStub(UUID id) {
client.removeStubMapping(id);
}

@Override
public List<StubMapping> getStubMappings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public static void removeStub(StubMapping stubMapping) {
defaultInstance.get().removeStubMapping(stubMapping);
}

public static void removeStub(UUID id) {
defaultInstance.get().removeStubMapping(id);
}

public static ListStubMappingsResult listAllStubMappings() {
return defaultInstance.get().allStubMappings();
}
Expand Down Expand Up @@ -457,7 +461,9 @@ public void removeStubMapping(MappingBuilder mappingBuilder) {
public void removeStubMapping(StubMapping stubMapping) {
admin.removeStubMapping(stubMapping);
}

public void removeStubMapping(UUID id) {
admin.removeStubMapping(id);
}
public ListStubMappingsResult allStubMappings() {
return admin.listAllStubMappings();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ public void removeStub(StubMapping mappingBuilder) {
stubbing.removeStub(mappingBuilder);
}

@Override
public void removeStub(UUID id) {
stubbing.removeStub(id);
}

@Override
public List<StubMapping> getStubMappings() {
return stubbing.getStubMappings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public interface Stubbing {

void removeStub(StubMapping mappingBuilder);

void removeStub(UUID id);

List<StubMapping> getStubMappings();

StubMapping getSingleStubMapping(UUID id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,36 @@ public void removeStubThatDoesNotExists() {
assertThat(getMatchingStubCount("/stb-1", "/stb-2"), is(2));
}

@Test
public void removeStubWithUUIDThatExists() {

UUID id1 = UUID.randomUUID();

stubFor(get(urlEqualTo("/stub-1")).withId(id1).willReturn(aResponse().withBody("Stub-1-Body")));

assertThat(testClient.get("/stub-1").content(), is("Stub-1-Body"));

assertThat(getMatchingStubCount("/stub-1", ""), is(1));

removeStub(id1);

assertThat(getMatchingStubCount("/stub-1", ""), is(0));
}

@Test
public void removeStubWithUUIDThatDoesNotExists() {

UUID id1 = UUID.randomUUID();

stubFor(get(urlEqualTo("/stb-1")).withId(id1).willReturn(aResponse().withBody("Stb-1-Body")));

assertThat(testClient.get("/stb-1").content(), is("Stb-1-Body"));

removeStub(id1);

assertThat(getMatchingStubCount("/stb-1", ""), is(0));
}

private Predicate<StubMapping> withAnyOf(final String... urls) {
return mapping ->
mapping.getRequest().getUrl() != null
Expand Down

0 comments on commit 92bc595

Please sign in to comment.