Skip to content

Commit 4c49cce

Browse files
committed
fix(java-dsl): Add throws Exception to the signature of the response test methods, so you don't need to re-throw exceptions as RuntimeException
1 parent ef72510 commit 4c49cce

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
package io.contract_testing.contractcase.configuration;
22

3-
import io.contract_testing.contractcase.configuration.InteractionSetup;
4-
53
public interface TestErrorResponseFunction {
64

7-
void call(Exception e, InteractionSetup config);
5+
/**
6+
* Called by the framework to test an exception that you expected to throw from your interaction.
7+
* <p>
8+
* Implement this method with whatever assertions and tests you need to verify that the exception
9+
* was the one you expected.
10+
*
11+
* @param e The exception thrown by your trigger function.
12+
* @param config the interaction setup, useful if you need state variables or other context
13+
* @throws Exception Any exceptions thrown during your verification. Throwing an exception from
14+
* this method will fail the interaction.
15+
*/
16+
void call(Exception e, InteractionSetup config) throws Exception;
817
}
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
package io.contract_testing.contractcase.configuration;
22

3-
import io.contract_testing.contractcase.configuration.InteractionSetup;
4-
53
public interface TestResponseFunction<T> {
64

7-
void call(T returnedObject, InteractionSetup config);
5+
/**
6+
* Called by the framework to test the response from your interaction's trigger function..
7+
* <p>
8+
* Implement this method with whatever assertions and tests you need to verify that you have
9+
* unmarshalled the expected object correctly.
10+
*
11+
* @param returnedObject The object returned from your trigger function.
12+
* @param config the interaction setup, useful if you need state variables or other
13+
* context
14+
* @throws Exception Any exceptions thrown during your verification. Throwing an exception from
15+
* this method will fail the interaction.
16+
*/
17+
void call(T returnedObject, InteractionSetup config) throws Exception;
818
}

0 commit comments

Comments
 (0)