Polish
This commit is contained in:
@@ -103,7 +103,7 @@ public class WireMockConfiguration implements SmartLifecycle {
|
||||
pattern = pattern + "**/*.json";
|
||||
}
|
||||
for (Resource resource : resolver.getResources(pattern)) {
|
||||
this.server.addStubMapping(WireMock2_1_7_StubMapping
|
||||
this.server.addStubMapping(WireMockStubMapping
|
||||
.buildFrom(StreamUtils.copyToString(resource.getInputStream(), Charset.forName("UTF-8"))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.jayway.jsonpath.JsonPath;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class WireMock2_1_7_StubMapping {
|
||||
public class WireMockStubMapping {
|
||||
public static StubMapping buildFrom(String mappingDefinition) {
|
||||
DocumentContext context = JsonPath.parse(mappingDefinition);
|
||||
context.delete("$.id");
|
||||
@@ -8,14 +8,14 @@ import com.github.tomakehurst.wiremock.stubbing.StubMapping;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class WireMock2_1_7_StubMappingTest {
|
||||
public class WireMockStubMappingTest {
|
||||
private static final String stub_2_1_7 = "{\"request\" : { \"method\" : \"GET\" }, \"response\" : { \"status\" : 200 }}";
|
||||
private static final String stub_2_5_1 = "{\"id\" : \"77514bd4-a102-4478-a3c0-0fda8b905591\", \"request\" : { \"method\" : \"GET\" }, \"response\" : { \"status\" : 200 }, \"uuid\" : \"77514bd4-a102-4478-a3c0-0fda8b905591\"}";
|
||||
|
||||
@Test
|
||||
public void should_successfully_parse_a_WireMock_2_1_7_stub() {
|
||||
// when:
|
||||
StubMapping mapping = WireMock2_1_7_StubMapping.buildFrom(stub_2_1_7);
|
||||
StubMapping mapping = WireMockStubMapping.buildFrom(stub_2_1_7);
|
||||
// then:
|
||||
JSONAssert.assertEquals(stub_2_1_7, mapping.toString(), false);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class WireMock2_1_7_StubMappingTest {
|
||||
@Test
|
||||
public void should_successfully_parse_a_WireMock_2_5_1_stub() {
|
||||
// when:
|
||||
StubMapping mapping = WireMock2_1_7_StubMapping.buildFrom(stub_2_5_1);
|
||||
StubMapping mapping = WireMockStubMapping.buildFrom(stub_2_5_1);
|
||||
// then:
|
||||
JSONAssert.assertEquals(stub_2_1_7, mapping.toString(), false);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.cloud.contract.wiremock.WireMock2_1_7_StubMapping;
|
||||
import org.springframework.cloud.contract.wiremock.WireMockStubMapping;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -68,7 +68,7 @@ public class WireMockSnippetTests {
|
||||
|
||||
File stub = new File(this.outputFolder, "stubs/foo.json");
|
||||
assertThat(stub).exists();
|
||||
StubMapping stubMapping = WireMock2_1_7_StubMapping
|
||||
StubMapping stubMapping = WireMockStubMapping
|
||||
.buildFrom(new String(Files.readAllBytes(stub.toPath())));
|
||||
assertThat(stubMapping.getResponse().getStatus())
|
||||
.isEqualTo(HttpStatus.ACCEPTED.value());
|
||||
@@ -84,7 +84,7 @@ public class WireMockSnippetTests {
|
||||
|
||||
File stub = new File(this.outputFolder, "stubs/foo.json");
|
||||
assertThat(stub).exists();
|
||||
StubMapping stubMapping = WireMock2_1_7_StubMapping
|
||||
StubMapping stubMapping = WireMockStubMapping
|
||||
.buildFrom(new String(Files.readAllBytes(stub.toPath())));
|
||||
assertThat(stubMapping.getRequest().getBodyPatterns().get(0))
|
||||
.isInstanceOf(EqualToJsonPattern.class);
|
||||
|
||||
Reference in New Issue
Block a user