22
33import com .baeldung .cloud .openfeign .ExampleApplication ;
44import com .github .tomakehurst .wiremock .WireMockServer ;
5+
56import org .junit .jupiter .api .AfterEach ;
67import org .junit .jupiter .api .BeforeEach ;
78import org .junit .jupiter .api .Disabled ;
@@ -43,8 +44,7 @@ public void startWireMockServer() {
4344 configureFor ("localhost" , 8083 );
4445 wireMockServer .start ();
4546
46- stubFor (post (urlEqualTo ("/reports" ))
47- .willReturn (aResponse ().withStatus (HttpStatus .OK .value ())));
47+ stubFor (post (urlEqualTo ("/reports" )).willReturn (aResponse ().withStatus (HttpStatus .OK .value ())));
4848 }
4949
5050 @ AfterEach
@@ -53,10 +53,9 @@ public void stopWireMockServer() {
5353 }
5454
5555 @ Test
56- void givenRestCalls_whenBothReturnsOk_thenReturnCorrectResult ()
57- throws ExecutionException , InterruptedException {
58- stubFor (get (urlEqualTo ("/payment_methods?site_id=BR" ))
59- .willReturn (aResponse ().withStatus (HttpStatus .OK .value ()).withBody ("credit_card" )));
56+ void givenRestCalls_whenBothReturnsOk_thenReturnCorrectResult () throws ExecutionException , InterruptedException {
57+ stubFor (get (urlEqualTo ("/payment_methods?site_id=BR" )).willReturn (aResponse ().withStatus (HttpStatus .OK .value ())
58+ .withBody ("credit_card" )));
6059
6160 String result = purchaseService .executePurchase ("BR" );
6261
@@ -65,10 +64,8 @@ void givenRestCalls_whenBothReturnsOk_thenReturnCorrectResult()
6564 }
6665
6766 @ Test
68- void givenRestCalls_whenPurchaseReturns404_thenReturnDefault ()
69- throws ExecutionException , InterruptedException {
70- stubFor (get (urlEqualTo ("/payment_methods?site_id=BR" ))
71- .willReturn (aResponse ().withStatus (HttpStatus .NOT_FOUND .value ())));
67+ void givenRestCalls_whenPurchaseReturns404_thenReturnDefault () throws ExecutionException , InterruptedException {
68+ stubFor (get (urlEqualTo ("/payment_methods?site_id=BR" )).willReturn (aResponse ().withStatus (HttpStatus .NOT_FOUND .value ())));
7269
7370 String result = purchaseService .executePurchase ("BR" );
7471
@@ -79,8 +76,7 @@ void givenRestCalls_whenPurchaseReturns404_thenReturnDefault()
7976 @ Test
8077 @ Disabled
8178 void givenRestCalls_whenPurchaseCompletableFutureTimeout_thenThrowNewException () {
82- stubFor (get (urlEqualTo ("/payment_methods?site_id=BR" ))
83- .willReturn (aResponse ().withFixedDelay (550 )));
79+ stubFor (get (urlEqualTo ("/payment_methods?site_id=BR" )).willReturn (aResponse ().withFixedDelay (550 )));
8480
8581 Throwable error = assertThrows (ExecutionException .class , () -> purchaseService .executePurchase ("BR" ));
8682
@@ -89,8 +85,7 @@ void givenRestCalls_whenPurchaseCompletableFutureTimeout_thenThrowNewException()
8985
9086 @ Test
9187 void givenRestCalls_whenPurchaseRequestWebTimeout_thenThrowNewException () {
92- stubFor (get (urlEqualTo ("/payment_methods?site_id=BR" ))
93- .willReturn (aResponse ().withFixedDelay (250 )));
88+ stubFor (get (urlEqualTo ("/payment_methods?site_id=BR" )).willReturn (aResponse ().withFixedDelay (250 )));
9489
9590 Throwable error = assertThrows (ExecutionException .class , () -> purchaseService .executePurchase ("BR" ));
9691
0 commit comments