Skip to content

Commit

Permalink
✨ update wiremock 2 -> 3
Browse files Browse the repository at this point in the history
  • Loading branch information
nilwurtz committed Aug 31, 2023
1 parent 2c5bc80 commit 3f0dd56
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

### Changed

## [0.6.0] - 2023-08-31
### Changed
- Update wiremock 2.27.2 -> 3.0.0!
- `withRequestQueryAndVariables` method has been changed to deprecate.

## [0.5.0] - 2023-08-11
Expand Down
46 changes: 8 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Graphql Wiremock Extension - Graphql Body Matcher

*A extension for GraphQL testing with Wiremock*
⚠️ **IMPORTANT**: Starting from version 0.6, this extension requires WireMock 3.x. WireMock 2.x is no longer supported from this version onwards.

*An extension for GraphQL testing with Wiremock*

GraphqlBodyMatcher is an extension for [WireMock](https://wiremock.org/) that allows for semantical verification of GraphQL requests.

Expand Down Expand Up @@ -28,7 +30,7 @@ repositories {
}
dependencies {
testImplementation 'io.github.nilwurtz:wiremock-graphql-extension:0.5.0'
testImplementation 'io.github.nilwurtz:wiremock-graphql-extension:0.6.0'
}
```

Expand All @@ -38,7 +40,7 @@ dependencies {
<dependency>
<groupId>io.github.nilwurtz</groupId>
<artifactId>wiremock-graphql-extension</artifactId>
<version>0.5.0</version>
<version>0.6.0</version>
<scope>test</scope>
</dependency>
```
Expand Down Expand Up @@ -87,39 +89,7 @@ WireMock.stubFor(
)
```

The `withRequestQueryAndVariables` method can also be used:

```kotlin
import io.github.nilwurtz.GraphqlBodyMatcher

WireMock.stubFor(
WireMock.post(WireMock.urlEqualTo("/graphql"))
.andMatching(GraphqlBodyMatcher.withRequestQueryAndVariables("{ hero { name }}"))
.willReturn(WireMock.ok())
)
```

```kotlin
val expectedQuery = """
query HeroInfo($id: Int) {
hero(id: $id) {
name
}
}
""".trimIndent()

val expectedVariables = """
{
"id": 1
}
""".trimIndent()

WireMock.stubFor(
WireMock.post(WireMock.urlEqualTo("/graphql"))
.andMatching(GraphqlBodyMatcher.withRequestQueryAndVariables(expectedQuery, expectedVariables))
.willReturn(WireMock.ok())
)
```
The `withRequestQueryAndVariables` method has been deprecated from version 0.6.0 onwards. Please use `withRequestJson` instead.

## Running with a Remote Wiremock Server 🌍

Expand All @@ -133,15 +103,15 @@ Please download `wiremock-graphql-extension-x.y.z-jar-with-dependencies.jar` fro
docker run -it --rm \
-p 8080:8080 \
--name wiremock \
-v /path/to/wiremock-graphql-extension-0.5.0-jar-with-dependencies.jar:/var/wiremock/extensions/wiremock-graphql-extension-0.5.0-jar-with-dependencies.jar \
-v /path/to/wiremock-graphql-extension-0.6.0-jar-with-dependencies.jar:/var/wiremock/extensions/wiremock-graphql-extension-0.6.0-jar-with-dependencies.jar \
wiremock/wiremock \
--extensions io.github.nilwurtz.GraphqlBodyMatcher
```

#### When building with `docker build`:
```dockerfile
FROM wiremock/wiremock:latest
COPY ./wiremock-graphql-extension-0.5.0-jar-with-dependencies.jar /var/wiremock/extensions/wiremock-graphql-extension-0.5.0-jar-with-dependencies.jar
COPY ./wiremock-graphql-extension-0.6.0-jar-with-dependencies.jar /var/wiremock/extensions/wiremock-graphql-extension-0.6.0-jar-with-dependencies.jar
CMD ["--extensions", "io.github.nilwurtz.GraphqlBodyMatcher"]
```

Expand Down
6 changes: 3 additions & 3 deletions e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<kotlin.compiler.jvmTarget>${java.version}</kotlin.compiler.jvmTarget>
<gauge.java.version>0.9.1</gauge.java.version>
<gauge.maven.version>1.5.0</gauge.maven.version>
<wiremock.version>2.27.2</wiremock.version>
<wiremock.version>3.0.0</wiremock.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand All @@ -36,8 +36,8 @@
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions wiremock-graphql-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<gpg.skip>true</gpg.skip>
<kotlin.version>1.8.20</kotlin.version>
<junit.version>5.9.2</junit.version>
<wiremock.version>2.27.2</wiremock.version>
<wiremock.version>3.0.0</wiremock.version>
<graphql-java.version>20.2</graphql-java.version>
</properties>

Expand Down Expand Up @@ -66,7 +66,7 @@
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>${wiremock.version}</version>
</dependency>
Expand Down

1 comment on commit 3f0dd56

@nilwurtz
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resolves #4

Please sign in to comment.