forked from goshippo/shippo-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRateTest.java
More file actions
45 lines (37 loc) · 1.44 KB
/
RateTest.java
File metadata and controls
45 lines (37 loc) · 1.44 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
package com.shippo.model;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import com.shippo.exception.APIConnectionException;
import com.shippo.exception.APIException;
import com.shippo.exception.AuthenticationException;
import com.shippo.exception.InvalidRequestException;
public class RateTest extends ShippoTest {
@Test
public void testValidCreate() {
RateCollection testObject = (RateCollection) getDefaultObject();
assertNotNull(testObject.getCount());
}
@Test(expected = InvalidRequestException.class)
public void testInvalidRetrieve() throws AuthenticationException, InvalidRequestException, APIConnectionException,
APIException {
Rate.retrieve("invalid_id");
}
public static Object getDefaultObject() {
Shipment testObject = (Shipment) ShipmentTest.getDefaultObject();
Map<String, Object> objectMap = new HashMap<String, Object>();
objectMap.put("id", testObject.getObjectId());
objectMap.put("currency_code", "USD");
try {
Shipment.getShippingRates(objectMap);
// Allow five seconds to pass for server rates generation
Thread.sleep(5000);
return Shipment.getShippingRates(objectMap);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}