-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathEasyPostClientTest.java
More file actions
47 lines (37 loc) · 1.34 KB
/
EasyPostClientTest.java
File metadata and controls
47 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.easypost;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.easypost.exception.EasyPostException;
import com.easypost.http.Requestor.RequestMethod;
public final class EasyPostClientTest {
private static TestUtils.VCR vcr;
/**
* Set up the testing environment for this file.
*
* @throws EasyPostException when the request fails.
*/
@BeforeAll
public static void setup() throws EasyPostException {
vcr = new TestUtils.VCR("client", TestUtils.ApiKey.TEST);
}
/**
* Test making a generic API call.
*
* @throws EasyPostException when the request fails.
*/
@Test
public void testMakeApiCall() throws EasyPostException {
vcr.setUpTest("make_api_call");
Map<String, Object> params = new HashMap<>();
params.put("page_size", 1);
Map<String, Object> response = vcr.client.makeApiCall(RequestMethod.GET, "addresses", params);
List<?> addresses = (List<?>) response.get("addresses");
assertEquals(1, addresses.size());
Map<String, Object> firstAddress = (Map<String, Object>) addresses.get(0);
assertEquals("Address", firstAddress.get("object"));
}
}