Bumped WireMock to 2.30.1; fixes gh-1698

This commit is contained in:
Marcin Grzejszczak
2021-08-16 10:25:52 +02:00
parent 2f37b46dde
commit 3d68786ff4
8 changed files with 23 additions and 18 deletions

View File

@@ -15,7 +15,7 @@
<name>spring-cloud-contract-dependencies</name>
<description>Spring Cloud Contract Dependencies</description>
<properties>
<wiremock.version>2.29.1</wiremock.version>
<wiremock.version>2.30.1</wiremock.version>
<jsonassert.version>0.6.1</jsonassert.version>
</properties>
<dependencyManagement>

View File

@@ -99,8 +99,8 @@ public class WireMockHttpServerStub implements HttpServerStub {
return extensions.toArray(new Extension[extensions.size()]);
}
private Map<String, Helper> helpers() {
Map<String, Helper> helpers = new HashMap<>();
private Map<String, Helper<?>> helpers() {
Map<String, Helper<?>> helpers = new HashMap<>();
helpers.put(HandlebarsJsonPathHelper.NAME, new HandlebarsJsonPathHelper());
helpers.put(HandlebarsEscapeHelper.NAME, new HandlebarsEscapeHelper());
return helpers;

View File

@@ -16,7 +16,7 @@
package org.springframework.cloud.contract.verifier.wiremock;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.common.Metadata;
import com.github.tomakehurst.wiremock.extension.Parameters;
import com.github.tomakehurst.wiremock.extension.PostServeActionDefinition;
import com.github.tomakehurst.wiremock.http.ChunkedDribbleDelay;
import com.github.tomakehurst.wiremock.http.DelayDistribution;
import com.github.tomakehurst.wiremock.http.Fault;
@@ -51,9 +52,9 @@ class DefaultWireMockStubPostProcessor implements WireMockStubPostProcessor {
}
public void setPostServeActions(StubMapping stubMapping, StubMapping stubMappingFromMetadata) {
Map<String, Parameters> postServeActions = stubMapping.getPostServeActions();
postServeActions = postServeActions != null ? postServeActions : new HashMap<>();
postServeActions.putAll(stubMappingFromMetadata.getPostServeActions());
List<PostServeActionDefinition> postServeActions = stubMapping.getPostServeActions();
postServeActions = postServeActions != null ? postServeActions : new ArrayList<>();
postServeActions.addAll(stubMappingFromMetadata.getPostServeActions());
stubMapping.setPostServeActions(postServeActions);
}

View File

@@ -18,10 +18,11 @@ package org.springframework.cloud.contract.verifier.wiremock;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.extension.Parameters;
import com.github.tomakehurst.wiremock.extension.PostServeActionDefinition;
import com.github.tomakehurst.wiremock.stubbing.StubMapping;
import org.junit.jupiter.api.Test;
@@ -151,9 +152,12 @@ class DefaultWireMockStubPostProcessorTests {
then(result.getRequest().getMethod().getName()).isEqualTo("GET");
then(result.getResponse().getStatus()).isEqualTo(200);
then(result.getResponse().getBody()).isEqualTo("pong");
then(result.getPostServeActions()).containsKey("webhook");
Parameters webhook = result.getPostServeActions().get("webhook");
then(webhook.getString("method")).isEqualTo("POST");
then(result.getPostServeActions().stream().map(a -> a.getName()).collect(Collectors.toList()))
.contains("webhook");
PostServeActionDefinition definition = result.getPostServeActions().stream()
.filter(a -> a.getName().equals("webhook")).findFirst()
.orElseThrow(() -> new AssertionError("No webhook action found"));
then(definition.getParameters().getString("method")).isEqualTo("POST");
}
}

View File

@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
wiremockVersion=2.29.1
wiremockVersion=2.30.1
jsonAssertVersion=0.6.1
verifierVersion=3.0.4-SNAPSHOT
groovyVersion=2.4.17

View File

@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
wiremockVersion=2.29.1
wiremockVersion=2.30.1
jsonAssertVersion=0.6.1
verifierVersion=3.0.4-SNAPSHOT
bootVersion=2.4.7

View File

@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
wiremockVersion=2.29.1
wiremockVersion=2.30.1
jsonAssertVersion=0.6.1
verifierVersion=3.0.4-SNAPSHOT
bootVersion=2.4.7

View File

@@ -42,16 +42,16 @@ public class DefaultResponseTransformer extends ResponseTemplateTransformer {
super(global);
}
public DefaultResponseTransformer(boolean global, String helperName, Helper helper) {
public DefaultResponseTransformer(boolean global, String helperName, Helper<?> helper) {
super(global, helperName, helper);
}
public DefaultResponseTransformer(boolean global, Map<String, Helper> helpers) {
public DefaultResponseTransformer(boolean global, Map<String, Helper<?>> helpers) {
super(global, helpers);
}
private static Map<String, Helper> defaultHelpers() {
Map<String, Helper> helpers = new HashMap<>();
private static Map<String, Helper<?>> defaultHelpers() {
Map<String, Helper<?>> helpers = new HashMap<>();
helpers.put(HandlebarsJsonPathHelper.NAME, new HandlebarsJsonPathHelper());
helpers.put(HandlebarsEscapeHelper.NAME, new HandlebarsEscapeHelper());
return helpers;