Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Oct 10, 2024
1 parent 7f9bc1c commit d8a6206
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
18 changes: 9 additions & 9 deletions src/main/java/org/wiremock/spring/InjectWireMock.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
import java.lang.annotation.Target;

/**
* Injects WireMock instance previously configured on the class or field level
* with {@link ConfigureWireMock}.
* Injects WireMock instance previously configured on the class or field level with {@link
* ConfigureWireMock}.
*
* @author Maciej Walkowiak
*/
@Target({ ElementType.FIELD, ElementType.PARAMETER })
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface InjectWireMock {

/**
* The name of WireMock instance to inject.
*
* @return the name of WireMock instance to inject.
*/
String value() default "wiremock";
/**
* The name of WireMock instance to inject.
*
* @return the name of WireMock instance to inject.
*/
String value() default "wiremock";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;

import com.github.tomakehurst.wiremock.WireMockServer;
import io.restassured.RestAssured;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.wiremock.spring.EnableWireMock;
import org.wiremock.spring.InjectWireMock;

import com.github.tomakehurst.wiremock.WireMockServer;

import io.restassured.RestAssured;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableWireMock
class InjectNamedWireMockTest {

@InjectWireMock
private WireMockServer wireMockServer;
@InjectWireMock private WireMockServer wireMockServer;

@Value("${wiremock.server.baseUrl}")
private String wiremockUrl;
@Value("${wiremock.server.baseUrl}")
private String wiremockUrl;

@Test
void returnsTodos() {
this.wireMockServer.stubFor(get("/ping").willReturn(aResponse().withStatus(200)));
@Test
void returnsTodos() {
this.wireMockServer.stubFor(get("/ping").willReturn(aResponse().withStatus(200)));

RestAssured.when().get(this.wiremockUrl + "/ping").then().statusCode(200);
}
RestAssured.when().get(this.wiremockUrl + "/ping").then().statusCode(200);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,29 @@
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;

import com.github.tomakehurst.wiremock.WireMockServer;
import io.restassured.RestAssured;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.wiremock.spring.ConfigureWireMock;
import org.wiremock.spring.EnableWireMock;
import org.wiremock.spring.InjectWireMock;

import com.github.tomakehurst.wiremock.WireMockServer;

import io.restassured.RestAssured;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableWireMock(@ConfigureWireMock(name = "mywiremock"))
class InjectDefaultWireMockTest {

@InjectWireMock("mywiremock")
private WireMockServer wireMockServer;
@InjectWireMock("mywiremock")
private WireMockServer wireMockServer;

@Value("${wiremock.server.baseUrl}")
private String wiremockUrl;
@Value("${wiremock.server.baseUrl}")
private String wiremockUrl;

@Test
void returnsTodos() {
this.wireMockServer.stubFor(get("/ping").willReturn(aResponse().withStatus(200)));
@Test
void returnsTodos() {
this.wireMockServer.stubFor(get("/ping").willReturn(aResponse().withStatus(200)));

RestAssured.when().get(this.wiremockUrl + "/ping").then().statusCode(200);
}
RestAssured.when().get(this.wiremockUrl + "/ping").then().statusCode(200);
}
}

0 comments on commit d8a6206

Please sign in to comment.