-
-
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(JUnit5): Support verification tests for sync request/response me…
…ssages with MessageTestTarget #1681
- Loading branch information
1 parent
1721cb0
commit c07f707
Showing
9 changed files
with
453 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
31 changes: 31 additions & 0 deletions
31
...junit5/src/test/java/au/com/dius/pact/provider/junit5/SynchronousMessageContractTest.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,31 @@ | ||
package au.com.dius.pact.provider.junit5; | ||
|
||
import au.com.dius.pact.core.model.Interaction; | ||
import au.com.dius.pact.core.model.Pact; | ||
import au.com.dius.pact.core.model.v4.MessageContents; | ||
import au.com.dius.pact.provider.PactVerifyProvider; | ||
import au.com.dius.pact.provider.junitsupport.Provider; | ||
import au.com.dius.pact.provider.junitsupport.loader.PactFolder; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.TestTemplate; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@Provider("KafkaRequestReplyProvider") | ||
@PactFolder("src/test/resources/amqp_pacts") | ||
class SynchronousMessageContractTest { | ||
@TestTemplate | ||
@ExtendWith(PactVerificationInvocationContextProvider.class) | ||
void testTemplate(Pact pact, Interaction interaction, PactVerificationContext context) { | ||
context.verifyInteraction(); | ||
} | ||
|
||
@BeforeEach | ||
void before(PactVerificationContext context) { | ||
context.setTarget(new MessageTestTarget()); | ||
} | ||
|
||
@PactVerifyProvider("a test message") | ||
public String verifyMessageForOrder(MessageContents request) { | ||
return "{\"name\": \"Fred\", \"testParam1\": \"value1\",\"testParam2\": \"value2\"}"; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
provider/junit5/src/test/resources/amqp_pacts/kafka-request-reply.json
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,77 @@ | ||
{ | ||
"consumer": { | ||
"name": "KafkaRequestReplyConsumer" | ||
}, | ||
"interactions": [ | ||
{ | ||
"comments": { | ||
"testname": "com.techgalery.springkafkaclient.PactTest.test(SynchronousMessages)" | ||
}, | ||
"description": "a test message", | ||
"key": "c13464bf", | ||
"pending": false, | ||
"request": { | ||
"contents": { | ||
"content": { | ||
"name": "abcd123" | ||
}, | ||
"contentType": "application/json", | ||
"encoded": false | ||
}, | ||
"matchingRules": { | ||
"body": { | ||
"$.name": { | ||
"combine": "AND", | ||
"matchers": [ | ||
{ | ||
"match": "type" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"metadata": { | ||
"contentType": "application/json" | ||
} | ||
}, | ||
"response": [ | ||
{ | ||
"contents": { | ||
"content": { | ||
"name": "321dcba" | ||
}, | ||
"contentType": "application/json", | ||
"encoded": false | ||
}, | ||
"matchingRules": { | ||
"body": { | ||
"$.name": { | ||
"combine": "AND", | ||
"matchers": [ | ||
{ | ||
"match": "type" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"metadata": { | ||
"contentType": "application/json" | ||
} | ||
} | ||
], | ||
"type": "Synchronous/Messages" | ||
} | ||
], | ||
"metadata": { | ||
"pact-jvm": { | ||
"version": "4.5.3" | ||
}, | ||
"pactSpecification": { | ||
"version": "4.0" | ||
} | ||
}, | ||
"provider": { | ||
"name": "KafkaRequestReplyProvider" | ||
} | ||
} |
Oops, something went wrong.