diff --git a/.gitignore b/.gitignore
index a4bf0c4..083458d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@
.sonarlint
/.DS_Store
+
+/**/target
diff --git a/boletofacilsdk-client/pom.xml b/boletofacilsdk-client/pom.xml
index f9bb845..748c16a 100644
--- a/boletofacilsdk-client/pom.xml
+++ b/boletofacilsdk-client/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.boletobancario
boletofacilsdk-client
- 1.0.7
+ 1.0.8
boletofacil-client
@@ -34,7 +34,7 @@
com.boletobancario
boletofacilsdk
- 1.0.7
+ 1.0.8
\ No newline at end of file
diff --git a/boletofacilsdk/pom.xml b/boletofacilsdk/pom.xml
index d60e34f..94a76e2 100644
--- a/boletofacilsdk/pom.xml
+++ b/boletofacilsdk/pom.xml
@@ -5,7 +5,7 @@
com.boletobancario
boletofacilsdk
- 1.0.7
+ 1.0.8
jar
Boleto Facil Java SDK
Boleto Facil JAVA SDK
diff --git a/boletofacilsdk/src/main/java/com/boletobancario/boletofacilsdk/BoletoFacil.java b/boletofacilsdk/src/main/java/com/boletobancario/boletofacilsdk/BoletoFacil.java
index 23a0c2d..7c5c404 100644
--- a/boletofacilsdk/src/main/java/com/boletobancario/boletofacilsdk/BoletoFacil.java
+++ b/boletofacilsdk/src/main/java/com/boletobancario/boletofacilsdk/BoletoFacil.java
@@ -1,7 +1,5 @@
package com.boletobancario.boletofacilsdk;
-import org.apache.commons.lang3.StringUtils;
-
import com.boletobancario.boletofacilsdk.enums.BoletoFacilEnvironment;
import com.boletobancario.boletofacilsdk.enums.RequestType;
import com.boletobancario.boletofacilsdk.enums.ResponseType;
@@ -20,195 +18,198 @@
import com.boletobancario.boletofacilsdk.model.response.PayeeResponse;
import com.boletobancario.boletofacilsdk.model.response.TransferResponse;
+import org.apache.commons.lang3.StringUtils;
+
public class BoletoFacil extends BoletoFacilBase {
- public BoletoFacil(BoletoFacilEnvironment boletoFacilEnvironment, String token) {
- this.boletoFacilEnvironment = boletoFacilEnvironment;
- if (StringUtils.isBlank(token)) {
- throw new BoletoFacilTokenException("Token do favorecido inválido");
- }
- this.token = token;
- }
- public ChargeResponse issueCharge(Charge charge) {
- return issueCharge(charge, ResponseType.JSON);
- }
+ public BoletoFacil(BoletoFacilEnvironment boletoFacilEnvironment, String token) {
+ this.boletoFacilEnvironment = boletoFacilEnvironment;
+ if (StringUtils.isBlank(token)) {
+ throw new BoletoFacilTokenException("Token do favorecido inválido");
+ }
+ this.token = token;
+ }
+
+ public ChargeResponse issueCharge(Charge charge) {
+ return issueCharge(charge, ResponseType.JSON);
+ }
- public ChargeResponse issueCharge(Charge charge, ResponseType responseType) {
- StringBuilder requestUri = new StringBuilder(getEndPoint() + "/issue-charge?");
- addRequestParameters(requestUri, RequestType.ISSUE_CHARGE, charge);
- return request(requestUri, responseType, ChargeResponse.class);
- }
+ public ChargeResponse issueCharge(Charge charge, ResponseType responseType) {
+ StringBuilder requestUri = new StringBuilder(getEndPoint() + "/issue-charge?");
+ addRequestParameters(requestUri, RequestType.ISSUE_CHARGE, charge);
+ return request(requestUri, responseType, ChargeResponse.class);
+ }
- public TransferResponse requestTransfer(Transfer transfer) {
- return requestTransfer(transfer, ResponseType.JSON);
- }
+ public TransferResponse requestTransfer(Transfer transfer) {
+ return requestTransfer(transfer, ResponseType.JSON);
+ }
- public TransferResponse requestTransfer(Transfer transfer, ResponseType responseType) {
- StringBuilder requestUri = new StringBuilder(getEndPoint() + "/request-transfer?");
- addRequestParameters(requestUri, RequestType.REQUEST_TRANSFER, transfer);
- return request(requestUri, responseType, TransferResponse.class);
- }
+ public TransferResponse requestTransfer(Transfer transfer, ResponseType responseType) {
+ StringBuilder requestUri = new StringBuilder(getEndPoint() + "/request-transfer?");
+ addRequestParameters(requestUri, RequestType.REQUEST_TRANSFER, transfer);
+ return request(requestUri, responseType, TransferResponse.class);
+ }
- public ListChargesResponse listCharges(ListChargesDates dates) {
- return listCharges(dates, ResponseType.JSON);
- }
+ public ListChargesResponse listCharges(ListChargesDates dates) {
+ return listCharges(dates, ResponseType.JSON);
+ }
- public ListChargesResponse listCharges(ListChargesDates dates, ResponseType responseType) {
- StringBuilder requestUri = new StringBuilder(getEndPoint() + "/list-charges?");
- addRequestParameters(requestUri, RequestType.LIST_CHARGES, dates);
- return request(requestUri, responseType, ListChargesResponse.class);
- }
+ public ListChargesResponse listCharges(ListChargesDates dates, ResponseType responseType) {
+ StringBuilder requestUri = new StringBuilder(getEndPoint() + "/list-charges?");
+ addRequestParameters(requestUri, RequestType.LIST_CHARGES, dates);
+ return request(requestUri, responseType, ListChargesResponse.class);
+ }
- public FetchBalanceResponse fetchBalance() {
- return fetchBalance(ResponseType.JSON);
- }
+ public FetchBalanceResponse fetchBalance() {
+ return fetchBalance(ResponseType.JSON);
+ }
- public FetchBalanceResponse fetchBalance(ResponseType responseType) {
- StringBuilder requestUri = new StringBuilder(getEndPoint() + "/fetch-balance?");
- addRequestParameters(requestUri, RequestType.FETCH_BALANCE, null);
- return request(requestUri, responseType, FetchBalanceResponse.class);
- }
+ public FetchBalanceResponse fetchBalance(ResponseType responseType) {
+ StringBuilder requestUri = new StringBuilder(getEndPoint() + "/fetch-balance?");
+ addRequestParameters(requestUri, RequestType.FETCH_BALANCE, null);
+ return request(requestUri, responseType, FetchBalanceResponse.class);
+ }
- public CancelChargeResponse cancelCharge(Charge charge) {
- return cancelCharge(charge, ResponseType.JSON);
- }
+ public CancelChargeResponse cancelCharge(Charge charge) {
+ return cancelCharge(charge, ResponseType.JSON);
+ }
- public CancelChargeResponse cancelCharge(Charge charge, ResponseType responseType) {
- StringBuilder requestUri = new StringBuilder(getEndPoint() + "/cancel-charge?");
- addRequestParameters(requestUri, RequestType.CANCEL_CHARGE, charge);
- return request(requestUri, responseType, CancelChargeResponse.class);
- }
+ public CancelChargeResponse cancelCharge(Charge charge, ResponseType responseType) {
+ StringBuilder requestUri = new StringBuilder(getEndPoint() + "/cancel-charge?");
+ addRequestParameters(requestUri, RequestType.CANCEL_CHARGE, charge);
+ return request(requestUri, responseType, CancelChargeResponse.class);
+ }
- public PayeeResponse createPayee(Payee payee) {
- return createPayee(payee, ResponseType.JSON);
- }
+ public PayeeResponse createPayee(Payee payee) {
+ return createPayee(payee, ResponseType.JSON);
+ }
- public PayeeResponse createPayee(Payee payee, ResponseType responseType) {
- StringBuilder requestUri = new StringBuilder(getEndPoint() + "/create-payee?");
- addRequestParameters(requestUri, RequestType.CREATE_PAYEE, payee);
- return postRequest(requestUri, responseType, PayeeResponse.class);
- }
+ public PayeeResponse createPayee(Payee payee, ResponseType responseType) {
+ StringBuilder requestUri = new StringBuilder(getEndPoint() + "/create-payee?");
+ addRequestParameters(requestUri, RequestType.CREATE_PAYEE, payee);
+ return postRequest(requestUri, responseType, PayeeResponse.class);
+ }
- public FeeSchemaResponse createPayeeFeeSchema(Split split) {
- return createPayeeFeeSchema(split, ResponseType.JSON);
- }
+ public FeeSchemaResponse createPayeeFeeSchema(Split split) {
+ return createPayeeFeeSchema(split, ResponseType.JSON);
+ }
- public FeeSchemaResponse createPayeeFeeSchema(Split split, ResponseType responseType) {
- StringBuilder requestUri = new StringBuilder(getEndPoint() + "/create-payee-fee-schema?");
- addRequestParameters(requestUri, RequestType.CREATE_PAYEE_FEE_SCHEMA, split);
- return request(requestUri, responseType, FeeSchemaResponse.class);
- }
+ public FeeSchemaResponse createPayeeFeeSchema(Split split, ResponseType responseType) {
+ StringBuilder requestUri = new StringBuilder(getEndPoint() + "/create-payee-fee-schema?");
+ addRequestParameters(requestUri, RequestType.CREATE_PAYEE_FEE_SCHEMA, split);
+ return request(requestUri, responseType, FeeSchemaResponse.class);
+ }
- public PayeeResponse getPayeeStatus(Payee payee) {
- return getPayeeStatus(payee, ResponseType.JSON);
- }
+ public PayeeResponse getPayeeStatus(Payee payee) {
+ return getPayeeStatus(payee, ResponseType.JSON);
+ }
- public PayeeResponse getPayeeStatus(Payee payee, ResponseType responseType) {
- StringBuilder requestUri = new StringBuilder(getEndPoint() + "/get-payee-status?");
- addRequestParameters(requestUri, RequestType.GET_PAYEE_STATUS, payee);
- return request(requestUri, responseType, PayeeResponse.class);
- }
+ public PayeeResponse getPayeeStatus(Payee payee, ResponseType responseType) {
+ StringBuilder requestUri = new StringBuilder(getEndPoint() + "/get-payee-status?");
+ addRequestParameters(requestUri, RequestType.GET_PAYEE_STATUS, payee);
+ return request(requestUri, responseType, PayeeResponse.class);
+ }
- private void addRequestParameters(StringBuilder requestUri, RequestType requestType, ModelBase entity) {
- addTokenUriParameter(requestUri);
- switch (requestType) {
- case ISSUE_CHARGE:
- Charge chargeToIssue = (Charge) entity;
- addIssueChargeParameters(requestUri, chargeToIssue);
- break;
- case REQUEST_TRANSFER:
- Transfer transfer = (Transfer) entity;
- addRequestTransferParameters(requestUri, transfer);
- break;
- case LIST_CHARGES:
- ListChargesDates dates = (ListChargesDates) entity;
- addListChargeParameters(requestUri, dates);
- break;
- case FETCH_BALANCE:
- break;
- case CANCEL_CHARGE:
- Charge chargeToCancel = (Charge) entity;
- addCancelChargeParameters(requestUri, chargeToCancel);
- break;
- case CREATE_PAYEE:
- Payee payeeToCreate = (Payee) entity;
- addCreatePayeeParameters(requestUri, payeeToCreate);
- break;
- case CREATE_PAYEE_FEE_SCHEMA:
- Split split = (Split) entity;
- addCreatePayeeFeeSchemaParameters(requestUri, split);
- break;
- case GET_PAYEE_STATUS:
- Payee payeeToGetStatus = (Payee) entity;
- addGetPayeeStatusParameters(requestUri, payeeToGetStatus);
- break;
- }
- }
+ private void addRequestParameters(StringBuilder requestUri, RequestType requestType, ModelBase entity) {
+ addTokenUriParameter(requestUri);
+ switch (requestType) {
+ case ISSUE_CHARGE:
+ Charge chargeToIssue = (Charge)entity;
+ addIssueChargeParameters(requestUri, chargeToIssue);
+ break;
+ case REQUEST_TRANSFER:
+ Transfer transfer = (Transfer)entity;
+ addRequestTransferParameters(requestUri, transfer);
+ break;
+ case LIST_CHARGES:
+ ListChargesDates dates = (ListChargesDates)entity;
+ addListChargeParameters(requestUri, dates);
+ break;
+ case FETCH_BALANCE:
+ break;
+ case CANCEL_CHARGE:
+ Charge chargeToCancel = (Charge)entity;
+ addCancelChargeParameters(requestUri, chargeToCancel);
+ break;
+ case CREATE_PAYEE:
+ Payee payeeToCreate = (Payee)entity;
+ addCreatePayeeParameters(requestUri, payeeToCreate);
+ break;
+ case CREATE_PAYEE_FEE_SCHEMA:
+ Split split = (Split)entity;
+ addCreatePayeeFeeSchemaParameters(requestUri, split);
+ break;
+ case GET_PAYEE_STATUS:
+ Payee payeeToGetStatus = (Payee)entity;
+ addGetPayeeStatusParameters(requestUri, payeeToGetStatus);
+ break;
+ }
+ }
- private void addIssueChargeParameters(StringBuilder requestUri, Charge charge) {
- // @formatter:off
- addUriParameter(requestUri, "description", charge.getDescription());
- addUriParameter(requestUri, "reference", charge.getReference());
- addUriParameter(requestUri, "amount", charge.getAmount());
- addUriParameter(requestUri, "dueDate", charge.getDueDate());
- addUriParameter(requestUri, "installments", charge.getInstallments());
- addUriParameter(requestUri, "maxOverdueDays", charge.getMaxOverdueDays());
- addUriParameter(requestUri, "fine", charge.getFine());
- addUriParameter(requestUri, "interest", charge.getInterest());
- addUriParameter(requestUri, "discountAmount", charge.getDiscount() == null ? null : charge.getDiscount().getAmount());
- addUriParameter(requestUri, "discountDays", charge.getDiscount() == null ? null : charge.getDiscount().getDays());
- addUriParameter(requestUri, "payerName", charge.getPayer() == null ? null : charge.getPayer().getName());
- addUriParameter(requestUri, "payerCpfCnpj", charge.getPayer() == null ? null : charge.getPayer().getCpfCnpj());
- addUriParameter(requestUri, "payerEmail", charge.getPayer() == null ? null : charge.getPayer().getEmail());
- addUriParameter(requestUri, "payerSecondaryEmail", charge.getPayer() == null ? null : charge.getPayer().getSecondaryEmail());
- addUriParameter(requestUri, "payerPhone", charge.getPayer() == null ? null : charge.getPayer().getPhone());
- addUriParameter(requestUri, "payerBirthDate", charge.getPayer() == null ? null : charge.getPayer().getBirthDate());
- addUriParameter(requestUri, "billingAddressStreet", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getStreet());
- addUriParameter(requestUri, "billingAddressNumber", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getNumber());
- addUriParameter(requestUri, "billingAddressComplement", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getComplement());
- addUriParameter(requestUri, "billingAddressNeighborhood", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getNeighborhood());
- addUriParameter(requestUri, "billingAddressCity", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getCity());
- addUriParameter(requestUri, "billingAddressState", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getState());
- addUriParameter(requestUri, "billingAddressPostcode", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getPostcode());
- addUriParameter(requestUri, "notifyPayer", charge.getNotifyPayer());
- addUriParameter(requestUri, "notificationUrl", charge.getNotificationUrl());
- addUriParameter(requestUri, "feeSchemaToken", charge.getFeeSchemaToken());
- addUriParameter(requestUri, "referralToken", charge.getReferralToken());
- addUriParameter(requestUri, "splitRecipient", charge.getSplitRecipient());
- addUriParameter(requestUri, "paymentTypes", charge.getPaymentTypesAsString());
- addUriParameter(requestUri, "creditCardNumber", charge.getCreditCard() == null ? null : charge.getCreditCard().getNumber());
- addUriParameter(requestUri, "creditCardHolderName", charge.getCreditCard() == null ? null : charge.getCreditCard().getHolderName());
- addUriParameter(requestUri, "creditCardSecurityCode", charge.getCreditCard() == null ? null : charge.getCreditCard().getSecurityCode());
- addUriParameter(requestUri, "creditCardExpirationMonth", charge.getCreditCard() == null ? null : charge.getCreditCard().getExpirationMonth());
- addUriParameter(requestUri, "creditCardExpirationYear", charge.getCreditCard() == null ? null : charge.getCreditCard().getExpirationYear());
- addUriParameter(requestUri, "creditCardHash", charge.getCreditCardHash());
- addUriParameter(requestUri, "creditCardStore", charge.getCreditCardStore());
- addUriParameter(requestUri, "creditCardId", charge.getCreditCardId());
- addUriParameter(requestUri, "paymentAdvance", charge.getPaymentAdvance());
- // @formatter:on
- }
+ private void addIssueChargeParameters(StringBuilder requestUri, Charge charge) {
+ // @formatter:off
+ addUriParameter(requestUri, "description", charge.getDescription());
+ addUriParameter(requestUri, "reference", charge.getReference());
+ addUriParameter(requestUri, "amount", charge.getAmount());
+ addUriParameter(requestUri, "dueDate", charge.getDueDate());
+ addUriParameter(requestUri, "installments", charge.getInstallments());
+ addUriParameter(requestUri, "maxOverdueDays", charge.getMaxOverdueDays());
+ addUriParameter(requestUri, "fine", charge.getFine());
+ addUriParameter(requestUri, "interest", charge.getInterest());
+ addUriParameter(requestUri, "discountAmount", charge.getDiscount() == null ? null : charge.getDiscount().getAmount());
+ addUriParameter(requestUri, "discountDays", charge.getDiscount() == null ? null : charge.getDiscount().getDays());
+ addUriParameter(requestUri, "payerName", charge.getPayer() == null ? null : charge.getPayer().getName());
+ addUriParameter(requestUri, "payerCpfCnpj", charge.getPayer() == null ? null : charge.getPayer().getCpfCnpj());
+ addUriParameter(requestUri, "payerEmail", charge.getPayer() == null ? null : charge.getPayer().getEmail());
+ addUriParameter(requestUri, "payerSecondaryEmail", charge.getPayer() == null ? null : charge.getPayer().getSecondaryEmail());
+ addUriParameter(requestUri, "payerPhone", charge.getPayer() == null ? null : charge.getPayer().getPhone());
+ addUriParameter(requestUri, "payerBirthDate", charge.getPayer() == null ? null : charge.getPayer().getBirthDate());
+ addUriParameter(requestUri, "billingAddressStreet", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getStreet());
+ addUriParameter(requestUri, "billingAddressNumber", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getNumber());
+ addUriParameter(requestUri, "billingAddressComplement", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getComplement());
+ addUriParameter(requestUri, "billingAddressNeighborhood", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getNeighborhood());
+ addUriParameter(requestUri, "billingAddressCity", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getCity());
+ addUriParameter(requestUri, "billingAddressState", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getState());
+ addUriParameter(requestUri, "billingAddressPostcode", charge.getBillingAddress() == null ? null : charge.getBillingAddress().getPostcode());
+ addUriParameter(requestUri, "notifyPayer", charge.getNotifyPayer());
+ addUriParameter(requestUri, "notificationUrl", charge.getNotificationUrl());
+ addUriParameter(requestUri, "feeSchemaToken", charge.getFeeSchemaToken());
+ addUriParameter(requestUri, "referralToken", charge.getReferralToken());
+ addUriParameter(requestUri, "splitRecipient", charge.getSplitRecipient());
+ addUriParameter(requestUri, "paymentTypes", charge.getPaymentTypesAsString());
+ addUriParameter(requestUri, "creditCardNumber", charge.getCreditCard() == null ? null : charge.getCreditCard().getNumber());
+ addUriParameter(requestUri, "creditCardHolderName", charge.getCreditCard() == null ? null : charge.getCreditCard().getHolderName());
+ addUriParameter(requestUri, "creditCardSecurityCode", charge.getCreditCard() == null ? null : charge.getCreditCard().getSecurityCode());
+ addUriParameter(requestUri, "creditCardExpirationMonth", charge.getCreditCard() == null ? null : charge.getCreditCard().getExpirationMonth());
+ addUriParameter(requestUri, "creditCardExpirationYear", charge.getCreditCard() == null ? null : charge.getCreditCard().getExpirationYear());
+ addUriParameter(requestUri, "creditCardHash", charge.getCreditCardHash());
+ addUriParameter(requestUri, "creditCardStore", charge.getCreditCardStore());
+ addUriParameter(requestUri, "creditCardId", charge.getCreditCardId());
+ addUriParameter(requestUri, "paymentAdvance", charge.getPaymentAdvance());
+ // @formatter:on
+ }
- private void addRequestTransferParameters(StringBuilder requestUri, Transfer transfer) {
- addUriParameter(requestUri, "amount", transfer.getAmount());
- }
+ private void addRequestTransferParameters(StringBuilder requestUri, Transfer transfer) {
+ addUriParameter(requestUri, "amount", transfer.getAmount());
+ }
- private void addCancelChargeParameters(StringBuilder requestUri, Charge charge) {
- addUriParameter(requestUri, "code", charge.getCode());
- }
+ private void addCancelChargeParameters(StringBuilder requestUri, Charge charge) {
+ addUriParameter(requestUri, "code", charge.getCode());
+ }
- private void addListChargeParameters(StringBuilder requestUri, ListChargesDates dates) {
- // @formatter:off
- addUriParameter(requestUri, "beginDueDate", dates.getBeginDueDate());
- addUriParameter(requestUri, "endDueDate", dates.getEndDueDate());
- addUriParameter(requestUri, "beginPaymentDate", dates.getBeginPaymentDate());
- addUriParameter(requestUri, "endPaymentDate", dates.getEndPaymentDate());
- addUriParameter(requestUri, "beginPaymentConfirmation", dates.getBeginPaymentConfirmation());
- addUriParameter(requestUri, "endPaymentConfirmation", dates.getEndPaymentConfirmation());
- // @formatter:on
- }
+ private void addListChargeParameters(StringBuilder requestUri, ListChargesDates dates) {
+ // @formatter:off
+ addUriParameter(requestUri, "beginDueDate", dates.getBeginDueDate());
+ addUriParameter(requestUri, "endDueDate", dates.getEndDueDate());
+ addUriParameter(requestUri, "beginPaymentDate", dates.getBeginPaymentDate());
+ addUriParameter(requestUri, "endPaymentDate", dates.getEndPaymentDate());
+ addUriParameter(requestUri, "beginPaymentConfirmation", dates.getBeginPaymentConfirmation());
+ addUriParameter(requestUri, "endPaymentConfirmation", dates.getEndPaymentConfirmation());
+ // @formatter:on
+ }
- private void addCreatePayeeParameters(StringBuilder requestUri, Payee payee) {
- // @formatter:off
+ private void addCreatePayeeParameters(StringBuilder requestUri, Payee payee) {
+ // @formatter:off
addUriParameter(requestUri, "notificationUrl", payee.getNotificationUrl());
addUriParameter(requestUri, "name", payee.getName());
addUriParameter(requestUri, "cpfCnpj", payee.getCpfCnpj());
@@ -244,20 +245,23 @@ private void addCreatePayeeParameters(StringBuilder requestUri, Payee payee) {
if (payee.getAutoApprove() != null) {
addUriParameter(requestUri, "autoApprove", payee.getAutoApprove());
}
- // @formatter:on
- }
+ if (payee.getAutoTransfer() != null) {
+ addUriParameter(requestUri, "autoTransfer", payee.getAutoTransfer());
+ }
+ // @formatter:on
+ }
- private void addGetPayeeStatusParameters(StringBuilder requestUri, Payee payee) {
- // @formatter:off
+ private void addGetPayeeStatusParameters(StringBuilder requestUri, Payee payee) {
+ // @formatter:off
addUriParameter(requestUri, "payeeCpfCnpj", payee.getCpfCnpj());
- // @formatter:on
- }
+ // @formatter:on
+ }
- private void addCreatePayeeFeeSchemaParameters(StringBuilder requestUri, Split split) {
- // @formatter:off
+ private void addCreatePayeeFeeSchemaParameters(StringBuilder requestUri, Split split) {
+ // @formatter:off
addUriParameter(requestUri, "splitFixed", split.getSplitFixed());
addUriParameter(requestUri, "splitVariable", split.getSplitVariable());
addUriParameter(requestUri, "splitTriggerAmount", split.getSplitTriggerAmount());
- // @formatter:on
- }
+ // @formatter:on
+ }
}
diff --git a/boletofacilsdk/src/main/java/com/boletobancario/boletofacilsdk/model/entities/Payee.java b/boletofacilsdk/src/main/java/com/boletobancario/boletofacilsdk/model/entities/Payee.java
index e2c287a..b85120f 100644
--- a/boletofacilsdk/src/main/java/com/boletobancario/boletofacilsdk/model/entities/Payee.java
+++ b/boletofacilsdk/src/main/java/com/boletobancario/boletofacilsdk/model/entities/Payee.java
@@ -4,158 +4,168 @@
import com.boletobancario.boletofacilsdk.model.entities.enums.CompanyType;
public class Payee extends Person {
- private String notificationUrl;
- private String email;
- private String password;
- private String phone;
- private String linesOfBusiness;
- private String tradingName;
- private Person repr;
- private Person accountHolder;
- private BankAccount bankAccount;
- private Category category;
- private CompanyType companyType;
- private Address address;
- private Integer businessAreaId;
- private Boolean emailOptOut;
- private Boolean autoApprove;
-
- private String token;
- private String status;
-
- public String getNotificationUrl() {
- return notificationUrl;
- }
-
- public void setNotificationUrl(String notificationUrl) {
- this.notificationUrl = notificationUrl;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getPhone() {
- return phone;
- }
-
- public void setPhone(String phone) {
- this.phone = phone;
- }
-
- public String getLinesOfBusiness() {
- return linesOfBusiness;
- }
-
- public void setLinesOfBusiness(String linesOfBusiness) {
- this.linesOfBusiness = linesOfBusiness;
- }
-
- public String getTradingName() {
- return tradingName;
- }
-
- public void setTradingName(String tradingName) {
- this.tradingName = tradingName;
- }
-
- public Person getRepr() {
- return repr;
- }
-
- public void setRepr(Person repr) {
- this.repr = repr;
- }
-
- public Person getAccountHolder() {
- return accountHolder;
- }
-
- public void setAccountHolder(Person accountHolder) {
- this.accountHolder = accountHolder;
- }
-
- public BankAccount getBankAccount() {
- return bankAccount;
- }
-
- public void setBankAccount(BankAccount bankAccount) {
- this.bankAccount = bankAccount;
- }
-
- public Category getCategory() {
- return category;
- }
-
- public void setCategory(Category category) {
- this.category = category;
- }
-
- public CompanyType getCompanyType() {
- return companyType;
- }
-
- public void setCompanyType(CompanyType companyType) {
- this.companyType = companyType;
- }
-
- public Address getAddress() {
- return address;
- }
-
- public void setAddress(Address address) {
- this.address = address;
- }
- public Integer getBusinessAreaId() {
- return businessAreaId;
- }
+ private String notificationUrl;
+ private String email;
+ private String password;
+ private String phone;
+ private String linesOfBusiness;
+ private String tradingName;
+ private Person repr;
+ private Person accountHolder;
+ private BankAccount bankAccount;
+ private Category category;
+ private CompanyType companyType;
+ private Address address;
+ private Integer businessAreaId;
+ private Boolean emailOptOut;
+ private Boolean autoApprove;
+ private Boolean autoTransfer;
+
+ private String token;
+ private String status;
+
+ public String getNotificationUrl() {
+ return notificationUrl;
+ }
+
+ public void setNotificationUrl(String notificationUrl) {
+ this.notificationUrl = notificationUrl;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getLinesOfBusiness() {
+ return linesOfBusiness;
+ }
+
+ public void setLinesOfBusiness(String linesOfBusiness) {
+ this.linesOfBusiness = linesOfBusiness;
+ }
+
+ public String getTradingName() {
+ return tradingName;
+ }
+
+ public void setTradingName(String tradingName) {
+ this.tradingName = tradingName;
+ }
+
+ public Person getRepr() {
+ return repr;
+ }
+
+ public void setRepr(Person repr) {
+ this.repr = repr;
+ }
+
+ public Person getAccountHolder() {
+ return accountHolder;
+ }
+
+ public void setAccountHolder(Person accountHolder) {
+ this.accountHolder = accountHolder;
+ }
+
+ public BankAccount getBankAccount() {
+ return bankAccount;
+ }
+
+ public void setBankAccount(BankAccount bankAccount) {
+ this.bankAccount = bankAccount;
+ }
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public void setCategory(Category category) {
+ this.category = category;
+ }
+
+ public CompanyType getCompanyType() {
+ return companyType;
+ }
+
+ public void setCompanyType(CompanyType companyType) {
+ this.companyType = companyType;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
- public void setBusinessAreaId(Integer businessAreaId) {
- this.businessAreaId = businessAreaId;
- }
+ public Integer getBusinessAreaId() {
+ return businessAreaId;
+ }
- public Boolean getEmailOptOut() {
- return emailOptOut;
- }
+ public void setBusinessAreaId(Integer businessAreaId) {
+ this.businessAreaId = businessAreaId;
+ }
- public void setEmailOptOut(Boolean emailOptOut) {
- this.emailOptOut = emailOptOut;
- }
+ public Boolean getEmailOptOut() {
+ return emailOptOut;
+ }
- public Boolean getAutoApprove() {
- return autoApprove;
- }
+ public void setEmailOptOut(Boolean emailOptOut) {
+ this.emailOptOut = emailOptOut;
+ }
- public void setAutoApprove(Boolean autoApprove) {
- this.autoApprove = autoApprove;
- }
+ public Boolean getAutoApprove() {
+ return autoApprove;
+ }
- public String getToken() {
- return token;
- }
+ public void setAutoApprove(Boolean autoApprove) {
+ this.autoApprove = autoApprove;
+ }
- public void setToken(String token) {
- this.token = token;
- }
+ public Boolean getAutoTransfer() {
+ return autoTransfer;
+ }
- public String getStatus() {
- return status;
- }
+ public void setAutoTransfer(Boolean autoTransfer) {
+ this.autoTransfer = autoTransfer;
+ }
- public void setStatus(String status) {
- this.status = status;
- }
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
}
diff --git a/boletofacilsdk/src/test/java/com/boletobancario/boletofacilsdk/BoletoFacilTest.java b/boletofacilsdk/src/test/java/com/boletobancario/boletofacilsdk/BoletoFacilTest.java
index 041a6ea..6d956c8 100644
--- a/boletofacilsdk/src/test/java/com/boletobancario/boletofacilsdk/BoletoFacilTest.java
+++ b/boletofacilsdk/src/test/java/com/boletobancario/boletofacilsdk/BoletoFacilTest.java
@@ -13,17 +13,6 @@
import java.lang.reflect.Field;
import java.math.BigDecimal;
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-
import com.boletobancario.boletofacilsdk.enums.BoletoFacilEnvironment;
import com.boletobancario.boletofacilsdk.exceptions.BoletoFacilRequestException;
import com.boletobancario.boletofacilsdk.exceptions.BoletoFacilTokenException;
@@ -46,586 +35,553 @@
import com.boletobancario.boletofacilsdk.model.response.TransferResponse;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
public class BoletoFacilTest extends AbstractTest {
- @Test
- public void constructor() {
- BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
-
- Assert.assertNotNull(boletoFacil);
- Assert.assertEquals(BoletoFacilEnvironment.SANDBOX, boletoFacil.getBoletoFacilEnvironment());
- Assert.assertEquals("ABC", boletoFacil.getToken());
- }
-
- @Test(expected = BoletoFacilTokenException.class)
- public void constructorException() {
- new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "");
- }
-
- @Test
- public void issueChargeUniqueMandatoryFields() {
- expectGetOk("/issue-charge", "issueChargeUnique.txt");
- Charge charge = getCharge();
-
- BoletoFacil boletoFacil = getBoletoFacil();
- ChargeResponse response = boletoFacil.issueCharge(charge);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
- Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000",
- response.getData().getCharges().get(0).getPayNumber());
-
- verifyGet("/issue-charge");
- }
-
- @Test
- public void issueChargeCarnet() {
- expectGetOk("/issue-charge", "issueChargeCarnet.txt");
- Charge charge = getCharge();
- charge.setInstallments(3);
-
- BoletoFacil boletoFacil = getBoletoFacil();
- ChargeResponse response = boletoFacil.issueCharge(charge);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertEquals(3, response.getData().getCharges().size());
- Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
- Assert.assertTrue(response.getData().getCharges().get(1) instanceof Charge);
- Assert.assertTrue(response.getData().getCharges().get(2) instanceof Charge);
- Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
- Assert.assertEquals("102", response.getData().getCharges().get(1).getCode());
- Assert.assertEquals("103", response.getData().getCharges().get(2).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
- assertDate(getStartDateAddMonths(1), response.getData().getCharges().get(1).getDueDate());
- assertDate(getStartDateAddMonths(2), response.getData().getCharges().get(2).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(1).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(2).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000004115",
- response.getData().getCharges().get(0).getPayNumber());
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67250000004115",
- response.getData().getCharges().get(1).getPayNumber());
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67350000004115",
- response.getData().getCharges().get(2).getPayNumber());
-
- verifyGet("/issue-charge");
- }
-
- @Test
- @Ignore
- public void issueChargeWithProxy() {
- expectGetOkWithProxy("/issue-charge", "issueChargeUnique.txt");
- Charge charge = getCharge();
-
- BoletoFacil boletoFacil = getBoletoFacil();
- boletoFacil.setProxy("http://localhost", 9089, new UsernamePasswordCredentials("username", "password"));
- ChargeResponse response = boletoFacil.issueCharge(charge);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
- Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000",
- response.getData().getCharges().get(0).getPayNumber());
-
- verifyGet("/issue-charge");
- }
-
- @Test
- public void issueChargeWithCreditCardStoreAndCreditCardId() {
- expectGetOk("/issue-charge", "issueChargeWithCreditCardId.txt");
- Charge charge = getCharge();
- charge.setCreditCardStore(true);
- charge.setCreditCardId("XPTO-1234");
-
- BoletoFacil boletoFacil = getBoletoFacil();
- ChargeResponse response = boletoFacil.issueCharge(charge);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
- Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000",
- response.getData().getCharges().get(0).getPayNumber());
- Assert.assertNotNull(response.getData().getCharges().get(0).getPayments());
-
- Payment payment = response.getData().getCharges().get(0).getPayments().get(0);
- Assert.assertEquals(new BigDecimal("123.45"), payment.getAmount());
- Assert.assertEquals("XPTO-1234", payment.getCreditCardId());
- assertDate(getStartDate(), payment.getDate());
- Assert.assertEquals(new BigDecimal("4.56"), payment.getFee());
- Assert.assertEquals(Long.valueOf("123456"), payment.getId());
- Assert.assertEquals(PaymentStatus.CONFIRMED, payment.getStatus());
- Assert.assertEquals(PaymentType.CREDIT_CARD, payment.getType());
-
- verifyGet("/issue-charge");
- }
-
- @Test
- public void issueChargeWithCreditCardId() {
- expectGetOk("/issue-charge", "issueChargeUnique.txt");
- Charge charge = getCharge();
- charge.setCreditCardId("XPTO-1234");
-
- BoletoFacil boletoFacil = getBoletoFacil();
- ChargeResponse response = boletoFacil.issueCharge(charge);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
- Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000",
- response.getData().getCharges().get(0).getPayNumber());
-
- verifyGet("/issue-charge");
- }
-
- @Test
- public void issueChargeWithReferralToken() {
- expectGetOk("/issue-charge", "issueChargeUnique.txt");
- Charge charge = getCharge();
- charge.setReferralToken("TESTE_REFERRAL_TOKEN");
-
- BoletoFacil boletoFacil = getBoletoFacil();
- ChargeResponse response = boletoFacil.issueCharge(charge);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
- Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000",
- response.getData().getCharges().get(0).getPayNumber());
-
- verifyGet("/issue-charge");
- }
-
- @Test(expected = BoletoFacilRequestException.class)
- public void issueChargeErrorInvalidAmount() {
- expectGetError("/issue-charge", "issueChargeErrorInvalidAmount.txt");
- Charge charge = getCharge();
- charge.setAmount(BigDecimal.ZERO);
-
- BoletoFacil boletoFacil = getBoletoFacil();
- boletoFacil.issueCharge(charge);
- }
-
- @Test(expected = BoletoFacilRequestException.class)
- public void issueChargeErrorNoPayer() {
- expectGetError("/issue-charge", "issueChargeErrorNullPayer.txt");
- Charge charge = getCharge();
- charge.setPayer(null);
-
- BoletoFacil boletoFacil = getBoletoFacil();
- boletoFacil.issueCharge(charge);
- }
-
- @Test
- public void requestTransferPartialBalance() {
- expectGetOk("/request-transfer", "requestTransfer.txt");
- Transfer transfer = getTransfer();
- transfer.setAmount(BigDecimal.valueOf(150.00));
-
- BoletoFacil boletoFacil = getBoletoFacil();
- TransferResponse response = boletoFacil.requestTransfer(transfer);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
-
- verifyGet("/request-transfer");
- }
-
- @Test
- public void requestTransferFullBalance() {
- expectGetOk("/request-transfer", "requestTransfer.txt");
- Transfer transfer = getTransfer();
-
- BoletoFacil boletoFacil = getBoletoFacil();
- TransferResponse response = boletoFacil.requestTransfer(transfer);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
-
- verifyGet("/request-transfer");
- }
-
- @Test
- public void listCharges() {
- expectGetOk("/list-charges", "listCharges.txt");
- ListChargesDates dates = getListChargesDates();
-
- BoletoFacil boletoFacil = getBoletoFacil();
- ListChargesResponse response = boletoFacil.listCharges(dates);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
-
- Assert.assertEquals(3, response.getData().getCharges().size());
-
- Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
- Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000",
- response.getData().getCharges().get(0).getPayNumber());
- Assert.assertEquals(1, response.getData().getCharges().get(0).getPayments().size());
- Assert.assertTrue(response.getData().getCharges().get(0).getPayments().get(0) instanceof Payment);
- Assert.assertEquals(1113123, response.getData().getCharges().get(0).getPayments().get(0).getId().longValue());
- Assert.assertEquals(BigDecimal.valueOf(163.9),
- response.getData().getCharges().get(0).getPayments().get(0).getAmount());
- assertDate(getStartDate(), response.getData().getCharges().get(0).getPayments().get(0).getDate());
- Assert.assertEquals(BigDecimal.valueOf(4.34),
- response.getData().getCharges().get(0).getPayments().get(0).getFee());
- Assert.assertEquals(PaymentType.BOLETO, response.getData().getCharges().get(0).getPayments().get(0).getType());
- Assert.assertEquals(PaymentStatus.CONFIRMED,
- response.getData().getCharges().get(0).getPayments().get(0).getStatus());
-
- Assert.assertTrue(response.getData().getCharges().get(1) instanceof Charge);
- Assert.assertEquals("102", response.getData().getCharges().get(1).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(1).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(1).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001024 00236.601027 3 67150000015000",
- response.getData().getCharges().get(1).getPayNumber());
- Assert.assertEquals(2, response.getData().getCharges().get(1).getPayments().size());
- Assert.assertTrue(response.getData().getCharges().get(1).getPayments().get(0) instanceof Payment);
- Assert.assertEquals(1113124, response.getData().getCharges().get(1).getPayments().get(0).getId().longValue());
- Assert.assertEquals(BigDecimal.valueOf(1141.4),
- response.getData().getCharges().get(1).getPayments().get(0).getAmount());
- assertDate(getStartDate(), response.getData().getCharges().get(1).getPayments().get(0).getDate());
- Assert.assertEquals(BigDecimal.valueOf(27.8),
- response.getData().getCharges().get(1).getPayments().get(0).getFee());
- Assert.assertEquals(PaymentType.BOLETO, response.getData().getCharges().get(1).getPayments().get(0).getType());
- Assert.assertEquals(PaymentStatus.CONFIRMED,
- response.getData().getCharges().get(1).getPayments().get(0).getStatus());
- Assert.assertTrue(response.getData().getCharges().get(1).getPayments().get(1) instanceof Payment);
- Assert.assertEquals(1113125, response.getData().getCharges().get(1).getPayments().get(1).getId().longValue());
- Assert.assertEquals(BigDecimal.valueOf(1141.5),
- response.getData().getCharges().get(1).getPayments().get(1).getAmount());
- assertDate(getStartDate(), response.getData().getCharges().get(1).getPayments().get(1).getDate());
- Assert.assertEquals(BigDecimal.valueOf(27.85),
- response.getData().getCharges().get(1).getPayments().get(1).getFee());
- Assert.assertEquals(PaymentType.CREDIT_CARD,
- response.getData().getCharges().get(1).getPayments().get(1).getType());
- Assert.assertEquals(PaymentStatus.CONFIRMED,
- response.getData().getCharges().get(1).getPayments().get(1).getStatus());
-
- Assert.assertEquals("103", response.getData().getCharges().get(2).getCode());
- assertDate(getStartDate(), response.getData().getCharges().get(2).getDueDate());
- Assert.assertEquals(getBaseUrl(),
- response.getData().getCharges().get(2).getLink().substring(0, getBaseUrl().length()));
- Assert.assertEquals("03399.63290 64000.001024 00236.601027 3 67150000014000",
- response.getData().getCharges().get(2).getPayNumber());
- Assert.assertEquals(0, response.getData().getCharges().get(2).getPayments().size());
-
- verifyGet("/list-charges");
- }
-
- @Test(expected = BoletoFacilRequestException.class)
- public void listChargesErrorNoDatesInformed() {
- expectGetError("/list-charges", "listChargesError.txt");
- ListChargesDates dates = getListChargesDates();
-
- BoletoFacil boletoFacil = getBoletoFacil();
- boletoFacil.listCharges(dates);
- }
-
- @Test
- public void fetchBalance() {
- expectGetOk("/fetch-balance", "fetchBalance.txt");
-
- BoletoFacil boletoFacil = getBoletoFacil();
- FetchBalanceResponse response = boletoFacil.fetchBalance();
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData() instanceof PayeeBalance);
- Assert.assertEquals(BigDecimal.valueOf(100), response.getData().getBalance());
- Assert.assertEquals(BigDecimal.valueOf(30), response.getData().getWithheldBalance());
- Assert.assertEquals(BigDecimal.valueOf(70), response.getData().getTransferableBalance());
-
- verifyGet("/fetch-balance");
- }
-
- @Test
- public void cancelCharge() {
- expectGetOk("/cancel-charge", "cancelCharge.txt");
- Charge charge = getCharge();
- charge.setCode("12345678");
-
- BoletoFacil boletoFacil = getBoletoFacil();
- CancelChargeResponse response = boletoFacil.cancelCharge(charge);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
-
- verifyGet("/cancel-charge");
- }
-
- @Test(expected = BoletoFacilRequestException.class)
- public void cancelChargeError() {
- expectGetError("/cancel-charge", "cancelChargeError.txt");
- Charge charge = getCharge();
- charge.setCode("0");
-
- BoletoFacil boletoFacil = getBoletoFacil();
- boletoFacil.cancelCharge(charge);
- }
-
- @Test
- public void createPayeeMandatoryFields() {
- expectPostOk("/create-payee", "createPayee.txt");
- Payee payee = getPayee();
-
- BoletoFacil boletoFacil = getBoletoFacil();
- PayeeResponse response = boletoFacil.createPayee(payee);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData() instanceof Payee);
- Assert.assertEquals("22FAC22222EE2D22222222ADDDDDBEF38B222222D22D22E2", response.getData().getToken());
-
- verifyPost("/create-payee");
- }
-
- @Test
- public void createPayeeAutoApprovedAndEmailOptOut() {
- expectPostOk("/create-payee", "createPayee.txt");
- Payee payee = getPayee();
- payee.setEmailOptOut(true);
- payee.setAutoApprove(true);
-
- BoletoFacil boletoFacil = getBoletoFacil();
- PayeeResponse response = boletoFacil.createPayee(payee);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData() instanceof Payee);
- Assert.assertEquals("22FAC22222EE2D22222222ADDDDDBEF38B222222D22D22E2", response.getData().getToken());
-
- verifyPost("/create-payee");
- }
-
- @Test(expected = BoletoFacilRequestException.class)
- @Ignore
- public void createPayeeMethodNotAllowedException() {
- expectGetError("/create-payee", "cancelChargeError.txt");
- Payee payee = getPayee();
-
- BoletoFacil boletoFacil = getBoletoFacil();
- boletoFacil.createPayee(payee);
- }
-
- @Test
- public void createPayeeFeeSchemaSplitFixed() {
- expectGetOk("/create-payee-fee-schema", "feeSchema.txt");
- Split split = getSplit();
- split.setSplitFixed(BigDecimal.valueOf(5));
-
- BoletoFacil boletoFacil = getBoletoFacil();
- FeeSchemaResponse response = boletoFacil.createPayeeFeeSchema(split);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData() instanceof FeeSchema);
- Assert.assertEquals(123, response.getData().getId().longValue());
- Assert.assertEquals("37515135CBD4FA0176F77F944C15F064CB714C75FE23685B9EC84693A05B10F783FDC05C31BF5800",
- response.getData().getFeeSchemaToken());
-
- verifyGet("/create-payee-fee-schema");
- }
-
- @Test
- public void createPayeeFeeSchemaSplitVariable() {
- expectGetOk("/create-payee-fee-schema", "feeSchema.txt");
- Split split = getSplit();
- split.setSplitVariable(BigDecimal.valueOf(25));
-
- BoletoFacil boletoFacil = getBoletoFacil();
- FeeSchemaResponse response = boletoFacil.createPayeeFeeSchema(split);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData() instanceof FeeSchema);
- Assert.assertEquals(123, response.getData().getId().longValue());
- Assert.assertEquals("37515135CBD4FA0176F77F944C15F064CB714C75FE23685B9EC84693A05B10F783FDC05C31BF5800",
- response.getData().getFeeSchemaToken());
-
- verifyGet("/create-payee-fee-schema");
- }
-
- @Test
- public void getPayeeStatus() {
- expectGetOk("/get-payee-status", "payeeStatus.txt");
- Payee payee = getPayee();
-
- BoletoFacil boletoFacil = getBoletoFacil();
- PayeeResponse response = boletoFacil.getPayeeStatus(payee);
-
- Assert.assertNotNull(response);
- Assert.assertTrue(response.getSuccess());
- Assert.assertNotNull(response.getData());
- Assert.assertTrue(response.getData() instanceof Payee);
- Assert.assertEquals("Aprovado", response.getData().getStatus());
-
- verifyGet("/get-payee-status");
- }
-
- @Test(expected = BoletoFacilRequestException.class)
- public void getPayeeStatusInvalidPayeeException() {
- expectGetError("/get-payee-status", "payeeStatus.txt");
- Payee payee = getPayee();
- payee.setCpfCnpj("12345678000199");
-
- BoletoFacil boletoFacil = getBoletoFacil();
- boletoFacil.getPayeeStatus(payee);
- }
-
- @Test
- public void setProxy()
- throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
- BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
-
- Field httpClient = boletoFacil.getClass().getSuperclass().getDeclaredField("HTTP_CLIENT");
- httpClient.setAccessible(true);
-
- Assert.assertNull(((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertNull(((HttpClient) httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
-
- boletoFacil.setProxy("http://localhost");
-
- Assert.assertNotNull(((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertEquals("http://localhost",
- ((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertEquals(80, ((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyPort());
- Assert.assertNull(((HttpClient) httpClient.get(boletoFacil)).getState().getCredentials(AuthScope.ANY));
- }
-
- @Test
- public void setProxyWithPort()
- throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
- BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
-
- Field httpClient = boletoFacil.getClass().getSuperclass().getDeclaredField("HTTP_CLIENT");
- httpClient.setAccessible(true);
-
- Assert.assertNull(((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertNull(((HttpClient) httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
-
- boletoFacil.setProxy("http://localhost", 8088);
-
- Assert.assertNotNull(((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertEquals("http://localhost",
- ((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertEquals(8088, ((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyPort());
- Assert.assertNull(((HttpClient) httpClient.get(boletoFacil)).getState().getCredentials(AuthScope.ANY));
- }
-
- @Test
- public void setProxyWithPortAndCredentials()
- throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
- BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
-
- Field httpClient = boletoFacil.getClass().getSuperclass().getDeclaredField("HTTP_CLIENT");
- httpClient.setAccessible(true);
-
- Assert.assertNull(((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertNull(((HttpClient) httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
-
- Credentials credentials = new UsernamePasswordCredentials("username", "password");
- boletoFacil.setProxy("http://localhost", 8088, credentials);
-
- Assert.assertNotNull(((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertEquals("http://localhost",
- ((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
- Assert.assertEquals(8088, ((HttpClient) httpClient.get(boletoFacil)).getHostConfiguration().getProxyPort());
- Assert.assertNotNull(((HttpClient) httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
- Assert.assertEquals(credentials,
- ((HttpClient) httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
- }
-
- private void expectGetOk(String urlPath, String fileName) {
- stubFor(get(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC"))
- .withQueryParam("responseType", equalTo("JSON"))
- .willReturn(aResponse().withStatus(200).withBodyFile(fileName)));
- }
-
- private void expectPostOk(String urlPath, String fileName) {
- stubFor(post(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC"))
- .withQueryParam("responseType", equalTo("JSON"))
- .willReturn(aResponse().withStatus(200).withBodyFile(fileName)));
- // stubFor(post(urlPathEqualTo(urlPath)).withRequestBody(matching(".*token=ABC.*"))
- // .willReturn(aResponse().withStatus(200).withBodyFile(fileName)));
- }
-
- private void expectGetError(String urlPath, String fileName) {
- stubFor(get(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC"))
- .withQueryParam("responseType", equalTo("JSON"))
- .willReturn(aResponse().withStatus(422).withBodyFile(fileName)));
- }
-
- private void expectGetOkWithProxy(String urlPath, String fileName) {
- stubFor(get(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC"))
- .withQueryParam("responseType", equalTo("JSON"))
- .willReturn(aResponse().withStatus(200).withBodyFile(fileName).proxiedFrom("http://localhost:9089")));
- }
-
- private void verifyGet(String urlPath) {
- verify(getRequestedFor(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC"))
- .withQueryParam("responseType", equalTo("JSON")));
- }
-
- private void verifyPost(String urlPath) {
- verify(postRequestedFor(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC"))
- .withQueryParam("responseType", equalTo("JSON")));
- }
-
- private BoletoFacil getBoletoFacil() {
- return new BoletoFacil(BoletoFacilEnvironment.UNIT_TESTS, "ABC");
- }
-
- @After
- public void tearDown()
- throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
- BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
-
- Field httpClient = boletoFacil.getClass().getSuperclass().getDeclaredField("HTTP_CLIENT");
- httpClient.setAccessible(true);
- ((HttpClient) httpClient.get(boletoFacil)).setHostConfiguration(new HostConfiguration());
- ((HttpClient) httpClient.get(boletoFacil)).getState().setCredentials(AuthScope.ANY, null);
- }
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(9089);
+
+ @Test
+ public void constructor() {
+ BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
+
+ Assert.assertNotNull(boletoFacil);
+ Assert.assertEquals(BoletoFacilEnvironment.SANDBOX, boletoFacil.getBoletoFacilEnvironment());
+ Assert.assertEquals("ABC", boletoFacil.getToken());
+ }
+
+ @Test(expected = BoletoFacilTokenException.class)
+ public void constructorException() {
+ new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "");
+ }
+
+ @Test
+ public void issueChargeUniqueMandatoryFields() {
+ expectGetOk("/issue-charge", "issueChargeUnique.txt");
+ Charge charge = getCharge();
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ ChargeResponse response = boletoFacil.issueCharge(charge);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
+ Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000", response.getData().getCharges().get(0).getPayNumber());
+
+ verifyGet("/issue-charge");
+ }
+
+ @Test
+ public void issueChargeCarnet() {
+ expectGetOk("/issue-charge", "issueChargeCarnet.txt");
+ Charge charge = getCharge();
+ charge.setInstallments(3);
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ ChargeResponse response = boletoFacil.issueCharge(charge);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertEquals(3, response.getData().getCharges().size());
+ Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
+ Assert.assertTrue(response.getData().getCharges().get(1) instanceof Charge);
+ Assert.assertTrue(response.getData().getCharges().get(2) instanceof Charge);
+ Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
+ Assert.assertEquals("102", response.getData().getCharges().get(1).getCode());
+ Assert.assertEquals("103", response.getData().getCharges().get(2).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
+ assertDate(getStartDateAddMonths(1), response.getData().getCharges().get(1).getDueDate());
+ assertDate(getStartDateAddMonths(2), response.getData().getCharges().get(2).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(1).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(2).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000004115", response.getData().getCharges().get(0).getPayNumber());
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67250000004115", response.getData().getCharges().get(1).getPayNumber());
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67350000004115", response.getData().getCharges().get(2).getPayNumber());
+
+ verifyGet("/issue-charge");
+ }
+
+ @Test
+ @Ignore
+ public void issueChargeWithProxy() {
+ expectGetOkWithProxy("/issue-charge", "issueChargeUnique.txt");
+ Charge charge = getCharge();
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ boletoFacil.setProxy("http://localhost", 9089, new UsernamePasswordCredentials("username", "password"));
+ ChargeResponse response = boletoFacil.issueCharge(charge);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
+ Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000", response.getData().getCharges().get(0).getPayNumber());
+
+ verifyGet("/issue-charge");
+ }
+
+ @Test
+ public void issueChargeWithCreditCardStoreAndCreditCardId() {
+ expectGetOk("/issue-charge", "issueChargeWithCreditCardId.txt");
+ Charge charge = getCharge();
+ charge.setCreditCardStore(true);
+ charge.setCreditCardId("XPTO-1234");
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ ChargeResponse response = boletoFacil.issueCharge(charge);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
+ Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000", response.getData().getCharges().get(0).getPayNumber());
+ Assert.assertNotNull(response.getData().getCharges().get(0).getPayments());
+
+ Payment payment = response.getData().getCharges().get(0).getPayments().get(0);
+ Assert.assertEquals(new BigDecimal("123.45"), payment.getAmount());
+ Assert.assertEquals("XPTO-1234", payment.getCreditCardId());
+ assertDate(getStartDate(), payment.getDate());
+ Assert.assertEquals(new BigDecimal("4.56"), payment.getFee());
+ Assert.assertEquals(Long.valueOf("123456"), payment.getId());
+ Assert.assertEquals(PaymentStatus.CONFIRMED, payment.getStatus());
+ Assert.assertEquals(PaymentType.CREDIT_CARD, payment.getType());
+
+ verifyGet("/issue-charge");
+ }
+
+ @Test
+ public void issueChargeWithCreditCardId() {
+ expectGetOk("/issue-charge", "issueChargeUnique.txt");
+ Charge charge = getCharge();
+ charge.setCreditCardId("XPTO-1234");
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ ChargeResponse response = boletoFacil.issueCharge(charge);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
+ Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000", response.getData().getCharges().get(0).getPayNumber());
+
+ verifyGet("/issue-charge");
+ }
+
+ @Test
+ public void issueChargeWithReferralToken() {
+ expectGetOk("/issue-charge", "issueChargeUnique.txt");
+ Charge charge = getCharge();
+ charge.setReferralToken("TESTE_REFERRAL_TOKEN");
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ ChargeResponse response = boletoFacil.issueCharge(charge);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
+ Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000", response.getData().getCharges().get(0).getPayNumber());
+
+ verifyGet("/issue-charge");
+ }
+
+ @Test(expected = BoletoFacilRequestException.class)
+ public void issueChargeErrorInvalidAmount() {
+ expectGetError("/issue-charge", "issueChargeErrorInvalidAmount.txt");
+ Charge charge = getCharge();
+ charge.setAmount(BigDecimal.ZERO);
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ boletoFacil.issueCharge(charge);
+ }
+
+ @Test(expected = BoletoFacilRequestException.class)
+ public void issueChargeErrorNoPayer() {
+ expectGetError("/issue-charge", "issueChargeErrorNullPayer.txt");
+ Charge charge = getCharge();
+ charge.setPayer(null);
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ boletoFacil.issueCharge(charge);
+ }
+
+ @Test
+ public void requestTransferPartialBalance() {
+ expectGetOk("/request-transfer", "requestTransfer.txt");
+ Transfer transfer = getTransfer();
+ transfer.setAmount(BigDecimal.valueOf(150.00));
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ TransferResponse response = boletoFacil.requestTransfer(transfer);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+
+ verifyGet("/request-transfer");
+ }
+
+ @Test
+ public void requestTransferFullBalance() {
+ expectGetOk("/request-transfer", "requestTransfer.txt");
+ Transfer transfer = getTransfer();
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ TransferResponse response = boletoFacil.requestTransfer(transfer);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+
+ verifyGet("/request-transfer");
+ }
+
+ @Test
+ public void listCharges() {
+ expectGetOk("/list-charges", "listCharges.txt");
+ ListChargesDates dates = getListChargesDates();
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ ListChargesResponse response = boletoFacil.listCharges(dates);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+
+ Assert.assertEquals(3, response.getData().getCharges().size());
+
+ Assert.assertTrue(response.getData().getCharges().get(0) instanceof Charge);
+ Assert.assertEquals("101", response.getData().getCharges().get(0).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(0).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(0).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001014 00236.601027 8 67150000025000", response.getData().getCharges().get(0).getPayNumber());
+ Assert.assertEquals(1, response.getData().getCharges().get(0).getPayments().size());
+ Assert.assertTrue(response.getData().getCharges().get(0).getPayments().get(0) instanceof Payment);
+ Assert.assertEquals(1113123, response.getData().getCharges().get(0).getPayments().get(0).getId().longValue());
+ Assert.assertEquals(BigDecimal.valueOf(163.9), response.getData().getCharges().get(0).getPayments().get(0).getAmount());
+ assertDate(getStartDate(), response.getData().getCharges().get(0).getPayments().get(0).getDate());
+ Assert.assertEquals(BigDecimal.valueOf(4.34), response.getData().getCharges().get(0).getPayments().get(0).getFee());
+ Assert.assertEquals(PaymentType.BOLETO, response.getData().getCharges().get(0).getPayments().get(0).getType());
+ Assert.assertEquals(PaymentStatus.CONFIRMED, response.getData().getCharges().get(0).getPayments().get(0).getStatus());
+
+ Assert.assertTrue(response.getData().getCharges().get(1) instanceof Charge);
+ Assert.assertEquals("102", response.getData().getCharges().get(1).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(1).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(1).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001024 00236.601027 3 67150000015000", response.getData().getCharges().get(1).getPayNumber());
+ Assert.assertEquals(2, response.getData().getCharges().get(1).getPayments().size());
+ Assert.assertTrue(response.getData().getCharges().get(1).getPayments().get(0) instanceof Payment);
+ Assert.assertEquals(1113124, response.getData().getCharges().get(1).getPayments().get(0).getId().longValue());
+ Assert.assertEquals(BigDecimal.valueOf(1141.4), response.getData().getCharges().get(1).getPayments().get(0).getAmount());
+ assertDate(getStartDate(), response.getData().getCharges().get(1).getPayments().get(0).getDate());
+ Assert.assertEquals(BigDecimal.valueOf(27.8), response.getData().getCharges().get(1).getPayments().get(0).getFee());
+ Assert.assertEquals(PaymentType.BOLETO, response.getData().getCharges().get(1).getPayments().get(0).getType());
+ Assert.assertEquals(PaymentStatus.CONFIRMED, response.getData().getCharges().get(1).getPayments().get(0).getStatus());
+ Assert.assertTrue(response.getData().getCharges().get(1).getPayments().get(1) instanceof Payment);
+ Assert.assertEquals(1113125, response.getData().getCharges().get(1).getPayments().get(1).getId().longValue());
+ Assert.assertEquals(BigDecimal.valueOf(1141.5), response.getData().getCharges().get(1).getPayments().get(1).getAmount());
+ assertDate(getStartDate(), response.getData().getCharges().get(1).getPayments().get(1).getDate());
+ Assert.assertEquals(BigDecimal.valueOf(27.85), response.getData().getCharges().get(1).getPayments().get(1).getFee());
+ Assert.assertEquals(PaymentType.CREDIT_CARD, response.getData().getCharges().get(1).getPayments().get(1).getType());
+ Assert.assertEquals(PaymentStatus.CONFIRMED, response.getData().getCharges().get(1).getPayments().get(1).getStatus());
+
+ Assert.assertEquals("103", response.getData().getCharges().get(2).getCode());
+ assertDate(getStartDate(), response.getData().getCharges().get(2).getDueDate());
+ Assert.assertEquals(getBaseUrl(), response.getData().getCharges().get(2).getLink().substring(0, getBaseUrl().length()));
+ Assert.assertEquals("03399.63290 64000.001024 00236.601027 3 67150000014000", response.getData().getCharges().get(2).getPayNumber());
+ Assert.assertEquals(0, response.getData().getCharges().get(2).getPayments().size());
+
+ verifyGet("/list-charges");
+ }
+
+ @Test(expected = BoletoFacilRequestException.class)
+ public void listChargesErrorNoDatesInformed() {
+ expectGetError("/list-charges", "listChargesError.txt");
+ ListChargesDates dates = getListChargesDates();
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ boletoFacil.listCharges(dates);
+ }
+
+ @Test
+ public void fetchBalance() {
+ expectGetOk("/fetch-balance", "fetchBalance.txt");
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ FetchBalanceResponse response = boletoFacil.fetchBalance();
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData() instanceof PayeeBalance);
+ Assert.assertEquals(BigDecimal.valueOf(100), response.getData().getBalance());
+ Assert.assertEquals(BigDecimal.valueOf(30), response.getData().getWithheldBalance());
+ Assert.assertEquals(BigDecimal.valueOf(70), response.getData().getTransferableBalance());
+
+ verifyGet("/fetch-balance");
+ }
+
+ @Test
+ public void cancelCharge() {
+ expectGetOk("/cancel-charge", "cancelCharge.txt");
+ Charge charge = getCharge();
+ charge.setCode("12345678");
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ CancelChargeResponse response = boletoFacil.cancelCharge(charge);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+
+ verifyGet("/cancel-charge");
+ }
+
+ @Test(expected = BoletoFacilRequestException.class)
+ public void cancelChargeError() {
+ expectGetError("/cancel-charge", "cancelChargeError.txt");
+ Charge charge = getCharge();
+ charge.setCode("0");
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ boletoFacil.cancelCharge(charge);
+ }
+
+ @Test
+ public void createPayeeMandatoryFields() {
+ expectPostOk("/create-payee", "createPayee.txt");
+ Payee payee = getPayee();
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ PayeeResponse response = boletoFacil.createPayee(payee);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData() instanceof Payee);
+ Assert.assertEquals("22FAC22222EE2D22222222ADDDDDBEF38B222222D22D22E2", response.getData().getToken());
+
+ verifyPost("/create-payee");
+ }
+
+ @Test
+ public void createPayeeAutoApprovedAndEmailOptOutAndAutoTransfer() {
+ expectPostOk("/create-payee", "createPayee.txt");
+ Payee payee = getPayee();
+ payee.setEmailOptOut(true);
+ payee.setAutoApprove(true);
+ payee.setAutoTransfer(true);
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ PayeeResponse response = boletoFacil.createPayee(payee);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData() instanceof Payee);
+ Assert.assertEquals("22FAC22222EE2D22222222ADDDDDBEF38B222222D22D22E2", response.getData().getToken());
+
+ verifyPost("/create-payee");
+ }
+
+ @Test(expected = BoletoFacilRequestException.class)
+ @Ignore
+ public void createPayeeMethodNotAllowedException() {
+ expectGetError("/create-payee", "cancelChargeError.txt");
+ Payee payee = getPayee();
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ boletoFacil.createPayee(payee);
+ }
+
+ @Test
+ public void createPayeeFeeSchemaSplitFixed() {
+ expectGetOk("/create-payee-fee-schema", "feeSchema.txt");
+ Split split = getSplit();
+ split.setSplitFixed(BigDecimal.valueOf(5));
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ FeeSchemaResponse response = boletoFacil.createPayeeFeeSchema(split);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData() instanceof FeeSchema);
+ Assert.assertEquals(123, response.getData().getId().longValue());
+ Assert.assertEquals("37515135CBD4FA0176F77F944C15F064CB714C75FE23685B9EC84693A05B10F783FDC05C31BF5800",
+ response.getData().getFeeSchemaToken());
+
+ verifyGet("/create-payee-fee-schema");
+ }
+
+ @Test
+ public void createPayeeFeeSchemaSplitVariable() {
+ expectGetOk("/create-payee-fee-schema", "feeSchema.txt");
+ Split split = getSplit();
+ split.setSplitVariable(BigDecimal.valueOf(25));
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ FeeSchemaResponse response = boletoFacil.createPayeeFeeSchema(split);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData() instanceof FeeSchema);
+ Assert.assertEquals(123, response.getData().getId().longValue());
+ Assert.assertEquals("37515135CBD4FA0176F77F944C15F064CB714C75FE23685B9EC84693A05B10F783FDC05C31BF5800",
+ response.getData().getFeeSchemaToken());
+
+ verifyGet("/create-payee-fee-schema");
+ }
+
+ @Test
+ public void getPayeeStatus() {
+ expectGetOk("/get-payee-status", "payeeStatus.txt");
+ Payee payee = getPayee();
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ PayeeResponse response = boletoFacil.getPayeeStatus(payee);
+
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.getSuccess());
+ Assert.assertNotNull(response.getData());
+ Assert.assertTrue(response.getData() instanceof Payee);
+ Assert.assertEquals("Aprovado", response.getData().getStatus());
+
+ verifyGet("/get-payee-status");
+ }
+
+ @Test(expected = BoletoFacilRequestException.class)
+ public void getPayeeStatusInvalidPayeeException() {
+ expectGetError("/get-payee-status", "payeeStatus.txt");
+ Payee payee = getPayee();
+ payee.setCpfCnpj("12345678000199");
+
+ BoletoFacil boletoFacil = getBoletoFacil();
+ boletoFacil.getPayeeStatus(payee);
+ }
+
+ @Test
+ public void setProxy() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
+ BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
+
+ Field httpClient = boletoFacil.getClass().getSuperclass().getDeclaredField("HTTP_CLIENT");
+ httpClient.setAccessible(true);
+
+ Assert.assertNull(((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertNull(((HttpClient)httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
+
+ boletoFacil.setProxy("http://localhost");
+
+ Assert.assertNotNull(((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertEquals("http://localhost", ((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertEquals(80, ((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyPort());
+ Assert.assertNull(((HttpClient)httpClient.get(boletoFacil)).getState().getCredentials(AuthScope.ANY));
+ }
+
+ @Test
+ public void setProxyWithPort() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
+ BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
+
+ Field httpClient = boletoFacil.getClass().getSuperclass().getDeclaredField("HTTP_CLIENT");
+ httpClient.setAccessible(true);
+
+ Assert.assertNull(((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertNull(((HttpClient)httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
+
+ boletoFacil.setProxy("http://localhost", 8088);
+
+ Assert.assertNotNull(((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertEquals("http://localhost", ((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertEquals(8088, ((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyPort());
+ Assert.assertNull(((HttpClient)httpClient.get(boletoFacil)).getState().getCredentials(AuthScope.ANY));
+ }
+
+ @Test
+ public void setProxyWithPortAndCredentials() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
+ BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
+
+ Field httpClient = boletoFacil.getClass().getSuperclass().getDeclaredField("HTTP_CLIENT");
+ httpClient.setAccessible(true);
+
+ Assert.assertNull(((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertNull(((HttpClient)httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
+
+ Credentials credentials = new UsernamePasswordCredentials("username", "password");
+ boletoFacil.setProxy("http://localhost", 8088, credentials);
+
+ Assert.assertNotNull(((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertEquals("http://localhost", ((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyHost());
+ Assert.assertEquals(8088, ((HttpClient)httpClient.get(boletoFacil)).getHostConfiguration().getProxyPort());
+ Assert.assertNotNull(((HttpClient)httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
+ Assert.assertEquals(credentials, ((HttpClient)httpClient.get(boletoFacil)).getState().getProxyCredentials(AuthScope.ANY));
+ }
+
+ private void expectGetOk(String urlPath, String fileName) {
+ stubFor(get(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC")).withQueryParam("responseType", equalTo("JSON")).willReturn(
+ aResponse().withStatus(200).withBodyFile(fileName)));
+ }
+
+ private void expectPostOk(String urlPath, String fileName) {
+ stubFor(post(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC")).withQueryParam("responseType", equalTo("JSON")).willReturn(
+ aResponse().withStatus(200).withBodyFile(fileName)));
+ // stubFor(post(urlPathEqualTo(urlPath)).withRequestBody(matching(".*token=ABC.*"))
+ // .willReturn(aResponse().withStatus(200).withBodyFile(fileName)));
+ }
+
+ private void expectGetError(String urlPath, String fileName) {
+ stubFor(get(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC")).withQueryParam("responseType", equalTo("JSON")).willReturn(
+ aResponse().withStatus(422).withBodyFile(fileName)));
+ }
+
+ private void expectGetOkWithProxy(String urlPath, String fileName) {
+ stubFor(get(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC")).withQueryParam("responseType", equalTo("JSON")).willReturn(
+ aResponse().withStatus(200).withBodyFile(fileName).proxiedFrom("http://localhost:9089")));
+ }
+
+ private void verifyGet(String urlPath) {
+ verify(getRequestedFor(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC")).withQueryParam("responseType", equalTo("JSON")));
+ }
+
+ private void verifyPost(String urlPath) {
+ verify(postRequestedFor(urlPathEqualTo(urlPath)).withQueryParam("token", equalTo("ABC")).withQueryParam("responseType", equalTo("JSON")));
+ }
+
+ private BoletoFacil getBoletoFacil() {
+ return new BoletoFacil(BoletoFacilEnvironment.UNIT_TESTS, "ABC");
+ }
+
+ @After
+ public void tearDown() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+ BoletoFacil boletoFacil = new BoletoFacil(BoletoFacilEnvironment.SANDBOX, "ABC");
+
+ Field httpClient = boletoFacil.getClass().getSuperclass().getDeclaredField("HTTP_CLIENT");
+ httpClient.setAccessible(true);
+ ((HttpClient)httpClient.get(boletoFacil)).setHostConfiguration(new HostConfiguration());
+ ((HttpClient)httpClient.get(boletoFacil)).getState().setCredentials(AuthScope.ANY, null);
+ }
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(9089);
}
diff --git a/boletofacilsdk/src/test/java/com/boletobancario/boletofacilsdk/model/entities/PayeeTest.java b/boletofacilsdk/src/test/java/com/boletobancario/boletofacilsdk/model/entities/PayeeTest.java
index 366a4e1..b9b1711 100644
--- a/boletofacilsdk/src/test/java/com/boletobancario/boletofacilsdk/model/entities/PayeeTest.java
+++ b/boletofacilsdk/src/test/java/com/boletobancario/boletofacilsdk/model/entities/PayeeTest.java
@@ -1,72 +1,77 @@
package com.boletobancario.boletofacilsdk.model.entities;
-import org.junit.Assert;
-import org.junit.Test;
-
import com.boletobancario.boletofacilsdk.AbstractTest;
import com.boletobancario.boletofacilsdk.model.entities.enums.Category;
import com.boletobancario.boletofacilsdk.model.entities.enums.CompanyType;
+import org.junit.Assert;
+import org.junit.Test;
+
public class PayeeTest extends AbstractTest {
- @Test
- public void constructorAndAttributes() {
- Payee obj = new Payee();
- Assert.assertNotNull(obj);
- Assert.assertNull(obj.getNotificationUrl());
- Assert.assertNull(obj.getEmail());
- Assert.assertNull(obj.getPassword());
- Assert.assertNull(obj.getPhone());
- Assert.assertNull(obj.getLinesOfBusiness());
- Assert.assertNull(obj.getTradingName());
- Assert.assertNull(obj.getRepr());
- Assert.assertNull(obj.getAccountHolder());
- Assert.assertNull(obj.getBankAccount());
- Assert.assertNull(obj.getCategory());
- Assert.assertNull(obj.getCompanyType());
- Assert.assertNull(obj.getAddress());
- Assert.assertNull(obj.getBusinessAreaId());
- Assert.assertNull(obj.getEmailOptOut());
- Assert.assertNull(obj.getAutoApprove());
- Assert.assertNull(obj.getToken());
- Assert.assertNull(obj.getStatus());
+ @Test
+ public void constructorAndAttributes() {
+ Payee obj = new Payee();
+
+ Assert.assertNotNull(obj);
+ Assert.assertNull(obj.getNotificationUrl());
+ Assert.assertNull(obj.getEmail());
+ Assert.assertNull(obj.getPassword());
+ Assert.assertNull(obj.getPhone());
+ Assert.assertNull(obj.getLinesOfBusiness());
+ Assert.assertNull(obj.getTradingName());
+ Assert.assertNull(obj.getRepr());
+ Assert.assertNull(obj.getAccountHolder());
+ Assert.assertNull(obj.getBankAccount());
+ Assert.assertNull(obj.getCategory());
+ Assert.assertNull(obj.getCompanyType());
+ Assert.assertNull(obj.getAddress());
+ Assert.assertNull(obj.getBusinessAreaId());
+ Assert.assertNull(obj.getEmailOptOut());
+ Assert.assertNull(obj.getAutoApprove());
+ Assert.assertNull(obj.getAutoTransfer());
+ Assert.assertNull(obj.getToken());
+ Assert.assertNull(obj.getStatus());
- obj.setNotificationUrl("http://www.notification.br/url");
- obj.setEmail("email@email.com");
- obj.setPassword("Pass1word!");
- obj.setPhone("(11) 99876-5432");
- obj.setLinesOfBusiness("Areas de atuacao da empresa");
- obj.setTradingName("Nome fantasia");
- obj.setRepr(new Person());
- obj.setAccountHolder(new Person());
- obj.setBankAccount(new BankAccount());
- obj.setCategory(Category.OTHER);
- obj.setCompanyType(CompanyType.LTDA);
- obj.setAddress(new Address());
- obj.setBusinessAreaId(Integer.MAX_VALUE);
- obj.setEmailOptOut(true);
- obj.setAutoApprove(false);
- obj.setToken("TOKEN12345");
- obj.setStatus("Approved");
+ obj.setNotificationUrl("http://www.notification.br/url");
+ obj.setEmail("email@email.com");
+ obj.setPassword("Pass1word!");
+ obj.setPhone("(11) 99876-5432");
+ obj.setLinesOfBusiness("Areas de atuacao da empresa");
+ obj.setTradingName("Nome fantasia");
+ obj.setRepr(new Person());
+ obj.setAccountHolder(new Person());
+ obj.setBankAccount(new BankAccount());
+ obj.setCategory(Category.OTHER);
+ obj.setCompanyType(CompanyType.LTDA);
+ obj.setAddress(new Address());
+ obj.setBusinessAreaId(Integer.MAX_VALUE);
+ obj.setEmailOptOut(true);
+ obj.setAutoApprove(false);
+ obj.setAutoTransfer(false);
+ obj.setToken("TOKEN12345");
+ obj.setStatus("Approved");
- Assert.assertEquals("http://www.notification.br/url", obj.getNotificationUrl());
- Assert.assertEquals("email@email.com", obj.getEmail());
- Assert.assertEquals("Pass1word!", obj.getPassword());
- Assert.assertEquals("(11) 99876-5432", obj.getPhone());
- Assert.assertEquals("Areas de atuacao da empresa", obj.getLinesOfBusiness());
- Assert.assertEquals("Nome fantasia", obj.getTradingName());
- Assert.assertNotNull(obj.getRepr());
- Assert.assertNotNull(obj.getAccountHolder());
- Assert.assertNotNull(obj.getBankAccount());
- Assert.assertEquals(Category.OTHER, obj.getCategory());
- Assert.assertEquals(CompanyType.LTDA, obj.getCompanyType());
- Assert.assertNotNull(obj.getAddress());
- Assert.assertEquals(Integer.MAX_VALUE, obj.getBusinessAreaId().intValue());
- Assert.assertNotNull(obj.getEmailOptOut());
- Assert.assertTrue(obj.getEmailOptOut());
- Assert.assertNotNull(obj.getAutoApprove());
- Assert.assertFalse(obj.getAutoApprove());
- Assert.assertEquals("TOKEN12345", obj.getToken());
- Assert.assertEquals("Approved", obj.getStatus());
- }
+ Assert.assertEquals("http://www.notification.br/url", obj.getNotificationUrl());
+ Assert.assertEquals("email@email.com", obj.getEmail());
+ Assert.assertEquals("Pass1word!", obj.getPassword());
+ Assert.assertEquals("(11) 99876-5432", obj.getPhone());
+ Assert.assertEquals("Areas de atuacao da empresa", obj.getLinesOfBusiness());
+ Assert.assertEquals("Nome fantasia", obj.getTradingName());
+ Assert.assertNotNull(obj.getRepr());
+ Assert.assertNotNull(obj.getAccountHolder());
+ Assert.assertNotNull(obj.getBankAccount());
+ Assert.assertEquals(Category.OTHER, obj.getCategory());
+ Assert.assertEquals(CompanyType.LTDA, obj.getCompanyType());
+ Assert.assertNotNull(obj.getAddress());
+ Assert.assertEquals(Integer.MAX_VALUE, obj.getBusinessAreaId().intValue());
+ Assert.assertNotNull(obj.getEmailOptOut());
+ Assert.assertTrue(obj.getEmailOptOut());
+ Assert.assertNotNull(obj.getAutoApprove());
+ Assert.assertFalse(obj.getAutoApprove());
+ Assert.assertNotNull(obj.getAutoTransfer());
+ Assert.assertFalse(obj.getAutoTransfer());
+ Assert.assertEquals("TOKEN12345", obj.getToken());
+ Assert.assertEquals("Approved", obj.getStatus());
+ }
}