Class BillingDatabaseClientMock
- java.lang.Object
-
- com.yahoo.vespa.hosted.controller.api.integration.billing.BillingDatabaseClientMock
-
- All Implemented Interfaces:
BillingDatabaseClient
public class BillingDatabaseClientMock extends Object implements BillingDatabaseClient
- Author:
- olaa
-
-
Constructor Summary
Constructors Constructor Description BillingDatabaseClientMock(Clock clock, PlanRegistry planRegistry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddLineItem(com.yahoo.config.provision.TenantName tenantName, Bill.LineItem lineItem, Optional<Bill.Id> invoiceId)Add a line item to an open billvoidcommitLineItems(com.yahoo.config.provision.TenantName tenantName, Bill.Id invoiceId)Associate all uncommitted line items to a given bill This is only allowed if the line item has not already been associated with an billBill.IdcreateBill(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent)Create a completely new Bill in the open state with no LineItems.voiddeactivateDefaultPaymentInstrument(com.yahoo.config.provision.TenantName tenant)Deactivates the default payment instrument for a tenant, if it exists.voiddeleteLineItem(String lineItemId)Delete a line item This is only allowed if the line item has not yet been associated with an billOptional<CollectionMethod>getCollectionMethod(com.yahoo.config.provision.TenantName tenantName)Get the current collection method for the tenant - if one has persistedOptional<InstrumentOwner>getDefaultPaymentInstrumentForTenant(com.yahoo.config.provision.TenantName tenantName)Optional<Plan>getPlan(com.yahoo.config.provision.TenantName tenantName)Return the plan for the given tenantMap<com.yahoo.config.provision.TenantName,Optional<Plan>>getPlans(List<com.yahoo.config.provision.TenantName> tenants)Return the plan for the given tenants if present.StringgetStatus(Bill.Id invoiceId)List<Bill.LineItem>getUnusedLineItems(com.yahoo.config.provision.TenantName tenantName)Optional<Bill>readBill(Bill.Id billId)Read the given bill from the data sourceList<Bill>readBills()Read all bills, ordered by dateList<Bill>readBillsForTenant(com.yahoo.config.provision.TenantName tenant)Get all bills for a given tenant, ordered by datebooleansetActivePaymentInstrument(InstrumentOwner paymentInstrument)voidsetCollectionMethod(com.yahoo.config.provision.TenantName tenantName, CollectionMethod collectionMethod)Set the collection method for the tenantvoidsetPlan(com.yahoo.config.provision.TenantName tenantName, Plan plan)Set the current plan for the given tenantvoidsetStatus(Bill.Id invoiceId, String agent, String status)Set status for the given bill
-
-
-
Constructor Detail
-
BillingDatabaseClientMock
public BillingDatabaseClientMock(Clock clock, PlanRegistry planRegistry)
-
-
Method Detail
-
setActivePaymentInstrument
public boolean setActivePaymentInstrument(InstrumentOwner paymentInstrument)
- Specified by:
setActivePaymentInstrumentin interfaceBillingDatabaseClient
-
getDefaultPaymentInstrumentForTenant
public Optional<InstrumentOwner> getDefaultPaymentInstrumentForTenant(com.yahoo.config.provision.TenantName tenantName)
- Specified by:
getDefaultPaymentInstrumentForTenantin interfaceBillingDatabaseClient
-
createBill
public Bill.Id createBill(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent)
Description copied from interface:BillingDatabaseClientCreate a completely new Bill in the open state with no LineItems.- Specified by:
createBillin interfaceBillingDatabaseClient- Parameters:
tenant- The name of the tenant the bill is foragent- The agent that created the bill- Returns:
- The Id of the new bill
-
readBill
public Optional<Bill> readBill(Bill.Id billId)
Description copied from interface:BillingDatabaseClientRead the given bill from the data source- Specified by:
readBillin interfaceBillingDatabaseClient- Parameters:
billId- The Id of the bill to retrieve- Returns:
- The Bill if it exists, Optional.empty() if not.
-
addLineItem
public String addLineItem(com.yahoo.config.provision.TenantName tenantName, Bill.LineItem lineItem, Optional<Bill.Id> invoiceId)
Description copied from interface:BillingDatabaseClientAdd a line item to an open bill- Specified by:
addLineItemin interfaceBillingDatabaseClientinvoiceId- The optional ID of the bill this line item is for- Returns:
- The Id of the new line item
-
setStatus
public void setStatus(Bill.Id invoiceId, String agent, String status)
Description copied from interface:BillingDatabaseClientSet status for the given bill- Specified by:
setStatusin interfaceBillingDatabaseClient- Parameters:
invoiceId- The ID of the bill this status is foragent- The agent that added the statusstatus- The new status of the bill
-
getUnusedLineItems
public List<Bill.LineItem> getUnusedLineItems(com.yahoo.config.provision.TenantName tenantName)
- Specified by:
getUnusedLineItemsin interfaceBillingDatabaseClient
-
deleteLineItem
public void deleteLineItem(String lineItemId)
Description copied from interface:BillingDatabaseClientDelete a line item This is only allowed if the line item has not yet been associated with an bill- Specified by:
deleteLineItemin interfaceBillingDatabaseClient- Parameters:
lineItemId- The ID of the line item
-
commitLineItems
public void commitLineItems(com.yahoo.config.provision.TenantName tenantName, Bill.Id invoiceId)Description copied from interface:BillingDatabaseClientAssociate all uncommitted line items to a given bill This is only allowed if the line item has not already been associated with an bill- Specified by:
commitLineItemsin interfaceBillingDatabaseClient- Parameters:
tenantName- The tenant we want to commit line items forinvoiceId- The ID of the line item
-
getPlan
public Optional<Plan> getPlan(com.yahoo.config.provision.TenantName tenantName)
Description copied from interface:BillingDatabaseClientReturn the plan for the given tenant- Specified by:
getPlanin interfaceBillingDatabaseClient- Parameters:
tenantName- The tenant to retrieve the plan for- Returns:
- Optional.of the plan if present in DN, else Optional.empty
-
getPlans
public Map<com.yahoo.config.provision.TenantName,Optional<Plan>> getPlans(List<com.yahoo.config.provision.TenantName> tenants)
Description copied from interface:BillingDatabaseClientReturn the plan for the given tenants if present. If the database does not know of the tenant, the tenant is not included in the result.- Specified by:
getPlansin interfaceBillingDatabaseClient
-
setPlan
public void setPlan(com.yahoo.config.provision.TenantName tenantName, Plan plan)Description copied from interface:BillingDatabaseClientSet the current plan for the given tenant- Specified by:
setPlanin interfaceBillingDatabaseClient- Parameters:
tenantName- The tenant to set the plan forplan- The plan to use
-
deactivateDefaultPaymentInstrument
public void deactivateDefaultPaymentInstrument(com.yahoo.config.provision.TenantName tenant)
Description copied from interface:BillingDatabaseClientDeactivates the default payment instrument for a tenant, if it exists. Used during tenant deletion- Specified by:
deactivateDefaultPaymentInstrumentin interfaceBillingDatabaseClient
-
getCollectionMethod
public Optional<CollectionMethod> getCollectionMethod(com.yahoo.config.provision.TenantName tenantName)
Description copied from interface:BillingDatabaseClientGet the current collection method for the tenant - if one has persisted- Specified by:
getCollectionMethodin interfaceBillingDatabaseClient- Returns:
- Optional.empty if no collection method has been persisted for the tenant
-
setCollectionMethod
public void setCollectionMethod(com.yahoo.config.provision.TenantName tenantName, CollectionMethod collectionMethod)Description copied from interface:BillingDatabaseClientSet the collection method for the tenant- Specified by:
setCollectionMethodin interfaceBillingDatabaseClient- Parameters:
tenantName- The name of the tenant to set collection method forcollectionMethod- The collection method for the tenant
-
readBillsForTenant
public List<Bill> readBillsForTenant(com.yahoo.config.provision.TenantName tenant)
Description copied from interface:BillingDatabaseClientGet all bills for a given tenant, ordered by date- Specified by:
readBillsForTenantin interfaceBillingDatabaseClient- Parameters:
tenant- The name of the tenant- Returns:
- List of all bills ordered by date
-
readBills
public List<Bill> readBills()
Description copied from interface:BillingDatabaseClientRead all bills, ordered by date- Specified by:
readBillsin interfaceBillingDatabaseClient- Returns:
- List of all bills ordered by date
-
-