99import io .contract_testing .contractcase .ExampleDefinition ;
1010import io .contract_testing .contractcase .IndividualFailedTestConfig .IndividualFailedTestConfigBuilder ;
1111import io .contract_testing .contractcase .IndividualSuccessTestConfig .IndividualSuccessTestConfigBuilder ;
12+ import io .contract_testing .contractcase .LogLevel ;
1213import io .contract_testing .contractcase .PublishType ;
1314import io .contract_testing .contractcase .Trigger ;
1415import io .contract_testing .contractcase .case_example_mock_types .mocks .http .HttpExample ;
@@ -39,9 +40,9 @@ public class HttpApiExampleTest {
3940 .contractDir ("temp-contracts" )
4041 .build ());
4142
42- Trigger <String > getHealth = (Map < String , Object > config ) -> {
43+ Trigger <String > getHealth = (setupInfo ) -> {
4344 try {
44- return new ApiClient (( String ) config . get ("baseUrl" )).getHealth ();
45+ return new ApiClient (setupInfo . getInfo ("baseUrl" )).getHealth ();
4546 } catch (IOException e ) {
4647 throw new RuntimeException (e );
4748 }
@@ -86,7 +87,7 @@ public void testHealthUp() {
8687 IndividualSuccessTestConfigBuilder .<String >builder ()
8788 .withProviderName ("Java Example HTTP Server" )
8889 .withTrigger (getHealth )
89- .withTestResponse (status -> {
90+ .withTestResponse (( status , setupInfo ) -> {
9091 assertThat (status , is ("up" ));
9192 })
9293 );
@@ -108,7 +109,7 @@ public void testHealthDown() {
108109 IndividualSuccessTestConfigBuilder .<String >builder ()
109110 .withProviderName ("Java Example HTTP Server" )
110111 .withTrigger (getHealth )
111- .withTestResponse (status -> {
112+ .withTestResponse (( status , setupInfo ) -> {
112113 assertThat (status , is ("down" ));
113114 })
114115 );
@@ -127,7 +128,7 @@ public void testHealthUnavailable() {
127128 IndividualFailedTestConfigBuilder .<String >builder ()
128129 .withProviderName ("Java Example HTTP Server" )
129130 .withTrigger (getHealth )
130- .withTestErrorResponse (exception -> {
131+ .withTestErrorResponse (( exception , setupInfo ) -> {
131132 assertThat (exception .getMessage (), is ("The server is not ready" ));
132133 })
133134 );
@@ -156,16 +157,16 @@ public void testGetUserWithPathVariable() {
156157 ),
157158 IndividualSuccessTestConfigBuilder .<User >builder ()
158159 .withProviderName ("Java Example HTTP Server" )
159- .withTrigger ((config ) -> {
160+ .withTrigger ((setupInfo ) -> {
160161 try {
161- return new ApiClient (( String ) config . get ("baseUrl" ))
162- .getUser ((( Map < String , String >) config . get ( "variables" )). get ("userId" ));
162+ return new ApiClient (setupInfo . getInfo ("baseUrl" ))
163+ .getUser (setupInfo . getStateVariable ("userId" ));
163164 } catch (IOException e ) {
164165 throw new RuntimeException (e );
165166 }
166167 })
167- .withTestResponse (user -> {
168- assertThat (user .userId (), is ("123" ));
168+ .withTestResponse (( user , setupInfo ) -> {
169+ assertThat (user .userId (), is (setupInfo . getStateVariable ( "userId" ) ));
169170 })
170171 );
171172 }
@@ -193,16 +194,16 @@ public void testGetUserWithQueryVariable() {
193194 ),
194195 IndividualSuccessTestConfigBuilder .<User >builder ()
195196 .withProviderName ("Java Example HTTP Server" )
196- .withTrigger ((config ) -> {
197+ .withTrigger ((setupInfo ) -> {
197198 try {
198- return new ApiClient (( String ) config . get ("baseUrl" ))
199- .getUserQuery ((( Map < String , String >) config . get ( "variables" )). get ("userId" ));
199+ return new ApiClient (setupInfo . getInfo ("baseUrl" ))
200+ .getUserQuery (setupInfo . getStateVariable ("userId" ));
200201 } catch (IOException e ) {
201202 throw new RuntimeException (e );
202203 }
203204 })
204- .withTestResponse (user -> {
205- assertThat (user .userId (), is ("123" ));
205+ .withTestResponse (( user , setupInfo ) -> {
206+ assertThat (user .userId (), is (setupInfo . getStateVariable ( "userId" ) ));
206207 })
207208 );
208209 }
@@ -224,15 +225,15 @@ public void testGetUserWithQueryVariableWhenUserNotExist() {
224225 ),
225226 IndividualFailedTestConfigBuilder .<User >builder ()
226227 .withProviderName ("Java Example HTTP Server" )
227- .withTrigger ((config ) -> {
228+ .withTrigger ((setupInfo ) -> {
228229 try {
229- return new ApiClient (( String ) config . get ("baseUrl" ))
230- .getUserQuery ((( Map < String , String >) config . get ( "variables" )). get ("userId" ));
230+ return new ApiClient (setupInfo . getInfo ("baseUrl" ))
231+ .getUserQuery (setupInfo . getStateVariable ("userId" ));
231232 } catch (IOException e ) {
232233 throw new RuntimeException (e );
233234 }
234235 })
235- .withTestErrorResponse (exception -> {
236+ .withTestErrorResponse (( exception , setupInfo ) -> {
236237 assertThat (exception .getClass (), is (UserNotFoundException .class ));
237238 })
238239 );
0 commit comments