-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(V4): add support for status code matchers to JUnit DSL
- Loading branch information
Ronald Holshausen
committed
Jun 6, 2021
1 parent
466ab17
commit c77faa7
Showing
2 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...mer/junit/src/test/java/au/com/dius/pact/consumer/junit/v4/StatusCodeMatcherPactTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package au.com.dius.pact.consumer.junit.v4; | ||
|
||
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; | ||
import au.com.dius.pact.consumer.junit.PactProviderRule; | ||
import au.com.dius.pact.consumer.junit.PactVerification; | ||
import au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient; | ||
import au.com.dius.pact.core.model.PactSpecVersion; | ||
import au.com.dius.pact.core.model.V4Pact; | ||
import au.com.dius.pact.core.model.annotations.Pact; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class StatusCodeMatcherPactTest { | ||
|
||
@Rule | ||
public PactProviderRule mockTestProvider = new PactProviderRule("test_provider", PactSpecVersion.V4, this); | ||
|
||
@Pact(provider="test_provider", consumer="v4_test_consumer") | ||
public V4Pact createFragment(PactDslWithProvider builder) { | ||
return builder | ||
.uponReceiving("test interaction") | ||
.path("/") | ||
.method("GET") | ||
.willRespondWith() | ||
.successStatus() | ||
.body("{\"responsetest\": true, \"version\": \"v3\"}") | ||
.toPact(V4Pact.class); | ||
} | ||
|
||
@Test | ||
@PactVerification | ||
public void runTest() throws IOException { | ||
Map expectedResponse = Map.of("responsetest", true, "version", "v3"); | ||
assertEquals(new ConsumerClient(mockTestProvider.getUrl()).getAsMap("/", ""), expectedResponse); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters