Skip to content

Commit 0f0dd15

Browse files
committed
add integration tests for transfer cancellation
1 parent 5a02bc5 commit 0f0dd15

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.amadeus.ordering.transferOrders.transfers;
2+
3+
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
4+
import static com.github.tomakehurst.wiremock.client.WireMock.post;
5+
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
6+
import static org.junit.jupiter.api.Assertions.assertNotNull;
7+
8+
import com.amadeus.Amadeus;
9+
import com.amadeus.Params;
10+
import com.amadeus.exceptions.ResponseException;
11+
import com.amadeus.resources.TransferCancellation;
12+
import com.github.tomakehurst.wiremock.WireMockServer;
13+
import com.google.gson.JsonObject;
14+
import com.google.gson.JsonParser;
15+
import java.io.File;
16+
import java.io.IOException;
17+
import java.nio.file.Files;
18+
import org.junit.jupiter.api.AfterEach;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
21+
22+
// https://developers.amadeus.com/self-service/category/cars-and-transfers/api-doc/transfer-management
23+
public class CancellationIT {
24+
25+
WireMockServer wireMockServer;
26+
27+
private Amadeus amadeus;
28+
29+
/**
30+
* Authentication is conducted for each test.
31+
*/
32+
@BeforeEach
33+
public void setup() {
34+
wireMockServer = new WireMockServer(8080);
35+
wireMockServer.start();
36+
37+
// https://developers.amadeus.com/self-service/apis-docs/guides/authorization-262
38+
String address = "/v1/security/oauth2/token"
39+
+ "?grant_type=client_credentials&client_secret=DEMO&client_id=DEMO";
40+
wireMockServer.stubFor(post(urlEqualTo(address))
41+
.willReturn(aResponse().withHeader("Content-Type", "application/json")
42+
.withStatus(200)
43+
.withBodyFile("auth_ok.json")));
44+
45+
amadeus = Amadeus
46+
.builder("DEMO", "DEMO")
47+
.setHost("localhost")
48+
.setPort(8080)
49+
.setSsl(false)
50+
.setLogLevel("debug")
51+
.build();
52+
}
53+
54+
@AfterEach
55+
public void teardown() {
56+
wireMockServer.stop();
57+
}
58+
59+
@Test
60+
public void givenClientWhenCallTransferOrdersWithParamsThenOK()
61+
throws ResponseException, IOException {
62+
63+
//Given
64+
String address = "/v1/ordering/transfer-orders/123456/transfers/cancellation" + "?confirmNmb=12029761";
65+
wireMockServer.stubFor(post(urlEqualTo(address))
66+
.willReturn(aResponse().withHeader("Content-Type", "application/json")
67+
.withStatus(200)
68+
.withBodyFile("transfer_orders_management_response_ok.json")));
69+
Params params = Params.with("confirmNmb", "12029761");
70+
71+
//When
72+
TransferCancellation result = amadeus.ordering
73+
.transferOrder("123456").transfers.cancellation.post(params);
74+
75+
//Then
76+
assertNotNull(result);
77+
}
78+
79+
}

0 commit comments

Comments
 (0)