|
2 | 2 |
|
3 | 3 | import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; |
4 | 4 | import static java.net.HttpURLConnection.HTTP_OK; |
5 | | -import static java.util.Collections.singletonList; |
6 | 5 | import java.io.IOException; |
7 | 6 | import java.util.ArrayList; |
8 | 7 | import java.util.Arrays; |
@@ -1046,108 +1045,4 @@ public void testCreateOrderEventWithCryptoFields() throws JSONException, IOExcep |
1046 | 1045 |
|
1047 | 1046 | server.shutdown(); |
1048 | 1047 | } |
1049 | | - |
1050 | | - @Test |
1051 | | - public void testCreateOrderEventBookingWithPromoWithAmountUsd() throws JSONException, |
1052 | | - IOException, InterruptedException { |
1053 | | - |
1054 | | - // The expected JSON payload of the request. |
1055 | | - String expectedRequestBody = "{\n" + |
1056 | | - " \"$type\" : \"$create_order\",\n" + |
1057 | | - " \"$api_key\" : \"YOUR_API_KEY\",\n" + |
1058 | | - " \"$user_id\" : \"billy_jones_301\",\n" + |
1059 | | - "\n" + |
1060 | | - " \"$order_id\" : \"ORDER-28168441\",\n" + |
1061 | | - " \"$user_email\" : \"bill@gmail.com\",\n" + |
1062 | | - " \"$amount\" : 115940000,\n" + |
1063 | | - " \"$amount_usd\" : 155540000,\n" + |
1064 | | - " \"$currency_code\" : \"EUR\",\n" + |
1065 | | - " \"$payment_methods\" : [\n" + |
1066 | | - " {\n" + |
1067 | | - " \"$payment_type\" : \"$credit_card\",\n" + |
1068 | | - " \"$payment_gateway\" : \"$braintree\",\n" + |
1069 | | - " \"$card_bin\" : \"542486\",\n" + |
1070 | | - " \"$card_last4\" : \"4444\",\n" + |
1071 | | - " \"$card_bin_country\": \"US\",\n" + |
1072 | | - " \"$card_type\" : \"Gold\",\n" + |
1073 | | - " \"$card_brand\" : \"Visa\"\n" + |
1074 | | - " }\n" + |
1075 | | - " ],\n" + |
1076 | | - " \"$bookings\": [\n" + |
1077 | | - " {\n" + |
1078 | | - " \"$booking_type\": \"$flight\",\n" + |
1079 | | - " \"$title\": \"SFO - LAS, 2 Adults\",\n" + |
1080 | | - " \"$start_time\": 12038412903,\n" + |
1081 | | - " \"$end_time\": 12048412903,\n" + |
1082 | | - " \"$price\": 49900000,\n" + |
1083 | | - " \"$price_usd\": 55500000,\n" + |
1084 | | - " \"$currency_code\": \"EUR\",\n" + |
1085 | | - " \"$quantity\": 1,\n" + |
1086 | | - " }\n" + |
1087 | | - " ],\n" + |
1088 | | - "\n" + |
1089 | | - " \"$promotions\" : [\n" + |
1090 | | - " {\n" + |
1091 | | - " \"$promotion_id\" : \"FirstTimeBuyer\",\n" + |
1092 | | - " \"$status\" : \"$success\",\n" + |
1093 | | - " \"$description\" : \"$5 off\",\n" + |
1094 | | - " \"$discount\" : {\n" + |
1095 | | - " \"$amount\" : 5000000,\n" + |
1096 | | - " \"$amount_usd\" : 5550000,\n" + |
1097 | | - " \"$currency_code\" : \"EUR\"\n" + |
1098 | | - " }\n" + |
1099 | | - " }\n" + |
1100 | | - " ]\n" + |
1101 | | - "}"; |
1102 | | - |
1103 | | - // Start a new mock server and enqueue a mock response. |
1104 | | - MockWebServer server = new MockWebServer(); |
1105 | | - MockResponse response = new MockResponse(); |
1106 | | - response.setResponseCode(HTTP_OK); |
1107 | | - response.setBody("{\n" + |
1108 | | - " \"status\" : 0,\n" + |
1109 | | - " \"error_message\" : \"OK\",\n" + |
1110 | | - " \"time\" : 1327604222,\n" + |
1111 | | - " \"request\" : \"" + TestUtils.unescapeJson(expectedRequestBody) + "\"\n" + |
1112 | | - "}"); |
1113 | | - server.enqueue(response); |
1114 | | - server.start(); |
1115 | | - |
1116 | | - // Create a new client and link it to the mock server. |
1117 | | - SiftClient client = new SiftClient("YOUR_API_KEY", "YOUR_ACCOUNT_ID", |
1118 | | - new OkHttpClient.Builder() |
1119 | | - .addInterceptor(OkHttpUtils.urlRewritingInterceptor(server)) |
1120 | | - .build()); |
1121 | | - |
1122 | | - // Build and execute the request against the mock server. |
1123 | | - EventRequest request = client.buildRequest( |
1124 | | - new CreateOrderFieldSet() |
1125 | | - .setUserId("billy_jones_301") |
1126 | | - .setOrderId("ORDER-28168441") |
1127 | | - .setUserEmail("bill@gmail.com") |
1128 | | - .setAmount(115940000L) |
1129 | | - .setAmountUsd(155540000L) |
1130 | | - .setCurrencyCode("EUR") |
1131 | | - .setPaymentMethods(singletonList(TestUtils.samplePaymentMethodBinMetadata())) |
1132 | | - .setBookings(singletonList(TestUtils.sampleBookingWithPriceUsd())) |
1133 | | - .setPromotions(singletonList(TestUtils.samplePromotionWithAmountUsd())) |
1134 | | - ); |
1135 | | - |
1136 | | - EventResponse siftResponse = request.send(); |
1137 | | - |
1138 | | - // Verify the request. |
1139 | | - RecordedRequest request1 = server.takeRequest(); |
1140 | | - Assert.assertEquals("POST", request1.getMethod()); |
1141 | | - Assert.assertEquals("/v205/events", request1.getPath()); |
1142 | | - JSONAssert.assertEquals(expectedRequestBody, request.getFieldSet().toJson(), true); |
1143 | | - |
1144 | | - // Verify the response. |
1145 | | - Assert.assertEquals(HTTP_OK, siftResponse.getHttpStatusCode()); |
1146 | | - Assert.assertNotNull(siftResponse.getBody()); |
1147 | | - Assert.assertEquals(0, (int) siftResponse.getBody().getStatus()); |
1148 | | - JSONAssert.assertEquals(response.getBody().readUtf8(), |
1149 | | - siftResponse.getBody().toJson(), true); |
1150 | | - |
1151 | | - server.shutdown(); |
1152 | | - } |
1153 | 1048 | } |
0 commit comments