Skip to content

Commit

Permalink
Update Billing Model
Browse files Browse the repository at this point in the history
  • Loading branch information
baixinsui committed Mar 27, 2024
1 parent 6f4b232 commit 8bc57eb
Show file tree
Hide file tree
Showing 37 changed files with 468 additions and 455 deletions.
8 changes: 2 additions & 6 deletions modules/api/src/test/resources/ocl_terraform_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ cloudServiceProvider:
- name: cn-north-4
area: Asia China
billing:
# The business model(`flat`, `exponential`, ...)
model: flat
# The rental period (`daily`, `weekly`, `monthly`, `yearly`)
period: monthly
# The billing currency (`euro`, `usd`, ...)
currency: euro
# The model of billing (`yearly`, `monthly`, `daily`, `hourly`, `pay_per_use`)
billingModel: monthly
serviceHostingType: self
# The flavor of the service, the @category/@name/@version/@flavor can locate the specific service to be deployed.
flavors:
Expand Down
8 changes: 2 additions & 6 deletions modules/database/src/test/resources/ocl_terraform_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ cloudServiceProvider:
- name: cn-north-4
area: Asia China
billing:
# The business model(`flat`, `exponential`, ...)
model: flat
# The rental period (`daily`, `weekly`, `monthly`, `yearly`)
period: monthly
# The billing currency (`euro`, `usd`, ...)
currency: euro
# The model of billing (`yearly`, `monthly`, `daily`, `hourly`, `pay_per_use`)
billingModel: monthly
serviceHostingType: self
# The flavor of the service, the @category/@name/@version/@flavor can locate the specific service to be deployed.
flavors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ cloudServiceProvider:
- name: cn-north-4
area: Asia China
billing:
# The business model(`flat`, `exponential`, ...)
model: flat
# The rental period (`daily`, `weekly`, `monthly`, `yearly`)
period: monthly
# The billing currency (`euro`, `usd`, ...)
currency: euro
# The model of billing (`yearly`, `monthly`, `daily`, `hourly`, `pay_per_use`)
billingModel: monthly
serviceHostingType: self
# The flavor of the service, the @category/@name/@version/@flavor can locate the specific service to be deployed.
flavors:
Expand Down
8 changes: 2 additions & 6 deletions modules/deployment/src/test/resources/ocl_terraform_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ cloudServiceProvider:
- name: cn-north-4
area: Asia China
billing:
# The business model(`flat`, `exponential`, ...)
model: flat
# The rental period (`daily`, `weekly`, `monthly`, `yearly`)
period: monthly
# The billing currency (`euro`, `usd`, ...)
currency: euro
# The model of billing (`yearly`, `monthly`, `daily`, `hourly`, `pay_per_use`)
billingModel: monthly
serviceHostingType: self
# The flavor of the service, the @category/@name/@version/@flavor can locate the specific service to be deployed.
flavors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,19 @@
package org.eclipse.xpanse.modules.models.servicetemplate;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import lombok.Data;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.BillingCurrency;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.BillingPeriod;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.BillingModel;

/**
* Defines the billing model of the managed service.
*/
@Data
public class Billing implements Serializable {

@Serial
private static final long serialVersionUID = -8828746500103629059L;

@NotNull
@NotBlank
@NotEmpty
@Schema(description = "The business model of the managed service")
private String model;

@NotNull
@Schema(description = "The rental period of the managed service")
private BillingPeriod period;

@NotNull
@Schema(description = "The billing currency of the managed service, valid values: euro,uso")
private BillingCurrency currency;
@Schema(description = "The billing model of the managed service")
private BillingModel billingModel;

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,41 @@


/**
* Period for Billing.
* Model enum of Billing.
*/
public enum BillingPeriod {
DAILY("daily"),
WEEKLY("weekly"),
public enum BillingModel {

YEARLY("yearly"),
MONTHLY("monthly"),
QUARTERLY("quarterly"),
YEARLY("yearly");
DAILY("daily"),
HOURLY("hourly"),
PAY_PER_USE("pay_per_use");

private final String period;
private final String model;

BillingPeriod(String period) {
this.period = period;
BillingModel(String model) {
this.model = model;
}

/**
* For BillingPeriod serialize.
* For BillingModel serialize.
*/
@JsonCreator
public BillingPeriod getByValue(String period) {
for (BillingPeriod billingPeriod : values()) {
if (billingPeriod.period.equals(StringUtils.lowerCase(period))) {
return billingPeriod;
public static BillingModel getByValue(String model) {
for (BillingModel billingModel : values()) {
if (billingModel.model.equals(StringUtils.lowerCase(model))) {
return billingModel;
}
}
throw new UnsupportedEnumValueException(
String.format("BillingPeriod value %s is not supported.", period));
String.format("BillingModel value %s is not supported.", model));
}

/**
* For BillingPeriod deserialize.
* For BillingModel deserialize.
*/
@JsonValue
public String toValue() {
return this.period;
return this.model;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.List;
import org.eclipse.xpanse.modules.models.common.enums.Category;
import org.eclipse.xpanse.modules.models.common.enums.Csp;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.BillingModel;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.DeployerKind;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.ServiceHostingType;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -31,13 +32,13 @@ class OclTest {
private static final String description = "description";
private static final String namespace = "nameSpace";
private static final String icon = "icon";
private static final ServiceHostingType serviceHostingType = ServiceHostingType.SELF;
private static CloudServiceProvider cloudServiceProvider;
private static Deployment deployment;
private static List<Flavor> flavors;
private static Billing billing;
private static Ocl ocl;
private static ServiceProviderContactDetails serviceProviderContactDetails;
private static final ServiceHostingType serviceHostingType = ServiceHostingType.SELF;
private static ServiceProviderContactDetails serviceProviderContactDetails;

@BeforeEach
void setUp() {
Expand All @@ -58,7 +59,7 @@ void setUp() {
flavors = List.of(flavor);

billing = new Billing();
billing.setModel("model");
billing.setBillingModel(BillingModel.MONTHLY);

ocl = new Ocl();
ocl.setCategory(category);
Expand Down Expand Up @@ -107,7 +108,8 @@ public void testDeepCopy() {
assertNotSame(ocl.getDeployment(), aCopy.getDeployment());
assertEquals(ocl.getDeployment().getKind(), aCopy.getDeployment().getKind());
assertEquals(ocl.getServiceHostingType(), aCopy.getServiceHostingType());
assertEquals(ocl.getServiceProviderContactDetails(), aCopy.getServiceProviderContactDetails());
assertEquals(ocl.getServiceProviderContactDetails(),
aCopy.getServiceProviderContactDetails());
}

@Test
Expand Down Expand Up @@ -212,7 +214,7 @@ void testToString() {
", flavors=" + flavors +
", billing=" + billing +
", serviceHostingType=" + serviceHostingType +
", serviceProviderContactDetails=" + serviceProviderContactDetails +
", serviceProviderContactDetails=" + serviceProviderContactDetails +
")";

assertEquals(expectedString, ocl.toString());
Expand Down

0 comments on commit 8bc57eb

Please sign in to comment.