forked from wiremock/wiremock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed wiremock#1684 - Expose RemoveStubMappingTask through HttpAdminC…
…lient
- Loading branch information
Showing
7 changed files
with
123 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/test/java/com/github/tomakehurst/wiremock/admin/OldRemoveStubMappingTaskTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) 2013-2022 Thomas Akehurst | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.github.tomakehurst.wiremock.admin; | ||
|
||
import static com.github.tomakehurst.wiremock.stubbing.StubMapping.buildJsonStringFor; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import com.github.tomakehurst.wiremock.admin.model.PathParams; | ||
import com.github.tomakehurst.wiremock.admin.tasks.OldRemoveStubMappingTask; | ||
import com.github.tomakehurst.wiremock.core.Admin; | ||
import com.github.tomakehurst.wiremock.http.Request; | ||
import com.github.tomakehurst.wiremock.http.ResponseDefinition; | ||
import com.github.tomakehurst.wiremock.stubbing.StubMapping; | ||
import java.net.HttpURLConnection; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
public class OldRemoveStubMappingTaskTest { | ||
|
||
private static final StubMapping MOCK_MAPPING = new StubMapping(null, new ResponseDefinition()); | ||
|
||
private Admin mockAdmin = Mockito.mock(Admin.class); | ||
private Request mockRequest = Mockito.mock(Request.class); | ||
|
||
private OldRemoveStubMappingTask removeStubMappingTask = new OldRemoveStubMappingTask(); | ||
|
||
@Test | ||
public void delegatesSavingMappingsToAdmin() { | ||
when(mockRequest.getBodyAsString()).thenReturn(buildJsonStringFor(MOCK_MAPPING)); | ||
|
||
removeStubMappingTask.execute(mockAdmin, mockRequest, PathParams.empty()); | ||
|
||
verify(mockAdmin).removeStubMapping(any(StubMapping.class)); | ||
} | ||
|
||
@Test | ||
public void returnsOKResponse() { | ||
when(mockRequest.getBodyAsString()).thenReturn(buildJsonStringFor(MOCK_MAPPING)); | ||
|
||
ResponseDefinition response = | ||
removeStubMappingTask.execute(mockAdmin, mockRequest, PathParams.empty()); | ||
|
||
assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK)); | ||
verify(mockAdmin).removeStubMapping(any(StubMapping.class)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters