Skip to content

Commit b0084ca

Browse files
committed
add integration tests: transfer offers
1 parent 05dd262 commit b0084ca

File tree

7 files changed

+728
-0
lines changed

7 files changed

+728
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.amadeus.shopping.availability;
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.exceptions.ResponseException;
10+
import com.amadeus.resources.TransferOffersPost;
11+
import com.github.tomakehurst.wiremock.WireMockServer;
12+
import com.google.gson.JsonObject;
13+
import com.google.gson.JsonParser;
14+
import java.io.File;
15+
import java.io.IOException;
16+
import java.nio.file.Files;
17+
import org.junit.jupiter.api.AfterEach;
18+
import org.junit.jupiter.api.BeforeEach;
19+
import org.junit.jupiter.api.Test;
20+
21+
// https://developers.amadeus.com/self-service/category/cars-and-transfers/api-doc/transfer-search
22+
public class TransferOffersIT {
23+
24+
WireMockServer wireMockServer;
25+
26+
private Amadeus amadeus;
27+
28+
/**
29+
* Authentication is conducted for each test.
30+
*/
31+
@BeforeEach
32+
public void setup() {
33+
wireMockServer = new WireMockServer(8080);
34+
wireMockServer.start();
35+
36+
//https://developers.amadeus.com/self-service/apis-docs/guides/authorization-262
37+
String address = "/v1/security/oauth2/token"
38+
+ "?grant_type=client_credentials&client_secret=DEMO&client_id=DEMO";
39+
wireMockServer.stubFor(post(urlEqualTo(address))
40+
.willReturn(aResponse().withHeader("Content-Type", "application/json")
41+
.withStatus(200)
42+
.withBodyFile("auth_ok.json")));
43+
44+
amadeus = Amadeus
45+
.builder("DEMO", "DEMO")
46+
.setHost("localhost")
47+
.setPort(8080)
48+
.setSsl(false)
49+
.setLogLevel("debug")
50+
.build();
51+
}
52+
53+
@AfterEach
54+
public void teardown() {
55+
wireMockServer.stop();
56+
}
57+
58+
@Test
59+
public void givenClientWhenCallTransferOffersWithParamsThenOK()
60+
throws ResponseException, IOException {
61+
62+
//Given
63+
String address = "/v1/shopping/transfer-offers";
64+
wireMockServer.stubFor(post(urlEqualTo(address))
65+
.willReturn(aResponse().withHeader("Content-Type", "application/json")
66+
.withStatus(200)
67+
.withBodyFile("transfer_offers_response_ok.json")));
68+
69+
JsonObject request = getRequestFromResources("transfer_offers_request_ok.json");
70+
71+
//When
72+
TransferOffersPost[] result = amadeus.shopping.transferOffers.post(request);
73+
74+
//Then
75+
assertNotNull(result);
76+
}
77+
78+
private JsonObject getRequestFromResources(String jsonFile) throws IOException {
79+
80+
final String folder = "__files/";
81+
82+
ClassLoader classLoader = getClass().getClassLoader();
83+
File file = new File(classLoader.getResource(folder + jsonFile).getFile());
84+
String jsonString = new String(Files.readAllBytes(file.toPath()));
85+
86+
return new JsonParser().parse(jsonString).getAsJsonObject();
87+
}
88+
89+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"startLocationCode": "CDG",
3+
"endAddressLine": "Avenue Anatole France, 5",
4+
"endCityName": "Paris",
5+
"endZipCode": "75007",
6+
"endCountryCode": "FR",
7+
"endName": "Souvenirs De La Tour",
8+
"endGooglePlaceId": "ChIJL-DOWeBv5kcRfTbh97PimNc",
9+
"endGeoCode": "48.859466,2.2976965",
10+
"transferType": "PRIVATE",
11+
"startDateTime": "2021-11-10T10:30:00",
12+
"providerCodes": "TXO",
13+
"passengers": 2,
14+
"stopOvers": [
15+
{
16+
"duration": "PT2H30M",
17+
"sequenceNumber": 1,
18+
"addressLine": "Avenue de la Bourdonnais, 19",
19+
"countryCode": "FR",
20+
"cityName": "Paris",
21+
"zipCode": "75007",
22+
"googlePlaceId": "DOWeBv5kcRfTbh97PimN",
23+
"name": "De La Tours",
24+
"geoCode": "48.859477,2.2976985",
25+
"stateCode": "FR"
26+
}
27+
],
28+
"startConnectedSegment": {
29+
"transportationType": "FLIGHT",
30+
"transportationNumber": "AF380",
31+
"departure": {
32+
"localDateTime": "2021-11-10T09:00:00",
33+
"iataCode": "NCE"
34+
},
35+
"arrival": {
36+
"localDateTime": "2021-11-10T10:00:00",
37+
"iataCode": "CDG"
38+
}
39+
},
40+
"passengerCharacteristics": [
41+
{
42+
"passengerTypeCode": "ADT",
43+
"age": 20
44+
},
45+
{
46+
"passengerTypeCode": "CHD",
47+
"age": 10
48+
}
49+
]
50+
}
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
{
2+
"data": [
3+
{
4+
"type": "transfer-offer",
5+
"id": "0cb11574-4a02-11e8-842f-0ed5f89f718b",
6+
"transferType": "PRIVATE",
7+
"start": {
8+
"dateTime": "2021-11-10T10:30:00",
9+
"locationCode": "CDG"
10+
},
11+
"end": {
12+
"address": {
13+
"line": "Avenue Anatole France, 5",
14+
"zip": "75007",
15+
"countryCode": "FR",
16+
"cityName": "Paris",
17+
"latitude": 48.859466,
18+
"longitude": 2.2976965
19+
},
20+
"googlePlaceId": "ChIJL-DOWeBv5kcRfTbh97PimNc",
21+
"name": "Souvenirs De La Tour"
22+
},
23+
"stopOvers": [
24+
{
25+
"duration": "PT2H30M",
26+
"sequenceNumber": 1,
27+
"location": {
28+
"locationCode": "CDG",
29+
"address": {
30+
"line": "Avenue de la Bourdonnais, 19",
31+
"zip": "75007",
32+
"countryCode": "FR",
33+
"cityName": "Paris",
34+
"latitude": 48.859477,
35+
"longitude": 2.2976975
36+
},
37+
"googlePlaceId": "DOWeBv5kcRfTbh97PimN",
38+
"name": "De La Tours"
39+
}
40+
}
41+
],
42+
"vehicle": {
43+
"code": "VAN",
44+
"category": "BU",
45+
"description": "Mercedes-Benz V-Class, Chevrolet Suburban, Cadillac Escalade or similar",
46+
"seats": [
47+
{
48+
"count": 3
49+
}
50+
],
51+
"baggages": [
52+
{
53+
"count": 3,
54+
"size": "M"
55+
}
56+
],
57+
"imageURL": "https://provider.com/images/BU_VAN.png"
58+
},
59+
"serviceProvider": {
60+
"code": "ABC",
61+
"name": "Provider name",
62+
"logoUrl": "https://provider.com/images/logo.png",
63+
"termsUrl": "https://provider.com/terms_and_conditions.html",
64+
"contacts": {
65+
"phoneNumber": "+33123456789",
66+
"email": "[email protected]"
67+
},
68+
"settings": [
69+
"BILLING_ADDRESS_REQUIRED",
70+
"FLIGHT_NUMBER_REQUIRED",
71+
"CVV_NUMBER_REQUIRED"
72+
]
73+
},
74+
"quotation": {
75+
"monetaryAmount": "63.70",
76+
"currencyCode": "USD",
77+
"isEstimated": false,
78+
"base": {
79+
"monetaryAmount": "103.70"
80+
},
81+
"discount": {
82+
"monetaryAmount": "50.00"
83+
},
84+
"fees": [
85+
{
86+
"indicator": "AIRPORT",
87+
"monetaryAmount": "10.00"
88+
}
89+
],
90+
"totalTaxes": {
91+
"monetaryAmount": "12.74"
92+
},
93+
"totalFees": {
94+
"monetaryAmount": "10.00"
95+
}
96+
},
97+
"converted": {
98+
"monetaryAmount": "63.70",
99+
"currencyCode": "EUR",
100+
"isEstimated": false,
101+
"base": {
102+
"monetaryAmount": "103.70"
103+
},
104+
"discount": {
105+
"monetaryAmount": "50.00"
106+
},
107+
"fees": [
108+
{
109+
"indicator": "AIRPORT",
110+
"monetaryAmount": "10.00"
111+
}
112+
],
113+
"totalTaxes": {
114+
"monetaryAmount": "12.74"
115+
},
116+
"totalFees": {
117+
"monetaryAmount": "10.00"
118+
}
119+
},
120+
"extraServices": [
121+
{
122+
"code": "EWT",
123+
"itemId": "EWT0291",
124+
"description": "Extra 15 min. wait",
125+
"quotation": {
126+
"monetaryAmount": "39.20",
127+
"currencyCode": "USD",
128+
"base": {
129+
"monetaryAmount": "36.00"
130+
},
131+
"totalTaxes": {
132+
"monetaryAmount": "3.20"
133+
}
134+
},
135+
"converted": {
136+
"monetaryAmount": "32.70",
137+
"currencyCode": "EUR",
138+
"base": {
139+
"monetaryAmount": "30.00"
140+
},
141+
"totalTaxes": {
142+
"monetaryAmount": "2.7"
143+
}
144+
},
145+
"isBookable": true,
146+
"taxIncluded": true,
147+
"includedInTotal": false
148+
}
149+
],
150+
"equipment": [
151+
{
152+
"code": "BBS",
153+
"description": "Baby stroller or Push chair",
154+
"quotation": {
155+
"monetaryAmount": "39.20",
156+
"currencyCode": "USD",
157+
"base": {
158+
"monetaryAmount": "36.00"
159+
},
160+
"totalTaxes": {
161+
"monetaryAmount": "3.20"
162+
}
163+
},
164+
"converted": {
165+
"monetaryAmount": "32.70",
166+
"currencyCode": "EUR",
167+
"base": {
168+
"monetaryAmount": "30.00"
169+
},
170+
"totalTaxes": {
171+
"monetaryAmount": "2.7"
172+
}
173+
},
174+
"isBookable": true,
175+
"taxIncluded": true,
176+
"includedInTotal": false
177+
}
178+
],
179+
"cancellationRules": [
180+
{
181+
"feeType": "PERCENTAGE",
182+
"feeValue": "100",
183+
"metricType": "DAYS",
184+
"metricMin": "0",
185+
"metricMax": "1"
186+
},
187+
{
188+
"feeType": "PERCENTAGE",
189+
"feeValue": "0",
190+
"metricType": "DAYS",
191+
"metricMin": "1",
192+
"metricMax": "100"
193+
}
194+
],
195+
"methodsOfPaymentAccepted": [
196+
"CREDIT_CARD",
197+
"INVOICE"
198+
],
199+
"discountCodes": [
200+
{
201+
"type": "CD",
202+
"value": "FJKS0289LDIW234"
203+
}
204+
],
205+
"distance": {
206+
"value": 152,
207+
"unit": "KM"
208+
},
209+
"startConnectedSegment": {
210+
"transportationType": "FLIGHT",
211+
"transportationNumber": "AF380",
212+
"departure": {
213+
"localDateTime": "2021-11-10T09:00:00",
214+
"iataCode": "NCE"
215+
},
216+
"arrival": {
217+
"localDateTime": "2021-11-10T10:00:00",
218+
"iataCode": "CDG"
219+
}
220+
},
221+
"passengerCharacteristics": [
222+
{
223+
"passengerTypeCode": "ADT",
224+
"age": 20
225+
},
226+
{
227+
"passengerTypeCode": "CHD",
228+
"age": 10
229+
}
230+
]
231+
}
232+
],
233+
"warnings": [
234+
{
235+
"code": 101,
236+
"title": "PICK-UP DATE TIME CHANGED",
237+
"detail": "Transfer pick-up date and time have been changed by provider",
238+
"source": {
239+
"pointer": "/data/1/start/dateTime",
240+
"parameter": "dateTime"
241+
}
242+
}
243+
]
244+
}

src/test/resources/__files/transfer_orders_management_request_ok.json

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"data": {
3+
"confirmNbr": "2904892",
4+
"reservationStatus": "CANCELLED"
5+
}
6+
}

0 commit comments

Comments
 (0)