Skip to content
This repository was archived by the owner on Mar 29, 2025. It is now read-only.

Commit c8a2519

Browse files
authored
Replace spring-cloud-contract-wiremock with wiremock-spring-boot (#25)
1 parent e9c1738 commit c8a2519

File tree

4 files changed

+18
-33
lines changed

4 files changed

+18
-33
lines changed

pom.xml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,6 @@
4343
<notion-sdk-jvm.version>1.11.1</notion-sdk-jvm.version>
4444
</properties>
4545

46-
<dependencyManagement>
47-
<dependencies>
48-
<dependency>
49-
<groupId>org.springframework.cloud</groupId>
50-
<artifactId>spring-cloud-dependencies</artifactId>
51-
<version>2022.0.4</version>
52-
<type>pom</type>
53-
<scope>import</scope>
54-
</dependency>
55-
</dependencies>
56-
</dependencyManagement>
5746
<dependencies>
5847
<!-- Compile -->
5948
<dependency>
@@ -107,8 +96,9 @@
10796
<scope>test</scope>
10897
</dependency>
10998
<dependency>
110-
<groupId>org.springframework.cloud</groupId>
111-
<artifactId>spring-cloud-contract-wiremock</artifactId>
99+
<groupId>org.wiremock.integrations</groupId>
100+
<artifactId>wiremock-spring-boot</artifactId>
101+
<version>3.0.2</version>
112102
<scope>test</scope>
113103
</dependency>
114104
</dependencies>

src/test/java/io/github/scordio/springframework/batch/extensions/notion/it/IntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import org.springframework.batch.test.context.SpringBatchTest;
1919
import org.springframework.boot.test.context.SpringBootTest;
20-
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
20+
import org.wiremock.spring.EnableWireMock;
2121

2222
import java.lang.annotation.Retention;
2323
import java.lang.annotation.Target;
@@ -29,7 +29,7 @@
2929
@Retention(RUNTIME)
3030
@SpringBootTest(properties = "spring.batch.job.enabled=false")
3131
@SpringBatchTest
32-
@AutoConfigureWireMock(port = 0)
32+
@EnableWireMock
3333
public @interface IntegrationTest {
3434

3535
}

src/test/java/io/github/scordio/springframework/batch/extensions/notion/it/pagination/MultiplePagesDescendingTests.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import io.github.scordio.springframework.batch.extensions.notion.it.pagination.MultiplePagesDescendingTests.PaginatedDescendingJob.Item;
2222
import io.github.scordio.springframework.batch.extensions.notion.mapping.RecordPropertyMapper;
2323
import org.json.JSONObject;
24-
import org.junit.jupiter.api.BeforeAll;
2524
import org.junit.jupiter.api.Test;
2625
import org.springframework.batch.core.Job;
2726
import org.springframework.batch.core.JobExecution;
@@ -76,8 +75,9 @@ class MultiplePagesDescendingTests {
7675
@Autowired
7776
ListItemWriter<Item> itemWriter;
7877

79-
@BeforeAll
80-
static void wiremockStubbing() {
78+
@Test
79+
void should_succeed() throws Exception {
80+
// GIVEN
8181
UUID thirdResultId = randomUUID();
8282

8383
JSONObject firstResult = result(randomUUID(), DATABASE_ID,
@@ -100,12 +100,10 @@ static void wiremockStubbing() {
100100
.withHeader(NOTION_VERSION, equalTo(NOTION_VERSION_VALUE))
101101
.withRequestBody(equalToJson(queryRequest(thirdResultId, PAGE_SIZE, sortByProperty("Name", DESCENDING))))
102102
.willReturn(okJson(queryResponse(thirdResult))));
103-
}
104103

105-
@Test
106-
void should_succeed() throws Exception {
107104
// WHEN
108105
JobExecution jobExecution = launcher.launchJob();
106+
109107
// THEN
110108
then(jobExecution.getExitStatus()).isEqualTo(COMPLETED);
111109

@@ -119,8 +117,8 @@ void should_succeed() throws Exception {
119117
@SpringBootApplication
120118
static class PaginatedDescendingJob {
121119

122-
@Value("${wiremock.server.port}")
123-
private int wiremockPort;
120+
@Value("${wiremock.server.baseUrl}")
121+
private String wiremockBaseUrl;
124122

125123
@Bean
126124
Job job(JobRepository jobRepository, Step step) {
@@ -143,7 +141,7 @@ NotionDatabaseItemReader<Item> itemReader() {
143141
reader.setSaveState(false);
144142

145143
reader.setToken("token");
146-
reader.setBaseUrl("http://localhost:" + wiremockPort);
144+
reader.setBaseUrl(wiremockBaseUrl);
147145
reader.setDatabaseId(DATABASE_ID.toString());
148146

149147
reader.setPageSize(PAGE_SIZE);

src/test/java/io/github/scordio/springframework/batch/extensions/notion/it/pagination/MultiplePagesTests.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import io.github.scordio.springframework.batch.extensions.notion.it.pagination.MultiplePagesTests.PaginatedJob.Item;
2121
import io.github.scordio.springframework.batch.extensions.notion.mapping.RecordPropertyMapper;
2222
import org.json.JSONObject;
23-
import org.junit.jupiter.api.BeforeAll;
2423
import org.junit.jupiter.api.Test;
2524
import org.springframework.batch.core.Job;
2625
import org.springframework.batch.core.JobExecution;
@@ -73,8 +72,9 @@ class MultiplePagesTests {
7372
@Autowired
7473
ListItemWriter<Item> itemWriter;
7574

76-
@BeforeAll
77-
static void wiremockStubbing() {
75+
@Test
76+
void should_succeed() throws Exception {
77+
// GIVEN
7878
UUID thirdResultId = randomUUID();
7979

8080
JSONObject firstResult = result(randomUUID(), DATABASE_ID,
@@ -97,10 +97,7 @@ static void wiremockStubbing() {
9797
.withHeader(NOTION_VERSION, equalTo(NOTION_VERSION_VALUE))
9898
.withRequestBody(equalToJson(queryRequest(thirdResultId, PAGE_SIZE)))
9999
.willReturn(okJson(queryResponse(thirdResult))));
100-
}
101100

102-
@Test
103-
void should_succeed() throws Exception {
104101
// WHEN
105102
JobExecution jobExecution = launcher.launchJob();
106103

@@ -117,8 +114,8 @@ void should_succeed() throws Exception {
117114
@SpringBootApplication
118115
static class PaginatedJob {
119116

120-
@Value("${wiremock.server.port}")
121-
private int wiremockPort;
117+
@Value("${wiremock.server.baseUrl}")
118+
private String wiremockBaseUrl;
122119

123120
@Bean
124121
Job job(JobRepository jobRepository, Step step) {
@@ -141,7 +138,7 @@ NotionDatabaseItemReader<Item> itemReader() {
141138
reader.setSaveState(false);
142139

143140
reader.setToken("token");
144-
reader.setBaseUrl("http://localhost:" + wiremockPort);
141+
reader.setBaseUrl(wiremockBaseUrl);
145142
reader.setDatabaseId(DATABASE_ID.toString());
146143

147144
reader.setPageSize(PAGE_SIZE);

0 commit comments

Comments
 (0)