Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions __tests__/Api/BankAccountsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,50 @@ public void bankAccountGetTestCatchesExceptionWithResponseBody() throws ApiExcep
@Test(enabled=false, groups={"Unit", "Verify", "Bank Account", "Valid"})
public void bankAccountVerifyTest() throws ApiException {
BankAccountsApi bankAccountsApiMock = mock(BankAccountsApi.class);
BankAccount FakeBankAccount = new BankAccount();
BankAccount FakeBankAccount = new BankAccount();
BankAccountVerify bankAccountVerify = new BankAccountVerify();
List<Integer> amounts = new ArrayList<Integer>();

FakeBankAccount.setId("bank_fakeId");
amounts.add(1);
amounts.add(2);
bankAccountVerify.setAmounts(amounts);

when(bankAccountsApiMock.verify("bank_fakeId", bankAccountVerify)).thenReturn(FakeBankAccount);
BankAccount response = bankAccountsApiMock.verify("bank_fakeId", bankAccountVerify);

Assert.assertEquals(FakeBankAccount.getId(), response.getId());
}

@Test(enabled=true, groups={"Unit", "Verify", "Bank Account", "Valid"})
public void bankAccountVerifyWithDescriptorCodeTest() throws ApiException {
BankAccountsApi bankAccountsApiMock = mock(BankAccountsApi.class);
BankAccount fakeBankAccount = new BankAccount();
BankAccountVerify bankAccountVerify = new BankAccountVerify();

fakeBankAccount.setId("bank_fakeId");
bankAccountVerify.setDescriptorCode("SM11AA");

when(bankAccountsApiMock.verify("bank_fakeId", bankAccountVerify)).thenReturn(fakeBankAccount);
BankAccount response = bankAccountsApiMock.verify("bank_fakeId", bankAccountVerify);

Assert.assertEquals(fakeBankAccount.getId(), response.getId());
}

@Test(enabled=true, groups={"Unit", "Bank Account", "Valid"})
public void bankAccountHasMicrodepositTypeTest() throws ApiException {
BankAccount account = new BankAccount();
account.setId("bank_fakeId");

account.setMicrodepositType("amounts");
Assert.assertEquals(account.getMicrodepositType(), "amounts");

account.setMicrodepositType("descriptor_code");
Assert.assertEquals(account.getMicrodepositType(), "descriptor_code");

account.setMicrodepositType(null);
Assert.assertNull(account.getMicrodepositType());
}

@Test(enabled=true, groups={"Unit", "List", "Bank Account", "Valid"})
public void bankAccountsListTest() throws ApiException {
Expand Down
36 changes: 36 additions & 0 deletions __tests__/Integration/BankAccountsApiSpecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,42 @@ public void bankAccountVerifyTest() throws ApiException {
createdBankAccounts.add(response);
}

@Test(
enabled=true,
groups={"Integration", "Verify", "Bank Account", "Valid"}
)
public void bankAccountVerifyWithDescriptorCodeTest() throws ApiException {
BankAccount created = validApi.create(BankAccountWritableList.get(0));
createdBankAccounts.add(created);

BankAccountVerify bv = new BankAccountVerify();
bv.setDescriptorCode("SM11AA");

BankAccount response = validApi.verify(created.getId(), bv);

Assert.assertNotNull(response);
Assert.assertNotNull(response.getId());
Assert.assertEquals(response.getId(), created.getId());
}

@Test(
enabled=true,
groups={"Integration", "Get", "Bank Account", "Valid"}
)
public void bankAccountHasMicrodepositTypeTest() throws ApiException {
BankAccount created = validApi.create(BankAccountWritableList.get(0));
createdBankAccounts.add(created);

BankAccount retrieved = validApi.get(created.getId());

Assert.assertNotNull(retrieved);
String mdType = retrieved.getMicrodepositType();
Assert.assertTrue(
mdType == null || mdType.equals("amounts") || mdType.equals("descriptor_code"),
"microdeposit_type should be 'amounts', 'descriptor_code', or null but was: " + mdType
);
}

@Test(
enabled=true,
expectedExceptions={ApiException.class},
Expand Down
8 changes: 8 additions & 0 deletions __tests__/Model/BankAccountTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public Object[][] bankAccountDpMethod() {
{"deleted", false},
{"deleted", true},
{"object", BankAccount.ObjectEnum.BANK_ACCOUNT},
{"microdeposit_type", "amounts"},
{"microdeposit_type", "descriptor_code"},
};
}

Expand Down Expand Up @@ -125,6 +127,12 @@ public void bankAccountTestWithProvidedValue(String prop, Object val) throws Exc
Assert.assertEquals(rec.getObject(), castedVal);
break;
}
case "microdeposit_type": {
String castedVal = (String)val;
rec.setMicrodepositType(castedVal);
Assert.assertEquals(rec.getMicrodepositType(), castedVal);
break;
}
default:
throw new Exception("Wrong prop name: " + prop);
}
Expand Down
42 changes: 41 additions & 1 deletion __tests__/Model/BankAccountVerifyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,53 @@

public class BankAccountVerifyTest {
@Test(enabled=true)
public void bankAccountVerifyTest() {
public void bankAccountVerifyWithAmountsTest() {
BankAccountVerify rec = new BankAccountVerify();

List<Integer> amounts = new ArrayList<Integer>();
amounts.add(1);
amounts.add(2);
rec.setAmounts(amounts);
Assert.assertEquals(rec.getAmounts(), amounts);
Assert.assertNull(rec.getDescriptorCode());
Assert.assertTrue(rec.isValid());
}

@Test(enabled=true)
public void bankAccountVerifyWithDescriptorCodeTest() {
BankAccountVerify rec = new BankAccountVerify();
rec.setDescriptorCode("SM11AA");
Assert.assertEquals(rec.getDescriptorCode(), "SM11AA");
Assert.assertNull(rec.getAmounts());
Assert.assertTrue(rec.isValid());
}

@Test(enabled=true)
public void bankAccountVerifyInvalidWhenNeitherSetTest() {
BankAccountVerify rec = new BankAccountVerify();
Assert.assertFalse(rec.isValid());
}

@Test(enabled=true)
public void bankAccountVerifyInvalidWhenBothSetTest() {
BankAccountVerify rec = new BankAccountVerify();
List<Integer> amounts = new ArrayList<Integer>();
amounts.add(1);
amounts.add(2);
rec.setAmounts(amounts);
rec.setDescriptorCode("SM11AA");
Assert.assertFalse(rec.isValid());
}

@Test(enabled=true, expectedExceptions = {IllegalArgumentException.class})
public void bankAccountVerifyInvalidDescriptorCodePatternTest() {
BankAccountVerify rec = new BankAccountVerify();
rec.setDescriptorCode("INVALID");
}

@Test(enabled=true, expectedExceptions = {IllegalArgumentException.class})
public void bankAccountVerifyDescriptorCodeTooShortTest() {
BankAccountVerify rec = new BankAccountVerify();
rec.setDescriptorCode("SM1");
}
}
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>com.lob</groupId>
<artifactId>lob-java</artifactId>
<packaging>jar</packaging>
<version>13.4.8-SNAPSHOT</version>
<version>13.5.0-SNAPSHOT</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>Parent pom for the Lob API Java Wrapper</description>
<url>https://github.com/lob/lob-java</url>
Expand Down Expand Up @@ -64,7 +64,6 @@
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
Expand Down
35 changes: 29 additions & 6 deletions src/main/java/com/lob/model/BankAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,21 +403,37 @@ public ObjectEnum read(final JsonReader jsonReader) throws IOException {
public static final String SERIALIZED_NAME_OBJECT = "object";

@SerializedName(SERIALIZED_NAME_OBJECT)


private ObjectEnum _object = ObjectEnum.BANK_ACCOUNT;
/**
* Get _object
* @return _object
**/

@javax.annotation.Nonnull

@ApiModelProperty(required = true, value = "")

public ObjectEnum getObject() {
return _object;
}

public static final String SERIALIZED_NAME_MICRODEPOSIT_TYPE = "microdeposit_type";

@SerializedName(SERIALIZED_NAME_MICRODEPOSIT_TYPE)
private String microdepositType;

/**
* The type of microdeposit verification required. Present when verified is false; null once the account is verified.
* Use this to determine which field to submit to the verify endpoint: amounts or descriptor_code.
* @return microdepositType
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "The type of microdeposit verification required. Present when verified is false; null once the account is verified.")
public String getMicrodepositType() {
return microdepositType;
}



Expand Down Expand Up @@ -632,6 +648,10 @@ public void setObject(ObjectEnum _object) {
this._object = _object;
}

public void setMicrodepositType(String microdepositType) {
this.microdepositType = microdepositType;
}



@Override
Expand All @@ -656,7 +676,8 @@ public boolean equals(Object o) {
Objects.equals(this.dateCreated, bankAccount.dateCreated) &&
Objects.equals(this.dateModified, bankAccount.dateModified) &&
Objects.equals(this.deleted, bankAccount.deleted) &&
Objects.equals(this._object, bankAccount._object);
Objects.equals(this._object, bankAccount._object) &&
Objects.equals(this.microdepositType, bankAccount.microdepositType);
}

private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
Expand All @@ -665,7 +686,7 @@ private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b)

@Override
public int hashCode() {
return Objects.hash(description, routingNumber, accountNumber, accountType, signatory, metadata, id, signatureUrl, bankName, verified, dateCreated, dateModified, deleted, _object);
return Objects.hash(description, routingNumber, accountNumber, accountType, signatory, metadata, id, signatureUrl, bankName, verified, dateCreated, dateModified, deleted, _object, microdepositType);
}

private static <T> int hashCodeNullable(JsonNullable<T> a) {
Expand Down Expand Up @@ -693,6 +714,7 @@ public String toString() {
sb.append(" dateModified: ").append(toIndentedString(dateModified)).append("\n");
sb.append(" deleted: ").append(toIndentedString(deleted)).append("\n");
sb.append(" _object: ").append(toIndentedString(_object)).append("\n");
sb.append(" microdepositType: ").append(toIndentedString(microdepositType)).append("\n");
sb.append("}");
return sb.toString();
}
Expand All @@ -713,6 +735,7 @@ public Map<String, Object> toMap() {
localMap.put("date_modified", dateModified);
localMap.put("deleted", deleted);
localMap.put("object", _object);
localMap.put("microdeposit_type", microdepositType);
return localMap;
}

Expand Down
42 changes: 30 additions & 12 deletions src/main/java/com/lob/model/BankAccountVerify.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,41 @@ public List<Integer> getAmounts() {
return this.amounts;
}


/*
public BankAccountVerify amounts(List<Integer> amounts) {

this.amounts = amounts;
return this;
}
*/

public BankAccountVerify addAmountsItem(Integer amountsItem) {
if (this.amounts == null) {
this.amounts = new ArrayList<Integer>();
}
this.amounts.add(amountsItem);
return this;
}


public void setAmounts(List<Integer> amounts) {
this.amounts = amounts;
}

public static final String SERIALIZED_NAME_DESCRIPTOR_CODE = "descriptor_code";
private static final java.util.regex.Pattern DESCRIPTOR_CODE_PATTERN =
java.util.regex.Pattern.compile("^SM[a-zA-Z0-9]{4}$");

@SerializedName(SERIALIZED_NAME_DESCRIPTOR_CODE)
private String descriptorCode;
Comment thread
kevinpjones marked this conversation as resolved.

public String getDescriptorCode() {
return this.descriptorCode;
}

public void setDescriptorCode(String descriptorCode) {
if (descriptorCode != null && !DESCRIPTOR_CODE_PATTERN.matcher(descriptorCode).matches()) {
throw new IllegalArgumentException("Invalid descriptor_code: must match ^SM[a-zA-Z0-9]{4}$");
}
this.descriptorCode = descriptorCode;
}
Comment thread
kevinpjones marked this conversation as resolved.

public boolean isValid() {
boolean hasAmounts = amounts != null && !amounts.isEmpty();
boolean hasDescriptorCode = descriptorCode != null && !descriptorCode.isEmpty();
return hasAmounts ^ hasDescriptorCode;
}
Comment thread
kevinpjones marked this conversation as resolved.

@Override
public boolean equals(Object o) {
Expand All @@ -75,26 +90,29 @@ public boolean equals(Object o) {
return false;
}
BankAccountVerify bankAccountVerify = (BankAccountVerify) o;
return Objects.equals(this.amounts, bankAccountVerify.amounts);
return Objects.equals(this.amounts, bankAccountVerify.amounts) &&
Objects.equals(this.descriptorCode, bankAccountVerify.descriptorCode);
}

@Override
public int hashCode() {
return Objects.hash(amounts);
return Objects.hash(amounts, descriptorCode);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{\n");
sb.append(" amounts: ").append(toIndentedString(amounts)).append("\n");
sb.append(" descriptorCode: ").append(toIndentedString(descriptorCode)).append("\n");
sb.append("}");
return sb.toString();
}

public Map<String, Object> toMap() {
Map<String, Object> localMap = new HashMap<String, Object>();
localMap.put("amounts", amounts);
localMap.put("descriptor_code", descriptorCode);
return localMap;
}

Expand Down