forked from goshippo/shippo-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShippoTest.java
47 lines (40 loc) · 1.28 KB
/
ShippoTest.java
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.shippo.model;
import com.shippo.Shippo;
import org.junit.Before;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
public class ShippoTest {
@Before
public void setAPIKey() {
Shippo.apiKey.set("shippo_test_cf1b6d0655e59fc6316880580765066038ef20d8");
// Some tests make assertions on response models based on whether a test api key
// is used
Shippo.apiKeyIsTest.set(true);
Shippo.DEBUG = true;
}
@Before
public void setVersion() {
Shippo.apiVersion = "2018-02-08";
}
public Map<String, Object> getInvalidObjectMap() {
Map<String, Object> map = new HashMap<String, Object>();
return map;
}
public static Object nullToEmptyString(Object value) {
return value == null ? "" : value;
}
// Make sure we get a test rate. We are using a test auth token, so it should
// not be possible to get a non-test rate back,
// but previous author was uncertain, and I don't know enough about the
// underlying implementation to be sure.
static Rate selectTestRate(List<Rate> rateList) {
return rateList.stream().filter(new Predicate<Rate>() {
@Override
public boolean test(Rate rate) {
return rate.isTest();
}
}).findAny().orElseThrow(() -> new RuntimeException("Did not find test rate."));
}
}