Skip to content

Commit 24d447b

Browse files
committed
test: address verificatione errors
1 parent 5f4cb0b commit 24d447b

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/test/java/com/easypost/AddressTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.easypost.exception.General.EndOfPaginationError;
66
import com.easypost.model.Address;
77
import com.easypost.model.AddressCollection;
8+
import com.easypost.model.AddressDetail;
9+
import com.easypost.model.AddressVerificationFieldError;
810
import org.junit.jupiter.api.BeforeAll;
911
import org.junit.jupiter.api.Test;
1012

@@ -88,8 +90,21 @@ public void testCreateVerify() throws EasyPostException {
8890
address = vcr.client.address.create(addressData);
8991

9092
assertInstanceOf(Address.class, address);
91-
assertNotNull(address.getVerifications().getDelivery());
92-
assertNotNull(address.getVerifications().getZip4());
93+
assertEquals(false, address.getVerifications().getDelivery().getSuccess());
94+
assertInstanceOf(AddressDetail.class, address.getVerifications().getDelivery().getDetails());
95+
AddressVerificationFieldError addressVerificationFieldErrorGetDelivery = address.getVerifications().getDelivery().getErrors().get(0);
96+
assertEquals("E.ADDRESS.NOT_FOUND", addressVerificationFieldErrorGetDelivery.getCode());
97+
assertEquals("address", addressVerificationFieldErrorGetDelivery.getField());
98+
assertNull(addressVerificationFieldErrorGetDelivery.getSuggestion());
99+
assertEquals("Address not found", addressVerificationFieldErrorGetDelivery.getMessage());
100+
101+
assertEquals(false, address.getVerifications().getZip4().getSuccess());
102+
assertNull(address.getVerifications().getZip4().getDetails());
103+
AddressVerificationFieldError addressVerificationFieldErrorZip4 = address.getVerifications().getZip4().getErrors().get(0);
104+
assertEquals("E.ADDRESS.NOT_FOUND", addressVerificationFieldErrorZip4.getCode());
105+
assertEquals("address", addressVerificationFieldErrorZip4.getField());
106+
assertNull(addressVerificationFieldErrorZip4.getSuggestion());
107+
assertEquals("Address not found", addressVerificationFieldErrorZip4.getMessage());
93108
}
94109

95110
/**

src/test/java/com/easypost/CarrierAccountTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.easypost.http.Requestor;
66
import com.easypost.model.CarrierAccount;
77
import com.easypost.model.CarrierType;
8+
import com.easypost.model.FieldError;
89
import com.easypost.model.Pickup;
910
import com.easypost.model.Shipment;
1011
import com.google.common.collect.ImmutableMap;
@@ -109,8 +110,9 @@ public void testCreateWithCustomWorkflow() throws EasyPostException {
109110
// We're sending bad data to the API, so we expect an error
110111
assertEquals(422, e.getStatusCode());
111112
// We expect one of the sub-errors to be regarding a missing field
112-
// assertTrue(e.getErrors().stream().anyMatch(error -> error.getField().equals("account_number") &&
113-
// error.getMessage().equals("must be present and a string")));
113+
FieldError fieldError = (FieldError) e.getErrors().get(0);
114+
assertEquals("shipping_streets", fieldError.getField());
115+
assertEquals("must be present and a string", fieldError.getMessage());
114116
}
115117
}
116118

0 commit comments

Comments
 (0)