2
2
3
3
import com .baeldung .cloud .openfeign .ExampleApplication ;
4
4
import com .github .tomakehurst .wiremock .WireMockServer ;
5
+
5
6
import org .junit .jupiter .api .AfterEach ;
6
7
import org .junit .jupiter .api .BeforeEach ;
7
8
import org .junit .jupiter .api .Disabled ;
@@ -43,8 +44,7 @@ public void startWireMockServer() {
43
44
configureFor ("localhost" , 8083 );
44
45
wireMockServer .start ();
45
46
46
- stubFor (post (urlEqualTo ("/reports" ))
47
- .willReturn (aResponse ().withStatus (HttpStatus .OK .value ())));
47
+ stubFor (post (urlEqualTo ("/reports" )).willReturn (aResponse ().withStatus (HttpStatus .OK .value ())));
48
48
}
49
49
50
50
@ AfterEach
@@ -53,10 +53,9 @@ public void stopWireMockServer() {
53
53
}
54
54
55
55
@ 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" )));
60
59
61
60
String result = purchaseService .executePurchase ("BR" );
62
61
@@ -65,10 +64,8 @@ void givenRestCalls_whenBothReturnsOk_thenReturnCorrectResult()
65
64
}
66
65
67
66
@ 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 ())));
72
69
73
70
String result = purchaseService .executePurchase ("BR" );
74
71
@@ -79,8 +76,7 @@ void givenRestCalls_whenPurchaseReturns404_thenReturnDefault()
79
76
@ Test
80
77
@ Disabled
81
78
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 )));
84
80
85
81
Throwable error = assertThrows (ExecutionException .class , () -> purchaseService .executePurchase ("BR" ));
86
82
@@ -89,8 +85,7 @@ void givenRestCalls_whenPurchaseCompletableFutureTimeout_thenThrowNewException()
89
85
90
86
@ Test
91
87
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 )));
94
89
95
90
Throwable error = assertThrows (ExecutionException .class , () -> purchaseService .executePurchase ("BR" ));
96
91
0 commit comments