diff --git a/doc/models/invoice-avatax-details.md b/doc/models/invoice-avatax-details.md new file mode 100644 index 00000000..11352d20 --- /dev/null +++ b/doc/models/invoice-avatax-details.md @@ -0,0 +1,29 @@ + +# Invoice Avatax Details + +## Structure + +`InvoiceAvataxDetails` + +## Fields + +| Name | Type | Tags | Description | Getter | Setter | +| --- | --- | --- | --- | --- | --- | +| `Id` | `Long` | Optional | - | Long getId() | setId(Long id) | +| `Status` | `String` | Optional | - | String getStatus() | setStatus(String status) | +| `DocumentCode` | `String` | Optional | - | String getDocumentCode() | setDocumentCode(String documentCode) | +| `CommitDate` | `ZonedDateTime` | Optional | - | ZonedDateTime getCommitDate() | setCommitDate(ZonedDateTime commitDate) | +| `ModifyDate` | `ZonedDateTime` | Optional | - | ZonedDateTime getModifyDate() | setModifyDate(ZonedDateTime modifyDate) | + +## Example (as JSON) + +```json +{ + "id": 112, + "status": "status2", + "document_code": "document_code0", + "commit_date": "2016-03-13T12:52:32.123Z", + "modify_date": "2016-03-13T12:52:32.123Z" +} +``` + diff --git a/doc/models/invoice-debit.md b/doc/models/invoice-debit.md new file mode 100644 index 00000000..7467bdfc --- /dev/null +++ b/doc/models/invoice-debit.md @@ -0,0 +1,32 @@ + +# Invoice Debit + +## Structure + +`InvoiceDebit` + +## Fields + +| Name | Type | Tags | Description | Getter | Setter | +| --- | --- | --- | --- | --- | --- | +| `Uid` | `String` | Optional | - | String getUid() | setUid(String uid) | +| `DebitNoteNumber` | `String` | Optional | - | String getDebitNoteNumber() | setDebitNoteNumber(String debitNoteNumber) | +| `DebitNoteUid` | `String` | Optional | - | String getDebitNoteUid() | setDebitNoteUid(String debitNoteUid) | +| `Role` | [`DebitNoteRole`](../../doc/models/debit-note-role.md) | Optional | The role of the debit note. | DebitNoteRole getRole() | setRole(DebitNoteRole role) | +| `TransactionTime` | `ZonedDateTime` | Optional | - | ZonedDateTime getTransactionTime() | setTransactionTime(ZonedDateTime transactionTime) | +| `Memo` | `String` | Optional | - | String getMemo() | setMemo(String memo) | +| `OriginalAmount` | `String` | Optional | - | String getOriginalAmount() | setOriginalAmount(String originalAmount) | +| `AppliedAmount` | `String` | Optional | - | String getAppliedAmount() | setAppliedAmount(String appliedAmount) | + +## Example (as JSON) + +```json +{ + "uid": "uid2", + "debit_note_number": "debit_note_number2", + "debit_note_uid": "debit_note_uid8", + "role": "chargeback", + "transaction_time": "2016-03-13T12:52:32.123Z" +} +``` + diff --git a/doc/models/invoice-line-item.md b/doc/models/invoice-line-item.md index a3e5efe3..578bbee6 100644 --- a/doc/models/invoice-line-item.md +++ b/doc/models/invoice-line-item.md @@ -26,6 +26,7 @@ | `ProductVersion` | `Integer` | Optional | The version of the product subscribed when the charge was made. | Integer getProductVersion() | setProductVersion(Integer productVersion) | | `ComponentId` | `Integer` | Optional | The ID of the component being billed. Will be `nil` for non-component charges. | Integer getComponentId() | setComponentId(Integer componentId) | | `PricePointId` | `Integer` | Optional | The price point ID of the component being billed. Will be `nil` for non-component charges. | Integer getPricePointId() | setPricePointId(Integer pricePointId) | +| `BillingScheduleItemId` | `Integer` | Optional | - | Integer getBillingScheduleItemId() | setBillingScheduleItemId(Integer billingScheduleItemId) | | `Hide` | `Boolean` | Optional | - | Boolean getHide() | setHide(Boolean hide) | | `ComponentCostData` | [`InvoiceLineItemComponentCostData`](../../doc/models/invoice-line-item-component-cost-data.md) | Optional | - | InvoiceLineItemComponentCostData getComponentCostData() | setComponentCostData(InvoiceLineItemComponentCostData componentCostData) | | `ProductPricePointId` | `Integer` | Optional | The price point ID of the line item's product | Integer getProductPricePointId() | setProductPricePointId(Integer productPricePointId) | diff --git a/doc/models/invoice.md b/doc/models/invoice.md index a04c01d8..41ce26f6 100644 --- a/doc/models/invoice.md +++ b/doc/models/invoice.md @@ -48,6 +48,7 @@ | `TaxAmount` | `String` | Optional | Total tax on the invoice. | String getTaxAmount() | setTaxAmount(String taxAmount) | | `TotalAmount` | `String` | Optional | The invoice total, which is `subtotal_amount - discount_amount + tax_amount`.' | String getTotalAmount() | setTotalAmount(String totalAmount) | | `CreditAmount` | `String` | Optional | The amount of credit (from credit notes) applied to this invoice.

Credits offset the amount due from the customer. | String getCreditAmount() | setCreditAmount(String creditAmount) | +| `DebitAmount` | `String` | Optional | - | String getDebitAmount() | setDebitAmount(String debitAmount) | | `RefundAmount` | `String` | Optional | - | String getRefundAmount() | setRefundAmount(String refundAmount) | | `PaidAmount` | `String` | Optional | The amount paid on the invoice by the customer. | String getPaidAmount() | setPaidAmount(String paidAmount) | | `DueAmount` | `String` | Optional | Amount due on the invoice, which is `total_amount - credit_amount - paid_amount`. | String getDueAmount() | setDueAmount(String dueAmount) | @@ -55,10 +56,12 @@ | `Discounts` | [`List`](../../doc/models/invoice-discount.md) | Optional | - | List getDiscounts() | setDiscounts(List discounts) | | `Taxes` | [`List`](../../doc/models/invoice-tax.md) | Optional | - | List getTaxes() | setTaxes(List taxes) | | `Credits` | [`List`](../../doc/models/invoice-credit.md) | Optional | - | List getCredits() | setCredits(List credits) | +| `Debits` | [`List`](../../doc/models/invoice-debit.md) | Optional | - | List getDebits() | setDebits(List debits) | | `Refunds` | [`List`](../../doc/models/invoice-refund.md) | Optional | - | List getRefunds() | setRefunds(List refunds) | | `Payments` | [`List`](../../doc/models/invoice-payment.md) | Optional | - | List getPayments() | setPayments(List payments) | | `CustomFields` | [`List`](../../doc/models/invoice-custom-field.md) | Optional | - | List getCustomFields() | setCustomFields(List customFields) | | `DisplaySettings` | [`InvoiceDisplaySettings`](../../doc/models/invoice-display-settings.md) | Optional | - | InvoiceDisplaySettings getDisplaySettings() | setDisplaySettings(InvoiceDisplaySettings displaySettings) | +| `AvataxDetails` | [`InvoiceAvataxDetails`](../../doc/models/invoice-avatax-details.md) | Optional | - | InvoiceAvataxDetails getAvataxDetails() | setAvataxDetails(InvoiceAvataxDetails avataxDetails) | | `PublicUrl` | `String` | Optional | The public URL of the invoice | String getPublicUrl() | setPublicUrl(String publicUrl) | | `PreviousBalanceData` | [`InvoicePreviousBalance`](../../doc/models/invoice-previous-balance.md) | Optional | - | InvoicePreviousBalance getPreviousBalanceData() | setPreviousBalanceData(InvoicePreviousBalance previousBalanceData) | | `PublicUrlExpiresOn` | `LocalDate` | Optional | The format is `"YYYY-MM-DD"`. | LocalDate getPublicUrlExpiresOn() | setPublicUrlExpiresOn(LocalDate publicUrlExpiresOn) | diff --git a/src/main/java/com/maxio/advancedbilling/models/Invoice.java b/src/main/java/com/maxio/advancedbilling/models/Invoice.java index 8f1f80b3..8dce14a9 100644 --- a/src/main/java/com/maxio/advancedbilling/models/Invoice.java +++ b/src/main/java/com/maxio/advancedbilling/models/Invoice.java @@ -62,6 +62,7 @@ public class Invoice private String taxAmount; private String totalAmount; private String creditAmount; + private String debitAmount; private String refundAmount; private String paidAmount; private String dueAmount; @@ -69,10 +70,12 @@ public class Invoice private List discounts; private List taxes; private List credits; + private List debits; private List refunds; private List payments; private List customFields; private InvoiceDisplaySettings displaySettings; + private InvoiceAvataxDetails avataxDetails; private String publicUrl; private InvoicePreviousBalance previousBalanceData; private LocalDate publicUrlExpiresOn; @@ -124,6 +127,7 @@ public Invoice() { * @param taxAmount String value for taxAmount. * @param totalAmount String value for totalAmount. * @param creditAmount String value for creditAmount. + * @param debitAmount String value for debitAmount. * @param refundAmount String value for refundAmount. * @param paidAmount String value for paidAmount. * @param dueAmount String value for dueAmount. @@ -131,10 +135,12 @@ public Invoice() { * @param discounts List of InvoiceDiscount value for discounts. * @param taxes List of InvoiceTax value for taxes. * @param credits List of InvoiceCredit value for credits. + * @param debits List of InvoiceDebit value for debits. * @param refunds List of InvoiceRefund value for refunds. * @param payments List of InvoicePayment value for payments. * @param customFields List of InvoiceCustomField value for customFields. * @param displaySettings InvoiceDisplaySettings value for displaySettings. + * @param avataxDetails InvoiceAvataxDetails value for avataxDetails. * @param publicUrl String value for publicUrl. * @param previousBalanceData InvoicePreviousBalance value for previousBalanceData. * @param publicUrlExpiresOn LocalDate value for publicUrlExpiresOn. @@ -179,6 +185,7 @@ public Invoice( String taxAmount, String totalAmount, String creditAmount, + String debitAmount, String refundAmount, String paidAmount, String dueAmount, @@ -186,10 +193,12 @@ public Invoice( List discounts, List taxes, List credits, + List debits, List refunds, List payments, List customFields, InvoiceDisplaySettings displaySettings, + InvoiceAvataxDetails avataxDetails, String publicUrl, InvoicePreviousBalance previousBalanceData, LocalDate publicUrlExpiresOn) { @@ -232,6 +241,7 @@ public Invoice( this.taxAmount = taxAmount; this.totalAmount = totalAmount; this.creditAmount = creditAmount; + this.debitAmount = debitAmount; this.refundAmount = refundAmount; this.paidAmount = paidAmount; this.dueAmount = dueAmount; @@ -239,10 +249,12 @@ public Invoice( this.discounts = discounts; this.taxes = taxes; this.credits = credits; + this.debits = debits; this.refunds = refunds; this.payments = payments; this.customFields = customFields; this.displaySettings = displaySettings; + this.avataxDetails = avataxDetails; this.publicUrl = publicUrl; this.previousBalanceData = previousBalanceData; this.publicUrlExpiresOn = publicUrlExpiresOn; @@ -289,6 +301,7 @@ public Invoice( * @param taxAmount String value for taxAmount. * @param totalAmount String value for totalAmount. * @param creditAmount String value for creditAmount. + * @param debitAmount String value for debitAmount. * @param refundAmount String value for refundAmount. * @param paidAmount String value for paidAmount. * @param dueAmount String value for dueAmount. @@ -296,10 +309,12 @@ public Invoice( * @param discounts List of InvoiceDiscount value for discounts. * @param taxes List of InvoiceTax value for taxes. * @param credits List of InvoiceCredit value for credits. + * @param debits List of InvoiceDebit value for debits. * @param refunds List of InvoiceRefund value for refunds. * @param payments List of InvoicePayment value for payments. * @param customFields List of InvoiceCustomField value for customFields. * @param displaySettings InvoiceDisplaySettings value for displaySettings. + * @param avataxDetails InvoiceAvataxDetails value for avataxDetails. * @param publicUrl String value for publicUrl. * @param previousBalanceData InvoicePreviousBalance value for previousBalanceData. * @param publicUrlExpiresOn LocalDate value for publicUrlExpiresOn. @@ -319,11 +334,12 @@ protected Invoice(Long id, String uid, Integer siteId, Integer customerId, InvoicePayer payer, List recipientEmails, Integer netTerms, String memo, InvoiceAddress billingAddress, InvoiceAddress shippingAddress, String subtotalAmount, String discountAmount, String taxAmount, String totalAmount, String creditAmount, - String refundAmount, String paidAmount, String dueAmount, + String debitAmount, String refundAmount, String paidAmount, String dueAmount, List lineItems, List discounts, - List taxes, List credits, List refunds, - List payments, List customFields, - InvoiceDisplaySettings displaySettings, String publicUrl, + List taxes, List credits, List debits, + List refunds, List payments, + List customFields, InvoiceDisplaySettings displaySettings, + InvoiceAvataxDetails avataxDetails, String publicUrl, InvoicePreviousBalance previousBalanceData, LocalDate publicUrlExpiresOn) { this.id = id; this.uid = uid; @@ -364,6 +380,7 @@ protected Invoice(Long id, String uid, Integer siteId, Integer customerId, this.taxAmount = taxAmount; this.totalAmount = totalAmount; this.creditAmount = creditAmount; + this.debitAmount = debitAmount; this.refundAmount = refundAmount; this.paidAmount = paidAmount; this.dueAmount = dueAmount; @@ -371,10 +388,12 @@ protected Invoice(Long id, String uid, Integer siteId, Integer customerId, this.discounts = discounts; this.taxes = taxes; this.credits = credits; + this.debits = debits; this.refunds = refunds; this.payments = payments; this.customFields = customFields; this.displaySettings = displaySettings; + this.avataxDetails = avataxDetails; this.publicUrl = publicUrl; this.previousBalanceData = previousBalanceData; this.publicUrlExpiresOn = publicUrlExpiresOn; @@ -1354,6 +1373,25 @@ public void setCreditAmount(String creditAmount) { this.creditAmount = creditAmount; } + /** + * Getter for DebitAmount. + * @return Returns the String + */ + @JsonGetter("debit_amount") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getDebitAmount() { + return debitAmount; + } + + /** + * Setter for DebitAmount. + * @param debitAmount Value for String + */ + @JsonSetter("debit_amount") + public void setDebitAmount(String debitAmount) { + this.debitAmount = debitAmount; + } + /** * Getter for RefundAmount. * @return Returns the String @@ -1493,6 +1531,25 @@ public void setCredits(List credits) { this.credits = credits; } + /** + * Getter for Debits. + * @return Returns the List of InvoiceDebit + */ + @JsonGetter("debits") + @JsonInclude(JsonInclude.Include.NON_NULL) + public List getDebits() { + return debits; + } + + /** + * Setter for Debits. + * @param debits Value for List of InvoiceDebit + */ + @JsonSetter("debits") + public void setDebits(List debits) { + this.debits = debits; + } + /** * Getter for Refunds. * @return Returns the List of InvoiceRefund @@ -1569,6 +1626,25 @@ public void setDisplaySettings(InvoiceDisplaySettings displaySettings) { this.displaySettings = displaySettings; } + /** + * Getter for AvataxDetails. + * @return Returns the InvoiceAvataxDetails + */ + @JsonGetter("avatax_details") + @JsonInclude(JsonInclude.Include.NON_NULL) + public InvoiceAvataxDetails getAvataxDetails() { + return avataxDetails; + } + + /** + * Setter for AvataxDetails. + * @param avataxDetails Value for InvoiceAvataxDetails + */ + @JsonSetter("avatax_details") + public void setAvataxDetails(InvoiceAvataxDetails avataxDetails) { + this.avataxDetails = avataxDetails; + } + /** * Getter for PublicUrl. * The public URL of the invoice @@ -1655,11 +1731,12 @@ public String toString() { + memo + ", billingAddress=" + billingAddress + ", shippingAddress=" + shippingAddress + ", subtotalAmount=" + subtotalAmount + ", discountAmount=" + discountAmount + ", taxAmount=" + taxAmount + ", totalAmount=" + totalAmount - + ", creditAmount=" + creditAmount + ", refundAmount=" + refundAmount - + ", paidAmount=" + paidAmount + ", dueAmount=" + dueAmount + ", lineItems=" - + lineItems + ", discounts=" + discounts + ", taxes=" + taxes + ", credits=" - + credits + ", refunds=" + refunds + ", payments=" + payments + ", customFields=" - + customFields + ", displaySettings=" + displaySettings + ", publicUrl=" + publicUrl + + ", creditAmount=" + creditAmount + ", debitAmount=" + debitAmount + + ", refundAmount=" + refundAmount + ", paidAmount=" + paidAmount + ", dueAmount=" + + dueAmount + ", lineItems=" + lineItems + ", discounts=" + discounts + ", taxes=" + + taxes + ", credits=" + credits + ", debits=" + debits + ", refunds=" + refunds + + ", payments=" + payments + ", customFields=" + customFields + ", displaySettings=" + + displaySettings + ", avataxDetails=" + avataxDetails + ", publicUrl=" + publicUrl + ", previousBalanceData=" + previousBalanceData + ", publicUrlExpiresOn=" + publicUrlExpiresOn + ", additionalProperties=" + getAdditionalProperties() + "]"; } @@ -1704,6 +1781,7 @@ public Builder toBuilder() { .taxAmount(getTaxAmount()) .totalAmount(getTotalAmount()) .creditAmount(getCreditAmount()) + .debitAmount(getDebitAmount()) .refundAmount(getRefundAmount()) .paidAmount(getPaidAmount()) .dueAmount(getDueAmount()) @@ -1711,10 +1789,12 @@ public Builder toBuilder() { .discounts(getDiscounts()) .taxes(getTaxes()) .credits(getCredits()) + .debits(getDebits()) .refunds(getRefunds()) .payments(getPayments()) .customFields(getCustomFields()) .displaySettings(getDisplaySettings()) + .avataxDetails(getAvataxDetails()) .publicUrl(getPublicUrl()) .previousBalanceData(getPreviousBalanceData()) .publicUrlExpiresOn(getPublicUrlExpiresOn()); @@ -1770,6 +1850,7 @@ public static class Builder { private String taxAmount; private String totalAmount; private String creditAmount; + private String debitAmount; private String refundAmount; private String paidAmount; private String dueAmount; @@ -1777,10 +1858,12 @@ public static class Builder { private List discounts; private List taxes; private List credits; + private List debits; private List refunds; private List payments; private List customFields; private InvoiceDisplaySettings displaySettings; + private InvoiceAvataxDetails avataxDetails; private String publicUrl; private InvoicePreviousBalance previousBalanceData; private LocalDate publicUrlExpiresOn; @@ -2231,6 +2314,16 @@ public Builder creditAmount(String creditAmount) { return this; } + /** + * Setter for debitAmount. + * @param debitAmount String value for debitAmount. + * @return Builder + */ + public Builder debitAmount(String debitAmount) { + this.debitAmount = debitAmount; + return this; + } + /** * Setter for refundAmount. * @param refundAmount String value for refundAmount. @@ -2301,6 +2394,16 @@ public Builder credits(List credits) { return this; } + /** + * Setter for debits. + * @param debits List of InvoiceDebit value for debits. + * @return Builder + */ + public Builder debits(List debits) { + this.debits = debits; + return this; + } + /** * Setter for refunds. * @param refunds List of InvoiceRefund value for refunds. @@ -2341,6 +2444,16 @@ public Builder displaySettings(InvoiceDisplaySettings displaySettings) { return this; } + /** + * Setter for avataxDetails. + * @param avataxDetails InvoiceAvataxDetails value for avataxDetails. + * @return Builder + */ + public Builder avataxDetails(InvoiceAvataxDetails avataxDetails) { + this.avataxDetails = avataxDetails; + return this; + } + /** * Setter for publicUrl. * @param publicUrl String value for publicUrl. @@ -2383,9 +2496,9 @@ public Invoice build() { groupPrimarySubscriptionId, productName, productFamilyName, seller, customer, payer, recipientEmails, netTerms, memo, billingAddress, shippingAddress, subtotalAmount, discountAmount, taxAmount, totalAmount, creditAmount, - refundAmount, paidAmount, dueAmount, lineItems, discounts, taxes, credits, - refunds, payments, customFields, displaySettings, publicUrl, - previousBalanceData, publicUrlExpiresOn); + debitAmount, refundAmount, paidAmount, dueAmount, lineItems, discounts, taxes, + credits, debits, refunds, payments, customFields, displaySettings, + avataxDetails, publicUrl, previousBalanceData, publicUrlExpiresOn); } } } diff --git a/src/main/java/com/maxio/advancedbilling/models/InvoiceAvataxDetails.java b/src/main/java/com/maxio/advancedbilling/models/InvoiceAvataxDetails.java new file mode 100644 index 00000000..032b76da --- /dev/null +++ b/src/main/java/com/maxio/advancedbilling/models/InvoiceAvataxDetails.java @@ -0,0 +1,394 @@ +/* + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +package com.maxio.advancedbilling.models; + +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.maxio.advancedbilling.DateTimeHelper; +import io.apimatic.core.types.BaseModel; +import io.apimatic.core.types.OptionalNullable; +import java.time.ZonedDateTime; + +/** + * This is a model class for InvoiceAvataxDetails type. + */ +public class InvoiceAvataxDetails + extends BaseModel { + private OptionalNullable id; + private OptionalNullable status; + private OptionalNullable documentCode; + private OptionalNullable commitDate; + private OptionalNullable modifyDate; + + /** + * Default constructor. + */ + public InvoiceAvataxDetails() { + } + + /** + * Initialization constructor. + * @param id Long value for id. + * @param status String value for status. + * @param documentCode String value for documentCode. + * @param commitDate ZonedDateTime value for commitDate. + * @param modifyDate ZonedDateTime value for modifyDate. + */ + public InvoiceAvataxDetails( + Long id, + String status, + String documentCode, + ZonedDateTime commitDate, + ZonedDateTime modifyDate) { + this.id = OptionalNullable.of(id); + this.status = OptionalNullable.of(status); + this.documentCode = OptionalNullable.of(documentCode); + this.commitDate = OptionalNullable.of(commitDate); + this.modifyDate = OptionalNullable.of(modifyDate); + } + + /** + * Initialization constructor. + * @param id Long value for id. + * @param status String value for status. + * @param documentCode String value for documentCode. + * @param commitDate ZonedDateTime value for commitDate. + * @param modifyDate ZonedDateTime value for modifyDate. + */ + + protected InvoiceAvataxDetails(OptionalNullable id, OptionalNullable status, + OptionalNullable documentCode, OptionalNullable commitDate, + OptionalNullable modifyDate) { + this.id = id; + this.status = status; + this.documentCode = documentCode; + this.commitDate = commitDate; + this.modifyDate = modifyDate; + } + + /** + * Internal Getter for Id. + * @return Returns the Internal Long + */ + @JsonGetter("id") + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSerialize(using = OptionalNullable.Serializer.class) + protected OptionalNullable internalGetId() { + return this.id; + } + + /** + * Getter for Id. + * @return Returns the Long + */ + public Long getId() { + return OptionalNullable.getFrom(id); + } + + /** + * Setter for Id. + * @param id Value for Long + */ + @JsonSetter("id") + public void setId(Long id) { + this.id = OptionalNullable.of(id); + } + + /** + * UnSetter for Id. + */ + public void unsetId() { + id = null; + } + + /** + * Internal Getter for Status. + * @return Returns the Internal String + */ + @JsonGetter("status") + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSerialize(using = OptionalNullable.Serializer.class) + protected OptionalNullable internalGetStatus() { + return this.status; + } + + /** + * Getter for Status. + * @return Returns the String + */ + public String getStatus() { + return OptionalNullable.getFrom(status); + } + + /** + * Setter for Status. + * @param status Value for String + */ + @JsonSetter("status") + public void setStatus(String status) { + this.status = OptionalNullable.of(status); + } + + /** + * UnSetter for Status. + */ + public void unsetStatus() { + status = null; + } + + /** + * Internal Getter for DocumentCode. + * @return Returns the Internal String + */ + @JsonGetter("document_code") + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSerialize(using = OptionalNullable.Serializer.class) + protected OptionalNullable internalGetDocumentCode() { + return this.documentCode; + } + + /** + * Getter for DocumentCode. + * @return Returns the String + */ + public String getDocumentCode() { + return OptionalNullable.getFrom(documentCode); + } + + /** + * Setter for DocumentCode. + * @param documentCode Value for String + */ + @JsonSetter("document_code") + public void setDocumentCode(String documentCode) { + this.documentCode = OptionalNullable.of(documentCode); + } + + /** + * UnSetter for DocumentCode. + */ + public void unsetDocumentCode() { + documentCode = null; + } + + /** + * Internal Getter for CommitDate. + * @return Returns the Internal ZonedDateTime + */ + @JsonGetter("commit_date") + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSerialize(using = OptionalNullable.ZonedRfc8601DateTimeSerializer.class) + protected OptionalNullable internalGetCommitDate() { + return this.commitDate; + } + + /** + * Getter for CommitDate. + * @return Returns the ZonedDateTime + */ + public ZonedDateTime getCommitDate() { + return OptionalNullable.getFrom(commitDate); + } + + /** + * Setter for CommitDate. + * @param commitDate Value for ZonedDateTime + */ + @JsonSetter("commit_date") + @JsonDeserialize(using = DateTimeHelper.Rfc8601DateTimeDeserializer.class) + public void setCommitDate(ZonedDateTime commitDate) { + this.commitDate = OptionalNullable.of(commitDate); + } + + /** + * UnSetter for CommitDate. + */ + public void unsetCommitDate() { + commitDate = null; + } + + /** + * Internal Getter for ModifyDate. + * @return Returns the Internal ZonedDateTime + */ + @JsonGetter("modify_date") + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSerialize(using = OptionalNullable.ZonedRfc8601DateTimeSerializer.class) + protected OptionalNullable internalGetModifyDate() { + return this.modifyDate; + } + + /** + * Getter for ModifyDate. + * @return Returns the ZonedDateTime + */ + public ZonedDateTime getModifyDate() { + return OptionalNullable.getFrom(modifyDate); + } + + /** + * Setter for ModifyDate. + * @param modifyDate Value for ZonedDateTime + */ + @JsonSetter("modify_date") + @JsonDeserialize(using = DateTimeHelper.Rfc8601DateTimeDeserializer.class) + public void setModifyDate(ZonedDateTime modifyDate) { + this.modifyDate = OptionalNullable.of(modifyDate); + } + + /** + * UnSetter for ModifyDate. + */ + public void unsetModifyDate() { + modifyDate = null; + } + + /** + * Converts this InvoiceAvataxDetails into string format. + * @return String representation of this class + */ + @Override + public String toString() { + return "InvoiceAvataxDetails [" + "id=" + id + ", status=" + status + ", documentCode=" + + documentCode + ", commitDate=" + commitDate + ", modifyDate=" + modifyDate + + ", additionalProperties=" + getAdditionalProperties() + "]"; + } + + /** + * Builds a new {@link InvoiceAvataxDetails.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link InvoiceAvataxDetails.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.id = internalGetId(); + builder.status = internalGetStatus(); + builder.documentCode = internalGetDocumentCode(); + builder.commitDate = internalGetCommitDate(); + builder.modifyDate = internalGetModifyDate(); + return builder; + } + + /** + * Class to build instances of {@link InvoiceAvataxDetails}. + */ + public static class Builder { + private OptionalNullable id; + private OptionalNullable status; + private OptionalNullable documentCode; + private OptionalNullable commitDate; + private OptionalNullable modifyDate; + + + + /** + * Setter for id. + * @param id Long value for id. + * @return Builder + */ + public Builder id(Long id) { + this.id = OptionalNullable.of(id); + return this; + } + + /** + * UnSetter for id. + * @return Builder + */ + public Builder unsetId() { + id = null; + return this; + } + + /** + * Setter for status. + * @param status String value for status. + * @return Builder + */ + public Builder status(String status) { + this.status = OptionalNullable.of(status); + return this; + } + + /** + * UnSetter for status. + * @return Builder + */ + public Builder unsetStatus() { + status = null; + return this; + } + + /** + * Setter for documentCode. + * @param documentCode String value for documentCode. + * @return Builder + */ + public Builder documentCode(String documentCode) { + this.documentCode = OptionalNullable.of(documentCode); + return this; + } + + /** + * UnSetter for documentCode. + * @return Builder + */ + public Builder unsetDocumentCode() { + documentCode = null; + return this; + } + + /** + * Setter for commitDate. + * @param commitDate ZonedDateTime value for commitDate. + * @return Builder + */ + public Builder commitDate(ZonedDateTime commitDate) { + this.commitDate = OptionalNullable.of(commitDate); + return this; + } + + /** + * UnSetter for commitDate. + * @return Builder + */ + public Builder unsetCommitDate() { + commitDate = null; + return this; + } + + /** + * Setter for modifyDate. + * @param modifyDate ZonedDateTime value for modifyDate. + * @return Builder + */ + public Builder modifyDate(ZonedDateTime modifyDate) { + this.modifyDate = OptionalNullable.of(modifyDate); + return this; + } + + /** + * UnSetter for modifyDate. + * @return Builder + */ + public Builder unsetModifyDate() { + modifyDate = null; + return this; + } + + /** + * Builds a new {@link InvoiceAvataxDetails} object using the set fields. + * @return {@link InvoiceAvataxDetails} + */ + public InvoiceAvataxDetails build() { + return new InvoiceAvataxDetails(id, status, documentCode, commitDate, modifyDate); + } + } +} diff --git a/src/main/java/com/maxio/advancedbilling/models/InvoiceDebit.java b/src/main/java/com/maxio/advancedbilling/models/InvoiceDebit.java new file mode 100644 index 00000000..94258997 --- /dev/null +++ b/src/main/java/com/maxio/advancedbilling/models/InvoiceDebit.java @@ -0,0 +1,359 @@ +/* + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +package com.maxio.advancedbilling.models; + +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.maxio.advancedbilling.DateTimeHelper; +import io.apimatic.core.types.BaseModel; +import java.time.ZonedDateTime; + +/** + * This is a model class for InvoiceDebit type. + */ +public class InvoiceDebit + extends BaseModel { + private String uid; + private String debitNoteNumber; + private String debitNoteUid; + private DebitNoteRole role; + private ZonedDateTime transactionTime; + private String memo; + private String originalAmount; + private String appliedAmount; + + /** + * Default constructor. + */ + public InvoiceDebit() { + } + + /** + * Initialization constructor. + * @param uid String value for uid. + * @param debitNoteNumber String value for debitNoteNumber. + * @param debitNoteUid String value for debitNoteUid. + * @param role DebitNoteRole value for role. + * @param transactionTime ZonedDateTime value for transactionTime. + * @param memo String value for memo. + * @param originalAmount String value for originalAmount. + * @param appliedAmount String value for appliedAmount. + */ + public InvoiceDebit( + String uid, + String debitNoteNumber, + String debitNoteUid, + DebitNoteRole role, + ZonedDateTime transactionTime, + String memo, + String originalAmount, + String appliedAmount) { + this.uid = uid; + this.debitNoteNumber = debitNoteNumber; + this.debitNoteUid = debitNoteUid; + this.role = role; + this.transactionTime = transactionTime; + this.memo = memo; + this.originalAmount = originalAmount; + this.appliedAmount = appliedAmount; + } + + /** + * Getter for Uid. + * @return Returns the String + */ + @JsonGetter("uid") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getUid() { + return uid; + } + + /** + * Setter for Uid. + * @param uid Value for String + */ + @JsonSetter("uid") + public void setUid(String uid) { + this.uid = uid; + } + + /** + * Getter for DebitNoteNumber. + * @return Returns the String + */ + @JsonGetter("debit_note_number") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getDebitNoteNumber() { + return debitNoteNumber; + } + + /** + * Setter for DebitNoteNumber. + * @param debitNoteNumber Value for String + */ + @JsonSetter("debit_note_number") + public void setDebitNoteNumber(String debitNoteNumber) { + this.debitNoteNumber = debitNoteNumber; + } + + /** + * Getter for DebitNoteUid. + * @return Returns the String + */ + @JsonGetter("debit_note_uid") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getDebitNoteUid() { + return debitNoteUid; + } + + /** + * Setter for DebitNoteUid. + * @param debitNoteUid Value for String + */ + @JsonSetter("debit_note_uid") + public void setDebitNoteUid(String debitNoteUid) { + this.debitNoteUid = debitNoteUid; + } + + /** + * Getter for Role. + * The role of the debit note. + * @return Returns the DebitNoteRole + */ + @JsonGetter("role") + @JsonInclude(JsonInclude.Include.NON_NULL) + public DebitNoteRole getRole() { + return role; + } + + /** + * Setter for Role. + * The role of the debit note. + * @param role Value for DebitNoteRole + */ + @JsonSetter("role") + public void setRole(DebitNoteRole role) { + this.role = role; + } + + /** + * Getter for TransactionTime. + * @return Returns the ZonedDateTime + */ + @JsonGetter("transaction_time") + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSerialize(using = DateTimeHelper.Rfc8601DateTimeSerializer.class) + public ZonedDateTime getTransactionTime() { + return transactionTime; + } + + /** + * Setter for TransactionTime. + * @param transactionTime Value for ZonedDateTime + */ + @JsonSetter("transaction_time") + @JsonDeserialize(using = DateTimeHelper.Rfc8601DateTimeDeserializer.class) + public void setTransactionTime(ZonedDateTime transactionTime) { + this.transactionTime = transactionTime; + } + + /** + * Getter for Memo. + * @return Returns the String + */ + @JsonGetter("memo") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getMemo() { + return memo; + } + + /** + * Setter for Memo. + * @param memo Value for String + */ + @JsonSetter("memo") + public void setMemo(String memo) { + this.memo = memo; + } + + /** + * Getter for OriginalAmount. + * @return Returns the String + */ + @JsonGetter("original_amount") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getOriginalAmount() { + return originalAmount; + } + + /** + * Setter for OriginalAmount. + * @param originalAmount Value for String + */ + @JsonSetter("original_amount") + public void setOriginalAmount(String originalAmount) { + this.originalAmount = originalAmount; + } + + /** + * Getter for AppliedAmount. + * @return Returns the String + */ + @JsonGetter("applied_amount") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getAppliedAmount() { + return appliedAmount; + } + + /** + * Setter for AppliedAmount. + * @param appliedAmount Value for String + */ + @JsonSetter("applied_amount") + public void setAppliedAmount(String appliedAmount) { + this.appliedAmount = appliedAmount; + } + + /** + * Converts this InvoiceDebit into string format. + * @return String representation of this class + */ + @Override + public String toString() { + return "InvoiceDebit [" + "uid=" + uid + ", debitNoteNumber=" + debitNoteNumber + + ", debitNoteUid=" + debitNoteUid + ", role=" + role + ", transactionTime=" + + transactionTime + ", memo=" + memo + ", originalAmount=" + originalAmount + + ", appliedAmount=" + appliedAmount + ", additionalProperties=" + + getAdditionalProperties() + "]"; + } + + /** + * Builds a new {@link InvoiceDebit.Builder} object. + * Creates the instance with the state of the current model. + * @return a new {@link InvoiceDebit.Builder} object + */ + public Builder toBuilder() { + Builder builder = new Builder() + .uid(getUid()) + .debitNoteNumber(getDebitNoteNumber()) + .debitNoteUid(getDebitNoteUid()) + .role(getRole()) + .transactionTime(getTransactionTime()) + .memo(getMemo()) + .originalAmount(getOriginalAmount()) + .appliedAmount(getAppliedAmount()); + return builder; + } + + /** + * Class to build instances of {@link InvoiceDebit}. + */ + public static class Builder { + private String uid; + private String debitNoteNumber; + private String debitNoteUid; + private DebitNoteRole role; + private ZonedDateTime transactionTime; + private String memo; + private String originalAmount; + private String appliedAmount; + + + + /** + * Setter for uid. + * @param uid String value for uid. + * @return Builder + */ + public Builder uid(String uid) { + this.uid = uid; + return this; + } + + /** + * Setter for debitNoteNumber. + * @param debitNoteNumber String value for debitNoteNumber. + * @return Builder + */ + public Builder debitNoteNumber(String debitNoteNumber) { + this.debitNoteNumber = debitNoteNumber; + return this; + } + + /** + * Setter for debitNoteUid. + * @param debitNoteUid String value for debitNoteUid. + * @return Builder + */ + public Builder debitNoteUid(String debitNoteUid) { + this.debitNoteUid = debitNoteUid; + return this; + } + + /** + * Setter for role. + * @param role DebitNoteRole value for role. + * @return Builder + */ + public Builder role(DebitNoteRole role) { + this.role = role; + return this; + } + + /** + * Setter for transactionTime. + * @param transactionTime ZonedDateTime value for transactionTime. + * @return Builder + */ + public Builder transactionTime(ZonedDateTime transactionTime) { + this.transactionTime = transactionTime; + return this; + } + + /** + * Setter for memo. + * @param memo String value for memo. + * @return Builder + */ + public Builder memo(String memo) { + this.memo = memo; + return this; + } + + /** + * Setter for originalAmount. + * @param originalAmount String value for originalAmount. + * @return Builder + */ + public Builder originalAmount(String originalAmount) { + this.originalAmount = originalAmount; + return this; + } + + /** + * Setter for appliedAmount. + * @param appliedAmount String value for appliedAmount. + * @return Builder + */ + public Builder appliedAmount(String appliedAmount) { + this.appliedAmount = appliedAmount; + return this; + } + + /** + * Builds a new {@link InvoiceDebit} object using the set fields. + * @return {@link InvoiceDebit} + */ + public InvoiceDebit build() { + return new InvoiceDebit(uid, debitNoteNumber, debitNoteUid, role, transactionTime, memo, + originalAmount, appliedAmount); + } + } +} diff --git a/src/main/java/com/maxio/advancedbilling/models/InvoiceLineItem.java b/src/main/java/com/maxio/advancedbilling/models/InvoiceLineItem.java index a886d39f..e5a2778d 100644 --- a/src/main/java/com/maxio/advancedbilling/models/InvoiceLineItem.java +++ b/src/main/java/com/maxio/advancedbilling/models/InvoiceLineItem.java @@ -38,6 +38,7 @@ public class InvoiceLineItem private OptionalNullable productVersion; private OptionalNullable componentId; private OptionalNullable pricePointId; + private OptionalNullable billingScheduleItemId; private Boolean hide; private OptionalNullable componentCostData; private OptionalNullable productPricePointId; @@ -69,6 +70,7 @@ public InvoiceLineItem() { * @param productVersion Integer value for productVersion. * @param componentId Integer value for componentId. * @param pricePointId Integer value for pricePointId. + * @param billingScheduleItemId Integer value for billingScheduleItemId. * @param hide Boolean value for hide. * @param componentCostData InvoiceLineItemComponentCostData value for componentCostData. * @param productPricePointId Integer value for productPricePointId. @@ -93,6 +95,7 @@ public InvoiceLineItem( Integer productVersion, Integer componentId, Integer pricePointId, + Integer billingScheduleItemId, Boolean hide, InvoiceLineItemComponentCostData componentCostData, Integer productPricePointId, @@ -115,6 +118,7 @@ public InvoiceLineItem( this.productVersion = OptionalNullable.of(productVersion); this.componentId = OptionalNullable.of(componentId); this.pricePointId = OptionalNullable.of(pricePointId); + this.billingScheduleItemId = OptionalNullable.of(billingScheduleItemId); this.hide = hide; this.componentCostData = OptionalNullable.of(componentCostData); this.productPricePointId = OptionalNullable.of(productPricePointId); @@ -141,6 +145,7 @@ public InvoiceLineItem( * @param productVersion Integer value for productVersion. * @param componentId Integer value for componentId. * @param pricePointId Integer value for pricePointId. + * @param billingScheduleItemId Integer value for billingScheduleItemId. * @param hide Boolean value for hide. * @param componentCostData InvoiceLineItemComponentCostData value for componentCostData. * @param productPricePointId Integer value for productPricePointId. @@ -153,8 +158,8 @@ protected InvoiceLineItem(String uid, String title, String description, String q String totalAmount, Boolean tieredUnitPrice, LocalDate periodRangeStart, LocalDate periodRangeEnd, Integer transactionId, OptionalNullable productId, OptionalNullable productVersion, OptionalNullable componentId, - OptionalNullable pricePointId, Boolean hide, - OptionalNullable componentCostData, + OptionalNullable pricePointId, OptionalNullable billingScheduleItemId, + Boolean hide, OptionalNullable componentCostData, OptionalNullable productPricePointId, Boolean customItem, String kind) { this.uid = uid; this.title = title; @@ -173,6 +178,7 @@ protected InvoiceLineItem(String uid, String title, String description, String q this.productVersion = productVersion; this.componentId = componentId; this.pricePointId = pricePointId; + this.billingScheduleItemId = billingScheduleItemId; this.hide = hide; this.componentCostData = componentCostData; this.productPricePointId = productPricePointId; @@ -671,6 +677,41 @@ public void unsetPricePointId() { pricePointId = null; } + /** + * Internal Getter for BillingScheduleItemId. + * @return Returns the Internal Integer + */ + @JsonGetter("billing_schedule_item_id") + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSerialize(using = OptionalNullable.Serializer.class) + protected OptionalNullable internalGetBillingScheduleItemId() { + return this.billingScheduleItemId; + } + + /** + * Getter for BillingScheduleItemId. + * @return Returns the Integer + */ + public Integer getBillingScheduleItemId() { + return OptionalNullable.getFrom(billingScheduleItemId); + } + + /** + * Setter for BillingScheduleItemId. + * @param billingScheduleItemId Value for Integer + */ + @JsonSetter("billing_schedule_item_id") + public void setBillingScheduleItemId(Integer billingScheduleItemId) { + this.billingScheduleItemId = OptionalNullable.of(billingScheduleItemId); + } + + /** + * UnSetter for BillingScheduleItemId. + */ + public void unsetBillingScheduleItemId() { + billingScheduleItemId = null; + } + /** * Getter for Hide. * @return Returns the Boolean @@ -815,7 +856,8 @@ public String toString() { + tieredUnitPrice + ", periodRangeStart=" + periodRangeStart + ", periodRangeEnd=" + periodRangeEnd + ", transactionId=" + transactionId + ", productId=" + productId + ", productVersion=" + productVersion + ", componentId=" + componentId - + ", pricePointId=" + pricePointId + ", hide=" + hide + ", componentCostData=" + + ", pricePointId=" + pricePointId + ", billingScheduleItemId=" + + billingScheduleItemId + ", hide=" + hide + ", componentCostData=" + componentCostData + ", productPricePointId=" + productPricePointId + ", customItem=" + customItem + ", kind=" + kind + ", additionalProperties=" + getAdditionalProperties() + "]"; @@ -848,6 +890,7 @@ public Builder toBuilder() { builder.productVersion = internalGetProductVersion(); builder.componentId = internalGetComponentId(); builder.pricePointId = internalGetPricePointId(); + builder.billingScheduleItemId = internalGetBillingScheduleItemId(); builder.componentCostData = internalGetComponentCostData(); builder.productPricePointId = internalGetProductPricePointId(); return builder; @@ -874,6 +917,7 @@ public static class Builder { private OptionalNullable productVersion; private OptionalNullable componentId; private OptionalNullable pricePointId; + private OptionalNullable billingScheduleItemId; private Boolean hide; private OptionalNullable componentCostData; private OptionalNullable productPricePointId; @@ -1088,6 +1132,25 @@ public Builder unsetPricePointId() { return this; } + /** + * Setter for billingScheduleItemId. + * @param billingScheduleItemId Integer value for billingScheduleItemId. + * @return Builder + */ + public Builder billingScheduleItemId(Integer billingScheduleItemId) { + this.billingScheduleItemId = OptionalNullable.of(billingScheduleItemId); + return this; + } + + /** + * UnSetter for billingScheduleItemId. + * @return Builder + */ + public Builder unsetBillingScheduleItemId() { + billingScheduleItemId = null; + return this; + } + /** * Setter for hide. * @param hide Boolean value for hide. @@ -1164,7 +1227,8 @@ public InvoiceLineItem build() { return new InvoiceLineItem(uid, title, description, quantity, unitPrice, subtotalAmount, discountAmount, taxAmount, totalAmount, tieredUnitPrice, periodRangeStart, periodRangeEnd, transactionId, productId, productVersion, componentId, - pricePointId, hide, componentCostData, productPricePointId, customItem, kind); + pricePointId, billingScheduleItemId, hide, componentCostData, + productPricePointId, customItem, kind); } } } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/BaseCustomerInformationTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/BaseCustomerInformationTest.java index 898894e7..bf96b1fc 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/BaseCustomerInformationTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/BaseCustomerInformationTest.java @@ -49,9 +49,9 @@ import static org.assertj.core.api.Assertions.assertThat; public abstract class BaseCustomerInformationTest { - protected final TestSetup TEST_SETUP = new TestSetup(); - protected final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - protected final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + protected final AdvancedBillingClient client = TestClientProvider.getClient(); + protected final TestSetup testSetup = new TestSetup(client); + protected final InvoicesController invoicesController = client.getInvoicesController(); protected Product product; protected Customer customer; @@ -62,11 +62,11 @@ public abstract class BaseCustomerInformationTest { @BeforeAll void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(125000)); - customer = TEST_SETUP.createCustomer(); - quantityBasedComponent = TEST_SETUP.createQuantityBasedComponent(productFamily.getId()); - CLIENT.getCustomFieldsController().createMetafields(ResourceType.CUSTOMERS, new CreateMetafieldsRequest( + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(125000)); + customer = testSetup.createCustomer(); + quantityBasedComponent = testSetup.createQuantityBasedComponent(productFamily.getId()); + client.getCustomFieldsController().createMetafields(ResourceType.CUSTOMERS, new CreateMetafieldsRequest( CreateMetafieldsRequestMetafields.fromListOfCreateMetafield(List.of( new CreateMetafield.Builder() .inputType(MetafieldInput.TEXT) @@ -83,7 +83,7 @@ void setUp() throws IOException, ApiException { .build()) .build() )))); - CLIENT.getCustomFieldsController().createMetafields(ResourceType.SUBSCRIPTIONS, new CreateMetafieldsRequest( + client.getCustomFieldsController().createMetafields(ResourceType.SUBSCRIPTIONS, new CreateMetafieldsRequest( CreateMetafieldsRequestMetafields.fromListOfCreateMetafield(List.of( new CreateMetafield.Builder() .inputType(MetafieldInput.TEXT) @@ -110,11 +110,11 @@ void teardown() throws IOException, ApiException { protected TestData setupCustomerDataChangedScenario() throws IOException, ApiException { subscription = createTestSubscription(); - CLIENT.getCustomFieldsController() + client.getCustomFieldsController() .createMetadata(ResourceType.CUSTOMERS, customer.getId(), new CreateMetadataRequest( List.of(new CreateMetadata("CustomerField1", "value1")) )); - CLIENT.getCustomFieldsController() + client.getCustomFieldsController() .createMetadata(ResourceType.SUBSCRIPTIONS, subscription.getId(), new CreateMetadataRequest( List.of(new CreateMetadata("SubscriptionField1", "value1")) )); @@ -123,18 +123,18 @@ protected TestData setupCustomerDataChangedScenario() throws IOException, ApiExc Customer updatedCustomer = updateCustomerData(); - CLIENT.getCustomFieldsController() + client.getCustomFieldsController() .updateMetadata(ResourceType.CUSTOMERS, customer.getId(), new UpdateMetadataRequest( new UpdateMetadata("CustomerField1", "CustomerField1", "newValue1") )); - CLIENT.getCustomFieldsController() + client.getCustomFieldsController() .createMetadata(ResourceType.SUBSCRIPTIONS, subscription.getId(), new CreateMetadataRequest( List.of(new CreateMetadata("SubscriptionField2", "value2")) )); - CLIENT.getCustomFieldsController() + client.getCustomFieldsController() .deleteMetadata(ResourceType.SUBSCRIPTIONS, subscription.getId(), "SubscriptionField1", List.of()); - subscriptionMetadata = CLIENT.getCustomFieldsController() + subscriptionMetadata = client.getCustomFieldsController() .listMetadataForResourceType(new ListMetadataForResourceTypeInput.Builder() .resourceIds(List.of(subscription.getId())) .resourceType(ResourceType.SUBSCRIPTIONS) @@ -144,7 +144,7 @@ protected TestData setupCustomerDataChangedScenario() throws IOException, ApiExc .stream() .collect(Collectors.toMap(Metadata::getName, Function.identity())); - customerMetadata = CLIENT.getCustomFieldsController() + customerMetadata = client.getCustomFieldsController() .listMetadataForResourceType(new ListMetadataForResourceTypeInput.Builder() .resourceIds(List.of(customer.getId())) .resourceType(ResourceType.CUSTOMERS) @@ -164,12 +164,12 @@ protected Subscription createTestSubscription() throws IOException, ApiException .unitBalance(10) .build()); - return TEST_SETUP.createSubscription(customer, product, s -> s + return testSetup.createSubscription(customer, product, s -> s .components(subscriptionComponents)); } protected Invoice createOpenInvoice(Subscription subscription) throws ApiException, IOException { - CLIENT.getSubscriptionComponentsController() + client.getSubscriptionComponentsController() .allocateComponent(subscription.getId(), quantityBasedComponent.getId(), new CreateAllocationRequest( new CreateAllocation.Builder() .memo("Allocate metered for invoice") @@ -178,7 +178,7 @@ protected Invoice createOpenInvoice(Subscription subscription) throws ApiExcepti .build()) ); - Invoice pendingInvoice = INVOICES_CONTROLLER.listInvoices( + Invoice pendingInvoice = invoicesController.listInvoices( new ListInvoicesInput.Builder() .status(InvoiceStatus.PENDING) .subscriptionId(subscription.getId()) @@ -186,12 +186,12 @@ protected Invoice createOpenInvoice(Subscription subscription) throws ApiExcepti .getInvoices() .get(0); - INVOICES_CONTROLLER.issueInvoice(pendingInvoice.getUid(), new IssueInvoiceRequest()); - return INVOICES_CONTROLLER.readInvoice(pendingInvoice.getUid()); + invoicesController.issueInvoice(pendingInvoice.getUid(), new IssueInvoiceRequest()); + return invoicesController.readInvoice(pendingInvoice.getUid()); } protected Customer updateCustomerData() throws ApiException, IOException { - return CLIENT.getCustomersController().updateCustomer(customer.getId(), new UpdateCustomerRequest(new UpdateCustomer.Builder() + return client.getCustomersController().updateCustomer(customer.getId(), new UpdateCustomerRequest(new UpdateCustomer.Builder() .firstName("New First Name") .lastName("New Last Name") .email("new@email.com") diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerCreateTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerCreateTest.java index 1c5ee846..5d0218c4 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerCreateTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerCreateTest.java @@ -55,29 +55,29 @@ import static org.junit.jupiter.api.Assertions.assertAll; public class InvoicesControllerCreateTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static ProductFamily productFamily; - private static Product product; - private static Component meteredComponent; - private static Customer customer; - private static Subscription subscription; - private static Coupon coupon; + private ProductFamily productFamily; + private Product product; + private Component meteredComponent; + private Customer customer; + private Subscription subscription; + private Coupon coupon; @BeforeAll - static void setUp() throws IOException, ApiException { - productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); - subscription = TEST_SETUP.createSubscription(customer, product); - meteredComponent = TEST_SETUP.createMeteredComponent(productFamily, 11.5); - coupon = TEST_SETUP.createAmountCoupon(productFamily, 1250, true); + void setUp() throws IOException, ApiException { + productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); + subscription = testSetup.createSubscription(customer, product); + meteredComponent = testSetup.createMeteredComponent(productFamily, 11.5); + coupon = testSetup.createAmountCoupon(productFamily, 1250, true); } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @@ -85,7 +85,7 @@ static void teardown() throws IOException, ApiException { @Test void shouldCreateInvoice() throws IOException, ApiException { // when - Invoice invoice = TEST_SETUP.createInvoice( + Invoice invoice = testSetup.createInvoice( subscription.getId(), b -> b .status(CreateInvoiceStatus.OPEN) @@ -204,9 +204,9 @@ void shouldCreateInvoice() throws IOException, ApiException { .hasSize(3) .extracting(BaseModel::getAdditionalProperties) .containsExactlyInAnyOrder( - Collections.singletonMap("billing_schedule_item_id", null), - Collections.singletonMap("billing_schedule_item_id", null), - Collections.singletonMap("billing_schedule_item_id", null) + Collections.emptyMap(), + Collections.emptyMap(), + Collections.emptyMap() ); assertThat(lineItems) .usingRecursiveFieldByFieldElementComparatorIgnoringFields("uid", "additionalProperties") @@ -220,7 +220,6 @@ void shouldCreateInvoice() throws IOException, ApiException { .discountAmount("12.5") .taxAmount("0.0") .totalAmount("0.0") - .kind("delay_capture") .tieredUnitPrice(false) .periodRangeStart(LocalDate.now()) .periodRangeEnd(LocalDate.now()) @@ -228,8 +227,10 @@ void shouldCreateInvoice() throws IOException, ApiException { .productVersion(null) .componentId(null) .pricePointId(null) + .billingScheduleItemId(null) .productPricePointId(null) .customItem(false) + .kind("delay_capture") .build(), new InvoiceLineItem.Builder() .title("Custom line") @@ -240,7 +241,6 @@ void shouldCreateInvoice() throws IOException, ApiException { .discountAmount("8.5") .taxAmount("0.0") .totalAmount("14.0") - .kind("delay_capture") .tieredUnitPrice(false) .periodRangeStart(LocalDate.now()) .periodRangeEnd(LocalDate.now()) @@ -248,8 +248,10 @@ void shouldCreateInvoice() throws IOException, ApiException { .productVersion(null) .componentId(null) .pricePointId(null) + .billingScheduleItemId(null) .productPricePointId(null) .customItem(true) + .kind("delay_capture") .build(), new InvoiceLineItem.Builder() .title(meteredComponent.getName()) @@ -260,7 +262,6 @@ void shouldCreateInvoice() throws IOException, ApiException { .discountAmount("0.0") .taxAmount("0.0") .totalAmount("115.0") - .kind("delay_capture") .tieredUnitPrice(false) .periodRangeStart(LocalDate.now()) .periodRangeEnd(LocalDate.now()) @@ -268,8 +269,10 @@ void shouldCreateInvoice() throws IOException, ApiException { .productVersion(null) .componentId(meteredComponent.getId()) .pricePointId(meteredComponent.getDefaultPricePointId()) + .billingScheduleItemId(null) .productPricePointId(null) .customItem(false) + .kind("delay_capture") .build() ); @@ -329,7 +332,7 @@ void shouldCreateInvoice() throws IOException, ApiException { void shouldReturn404WhenCreatingInvoiceForNonExistentSubscription() { // when - then CommonAssertions.assertNotFound( - () -> INVOICES_CONTROLLER.createInvoice(123, new CreateInvoiceRequest()) + () -> invoicesController.createInvoice(123, new CreateInvoiceRequest()) ); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java index 3ab73713..439b9ca2 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerIssueTest.java @@ -46,7 +46,6 @@ import java.time.LocalDate; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.stream.Stream; import static com.maxio.advancedbilling.utils.TestFixtures.INVOICE_SELLER; @@ -54,32 +53,32 @@ import static org.junit.jupiter.api.Assertions.assertAll; class InvoicesControllerIssueTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static Product product; - private static Component quantityBasedComponent; - private static Subscription subscription; - private static Customer customer; - private static Invoice openInvoice; - private static Invoice paidInvoice; + private Product product; + private Component quantityBasedComponent; + private Subscription subscription; + private Customer customer; + private Invoice openInvoice; + private Invoice paidInvoice; @BeforeAll - static void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); - quantityBasedComponent = TEST_SETUP.createQuantityBasedComponent( + void setUp() throws IOException, ApiException { + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); + quantityBasedComponent = testSetup.createQuantityBasedComponent( productFamily.getId(), b -> b.allowFractionalQuantities(true) ); - subscription = TEST_SETUP.createSubscription(customer, product); - paidInvoice = INVOICES_CONTROLLER + subscription = testSetup.createSubscription(customer, product); + paidInvoice = invoicesController .listInvoices(new ListInvoicesInput.Builder().subscriptionId(subscription.getId()).build()) .getInvoices() .get(0); - openInvoice = TEST_SETUP.createInvoice( + openInvoice = testSetup.createInvoice( subscription.getId(), b -> b .status(CreateInvoiceStatus.OPEN) @@ -101,7 +100,7 @@ static void setUp() throws IOException, ApiException { } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @@ -115,19 +114,19 @@ void shouldIssuePendingInvoice() throws IOException, ApiException { .build(); // this creates an invoice in the "PENDING" status - CLIENT.getSubscriptionComponentsController().allocateComponent( + client.getSubscriptionComponentsController().allocateComponent( subscription.getId(), quantityBasedComponent.getId(), new CreateAllocationRequest(createAllocation) ); - Invoice pendingInvoice = INVOICES_CONTROLLER + Invoice pendingInvoice = invoicesController .listInvoices(new ListInvoicesInput.Builder().status(InvoiceStatus.PENDING).build()) .getInvoices() .get(0); // when - Invoice issuedInvoice = INVOICES_CONTROLLER.issueInvoice( + Invoice issuedInvoice = invoicesController.issueInvoice( pendingInvoice.getUid(), new IssueInvoiceRequest(FailedPaymentAction.LEAVE_OPEN_INVOICE) ); @@ -211,7 +210,7 @@ void shouldIssuePendingInvoice() throws IOException, ApiException { assertThat(lineItems) .hasSize(1) .extracting(BaseModel::getAdditionalProperties) - .containsExactly(Collections.singletonMap("billing_schedule_item_id", null)); + .containsExactly(Collections.emptyMap()); assertThat(lineItems) .usingRecursiveFieldByFieldElementComparatorIgnoringFields("uid", "description", "additionalProperties") .containsExactly( @@ -264,12 +263,12 @@ void shouldIssuePendingInvoice() throws IOException, ApiException { void shouldReturn422WhenIssuingInvoiceWithIncorrectStatus(String invoiceUid) { // when - then CommonAssertions - .assertThatErrorListResponse(() -> INVOICES_CONTROLLER.issueInvoice(invoiceUid, new IssueInvoiceRequest())) + .assertThatErrorListResponse(() -> invoicesController.issueInvoice(invoiceUid, new IssueInvoiceRequest())) .isUnprocessableEntity() .hasErrors("Invoice must have 'pending' status"); } - private static Stream argsForShouldReturn422WhenIssuingInvoiceWithIncorrectStatus() { + private Stream argsForShouldReturn422WhenIssuingInvoiceWithIncorrectStatus() { return Stream.of( Arguments.arguments(paidInvoice.getUid()), Arguments.arguments(openInvoice.getUid()) @@ -280,7 +279,7 @@ private static Stream argsForShouldReturn422WhenIssuingInvoiceWithInc void shouldReturn404WhenIssuingNotExistentInvoice() { // when - then CommonAssertions.assertNotFound( - () -> INVOICES_CONTROLLER.issueInvoice("123", new IssueInvoiceRequest(FailedPaymentAction.LEAVE_OPEN_INVOICE)) + () -> invoicesController.issueInvoice("123", new IssueInvoiceRequest(FailedPaymentAction.LEAVE_OPEN_INVOICE)) ); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListCreditNotesTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListCreditNotesTest.java index 0d80d368..0872713b 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListCreditNotesTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListCreditNotesTest.java @@ -40,10 +40,10 @@ import static org.assertj.core.api.Assertions.assertThat; class InvoicesControllerListCreditNotesTest { - private final TestSetup TEST_SETUP = new TestSetup(); - private final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); - private final InvoicesControllerUtils invoicesControllerUtils = new InvoicesControllerUtils(CLIENT); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); + private final InvoicesControllerUtils invoicesControllerUtils = new InvoicesControllerUtils(client); private Product product; private Component quantityBasedComponent; @@ -54,24 +54,24 @@ class InvoicesControllerListCreditNotesTest { @BeforeAll void setUp() throws IOException, ApiException, InterruptedException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); - quantityBasedComponent = TEST_SETUP.createQuantityBasedComponent(productFamily.getId()); - coupon = TEST_SETUP.createAmountCoupon(productFamily, 1250, true); + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); + quantityBasedComponent = testSetup.createQuantityBasedComponent(productFamily.getId()); + coupon = testSetup.createAmountCoupon(productFamily, 1250, true); List subscriptionComponents = List.of( new CreateSubscriptionComponent.Builder() .componentId(CreateSubscriptionComponentComponentId.fromNumber(quantityBasedComponent.getId())) .allocatedQuantity(CreateSubscriptionComponentAllocatedQuantity.fromNumber(50)) .build()); - Subscription subscription = TEST_SETUP.createSubscription(customer, product, s -> s + Subscription subscription = testSetup.createSubscription(customer, product, s -> s .couponCode(coupon.getCode()) .components(subscriptionComponents) ); subscriptionId = subscription.getId(); paidInvoice = invoicesControllerUtils.getPaidInvoiceForSubscription(subscriptionId); // refund a part of the payment - INVOICES_CONTROLLER.refundInvoice(paidInvoice.getUid(), + invoicesController.refundInvoice(paidInvoice.getUid(), new RefundInvoiceRequest(RefundInvoiceRequestRefund.fromRefundInvoice( new RefundInvoice.Builder() .memo("Special refund") @@ -91,7 +91,7 @@ void teardown() throws IOException, ApiException { @Test void shouldReturnDefaultListOfCreditNotesExcludingAdditionalResponseArrays() throws IOException, ApiException { // when - List creditNotes = INVOICES_CONTROLLER + List creditNotes = invoicesController .listCreditNotes(new ListCreditNotesInput.Builder().subscriptionId(subscriptionId).build()) .getCreditNotes(); @@ -107,7 +107,7 @@ void shouldReturnDefaultListOfCreditNotesExcludingAdditionalResponseArrays() thr @Test void shouldReturnListOfCreditNotesWithAdditionalApplicationsData() throws IOException, ApiException { // when - List creditNotes = INVOICES_CONTROLLER + List creditNotes = invoicesController .listCreditNotes(new ListCreditNotesInput.Builder() .subscriptionId(subscriptionId) .applications(true) @@ -132,7 +132,7 @@ void shouldReturnListOfCreditNotesWithAdditionalApplicationsData() throws IOExce @Test void shouldReturnListOfCreditNotesWithAdditionalDiscountsData() throws IOException, ApiException { // when - List creditNotes = INVOICES_CONTROLLER + List creditNotes = invoicesController .listCreditNotes(new ListCreditNotesInput.Builder() .subscriptionId(subscriptionId) .discounts(true) @@ -163,7 +163,7 @@ void shouldReturnListOfCreditNotesWithAdditionalDiscountsData() throws IOExcepti @Test void shouldReturnListOfCreditNotesWithAdditionalLineItemsData() throws IOException, ApiException { // when - List creditNotes = INVOICES_CONTROLLER + List creditNotes = invoicesController .listCreditNotes(new ListCreditNotesInput.Builder() .subscriptionId(subscriptionId) .lineItems(true) @@ -221,7 +221,7 @@ void shouldReturnListOfCreditNotesWithAdditionalLineItemsData() throws IOExcepti @Test void shouldReturnListOfCreditNotesWithAdditionalRefundsData() throws IOException, ApiException { // when - List creditNotes = INVOICES_CONTROLLER + List creditNotes = invoicesController .listCreditNotes(new ListCreditNotesInput.Builder() .subscriptionId(subscriptionId) .refunds(true) @@ -256,7 +256,7 @@ void shouldReturnListOfCreditNotesWithAdditionalRefundsData() throws IOException @Test void shouldReturnListOfCreditNotesWithAdditionalTaxesData() throws IOException, ApiException { // when - List creditNotes = INVOICES_CONTROLLER + List creditNotes = invoicesController .listCreditNotes(new ListCreditNotesInput.Builder() .subscriptionId(subscriptionId) .taxes(true) @@ -272,7 +272,7 @@ void shouldReturnListOfCreditNotesWithAdditionalTaxesData() throws IOException, @Test void shouldReturnEmptyListWhenExceedingPagination() throws IOException, ApiException { // when - then - assertThat(INVOICES_CONTROLLER.listCreditNotes(new ListCreditNotesInput.Builder() + assertThat(invoicesController.listCreditNotes(new ListCreditNotesInput.Builder() .page(2) .build() ).getCreditNotes()).isEmpty(); @@ -281,10 +281,10 @@ void shouldReturnEmptyListWhenExceedingPagination() throws IOException, ApiExcep @Test void shouldReturnEmptyListWhenThereAreNoCredits() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); + Subscription subscription = testSetup.createSubscription(customer, product); // when - then - assertThat(INVOICES_CONTROLLER + assertThat(invoicesController .listCreditNotes(new ListCreditNotesInput.Builder().subscriptionId(subscription.getId()).build()) .getCreditNotes() ).isEmpty(); diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoiceEventsTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoiceEventsTest.java index 777cea0b..59ae0237 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoiceEventsTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoiceEventsTest.java @@ -25,18 +25,13 @@ import com.maxio.advancedbilling.models.FailedPaymentEvent; import com.maxio.advancedbilling.models.Invoice; import com.maxio.advancedbilling.models.InvoiceConsolidationLevel; -import com.maxio.advancedbilling.models.IssueInvoiceEvent; -import com.maxio.advancedbilling.models.RefundInvoiceEvent; -import com.maxio.advancedbilling.models.RemovePaymentEvent; -import com.maxio.advancedbilling.models.VoidInvoiceEvent; -import com.maxio.advancedbilling.models.VoidRemainderEvent; -import com.maxio.advancedbilling.models.containers.InvoiceEvent; import com.maxio.advancedbilling.models.InvoiceEventPaymentMethod; import com.maxio.advancedbilling.models.InvoiceEventType; import com.maxio.advancedbilling.models.InvoicePayment; import com.maxio.advancedbilling.models.InvoicePaymentMethodType; import com.maxio.advancedbilling.models.InvoicePaymentType; import com.maxio.advancedbilling.models.InvoiceStatus; +import com.maxio.advancedbilling.models.IssueInvoiceEvent; import com.maxio.advancedbilling.models.IssueInvoiceEventData; import com.maxio.advancedbilling.models.ListInvoiceEventsInput; import com.maxio.advancedbilling.models.ListInvoiceEventsResponse; @@ -48,16 +43,21 @@ import com.maxio.advancedbilling.models.Product; import com.maxio.advancedbilling.models.ProductFamily; import com.maxio.advancedbilling.models.RefundInvoice; +import com.maxio.advancedbilling.models.RefundInvoiceEvent; import com.maxio.advancedbilling.models.RefundInvoiceEventData; import com.maxio.advancedbilling.models.RefundInvoiceRequest; +import com.maxio.advancedbilling.models.RemovePaymentEvent; import com.maxio.advancedbilling.models.Subscription; import com.maxio.advancedbilling.models.VoidInvoice; +import com.maxio.advancedbilling.models.VoidInvoiceEvent; import com.maxio.advancedbilling.models.VoidInvoiceRequest; +import com.maxio.advancedbilling.models.VoidRemainderEvent; import com.maxio.advancedbilling.models.VoidRemainderEventData; import com.maxio.advancedbilling.models.containers.CreateInvoiceCouponAmount; import com.maxio.advancedbilling.models.containers.CreateInvoiceItemProductId; import com.maxio.advancedbilling.models.containers.CreateInvoiceItemQuantity; import com.maxio.advancedbilling.models.containers.CreateInvoicePaymentAmount; +import com.maxio.advancedbilling.models.containers.InvoiceEvent; import com.maxio.advancedbilling.models.containers.InvoiceEventPayment; import com.maxio.advancedbilling.models.containers.RefundInvoiceRequestRefund; import com.maxio.advancedbilling.utils.TestSetup; @@ -73,23 +73,23 @@ import static org.assertj.core.api.Assertions.assertThat; public class InvoicesControllerListInvoiceEventsTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static Product product; - private static Customer customer; - private static Subscription subscription; - private static Invoice expectedInvoice; + private Product product; + private Customer customer; + private Subscription subscription; + private Invoice expectedInvoice; @BeforeAll - static void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(125000)); - customer = TEST_SETUP.createCustomer(); - subscription = TEST_SETUP.createSubscription(customer, product); + void setUp() throws IOException, ApiException { + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(125000)); + customer = testSetup.createCustomer(); + subscription = testSetup.createSubscription(customer, product); - expectedInvoice = TEST_SETUP.createInvoice( + expectedInvoice = testSetup.createInvoice( subscription.getId(), b -> b .status(CreateInvoiceStatus.OPEN) @@ -109,7 +109,7 @@ static void setUp() throws IOException, ApiException { .build() ); - expectedInvoice = INVOICES_CONTROLLER.recordPaymentForInvoice(expectedInvoice.getUid(), new CreateInvoicePaymentRequest.Builder() + expectedInvoice = invoicesController.recordPaymentForInvoice(expectedInvoice.getUid(), new CreateInvoicePaymentRequest.Builder() .type(InvoicePaymentType.EXTERNAL) .payment(new CreateInvoicePayment.Builder() .method(InvoicePaymentMethodType.MONEY_ORDER) @@ -119,7 +119,7 @@ static void setUp() throws IOException, ApiException { InvoicePayment payment = expectedInvoice.getPayments().get(0); - expectedInvoice = INVOICES_CONTROLLER.refundInvoice(expectedInvoice.getUid(), new RefundInvoiceRequest( + expectedInvoice = invoicesController.refundInvoice(expectedInvoice.getUid(), new RefundInvoiceRequest( RefundInvoiceRequestRefund.fromRefundInvoice(new RefundInvoice.Builder() .applyCredit(true) .paymentId(payment.getTransactionId()) @@ -128,8 +128,8 @@ static void setUp() throws IOException, ApiException { .voidInvoice(false) .build())) ); - expectedInvoice = INVOICES_CONTROLLER.voidInvoice(expectedInvoice.getUid(), new VoidInvoiceRequest(new VoidInvoice("Test"))); - expectedInvoice = INVOICES_CONTROLLER.readInvoice(expectedInvoice.getUid()); + expectedInvoice = invoicesController.voidInvoice(expectedInvoice.getUid(), new VoidInvoiceRequest(new VoidInvoice("Test"))); + expectedInvoice = invoicesController.readInvoice(expectedInvoice.getUid()); try { // sometimes some events are missing @@ -140,14 +140,14 @@ static void setUp() throws IOException, ApiException { } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @Test void shouldReturnEmptyListIfInvoiceDoesNotExist() throws IOException, ApiException { // when - ListInvoiceEventsResponse response = INVOICES_CONTROLLER.listInvoiceEvents(new ListInvoiceEventsInput.Builder() + ListInvoiceEventsResponse response = invoicesController.listInvoiceEvents(new ListInvoiceEventsInput.Builder() .invoiceUid("uid_123445") .perPage(10) .build()); @@ -162,7 +162,7 @@ void shouldReturnEmptyListIfInvoiceDoesNotExist() throws IOException, ApiExcepti @Test void shouldReturnInvoiceEventsForExistingInvoice() throws IOException, ApiException { // when - ListInvoiceEventsResponse response = INVOICES_CONTROLLER.listInvoiceEvents( + ListInvoiceEventsResponse response = invoicesController.listInvoiceEvents( new ListInvoiceEventsInput.Builder() .invoiceUid(expectedInvoice.getUid()) .perPage(10) @@ -335,21 +335,21 @@ void shouldReturnInvoiceEventsForExistingInvoice() throws IOException, ApiExcept @Test void shouldReturnInvoiceEventsWithPaging() throws IOException, ApiException { // when - ListInvoiceEventsResponse page1 = INVOICES_CONTROLLER.listInvoiceEvents( + ListInvoiceEventsResponse page1 = invoicesController.listInvoiceEvents( new ListInvoiceEventsInput.Builder() .invoiceUid(expectedInvoice.getUid()) .perPage(2) .page(1) .build()); - ListInvoiceEventsResponse page2 = INVOICES_CONTROLLER.listInvoiceEvents( + ListInvoiceEventsResponse page2 = invoicesController.listInvoiceEvents( new ListInvoiceEventsInput.Builder() .invoiceUid(expectedInvoice.getUid()) .perPage(2) .page(2) .build()); - ListInvoiceEventsResponse page3 = INVOICES_CONTROLLER.listInvoiceEvents( + ListInvoiceEventsResponse page3 = invoicesController.listInvoiceEvents( new ListInvoiceEventsInput.Builder() .invoiceUid(expectedInvoice.getUid()) .perPage(2) @@ -376,7 +376,7 @@ void shouldReturnInvoiceEventsWithPaging() throws IOException, ApiException { @Test void shouldReturnInvoiceEventsFilteredByType() throws IOException, ApiException { // when - ListInvoiceEventsResponse response = INVOICES_CONTROLLER.listInvoiceEvents( + ListInvoiceEventsResponse response = invoicesController.listInvoiceEvents( new ListInvoiceEventsInput.Builder() .invoiceUid(expectedInvoice.getUid()) .eventTypes(List.of(InvoiceEventType.REFUND_INVOICE, InvoiceEventType.ISSUE_INVOICE)) @@ -390,9 +390,9 @@ void shouldReturnInvoiceEventsFilteredByType() throws IOException, ApiException assertThat(response.getPage()).isEqualTo(1); assertThat(response.getEvents()).hasSize(2); - IssueInvoiceEvent issueInvoiceEvent = assertCastable(response.getEvents().get(0), IssueInvoiceEvent.class); + IssueInvoiceEvent issueInvoiceEvent = assertCastable(response.getEvents().get(0), IssueInvoiceEvent.class); assertThat(issueInvoiceEvent.getEventType()).isEqualTo(InvoiceEventType.ISSUE_INVOICE); - RefundInvoiceEvent refundInvoiceEvent = assertCastable(response.getEvents().get(1), RefundInvoiceEvent.class); + RefundInvoiceEvent refundInvoiceEvent = assertCastable(response.getEvents().get(1), RefundInvoiceEvent.class); assertThat(refundInvoiceEvent.getEventType()).isEqualTo(InvoiceEventType.REFUND_INVOICE); } @@ -407,17 +407,22 @@ void shouldThrowUnauthorizedForInvalidCredentials() { void assertInvoiceInEvent(Invoice eventInvoice, Invoice invoice) { assertThat(eventInvoice.getAdditionalProperties()).satisfies(additionalProperties -> { + assertThat(additionalProperties.size()).isEqualTo(15); assertThat(additionalProperties.get("statement_id")).isNull(); assertThat(additionalProperties.get("legacy_invoice_number")).isNull(); assertThat(additionalProperties.get("backported_at")).isNull(); assertThat(additionalProperties.get("subscription_group_customer_ids")).isNull(); - assertThat(additionalProperties.get("debit_amount")).isEqualTo("0.0"); - assertThat(additionalProperties.get("debits")).usingRecursiveComparison().isEqualTo(List.of()); assertThat(additionalProperties.get("tax_exempt_amount")).isEqualTo("0.0"); assertThat(additionalProperties.get("status_changed_at")).isNotNull(); assertThat(additionalProperties.get("prepaid_usage_details")).isNull(); assertThat(additionalProperties.get("invoice_account_details")).isNull(); assertThat(additionalProperties.get("external_connected_data")).isNull(); + assertThat(additionalProperties.get("owner_id")).isNull(); + assertThat(additionalProperties.get("owner_type")).isNull(); + assertThat(additionalProperties.get("core_id")).isNull(); + assertThat(additionalProperties.get("core_invoice_number")).isNull(); + assertThat(additionalProperties.get("maxio_metadata")).isNull(); + assertThat(additionalProperties.get("core_po_number")).isNull(); }); assertThat(eventInvoice) .usingRecursiveComparison() diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoiceSegmentsTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoiceSegmentsTest.java index a552f775..34f0bfeb 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoiceSegmentsTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoiceSegmentsTest.java @@ -32,29 +32,28 @@ import static org.assertj.core.api.Assertions.assertThat; public class InvoicesControllerListInvoiceSegmentsTest { + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); - - private static SubscriptionGroupSignupResponse groupSignup; - private static Customer customer; - private static Subscription subscription; + private SubscriptionGroupSignupResponse groupSignup; + private Customer customer; + private Subscription subscription; @BeforeAll - static void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - Product product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - Component meteredComponent = TEST_SETUP.createMeteredComponent(productFamily, 11.5); + void setUp() throws IOException, ApiException { + ProductFamily productFamily = testSetup.createProductFamily(); + Product product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + Component meteredComponent = testSetup.createMeteredComponent(productFamily, 11.5); - customer = TEST_SETUP.createCustomer(); - subscription = TEST_SETUP.createSubscription(customer, product); + customer = testSetup.createCustomer(); + subscription = testSetup.createSubscription(customer, product); - groupSignup = TEST_SETUP.signupWithSubscriptionGroup(product, meteredComponent); + groupSignup = testSetup.signupWithSubscriptionGroup(product, meteredComponent); } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { TestTeardown testTeardown = new TestTeardown(); testTeardown.deleteCustomer(customer); testTeardown.deleteSubscriptionGroup(groupSignup); @@ -64,10 +63,10 @@ static void teardown() throws IOException, ApiException { void shouldListInvoiceSegmentsForConsolidatedInvoice() throws IOException, ApiException { // given // Invoice segments returned on the index will only include totals, not detailed breakdowns for line_items, - // discounts, taxes, credits, payments, or custom_fields - String[] IGNORED_FIELDS = {"credits", "customFields", "discounts", "lineItems", "payments", "refunds", "taxes", "updatedAt", "createdAt", "additionalProperties"}; + // discounts, taxes, credits, debits, payments, or custom_fields + String[] IGNORED_FIELDS = {"credits", "debits", "customFields", "discounts", "lineItems", "payments", "refunds", "taxes", "updatedAt", "createdAt", "additionalProperties"}; - Invoice subscriptionGroupInvoice = INVOICES_CONTROLLER + Invoice subscriptionGroupInvoice = invoicesController .listInvoices(new ListInvoicesInput.Builder() .customerIds(List.of(groupSignup.getCustomerId())) .status(InvoiceStatus.PAID) @@ -79,7 +78,7 @@ void shouldListInvoiceSegmentsForConsolidatedInvoice() throws IOException, ApiEx String uid2 = getInvoiceUid(groupSignup.getSubscriptionIds().get(1)); // when - ConsolidatedInvoice consolidatedInvoice = INVOICES_CONTROLLER.listConsolidatedInvoiceSegments( + ConsolidatedInvoice consolidatedInvoice = invoicesController.listConsolidatedInvoiceSegments( new ListConsolidatedInvoiceSegmentsInput.Builder() .perPage(10) .invoiceUid(subscriptionGroupInvoice.getUid()) @@ -96,19 +95,19 @@ void shouldListInvoiceSegmentsForConsolidatedInvoice() throws IOException, ApiEx assertThat(segment1) .usingRecursiveComparison() .ignoringFields(IGNORED_FIELDS) - .isEqualTo(INVOICES_CONTROLLER.readInvoice(uid1)); + .isEqualTo(invoicesController.readInvoice(uid1)); Invoice segment2 = subscriptionIdToInvoice.get(groupSignup.getSubscriptionIds().get(1)); assertThat(segment2) .usingRecursiveComparison() .ignoringFields(IGNORED_FIELDS) - .isEqualTo(INVOICES_CONTROLLER.readInvoice(uid2)); + .isEqualTo(invoicesController.readInvoice(uid2)); } @Test void shouldReturnEmptyListForNonConsolidatedInvoice() throws IOException, ApiException { // when - ConsolidatedInvoice response = INVOICES_CONTROLLER.listConsolidatedInvoiceSegments( + ConsolidatedInvoice response = invoicesController.listConsolidatedInvoiceSegments( new ListConsolidatedInvoiceSegmentsInput.Builder() .invoiceUid(getInvoiceUid(subscription.getId())) .build()); @@ -130,12 +129,12 @@ void shouldThrowUnauthorizedForInvalidCredentials() { @Test void shouldThrowNotFoundIfInvoiceDoesNotExist() { // when then - assertNotFound(() -> INVOICES_CONTROLLER.listConsolidatedInvoiceSegments( + assertNotFound(() -> invoicesController.listConsolidatedInvoiceSegments( new ListConsolidatedInvoiceSegmentsInput.Builder().invoiceUid("uid").build())); } private String getInvoiceUid(int subscriptionId) throws ApiException, IOException { - return INVOICES_CONTROLLER + return invoicesController .listInvoices(new ListInvoicesInput.Builder() .subscriptionId(subscriptionId) .build()) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoicesTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoicesTest.java index 1af122f0..4555b8af 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoicesTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerListInvoicesTest.java @@ -57,29 +57,29 @@ import static org.assertj.core.api.Assertions.assertThat; public class InvoicesControllerListInvoicesTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); - - private static ProductFamily productFamily; - private static Product product; - private static Product otherProduct; - private static Component meteredComponent; - private static final List customers = new ArrayList<>(); - private static final List subscriptions = new ArrayList<>(); - private static Coupon coupon; + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); + + private ProductFamily productFamily; + private Product product; + private Product otherProduct; + private Component meteredComponent; + private final List customers = new ArrayList<>(); + private final List subscriptions = new ArrayList<>(); + private Coupon coupon; @BeforeAll - static void setUp() throws IOException, ApiException { - productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - otherProduct = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(100)); + void setUp() throws IOException, ApiException { + productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + otherProduct = testSetup.createProduct(productFamily, b -> b.priceInCents(100)); - meteredComponent = TEST_SETUP.createMeteredComponent(productFamily, 11.5); - coupon = TEST_SETUP.createAmountCoupon(productFamily, 1250, true); + meteredComponent = testSetup.createMeteredComponent(productFamily, 11.5); + coupon = testSetup.createAmountCoupon(productFamily, 1250, true); for (int i = 0; i < 10; ++i) { - Customer customer = TEST_SETUP.createCustomer(); + Customer customer = testSetup.createCustomer(); List subscriptionComponents = List.of( new CreateSubscriptionComponent.Builder() @@ -87,7 +87,7 @@ static void setUp() throws IOException, ApiException { .unitBalance(10 + i) .build()); - Subscription subscription = TEST_SETUP.createSubscription(customer, product, s -> s + Subscription subscription = testSetup.createSubscription(customer, product, s -> s .couponCode(coupon.getCode()) .components(subscriptionComponents) ); @@ -95,7 +95,7 @@ static void setUp() throws IOException, ApiException { subscriptions.add(subscription); } - INVOICES_CONTROLLER.createInvoice(subscriptions.get(0).getId(), new CreateInvoiceRequest( + invoicesController.createInvoice(subscriptions.get(0).getId(), new CreateInvoiceRequest( new CreateInvoice.Builder() .paymentInstructions("Custom payment instructions") .memo("Custom memo") @@ -117,7 +117,7 @@ static void setUp() throws IOException, ApiException { } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { TestTeardown testTeardown = new TestTeardown(); for (Customer customer : customers) { testTeardown.deleteCustomer(customer); @@ -127,7 +127,7 @@ static void teardown() throws IOException, ApiException { @Test void shouldListAllInvoices() throws IOException, ApiException { // when - List invoices = INVOICES_CONTROLLER + List invoices = invoicesController .listInvoices(new ListInvoicesInput.Builder() .productIds(List.of(product.getId(), otherProduct.getId())) .build()) @@ -178,7 +178,7 @@ void shouldListInvoicesUsingSubscriptionId() throws IOException, ApiException { Subscription subscription = subscriptions.get(1); // when - List invoices = INVOICES_CONTROLLER + List invoices = invoicesController .listInvoices(new ListInvoicesInput.Builder() .subscriptionId(subscription.getId()) .lineItems(true) @@ -359,7 +359,7 @@ void shouldThrowUnauthorizedForInvalidCredentials() { } private List listSortedByNumberWithPaging(int page) throws ApiException, IOException { - return INVOICES_CONTROLLER + return invoicesController .listInvoices(new ListInvoicesInput.Builder() .perPage(5) .page(page) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerPreviewCustomerInformationChangesTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerPreviewCustomerInformationChangesTest.java index 300ca3ad..b102dfdf 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerPreviewCustomerInformationChangesTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerPreviewCustomerInformationChangesTest.java @@ -30,7 +30,7 @@ void shouldReturnEmptyPreviewIfNoChanges() throws IOException, ApiException { Invoice openInvoice = createOpenInvoice(subscription); // when - CustomerChangesPreviewResponse preview = INVOICES_CONTROLLER.previewCustomerInformationChanges(openInvoice.getUid()); + CustomerChangesPreviewResponse preview = invoicesController.previewCustomerInformationChanges(openInvoice.getUid()); // then assertThat(preview).isNotNull(); @@ -50,7 +50,7 @@ void shouldReturnPreviewOfChanges() throws IOException, ApiException { Invoice openInvoice = testData.openInvoice(); // when - CustomerChangesPreviewResponse preview = INVOICES_CONTROLLER.previewCustomerInformationChanges(openInvoice.getUid()); + CustomerChangesPreviewResponse preview = invoicesController.previewCustomerInformationChanges(openInvoice.getUid()); // then assertThat(preview).isNotNull(); @@ -94,9 +94,9 @@ void shouldReturnPreviewOfChanges() throws IOException, ApiException { @Test void shouldThrowExceptionIfInvoiceIsNotOpen() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); + Subscription subscription = testSetup.createSubscription(customer, product); - Invoice paidInvoice = INVOICES_CONTROLLER.listInvoices( + Invoice paidInvoice = invoicesController.listInvoices( new ListInvoicesInput.Builder() .status(InvoiceStatus.PAID) .subscriptionId(subscription.getId()) @@ -105,7 +105,7 @@ void shouldThrowExceptionIfInvoiceIsNotOpen() throws IOException, ApiException { .get(0); // when then - assertThatErrorListResponse(() -> INVOICES_CONTROLLER.previewCustomerInformationChanges(paidInvoice.getUid())) + assertThatErrorListResponse(() -> invoicesController.previewCustomerInformationChanges(paidInvoice.getUid())) .hasErrors("Invoice must have an open status") .isUnprocessableEntity(); } @@ -122,7 +122,7 @@ void shouldThrowUnauthorizedForInvalidCredentials() { @Test void shouldThrowNotFoundIfInvoiceDoesNotExist() { // when then - assertNotFound(() -> INVOICES_CONTROLLER.previewCustomerInformationChanges("uid_not_found")); + assertNotFound(() -> invoicesController.previewCustomerInformationChanges("uid_not_found")); } private void assertPayerData(InvoicePayerChange payer, Customer customer) { diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReadCreditNoteTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReadCreditNoteTest.java index e6789a90..dceb178b 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReadCreditNoteTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReadCreditNoteTest.java @@ -48,10 +48,10 @@ import static org.assertj.core.api.Assertions.assertThat; class InvoicesControllerReadCreditNoteTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); - private final InvoicesControllerUtils invoicesControllerUtils = new InvoicesControllerUtils(CLIENT); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); + private final InvoicesControllerUtils invoicesControllerUtils = new InvoicesControllerUtils(client); private Product product; private Component quantityBasedComponent; @@ -61,17 +61,17 @@ class InvoicesControllerReadCreditNoteTest { @BeforeAll void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); - quantityBasedComponent = TEST_SETUP.createQuantityBasedComponent(productFamily.getId()); - coupon = TEST_SETUP.createAmountCoupon(productFamily, 1250, true); + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); + quantityBasedComponent = testSetup.createQuantityBasedComponent(productFamily.getId()); + coupon = testSetup.createAmountCoupon(productFamily, 1250, true); List subscriptionComponents = List.of( new CreateSubscriptionComponent.Builder() .componentId(CreateSubscriptionComponentComponentId.fromNumber(quantityBasedComponent.getId())) .allocatedQuantity(CreateSubscriptionComponentAllocatedQuantity.fromNumber(50)) .build()); - subscription = TEST_SETUP.createSubscription(customer, product, s -> s + subscription = testSetup.createSubscription(customer, product, s -> s .couponCode(coupon.getCode()) .components(subscriptionComponents) ); @@ -90,7 +90,7 @@ void shouldReadCreditNotes() throws IOException, ApiException, InterruptedExcept InvoicePayment payment = paidInvoice.getPayments().get(0); // refund a part of the payment - INVOICES_CONTROLLER.refundInvoice(paidInvoice.getUid(), + invoicesController.refundInvoice(paidInvoice.getUid(), new RefundInvoiceRequest(RefundInvoiceRequestRefund.fromRefundInvoice( new RefundInvoice.Builder() .memo("Special refund") @@ -100,13 +100,13 @@ void shouldReadCreditNotes() throws IOException, ApiException, InterruptedExcept .build() ))); TimeUnit.SECONDS.sleep(1); - List creditNotes = INVOICES_CONTROLLER + List creditNotes = invoicesController .listCreditNotes(new ListCreditNotesInput.Builder().subscriptionId(subscriptionId).build()) .getCreditNotes(); assertThat(creditNotes).hasSize(1); // when - CreditNote creditNote = INVOICES_CONTROLLER.readCreditNote(creditNotes.get(0).getUid()); + CreditNote creditNote = invoicesController.readCreditNote(creditNotes.get(0).getUid()); // then assertThat(creditNote.getUid()).isNotNull(); @@ -263,7 +263,7 @@ void shouldReadCreditNotes() throws IOException, ApiException, InterruptedExcept @Test void shouldReturn404ForNotExistentInvoice() { // when - then - CommonAssertions.assertNotFound(() -> INVOICES_CONTROLLER.readCreditNote("not-existent-uid")); + CommonAssertions.assertNotFound(() -> invoicesController.readCreditNote("not-existent-uid")); } @Test diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReadInvoiceTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReadInvoiceTest.java index 180c9592..f1c2e6cc 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReadInvoiceTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReadInvoiceTest.java @@ -48,25 +48,25 @@ import static org.junit.jupiter.api.Assertions.assertAll; public class InvoicesControllerReadInvoiceTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static ProductFamily productFamily; - private static Product product; - private static Component meteredComponent; - private static Customer customer; - private static Subscription subscription; - private static Coupon coupon; + private ProductFamily productFamily; + private Product product; + private Component meteredComponent; + private Customer customer; + private Subscription subscription; + private Coupon coupon; @BeforeAll - static void setUp() throws IOException, ApiException { - productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - meteredComponent = TEST_SETUP.createMeteredComponent(productFamily, 13.05); - coupon = TEST_SETUP.createAmountCoupon(productFamily, 1010, true); + void setUp() throws IOException, ApiException { + productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + meteredComponent = testSetup.createMeteredComponent(productFamily, 13.05); + coupon = testSetup.createAmountCoupon(productFamily, 1010, true); - customer = TEST_SETUP.createCustomer(); + customer = testSetup.createCustomer(); List subscriptionComponents = List.of( new CreateSubscriptionComponent.Builder() @@ -74,20 +74,20 @@ static void setUp() throws IOException, ApiException { .unitBalance(10) .build()); - subscription = TEST_SETUP.createSubscription(customer, product, s -> s + subscription = testSetup.createSubscription(customer, product, s -> s .couponCode(coupon.getCode()) .components(subscriptionComponents)); } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @Test void shouldReadInvoice() throws IOException, ApiException { // given - String invoiceUid = INVOICES_CONTROLLER + String invoiceUid = invoicesController .listInvoices(new ListInvoicesInput.Builder() .subscriptionId(subscription.getId()) .build()) @@ -96,7 +96,7 @@ void shouldReadInvoice() throws IOException, ApiException { .getUid(); // when - Invoice invoice = INVOICES_CONTROLLER.readInvoice(invoiceUid); + Invoice invoice = invoicesController.readInvoice(invoiceUid); // then assertAll(() -> { @@ -280,6 +280,6 @@ void shouldThrowUnauthorizedForInvalidCredentials() { @Test void shouldThrowNotFoundIfInvoiceDoesNotExist() { // when then - assertNotFound(() -> INVOICES_CONTROLLER.readInvoice("uid_12345")); + assertNotFound(() -> invoicesController.readInvoice("uid_12345")); } } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForInvoiceTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForInvoiceTest.java index 8e81d858..1b8e78ba 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForInvoiceTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForInvoiceTest.java @@ -61,45 +61,45 @@ import static org.junit.jupiter.api.Assertions.assertAll; class InvoicesControllerRecordPaymentForInvoiceTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); - private final InvoicesControllerUtils invoicesControllerUtils = new InvoicesControllerUtils(CLIENT); - - private static ProductFamily productFamily; - private static Product product; - private static Customer customer; - private static Subscription subscription; - private static Invoice openInvoice; - private static CreditCardPaymentProfile creditCardPaymentProfile; + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); + private final InvoicesControllerUtils invoicesControllerUtils = new InvoicesControllerUtils(client); + + private ProductFamily productFamily; + private Product product; + private Customer customer; + private Subscription subscription; + private Invoice openInvoice; + private CreditCardPaymentProfile creditCardPaymentProfile; @BeforeAll void setUp() throws IOException, ApiException { - productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); - subscription = TEST_SETUP.createSubscription(customer, product); - creditCardPaymentProfile = CLIENT.getPaymentProfilesController() + productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); + subscription = testSetup.createSubscription(customer, product); + creditCardPaymentProfile = client.getPaymentProfilesController() .listPaymentProfiles(new ListPaymentProfilesInput.Builder().customerId(customer.getId()).build()) .get(0) .getPaymentProfile() .match(new PaymentProfileResponsePaymentProfileGetter<>()); - openInvoice = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); + openInvoice = testSetup.createOpenInvoice(subscription.getId(), product.getId()); } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @Test void shouldRecordPaymentUsingExistingPaymentProfile() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - Invoice openInvoice = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); + Subscription subscription = testSetup.createSubscription(customer, product); + Invoice openInvoice = testSetup.createOpenInvoice(subscription.getId(), product.getId()); // when - Invoice invoice = INVOICES_CONTROLLER.recordPaymentForInvoice( + Invoice invoice = invoicesController.recordPaymentForInvoice( openInvoice.getUid(), new CreateInvoicePaymentRequest( new CreateInvoicePayment.Builder() @@ -264,9 +264,9 @@ void shouldRecordPaymentUsingExistingPaymentProfile() throws IOException, ApiExc @Test void shouldRecordPaymentUsingSubscriptionPrepaymentAccount() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - Invoice openInvoice = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); - CLIENT.getSubscriptionInvoiceAccountController() + Subscription subscription = testSetup.createSubscription(customer, product); + Invoice openInvoice = testSetup.createOpenInvoice(subscription.getId(), product.getId()); + client.getSubscriptionInvoiceAccountController() .createPrepayment( subscription.getId(), new CreatePrepaymentRequest(new CreatePrepayment.Builder() @@ -279,7 +279,7 @@ void shouldRecordPaymentUsingSubscriptionPrepaymentAccount() throws IOException, ); // when - Invoice invoice = INVOICES_CONTROLLER.recordPaymentForInvoice( + Invoice invoice = invoicesController.recordPaymentForInvoice( openInvoice.getUid(), new CreateInvoicePaymentRequest( new CreateInvoicePayment.Builder().amount(CreateInvoicePaymentAmount.fromString("4.00")).build(), @@ -311,7 +311,7 @@ void shouldRecordPaymentUsingSubscriptionPrepaymentAccount() throws IOException, assertThat(payment.getGatewayUsed()).isNull(); assertThat(payment.getGatewayTransactionId()).isNull(); - List prepayments = CLIENT.getSubscriptionInvoiceAccountController() + List prepayments = client.getSubscriptionInvoiceAccountController() .listPrepayments(new ListPrepaymentsInput.Builder().subscriptionId(subscription.getId()).build()) .getPrepayments(); assertThat(prepayments) @@ -324,9 +324,9 @@ void shouldRecordPaymentUsingSubscriptionPrepaymentAccount() throws IOException, @Test void shouldRecordPaymentUsingSubscriptionServiceCreditAccount() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - Invoice openInvoice = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); - CLIENT.getSubscriptionInvoiceAccountController() + Subscription subscription = testSetup.createSubscription(customer, product); + Invoice openInvoice = testSetup.createOpenInvoice(subscription.getId(), product.getId()); + client.getSubscriptionInvoiceAccountController() .issueServiceCredit( subscription.getId(), new IssueServiceCreditRequest( @@ -338,7 +338,7 @@ void shouldRecordPaymentUsingSubscriptionServiceCreditAccount() throws IOExcepti ); // when - Invoice invoice = INVOICES_CONTROLLER.recordPaymentForInvoice( + Invoice invoice = invoicesController.recordPaymentForInvoice( openInvoice.getUid(), new CreateInvoicePaymentRequest( new CreateInvoicePayment.Builder().amount(CreateInvoicePaymentAmount.fromString("4.00")).build(), @@ -367,7 +367,7 @@ void shouldRecordPaymentUsingSubscriptionServiceCreditAccount() throws IOExcepti void shouldReturn422WhenRequestBodyIsIncorrect(String invoiceUid, CreateInvoicePaymentRequest request, String[] expectedErrors) { // when - then CommonAssertions - .assertThatErrorListResponse(() -> INVOICES_CONTROLLER.recordPaymentForInvoice(invoiceUid, request)) + .assertThatErrorListResponse(() -> invoicesController.recordPaymentForInvoice(invoiceUid, request)) .isUnprocessableEntity() .hasErrors(expectedErrors); } @@ -417,7 +417,7 @@ private Stream argsForShouldReturn422WhenRequestBodyIsIncorrect() thr @Test void shouldReturn404ForNotExistentInvoice() { // when - then - CommonAssertions.assertNotFound(() -> INVOICES_CONTROLLER + CommonAssertions.assertNotFound(() -> invoicesController .recordPaymentForInvoice("not-existent-invoice-uid", new CreateInvoicePaymentRequest()) ); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForMultipleInvoicesTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForMultipleInvoicesTest.java index d87f1082..969a02aa 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForMultipleInvoicesTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForMultipleInvoicesTest.java @@ -35,34 +35,34 @@ import static org.assertj.core.api.Assertions.assertThat; class InvoicesControllerRecordPaymentForMultipleInvoicesTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static Product product; - private static Customer customer; + private Product product; + private Customer customer; @BeforeAll - static void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); + void setUp() throws IOException, ApiException { + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @Test void shouldRecordFullPaymentForMultipleInvoices() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - Invoice openInvoice1 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); - Invoice openInvoice2 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); + Subscription subscription = testSetup.createSubscription(customer, product); + Invoice openInvoice1 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); + Invoice openInvoice2 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); // when - MultiInvoicePayment multiInvoicePayment = CLIENT.getInvoicesController() + MultiInvoicePayment multiInvoicePayment = client.getInvoicesController() .recordPaymentForMultipleInvoices( new CreateMultiInvoicePaymentRequest(new CreateMultiInvoicePayment.Builder( CreateMultiInvoicePaymentAmount.fromString("100.0"), @@ -96,7 +96,7 @@ void shouldRecordFullPaymentForMultipleInvoices() throws IOException, ApiExcepti .build() ); - assertThat(INVOICES_CONTROLLER + assertThat(invoicesController .listInvoices(new ListInvoicesInput.Builder() .subscriptionId(subscription.getId()) .build() @@ -112,12 +112,12 @@ void shouldRecordFullPaymentForMultipleInvoices() throws IOException, ApiExcepti @Test void shouldRecordPartialPaymentForMultipleInvoices() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - Invoice openInvoice1 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); - Invoice openInvoice2 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); + Subscription subscription = testSetup.createSubscription(customer, product); + Invoice openInvoice1 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); + Invoice openInvoice2 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); // when - MultiInvoicePayment multiInvoicePayment = CLIENT.getInvoicesController() + MultiInvoicePayment multiInvoicePayment = client.getInvoicesController() .recordPaymentForMultipleInvoices( new CreateMultiInvoicePaymentRequest(new CreateMultiInvoicePayment.Builder( CreateMultiInvoicePaymentAmount.fromString("6.0"), @@ -151,7 +151,7 @@ void shouldRecordPartialPaymentForMultipleInvoices() throws IOException, ApiExce .build() ); - assertThat(INVOICES_CONTROLLER + assertThat(invoicesController .listInvoices(new ListInvoicesInput.Builder() .subscriptionId(subscription.getId()) .status(InvoiceStatus.OPEN) @@ -172,7 +172,7 @@ void shouldReturn422WhenProvidedRequestBodyIsIncorrect(CreateMultiInvoicePayment String[] expectedErrors) { // when - then CommonAssertions - .assertThatErrorListResponse(() -> CLIENT.getInvoicesController() + .assertThatErrorListResponse(() -> client.getInvoicesController() .recordPaymentForMultipleInvoices( new CreateMultiInvoicePaymentRequest(new CreateMultiInvoicePayment .Builder(createMultiInvoicePaymentAmount, applications) @@ -187,11 +187,11 @@ void shouldReturn422WhenProvidedRequestBodyIsIncorrect(CreateMultiInvoicePayment .hasErrors(expectedErrors); } - private static Stream argsForShouldReturn422WhenProvidedRequestBodyIsIncorrect() throws IOException, ApiException { + private Stream argsForShouldReturn422WhenProvidedRequestBodyIsIncorrect() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - Invoice openInvoice1 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); - Invoice openInvoice2 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); + Subscription subscription = testSetup.createSubscription(customer, product); + Invoice openInvoice1 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); + Invoice openInvoice2 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); return Stream.of( Arguments.arguments( diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForSubscriptionTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForSubscriptionTest.java index 54de1d3b..b46e7258 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForSubscriptionTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRecordPaymentForSubscriptionTest.java @@ -32,34 +32,34 @@ import static org.assertj.core.api.Assertions.assertThat; class InvoicesControllerRecordPaymentForSubscriptionTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static Product product; - private static Customer customer; + private Product product; + private Customer customer; @BeforeAll - static void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); + void setUp() throws IOException, ApiException { + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @Test void shouldRecordPaymentForSubscriptionWithNoRemainder() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - Invoice openInvoice1 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); - Invoice openInvoice2 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); + Subscription subscription = testSetup.createSubscription(customer, product); + Invoice openInvoice1 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); + Invoice openInvoice2 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); // when - RecordPaymentResponse paymentResponse = INVOICES_CONTROLLER.recordPaymentForSubscription( + RecordPaymentResponse paymentResponse = invoicesController.recordPaymentForSubscription( subscription.getId(), new RecordPaymentRequest(new CreatePayment.Builder() .amount("8.00") @@ -94,12 +94,12 @@ void shouldRecordPaymentForSubscriptionWithNoRemainder() throws IOException, Api @Test void shouldRecordPaymentForSubscriptionWithPrepaymentRemainder() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - Invoice openInvoice1 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); - Invoice openInvoice2 = TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); + Subscription subscription = testSetup.createSubscription(customer, product); + Invoice openInvoice1 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); + Invoice openInvoice2 = testSetup.createOpenInvoice(subscription.getId(), product.getId()); // when - RecordPaymentResponse paymentResponse = INVOICES_CONTROLLER.recordPaymentForSubscription( + RecordPaymentResponse paymentResponse = invoicesController.recordPaymentForSubscription( subscription.getId(), new RecordPaymentRequest(new CreatePayment.Builder() .amount("100.00") @@ -143,16 +143,16 @@ void shouldRecordPaymentForSubscriptionWithPrepaymentRemainder() throws IOExcept void shouldReturn422WhenProvidedRequestBodyIsIncorrect(int subscriptionId, RecordPaymentRequest request, String[] expectedErrors) { // when - then CommonAssertions - .assertThatErrorListResponse(() -> INVOICES_CONTROLLER.recordPaymentForSubscription(subscriptionId, request)) + .assertThatErrorListResponse(() -> invoicesController.recordPaymentForSubscription(subscriptionId, request)) .isUnprocessableEntity() .hasErrors(expectedErrors); } - private static Stream argsForShouldReturn422WhenProvidedRequestBodyIsIncorrect() throws IOException, ApiException { + private Stream argsForShouldReturn422WhenProvidedRequestBodyIsIncorrect() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); - TEST_SETUP.createOpenInvoice(subscription.getId(), product.getId()); + Subscription subscription = testSetup.createSubscription(customer, product); + testSetup.createOpenInvoice(subscription.getId(), product.getId()); + testSetup.createOpenInvoice(subscription.getId(), product.getId()); return Stream.of( Arguments.arguments( @@ -181,7 +181,7 @@ private static Stream argsForShouldReturn422WhenProvidedRequestBodyIs @Test void shouldReturn404ForNotExistentSubscription() { // when - then - CommonAssertions.assertNotFound(() -> INVOICES_CONTROLLER + CommonAssertions.assertNotFound(() -> invoicesController .recordPaymentForSubscription(123, new RecordPaymentRequest()) ); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRefundInvoiceTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRefundInvoiceTest.java index b3c2e624..9f053c33 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRefundInvoiceTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerRefundInvoiceTest.java @@ -39,10 +39,10 @@ import static org.assertj.core.api.Assertions.assertThat; public class InvoicesControllerRefundInvoiceTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); - private final InvoicesControllerUtils invoicesControllerUtils = new InvoicesControllerUtils(CLIENT); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(); + private final InvoicesController invoicesController = client.getInvoicesController(); + private final InvoicesControllerUtils invoicesControllerUtils = new InvoicesControllerUtils(client); private Product product; private Component meteredComponent; @@ -53,17 +53,17 @@ public class InvoicesControllerRefundInvoiceTest { @BeforeAll void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); - meteredComponent = TEST_SETUP.createMeteredComponent(productFamily, 11.5); - coupon = TEST_SETUP.createAmountCoupon(productFamily, 1250, true); + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); + meteredComponent = testSetup.createMeteredComponent(productFamily, 11.5); + coupon = testSetup.createAmountCoupon(productFamily, 1250, true); List subscriptionComponents = List.of( new CreateSubscriptionComponent.Builder() .componentId(CreateSubscriptionComponentComponentId.fromNumber(meteredComponent.getId())) .unitBalance(100) .build()); - subscription = TEST_SETUP.createSubscription(customer, product, s -> s + subscription = testSetup.createSubscription(customer, product, s -> s .couponCode(coupon.getCode()) .components(subscriptionComponents) ); @@ -91,7 +91,7 @@ void shouldRefundInvoice() throws IOException, ApiException { InvoicePayment payment = paidInvoice.getPayments().get(0); // when - Invoice refundedInvoice = INVOICES_CONTROLLER.refundInvoice(paidInvoice.getUid(), + Invoice refundedInvoice = invoicesController.refundInvoice(paidInvoice.getUid(), new RefundInvoiceRequest(RefundInvoiceRequestRefund.fromRefundInvoice( new RefundInvoice.Builder() .memo("Special refund") @@ -121,14 +121,14 @@ void shouldRefundInvoice() throws IOException, ApiException { @Test void shouldRefundConsolidatedInvoice() throws IOException, ApiException { // given - groupSignup = TEST_SETUP.signupWithSubscriptionGroup(product, meteredComponent); + groupSignup = testSetup.signupWithSubscriptionGroup(product, meteredComponent); Invoice paidInvoice = invoicesControllerUtils.getPaidInvoiceForCustomer(groupSignup.getCustomerId()); InvoicePayment payment = paidInvoice.getPayments().get(0); // when - Invoice refundedInvoice = INVOICES_CONTROLLER.refundInvoice(paidInvoice.getUid(), + Invoice refundedInvoice = invoicesController.refundInvoice(paidInvoice.getUid(), new RefundInvoiceRequest(RefundInvoiceRequestRefund.fromRefundConsolidatedInvoice( new RefundConsolidatedInvoice.Builder() .memo("Special refund memo") @@ -166,11 +166,11 @@ void shouldRefundConsolidatedInvoice() throws IOException, ApiException { @Test void shouldRefundSpecificSegmentOfConsolidatedInvoice() throws IOException, ApiException { // given - groupSignup = TEST_SETUP.signupWithSubscriptionGroup(product, meteredComponent); + groupSignup = testSetup.signupWithSubscriptionGroup(product, meteredComponent); Invoice paidInvoice = invoicesControllerUtils.getPaidInvoiceForCustomer(groupSignup.getCustomerId()); - Invoice primarySegment = INVOICES_CONTROLLER + Invoice primarySegment = invoicesController .listInvoices(new ListInvoicesInput.Builder() .subscriptionId(groupSignup.getPrimarySubscriptionId()) .status(InvoiceStatus.PAID) @@ -181,7 +181,7 @@ void shouldRefundSpecificSegmentOfConsolidatedInvoice() throws IOException, ApiE InvoicePayment payment = paidInvoice.getPayments().get(0); // when - Invoice refundedInvoice = INVOICES_CONTROLLER.refundInvoice(paidInvoice.getUid(), + Invoice refundedInvoice = invoicesController.refundInvoice(paidInvoice.getUid(), new RefundInvoiceRequest(RefundInvoiceRequestRefund.fromRefundConsolidatedInvoice( new RefundConsolidatedInvoice.Builder() .memo("Refund primary segment") @@ -217,7 +217,7 @@ void shouldThrowExceptionIfAmountIsInvalid() throws IOException, ApiException { InvoicePayment payment = paidInvoice.getPayments().get(0); // when - assertThatErrorListResponse(() -> INVOICES_CONTROLLER.refundInvoice(paidInvoice.getUid(), + assertThatErrorListResponse(() -> invoicesController.refundInvoice(paidInvoice.getUid(), new RefundInvoiceRequest(RefundInvoiceRequestRefund.fromRefundInvoice( new RefundInvoice.Builder() .memo("Special refund") @@ -237,7 +237,7 @@ void shouldThrowExceptionIfPaymentDoesNotExist() throws IOException, ApiExceptio Invoice paidInvoice = invoicesControllerUtils.getPaidInvoiceForSubscription(subscription.getId()); // when - assertThatErrorListResponse(() -> INVOICES_CONTROLLER.refundInvoice(paidInvoice.getUid(), + assertThatErrorListResponse(() -> invoicesController.refundInvoice(paidInvoice.getUid(), new RefundInvoiceRequest(RefundInvoiceRequestRefund.fromRefundInvoice( new RefundInvoice.Builder() .memo("Special refund") @@ -254,7 +254,7 @@ void shouldThrowExceptionIfPaymentDoesNotExist() throws IOException, ApiExceptio @Test void shouldThrowExceptionIfInvoiceDoesNotExist() { // when - assertThatErrorListResponse(() -> INVOICES_CONTROLLER.refundInvoice("uid_1234455", + assertThatErrorListResponse(() -> invoicesController.refundInvoice("uid_1234455", new RefundInvoiceRequest(RefundInvoiceRequestRefund.fromRefundInvoice( new RefundInvoice.Builder() .memo("Special refund") @@ -273,7 +273,7 @@ private void assertRefundedInvoice(Invoice refundedInvoice, Invoice paidInvoice) assertThat(refundedInvoice) .usingRecursiveComparison() .ignoringFields("createdAt", "updatedAt", "previousBalanceData.capturedAt", - "payments.transactionTime", "creditAmount", "refundAmount", "credits", "refunds", "additionalProperties") + "payments.transactionTime", "creditAmount", "refundAmount", "credits", "debits", "refunds", "additionalProperties") .isEqualTo(paidInvoice); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReopenInvoiceTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReopenInvoiceTest.java index 51080a25..7fd1e769 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReopenInvoiceTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerReopenInvoiceTest.java @@ -35,24 +35,24 @@ import static org.assertj.core.api.Assertions.assertThat; public class InvoicesControllerReopenInvoiceTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static Product product; - private static Customer customer; - private static Component quantityBasedComponent; + private Product product; + private Customer customer; + private Component quantityBasedComponent; @BeforeAll - static void setUp() throws IOException, ApiException { - ProductFamily productFamily = TEST_SETUP.createProductFamily(); - product = TEST_SETUP.createProduct(productFamily, b -> b.priceInCents(125000)); - customer = TEST_SETUP.createCustomer(); - quantityBasedComponent = TEST_SETUP.createQuantityBasedComponent(productFamily.getId()); + void setUp() throws IOException, ApiException { + ProductFamily productFamily = testSetup.createProductFamily(); + product = testSetup.createProduct(productFamily, b -> b.priceInCents(125000)); + customer = testSetup.createCustomer(); + quantityBasedComponent = testSetup.createQuantityBasedComponent(productFamily.getId()); } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @@ -64,7 +64,7 @@ void shouldReopenCancelledInvoice() throws IOException, ApiException { Invoice cancelledInvoice = triggerCancelledInvoice(subscription); // when - Invoice reopenedInvoice = INVOICES_CONTROLLER.reopenInvoice(cancelledInvoice.getUid()); + Invoice reopenedInvoice = invoicesController.reopenInvoice(cancelledInvoice.getUid()); // then assertThat(reopenedInvoice).isNotNull(); @@ -78,9 +78,9 @@ void shouldReopenCancelledInvoice() throws IOException, ApiException { @Test void shouldThrowExceptionIfInvoiceIsNotCancelled() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); + Subscription subscription = testSetup.createSubscription(customer, product); - Invoice paidInvoice = INVOICES_CONTROLLER.listInvoices( + Invoice paidInvoice = invoicesController.listInvoices( new ListInvoicesInput.Builder() .status(InvoiceStatus.PAID) .subscriptionId(subscription.getId()) @@ -89,7 +89,7 @@ void shouldThrowExceptionIfInvoiceIsNotCancelled() throws IOException, ApiExcept .get(0); // when then - assertThatErrorListResponse(() -> INVOICES_CONTROLLER.reopenInvoice(paidInvoice.getUid())) + assertThatErrorListResponse(() -> invoicesController.reopenInvoice(paidInvoice.getUid())) .hasErrors("The invoice must be in canceled status to be reopened.") .hasErrorCode(422) .hasMessageStartingWith("HTTP Response Not OK. Status code: 422. Response:"); @@ -107,7 +107,7 @@ void shouldThrowUnauthorizedForInvalidCredentials() { @Test void shouldThrowNotFoundIfInvoiceDoesNotExist() { // when then - assertNotFound(() -> INVOICES_CONTROLLER.reopenInvoice("uid_not_found")); + assertNotFound(() -> invoicesController.reopenInvoice("uid_not_found")); } private Subscription createTestSubscription() throws IOException, ApiException { @@ -117,12 +117,12 @@ private Subscription createTestSubscription() throws IOException, ApiException { .unitBalance(10) .build()); - return TEST_SETUP.createSubscription(customer, product, s -> s + return testSetup.createSubscription(customer, product, s -> s .components(subscriptionComponents)); } private Invoice triggerCancelledInvoice(Subscription subscription) throws ApiException, IOException { - CLIENT.getSubscriptionComponentsController() + client.getSubscriptionComponentsController() .allocateComponent(subscription.getId(), quantityBasedComponent.getId(), new CreateAllocationRequest( new CreateAllocation.Builder() .memo("Allocate metered for invoice") @@ -131,7 +131,7 @@ private Invoice triggerCancelledInvoice(Subscription subscription) throws ApiExc .build()) ); - Invoice pendingInvoice = INVOICES_CONTROLLER.listInvoices( + Invoice pendingInvoice = invoicesController.listInvoices( new ListInvoicesInput.Builder() .status(InvoiceStatus.PENDING) .subscriptionId(subscription.getId()) @@ -139,14 +139,14 @@ private Invoice triggerCancelledInvoice(Subscription subscription) throws ApiExc .getInvoices() .get(0); - INVOICES_CONTROLLER.issueInvoice(pendingInvoice.getUid(), new IssueInvoiceRequest()); + invoicesController.issueInvoice(pendingInvoice.getUid(), new IssueInvoiceRequest()); - CLIENT.getSubscriptionStatusController() + client.getSubscriptionStatusController() .cancelSubscription(subscription.getId(), new CancellationRequest(new CancellationOptions.Builder() .cancellationMessage("Get lost") .build())); - Invoice cancelledInvoice = INVOICES_CONTROLLER.listInvoices( + Invoice cancelledInvoice = invoicesController.listInvoices( new ListInvoicesInput.Builder() .status(InvoiceStatus.CANCELED) .subscriptionId(subscription.getId()) @@ -154,6 +154,6 @@ private Invoice triggerCancelledInvoice(Subscription subscription) throws ApiExc .getInvoices() .get(0); - return INVOICES_CONTROLLER.readInvoice(cancelledInvoice.getUid()); + return invoicesController.readInvoice(cancelledInvoice.getUid()); } } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerSendTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerSendTest.java index ed321fd1..c9f8721c 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerSendTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerSendTest.java @@ -23,33 +23,33 @@ import static org.assertj.core.api.Assertions.assertThatNoException; class InvoicesControllerSendTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static Customer customer; - private static Invoice paidInvoice; + private Customer customer; + private Invoice paidInvoice; @BeforeAll - static void setUp() throws IOException, ApiException { - Product product = TEST_SETUP.createProduct(TEST_SETUP.createProductFamily(), b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - paidInvoice = INVOICES_CONTROLLER + void setUp() throws IOException, ApiException { + Product product = testSetup.createProduct(testSetup.createProductFamily(), b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); + Subscription subscription = testSetup.createSubscription(customer, product); + paidInvoice = invoicesController .listInvoices(new ListInvoicesInput.Builder().subscriptionId(subscription.getId()).build()) .getInvoices() .get(0); } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @Test void shouldSendInvoice() { // when - then - assertThatNoException().isThrownBy(() -> INVOICES_CONTROLLER.sendInvoice( + assertThatNoException().isThrownBy(() -> invoicesController.sendInvoice( paidInvoice.getUid(), new SendInvoiceRequest.Builder() .recipientEmails(List.of("recepient1@maxio.com", "recepient2@maxio.com")) @@ -64,10 +64,10 @@ void shouldSendInvoice() { void shouldReturn422WhenSendingInvalidEmailNotExistentInvoice() { // when - then CommonAssertions - .assertThatErrorListResponse(() -> INVOICES_CONTROLLER.sendInvoice(paidInvoice.getUid(), new SendInvoiceRequest.Builder() + .assertThatErrorListResponse(() -> invoicesController.sendInvoice(paidInvoice.getUid(), new SendInvoiceRequest.Builder() .recipientEmails(List.of("invalidemail")) - .ccRecipientEmails(List.of("user1@example.com","user1@example.com","user1@example.com", - "user1@example.com","user1@example.com","user1@example.com")) + .ccRecipientEmails(List.of("user1@example.com", "user1@example.com", "user1@example.com", + "user1@example.com", "user1@example.com", "user1@example.com")) .build())) .isUnprocessableEntity() .hasErrors("recipient_emails: must be a valid email address", "cc_recipient_emails: You can have 5 recipients at most"); @@ -77,7 +77,7 @@ void shouldReturn422WhenSendingInvalidEmailNotExistentInvoice() { void shouldReturn422WhenSendingNotExistentInvoice() { // when - then CommonAssertions - .assertThatErrorListResponse(() -> INVOICES_CONTROLLER.sendInvoice("123", new SendInvoiceRequest())) + .assertThatErrorListResponse(() -> invoicesController.sendInvoice("123", new SendInvoiceRequest())) .isUnprocessableEntity() .hasErrors("invoice: Unable to enqueue invoice for email delivery"); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerUpdateCustomerInformationChangesTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerUpdateCustomerInformationChangesTest.java index dd983df5..5373dba0 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerUpdateCustomerInformationChangesTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerUpdateCustomerInformationChangesTest.java @@ -30,7 +30,7 @@ void shouldUpdateCustomerInformation() throws IOException, ApiException { Invoice invoiceBeforeUpdate = testData.openInvoice(); // when - Invoice invoiceAfterUpdate = INVOICES_CONTROLLER.updateCustomerInformation(invoiceBeforeUpdate.getUid()); + Invoice invoiceAfterUpdate = invoicesController.updateCustomerInformation(invoiceBeforeUpdate.getUid()); // then assertThat(invoiceAfterUpdate).isNotNull(); @@ -65,9 +65,9 @@ void shouldUpdateCustomerInformation() throws IOException, ApiException { @Test void shouldThrowExceptionIfInvoiceIsNotOpen() throws IOException, ApiException { // given - Subscription subscription = TEST_SETUP.createSubscription(customer, product); + Subscription subscription = testSetup.createSubscription(customer, product); - Invoice paidInvoice = INVOICES_CONTROLLER.listInvoices( + Invoice paidInvoice = invoicesController.listInvoices( new ListInvoicesInput.Builder() .status(InvoiceStatus.PAID) .subscriptionId(subscription.getId()) @@ -76,7 +76,7 @@ void shouldThrowExceptionIfInvoiceIsNotOpen() throws IOException, ApiException { .get(0); // when then - assertThatErrorListResponse(() -> INVOICES_CONTROLLER.updateCustomerInformation(paidInvoice.getUid())) + assertThatErrorListResponse(() -> invoicesController.updateCustomerInformation(paidInvoice.getUid())) .hasErrors("Invoice must have an open status") .isUnprocessableEntity(); } @@ -93,7 +93,7 @@ void shouldThrowUnauthorizedForInvalidCredentials() { @Test void shouldThrowNotFoundIfInvoiceDoesNotExist() { // when then - assertNotFound(() -> INVOICES_CONTROLLER.updateCustomerInformation("uid_not_found")); + assertNotFound(() -> invoicesController.updateCustomerInformation("uid_not_found")); } private void assertCustomer(InvoiceCustomer invoiceCustomer, Customer customer) { diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerVoidTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerVoidTest.java index 4d594599..d845b857 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerVoidTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/invoices/InvoicesControllerVoidTest.java @@ -19,6 +19,7 @@ import com.maxio.advancedbilling.models.containers.CreateInvoiceCouponAmount; import com.maxio.advancedbilling.models.containers.CreateInvoiceItemProductId; import com.maxio.advancedbilling.models.containers.CreateInvoiceItemQuantity; +import com.maxio.advancedbilling.models.containers.CreateInvoiceItemUnitPrice; import com.maxio.advancedbilling.utils.TestSetup; import com.maxio.advancedbilling.utils.TestTeardown; import com.maxio.advancedbilling.utils.assertions.CommonAssertions; @@ -33,25 +34,25 @@ import static org.junit.jupiter.api.Assertions.assertAll; class InvoicesControllerVoidTest { - private static final TestSetup TEST_SETUP = new TestSetup(); - private static final AdvancedBillingClient CLIENT = TestClientProvider.getClient(); - private static final InvoicesController INVOICES_CONTROLLER = CLIENT.getInvoicesController(); + private final AdvancedBillingClient client = TestClientProvider.getClient(); + private final TestSetup testSetup = new TestSetup(client); + private final InvoicesController invoicesController = client.getInvoicesController(); - private static Product product; - private static Customer customer; - private static Invoice openInvoice; - private static Invoice paidInvoice; + private Product product; + private Customer customer; + private Invoice openInvoice; + private Invoice paidInvoice; @BeforeAll - static void setUp() throws IOException, ApiException { - product = TEST_SETUP.createProduct(TEST_SETUP.createProductFamily(), b -> b.priceInCents(1250)); - customer = TEST_SETUP.createCustomer(); - Subscription subscription = TEST_SETUP.createSubscription(customer, product); - paidInvoice = INVOICES_CONTROLLER + void setUp() throws IOException, ApiException { + product = testSetup.createProduct(testSetup.createProductFamily(), b -> b.priceInCents(1250)); + customer = testSetup.createCustomer(); + Subscription subscription = testSetup.createSubscription(customer, product); + paidInvoice = invoicesController .listInvoices(new ListInvoicesInput.Builder().subscriptionId(subscription.getId()).build()) .getInvoices() .get(0); - openInvoice = TEST_SETUP.createInvoice( + openInvoice = testSetup.createInvoice( subscription.getId(), b -> b .status(CreateInvoiceStatus.OPEN) @@ -59,6 +60,7 @@ static void setUp() throws IOException, ApiException { new CreateInvoiceItem.Builder() .productId(CreateInvoiceItemProductId.fromNumber(product.getId())) .quantity(CreateInvoiceItemQuantity.fromString("1")) + .unitPrice(CreateInvoiceItemUnitPrice.fromString("150.0")) .build() )) .coupons(List.of( @@ -73,14 +75,14 @@ static void setUp() throws IOException, ApiException { } @AfterAll - static void teardown() throws IOException, ApiException { + void teardown() throws IOException, ApiException { new TestTeardown().deleteCustomer(customer); } @Test void shouldVoidOpenInvoice() throws IOException, ApiException { // when - Invoice voidedInvoice = INVOICES_CONTROLLER.voidInvoice( + Invoice voidedInvoice = invoicesController.voidInvoice( openInvoice.getUid(), new VoidInvoiceRequest(new VoidInvoice("Duplicate invoice")) ); @@ -106,7 +108,7 @@ void shouldVoidOpenInvoice() throws IOException, ApiException { void shouldReturn422WhenVoidingPaidInvoice() { // when - then CommonAssertions - .assertThatErrorListResponse(() -> INVOICES_CONTROLLER + .assertThatErrorListResponse(() -> invoicesController .voidInvoice(paidInvoice.getUid(), new VoidInvoiceRequest(new VoidInvoice("Duplicate invoice")))) .isUnprocessableEntity() .hasErrors("Invoice status must be 'open', 'canceled', 'processing' or 'pending' and non-consolidated to be voided."); @@ -115,7 +117,7 @@ void shouldReturn422WhenVoidingPaidInvoice() { @Test void shouldReturn404WhenVoidingNotExistentInvoice() { // when - then - CommonAssertions.assertNotFound(() -> INVOICES_CONTROLLER + CommonAssertions.assertNotFound(() -> invoicesController .voidInvoice("123", new VoidInvoiceRequest(new VoidInvoice("Duplicate invoice"))) ); }