1
1
package pl .pawelosinski .dynatrace .nbp .task .backend .service ;
2
2
3
3
import com .github .tomakehurst .wiremock .WireMockServer ;
4
- import com .github .tomakehurst .wiremock .junit .WireMockRule ;
5
- import org .junit .Rule ;
6
4
import org .junit .jupiter .api .*;
7
5
import org .junit .runner .RunWith ;
8
6
import org .springframework .beans .factory .annotation .Autowired ;
9
7
import org .springframework .boot .test .context .SpringBootTest ;
10
8
import org .springframework .boot .test .web .client .TestRestTemplate ;
9
+ import org .springframework .test .context .ActiveProfiles ;
11
10
import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
12
- import org .springframework .test .context .web .WebAppConfiguration ;
13
- import org .springframework .test .web .servlet .MockMvc ;
14
- import org .springframework .test .web .servlet .setup .MockMvcBuilders ;
15
11
import org .springframework .web .client .HttpClientErrorException ;
16
- import org .springframework .web .context .WebApplicationContext ;
17
12
import pl .pawelosinski .dynatrace .nbp .task .backend .model .CurrencyRateTable ;
18
13
19
14
import static com .github .tomakehurst .wiremock .client .WireMock .*;
23
18
@ RunWith (SpringJUnit4ClassRunner .class )
24
19
@ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .RANDOM_PORT )
25
20
@ TestInstance (TestInstance .Lifecycle .PER_CLASS )
21
+ @ ActiveProfiles ("integration" )
26
22
public class CurrencyServiceTests {
27
23
28
24
@ Autowired
@@ -31,7 +27,7 @@ public class CurrencyServiceTests {
31
27
@ Autowired
32
28
private TestRestTemplate restTemplate ;
33
29
34
- private final WireMockServer wireMockServer = new WireMockServer (8080 );
30
+ private final WireMockServer wireMockServer = new WireMockServer (8123 );
35
31
36
32
@ BeforeAll
37
33
void startWireMock () {
@@ -56,9 +52,9 @@ public void shouldGetRateFromDay() throws Exception {
56
52
String currency = "gbp" ;
57
53
String date = "2012-01-02" ;
58
54
59
- configureFor ("localhost" , 8080 );
55
+ configureFor ("localhost" , 8123 );
60
56
61
- stubFor (get (urlPathEqualTo ( "http://api.nbp.pl /api/exchangerates/rates/a/gbp/2012-01-02/?format=json" ))
57
+ stubFor (get (urlEqualTo ( " /api/exchangerates/rates/a/gbp/2012-01-02/?format=json" ))
62
58
.willReturn (aResponse ()
63
59
.withHeader ("Content-Type" , "application/json" )
64
60
.withBodyFile ("fromDay.json" )));
@@ -79,7 +75,7 @@ public void shouldNotGetAnyResultFromDay() {
79
75
// Given
80
76
String currency = "USD" ;
81
77
String date = "2023-04-22" ;
82
- stubFor (get (urlPathEqualTo ( "http://api.nbp.pl /api/exchangerates/rates/a/USD/2023-04-22/?format=json" ))
78
+ stubFor (get (urlEqualTo ( " /api/exchangerates/rates/a/USD/2023-04-22/?format=json" ))
83
79
.willReturn (aResponse ().withStatus (404 )));
84
80
85
81
0 commit comments