Applied checkstyle rules

This commit is contained in:
Marcin Grzejszczak
2016-08-29 12:04:21 +02:00
parent c7a44b92ae
commit bfc2172d66
86 changed files with 509 additions and 482 deletions

View File

@@ -1,13 +1,13 @@
package org.springframework.cloud.contract.wiremock;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.springframework.http.HttpMethod;
import org.springframework.http.RequestEntity;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
import static org.assertj.core.api.Assertions.assertThat;
public class WiremockMockServerApplicationTests {
private RestTemplate restTemplate = new RestTemplate();
@@ -17,7 +17,7 @@ public class WiremockMockServerApplicationTests {
MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate) //
.baseUrl("http://example.org") //
.stubs("classpath:/mappings/resource.json").build();
assertThat(restTemplate.getForObject("http://example.org/resource", String.class))
assertThat(this.restTemplate.getForObject("http://example.org/resource", String.class))
.isEqualTo("Hello World");
server.verify();
}
@@ -27,7 +27,7 @@ public class WiremockMockServerApplicationTests {
MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate) //
.baseUrl("http://example.org") //
.stubs("classpath:/mappings/poster.json").build();
assertThat(restTemplate.postForObject("http://example.org/poster", "greeting",
assertThat(this.restTemplate.postForObject("http://example.org/poster", "greeting",
String.class)).isEqualTo("Hello World");
server.verify();
}
@@ -37,7 +37,7 @@ public class WiremockMockServerApplicationTests {
WireMockRestServiceServer.with(this.restTemplate) //
.baseUrl("http://example.org") //
.stubs("classpath:/mappings/*.json").ignoreExpectOrder(true).build();
assertThat(restTemplate.exchange("http://example.org/poster", HttpMethod.POST,
assertThat(this.restTemplate.exchange("http://example.org/poster", HttpMethod.POST,
RequestEntity.EMPTY, String.class).getBody()).isEqualTo("Accepted World");
}
@@ -46,7 +46,7 @@ public class WiremockMockServerApplicationTests {
WireMockRestServiceServer.with(this.restTemplate) //
.baseUrl("http://example.org") //
.stubs("classpath:/mappings").ignoreExpectOrder(true).build();
assertThat(restTemplate.getForObject("http://example.org/resource", String.class))
assertThat(this.restTemplate.getForObject("http://example.org/resource", String.class))
.isEqualTo("Hello World");
}

View File

@@ -1,7 +1,5 @@
package org.springframework.cloud.contract.wiremock;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfiguration.class)
@AutoConfigureRestDocs(outputDir = "target/snippets")
@@ -31,7 +31,7 @@ public class WiremockServerRestDocsApplicationTests {
@Test
public void contextLoads() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/resource"))
this.mockMvc.perform(MockMvcRequestBuilders.get("/resource"))
.andExpect(MockMvcResultMatchers.content().string("Hello World"))
.andDo(document("resource"));
}

View File

@@ -41,7 +41,7 @@ public class WiremockServerRestDocsMatcherApplicationTests {
@Test
public void matchesRequest() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.post("/resource").content("greeting")
this.mockMvc.perform(MockMvcRequestBuilders.post("/resource").content("greeting")
.contentType(MediaType.TEXT_PLAIN))
.andExpect(MockMvcResultMatchers.content().string("Hello World"))
.andDo(WireMockRestDocs.verify()
@@ -52,9 +52,9 @@ public class WiremockServerRestDocsMatcherApplicationTests {
@Test
public void doesNotMatch() throws Exception {
expected.expect(ComparisonFailure.class);
expected.expectMessage("wiremock did not match");
mockMvc.perform(MockMvcRequestBuilders.post("/resource").content("greeting")
this.expected.expect(ComparisonFailure.class);
this.expected.expectMessage("wiremock did not match");
this.mockMvc.perform(MockMvcRequestBuilders.post("/resource").content("greeting")
.contentType(MediaType.TEXT_PLAIN))
.andExpect(MockMvcResultMatchers.content().string("Hello World"))
.andDo(WireMockRestDocs.verify()