From b8b9d11a0c8598a0683a4f2d1f5daee2d08b8983 Mon Sep 17 00:00:00 2001 From: Armstrong Goes Date: Tue, 31 Aug 2021 18:52:53 -0300 Subject: [PATCH] Removed dependency from RAS order models --- pom.xml | 5 + .../fogbow/accs/api/http/response/Record.java | 2 +- .../cloud/fogbow/accs/core/SpecFactory.java | 12 +- .../accs/core/datastore/DatabaseManager.java | 6 +- .../datastore/OrderStorageConfiguration.java | 5 +- .../accountingstorage/RecordRepository.java | 2 +- .../AuditableOrderStateChangeRepository.java | 4 +- .../orderstorage/OrderRepository.java | 2 +- .../datastore/services/RecordService.java | 2 +- .../cloud/fogbow/accs/core/models/Record.java | 2 +- .../orders/AuditableOrderStateChange.java | 64 -------- .../accs/core/models/orders/ComputeOrder.java | 94 ----------- .../accs/core/models/orders/NetworkOrder.java | 51 ------ .../fogbow/accs/core/models/orders/Order.java | 150 ------------------ .../accs/core/models/orders/OrderState.java | 31 ---- .../accs/core/models/orders/VolumeOrder.java | 32 ---- .../accs/core/models/specs/NetworkSpec.java | 2 + .../accs/core/processors/SyncProcessor.java | 9 +- .../cloud/fogbow/accs/core/TestUtils.java | 9 +- .../datastore/services/RecordServiceTest.java | 2 +- .../core/processors/SyncProcessorTest.java | 7 +- 21 files changed, 40 insertions(+), 453 deletions(-) delete mode 100644 src/main/java/cloud/fogbow/accs/core/models/orders/AuditableOrderStateChange.java delete mode 100644 src/main/java/cloud/fogbow/accs/core/models/orders/ComputeOrder.java delete mode 100644 src/main/java/cloud/fogbow/accs/core/models/orders/NetworkOrder.java delete mode 100644 src/main/java/cloud/fogbow/accs/core/models/orders/Order.java delete mode 100644 src/main/java/cloud/fogbow/accs/core/models/orders/OrderState.java delete mode 100644 src/main/java/cloud/fogbow/accs/core/models/orders/VolumeOrder.java diff --git a/pom.xml b/pom.xml index dd271c5..fb639fb 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,11 @@ fogbow-as 0.0.1-SNAPSHOT + + fogbow + fogbow-ras + 0.0.1-SNAPSHOT + org.powermock powermock-module-junit4 diff --git a/src/main/java/cloud/fogbow/accs/api/http/response/Record.java b/src/main/java/cloud/fogbow/accs/api/http/response/Record.java index c9cd620..4e5b383 100644 --- a/src/main/java/cloud/fogbow/accs/api/http/response/Record.java +++ b/src/main/java/cloud/fogbow/accs/api/http/response/Record.java @@ -1,7 +1,7 @@ package cloud.fogbow.accs.api.http.response; -import cloud.fogbow.accs.core.models.orders.OrderState; import cloud.fogbow.accs.core.models.specs.OrderSpec; +import cloud.fogbow.ras.core.models.orders.OrderState; import cloud.fogbow.accs.constants.ApiDocumentation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/src/main/java/cloud/fogbow/accs/core/SpecFactory.java b/src/main/java/cloud/fogbow/accs/core/SpecFactory.java index bbca896..b8e10d8 100644 --- a/src/main/java/cloud/fogbow/accs/core/SpecFactory.java +++ b/src/main/java/cloud/fogbow/accs/core/SpecFactory.java @@ -3,15 +3,15 @@ import cloud.fogbow.accs.constants.Messages; import cloud.fogbow.accs.core.datastore.accountingstorage.OrderSpecRepository; import cloud.fogbow.accs.core.exceptions.TypeNotAllowedException; -import cloud.fogbow.accs.core.models.ResourceType; -import cloud.fogbow.accs.core.models.orders.ComputeOrder; -import cloud.fogbow.accs.core.models.orders.NetworkOrder; -import cloud.fogbow.accs.core.models.orders.Order; -import cloud.fogbow.accs.core.models.orders.VolumeOrder; import cloud.fogbow.accs.core.models.specs.ComputeSpec; import cloud.fogbow.accs.core.models.specs.NetworkSpec; import cloud.fogbow.accs.core.models.specs.OrderSpec; import cloud.fogbow.accs.core.models.specs.VolumeSpec; +import cloud.fogbow.ras.core.models.ResourceType; +import cloud.fogbow.ras.core.models.orders.ComputeOrder; +import cloud.fogbow.ras.core.models.orders.NetworkOrder; +import cloud.fogbow.ras.core.models.orders.Order; +import cloud.fogbow.ras.core.models.orders.VolumeOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -27,7 +27,7 @@ public OrderSpec constructSpec(Order order) { ResourceType resourceType = order.getType(); switch (resourceType) { case COMPUTE: - spec = new ComputeSpec(((ComputeOrder) order).getvCPU(), ((ComputeOrder) order).getMemory()); + spec = new ComputeSpec(((ComputeOrder) order).getvCPU(), ((ComputeOrder) order).getRam()); break; case NETWORK: spec = new NetworkSpec(((NetworkOrder) order).getCidr(), ((NetworkOrder) order).getAllocationMode()); diff --git a/src/main/java/cloud/fogbow/accs/core/datastore/DatabaseManager.java b/src/main/java/cloud/fogbow/accs/core/datastore/DatabaseManager.java index 77188d9..f33b4c7 100644 --- a/src/main/java/cloud/fogbow/accs/core/datastore/DatabaseManager.java +++ b/src/main/java/cloud/fogbow/accs/core/datastore/DatabaseManager.java @@ -9,10 +9,10 @@ import cloud.fogbow.accs.core.models.AccountingUser; import cloud.fogbow.accs.core.models.AuditableOrderIdRecorder; import cloud.fogbow.accs.core.models.Record; -import cloud.fogbow.accs.core.models.orders.AuditableOrderStateChange; -import cloud.fogbow.accs.core.models.orders.Order; -import cloud.fogbow.accs.core.models.orders.OrderState; import cloud.fogbow.common.models.SystemUser; +import cloud.fogbow.ras.core.datastore.orderstorage.AuditableOrderStateChange; +import cloud.fogbow.ras.core.models.orders.Order; +import cloud.fogbow.ras.core.models.orders.OrderState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/cloud/fogbow/accs/core/datastore/OrderStorageConfiguration.java b/src/main/java/cloud/fogbow/accs/core/datastore/OrderStorageConfiguration.java index 715f8e3..a5ea40a 100644 --- a/src/main/java/cloud/fogbow/accs/core/datastore/OrderStorageConfiguration.java +++ b/src/main/java/cloud/fogbow/accs/core/datastore/OrderStorageConfiguration.java @@ -31,7 +31,8 @@ public class OrderStorageConfiguration extends StorageConfiguration { // The order datasource properties names must use this prefix. public static final String ORDER_DATASOURCE_CONFIGURATION_PREFIX = "spring.order-datasource"; // All entities related to Order must be placed in this package. - private static final String ORDER_ENTITIES_PACKAGE = "cloud.fogbow.accs.core.models.orders"; + private static final String[] ORDER_ENTITIES_PACKAGES = { "cloud.fogbow.ras.core.models.orders", + "cloud.fogbow.ras.core.datastore.orderstorage" }; @Autowired private Environment env; @@ -45,7 +46,7 @@ public DataSource orderDataSource() { @Bean public LocalContainerEntityManagerFactoryBean orderEntityManager() { DataSource source = orderDataSource(); - String[] packagesToScan = { ORDER_ENTITIES_PACKAGE }; + String[] packagesToScan = ORDER_ENTITIES_PACKAGES; return getEntityManager(source, env, packagesToScan); } diff --git a/src/main/java/cloud/fogbow/accs/core/datastore/accountingstorage/RecordRepository.java b/src/main/java/cloud/fogbow/accs/core/datastore/accountingstorage/RecordRepository.java index d63e1a3..3de296f 100644 --- a/src/main/java/cloud/fogbow/accs/core/datastore/accountingstorage/RecordRepository.java +++ b/src/main/java/cloud/fogbow/accs/core/datastore/accountingstorage/RecordRepository.java @@ -3,7 +3,7 @@ import cloud.fogbow.accs.core.datastore.AccountingStorageConfiguration; import cloud.fogbow.accs.core.models.AccountingUser; import cloud.fogbow.accs.core.models.Record; -import cloud.fogbow.accs.core.models.orders.OrderState; +import cloud.fogbow.ras.core.models.orders.OrderState; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/cloud/fogbow/accs/core/datastore/orderstorage/AuditableOrderStateChangeRepository.java b/src/main/java/cloud/fogbow/accs/core/datastore/orderstorage/AuditableOrderStateChangeRepository.java index b717458..920c1e3 100644 --- a/src/main/java/cloud/fogbow/accs/core/datastore/orderstorage/AuditableOrderStateChangeRepository.java +++ b/src/main/java/cloud/fogbow/accs/core/datastore/orderstorage/AuditableOrderStateChangeRepository.java @@ -1,8 +1,8 @@ package cloud.fogbow.accs.core.datastore.orderstorage; import cloud.fogbow.accs.core.datastore.OrderStorageConfiguration; -import cloud.fogbow.accs.core.models.orders.AuditableOrderStateChange; -import cloud.fogbow.accs.core.models.orders.OrderState; +import cloud.fogbow.ras.core.datastore.orderstorage.AuditableOrderStateChange; +import cloud.fogbow.ras.core.models.orders.OrderState; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/cloud/fogbow/accs/core/datastore/orderstorage/OrderRepository.java b/src/main/java/cloud/fogbow/accs/core/datastore/orderstorage/OrderRepository.java index 62bb669..41a270e 100644 --- a/src/main/java/cloud/fogbow/accs/core/datastore/orderstorage/OrderRepository.java +++ b/src/main/java/cloud/fogbow/accs/core/datastore/orderstorage/OrderRepository.java @@ -1,7 +1,7 @@ package cloud.fogbow.accs.core.datastore.orderstorage; import cloud.fogbow.accs.core.datastore.OrderStorageConfiguration; -import cloud.fogbow.accs.core.models.orders.Order; +import cloud.fogbow.ras.core.models.orders.Order; import java.util.Optional; diff --git a/src/main/java/cloud/fogbow/accs/core/datastore/services/RecordService.java b/src/main/java/cloud/fogbow/accs/core/datastore/services/RecordService.java index 539a759..6b04e76 100644 --- a/src/main/java/cloud/fogbow/accs/core/datastore/services/RecordService.java +++ b/src/main/java/cloud/fogbow/accs/core/datastore/services/RecordService.java @@ -4,8 +4,8 @@ import cloud.fogbow.accs.core.datastore.accountingstorage.RecordRepository; import cloud.fogbow.accs.core.exceptions.InvalidIntervalException; import cloud.fogbow.accs.core.models.*; -import cloud.fogbow.accs.core.models.orders.OrderState; import cloud.fogbow.common.models.SystemUser; +import cloud.fogbow.ras.core.models.orders.OrderState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/src/main/java/cloud/fogbow/accs/core/models/Record.java b/src/main/java/cloud/fogbow/accs/core/models/Record.java index a95d192..a888ecb 100644 --- a/src/main/java/cloud/fogbow/accs/core/models/Record.java +++ b/src/main/java/cloud/fogbow/accs/core/models/Record.java @@ -1,7 +1,7 @@ package cloud.fogbow.accs.core.models; -import cloud.fogbow.accs.core.models.orders.OrderState; import cloud.fogbow.accs.core.models.specs.OrderSpec; +import cloud.fogbow.ras.core.models.orders.OrderState; import javax.persistence.*; diff --git a/src/main/java/cloud/fogbow/accs/core/models/orders/AuditableOrderStateChange.java b/src/main/java/cloud/fogbow/accs/core/models/orders/AuditableOrderStateChange.java deleted file mode 100644 index e6b0d09..0000000 --- a/src/main/java/cloud/fogbow/accs/core/models/orders/AuditableOrderStateChange.java +++ /dev/null @@ -1,64 +0,0 @@ -package cloud.fogbow.accs.core.models.orders; - -import javax.persistence.*; -import java.sql.Timestamp; - -@Entity -@Table(name = "state_change_event") -@SequenceGenerator(name="seq", initialValue=1, allocationSize = 1) -public class AuditableOrderStateChange { - @Id - @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq") - private Long id; - - @ManyToOne - private Order order; - - @Column - private Timestamp timestamp; - - @Column - @Enumerated(EnumType.STRING) - private OrderState newState; - - public AuditableOrderStateChange(Timestamp timestamp, Order order, OrderState newState) { - this.order = order; - this.timestamp = timestamp; - this.newState = newState; - } - - public AuditableOrderStateChange() {} - - public Order getOrder() { - return order; - } - - public void setOrder(Order order) { - this.order = order; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = timestamp; - } - - public OrderState getNewState() { - return newState; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public void setNewState(OrderState newState) { - this.newState = newState; - } -} - diff --git a/src/main/java/cloud/fogbow/accs/core/models/orders/ComputeOrder.java b/src/main/java/cloud/fogbow/accs/core/models/orders/ComputeOrder.java deleted file mode 100644 index a945830..0000000 --- a/src/main/java/cloud/fogbow/accs/core/models/orders/ComputeOrder.java +++ /dev/null @@ -1,94 +0,0 @@ -package cloud.fogbow.accs.core.models.orders; - -import org.apache.log4j.Logger; - -import javax.persistence.*; -import javax.validation.constraints.Size; -import java.util.*; - -@Entity -@Table(name = "compute_order_table") -public class ComputeOrder extends Order { - private static final long serialVersionUID = 1L; - - private static final String NAME_COLUMN_NAME = "name"; - private static final String IMAGE_ID_COLUMN_NAME = "image_id"; - private static final String PUBLIC_KEY_COLUMN_NAME = "public_key"; - - public static final int PUBLIC_KEY_MAX_SIZE = 1024; - - @Transient - private transient final Logger LOGGER = Logger.getLogger(ComputeOrder.class); - - @Column - private int vCPU; - - // Memory attribute, must be set in MB. - @Column - private int memory; - - // Disk attribute, must be set in GB. - @Column - private int disk; - - @Size(max = FIELDS_MAX_SIZE) - @Column(name = NAME_COLUMN_NAME) - private String name; - - @Size(max = FIELDS_MAX_SIZE) - @Column(name = IMAGE_ID_COLUMN_NAME) - private String imageId; - - @Size(max = PUBLIC_KEY_MAX_SIZE) - @Column(name = PUBLIC_KEY_COLUMN_NAME) - private String publicKey; - - @Column - @ElementCollection(fetch = FetchType.EAGER) - private List networkIds; - - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getvCPU() { - return vCPU; - } - - public int getMemory() { - return memory; - } - - public int getDisk() { - return disk; - } - - public String getImageId() { - return imageId; - } - - public String getPublicKey() { - return publicKey; - } - - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - public List getNetworkIds() { - if (networkIds == null) { - return Collections.unmodifiableList(new ArrayList<>()); - } - return Collections.unmodifiableList(this.networkIds); - } - - public void setNetworkIds(List networkIds) { - this.networkIds = networkIds; - } - -} diff --git a/src/main/java/cloud/fogbow/accs/core/models/orders/NetworkOrder.java b/src/main/java/cloud/fogbow/accs/core/models/orders/NetworkOrder.java deleted file mode 100644 index 7c5f4b6..0000000 --- a/src/main/java/cloud/fogbow/accs/core/models/orders/NetworkOrder.java +++ /dev/null @@ -1,51 +0,0 @@ -package cloud.fogbow.accs.core.models.orders; - -import cloud.fogbow.accs.core.models.specs.NetworkAllocationMode; -import org.apache.log4j.Logger; - -import javax.persistence.*; -import javax.validation.constraints.Size; - -@Entity -@Table(name = "network_order_table") -public class NetworkOrder extends Order { - private static final long serialVersionUID = 1L; - - private transient static final Logger LOGGER = Logger.getLogger(NetworkOrder.class); - - private static final String NAME_COLUMN_NAME = "name"; - private static final String GATEWAY_COLUMN_NAME = "gateway"; - private static final String CIDR_COLUMN_NAME = "cidr"; - - @Size(max = Order.FIELDS_MAX_SIZE) - @Column(name = NAME_COLUMN_NAME) - private String name; - - @Size(max = Order.FIELDS_MAX_SIZE) - @Column(name = GATEWAY_COLUMN_NAME) - private String gateway; - - @Size(max = Order.FIELDS_MAX_SIZE) - @Column(name = CIDR_COLUMN_NAME) - private String cidr; - - @Column - @Enumerated(EnumType.STRING) - private NetworkAllocationMode allocationMode; - - public String getName() { - return name; - } - - public String getGateway() { - return gateway; - } - - public String getCidr() { - return cidr; - } - - public NetworkAllocationMode getAllocationMode() { - return allocationMode; - } -} diff --git a/src/main/java/cloud/fogbow/accs/core/models/orders/Order.java b/src/main/java/cloud/fogbow/accs/core/models/orders/Order.java deleted file mode 100644 index 0a6be73..0000000 --- a/src/main/java/cloud/fogbow/accs/core/models/orders/Order.java +++ /dev/null @@ -1,150 +0,0 @@ -package cloud.fogbow.accs.core.models.orders; - -import cloud.fogbow.accs.core.models.ResourceType; - -import javax.persistence.*; -import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.Objects; - -@Entity -@Inheritance(strategy = InheritanceType.JOINED) -@Table(name = "order_table") -public class Order implements Serializable { - - protected static final int ID_FIXED_SIZE = 36; // UUID size - - private static final long serialVersionUID = 1L; - - protected static final String REQUESTER_COLUMN_NAME = "requester"; - protected static final String PROVIDER_COLUMN_NAME = "provider"; - protected static final String CLOUD_NAME_COLUMN_NAME = "cloud_name"; - protected static final String INSTANCE_ID_COLUMN_NAME = "instance_id"; - protected static final int FIELDS_MAX_SIZE = 255; - - @Column - @Id - @Size(max = ID_FIXED_SIZE) - private String id; - - @Column - @Enumerated(EnumType.STRING) - private OrderState orderState; - - @Column(name = REQUESTER_COLUMN_NAME) - @Size(max = FIELDS_MAX_SIZE) - private String requester; - - @Column(name = PROVIDER_COLUMN_NAME) - @Size(max = FIELDS_MAX_SIZE) - private String provider; - - @Column(name = CLOUD_NAME_COLUMN_NAME) - @Size(max = FIELDS_MAX_SIZE) - private String cloudName; - - @Column(name = INSTANCE_ID_COLUMN_NAME) - @Size(max = FIELDS_MAX_SIZE) - private String instanceId; - - @Column - @Size(max = FIELDS_MAX_SIZE) - private String userId; - - @Column - @Enumerated(EnumType.STRING) - protected ResourceType type; - - public OrderState getOrderState() { - return orderState; - } - - public void setOrderState(OrderState orderState) { - this.orderState = orderState; - } - - public String getRequester() { - return requester; - } - - public void setRequester(String requester) { - this.requester = requester; - } - - public String getProvider() { - return provider; - } - - public void setProvider(String provider) { - this.provider = provider; - } - - public String getCloudName() { - return cloudName; - } - - public void setCloudName(String cloudName) { - this.cloudName = cloudName; - } - - public String getInstanceId() { - return instanceId; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public static int getIdFixedSize() { - return ID_FIXED_SIZE; - } - - public static long getSerialVersionUID() { - return serialVersionUID; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Order order = (Order) o; - return Objects.equals(id, order.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getUserId() { - return this.userId; - } - - public ResourceType getType() { - return this.type; - } - - public void setType(ResourceType type) { - this.type = type; - } - - public Order() { - } - - public Order(String id) { - this.id = id; - } - -} diff --git a/src/main/java/cloud/fogbow/accs/core/models/orders/OrderState.java b/src/main/java/cloud/fogbow/accs/core/models/orders/OrderState.java deleted file mode 100644 index 498a163..0000000 --- a/src/main/java/cloud/fogbow/accs/core/models/orders/OrderState.java +++ /dev/null @@ -1,31 +0,0 @@ -package cloud.fogbow.accs.core.models.orders; - -public enum OrderState { - OPEN("OPEN"), - PENDING("PENDING"), - SPAWNING("SPAWNING"), - FULFILLED("FULFILLED"), - FAILED_AFTER_SUCCESSFUL_REQUEST("FAILED_AFTER_SUCCESSFUL_REQUEST"), - FAILED_ON_REQUEST("FAILED_ON_REQUEST"), - CLOSED("CLOSED"), - UNABLE_TO_CHECK_STATUS("UNABLE_TO_CHECK_STATUS"), - SELECTED("SELECTED"), - ASSIGNED_FOR_DELETION("ASSIGNED_FOR_DELETION"), - CHECKING_DELETION("CHECKING_DELETION"), - PAUSED("PAUSED"), - HIBERNATED("HIBERNATED"), - PAUSING("PAUSING"), - HIBERNATING("HIBERNATING"), - RESUMING("RESUMING"), - DEACTIVATED("DEACTIVATED"); - // an order that has been closed is stored twice in stable storage: - // one when the order is deleted (but instanceId != null), - // and another when it is deactivated (when instanceId == null); - // we need the deactivate state so that the add in the timestamp table won't break. - - private final String repr; - - OrderState(String repr) { - this.repr = repr; - } -} diff --git a/src/main/java/cloud/fogbow/accs/core/models/orders/VolumeOrder.java b/src/main/java/cloud/fogbow/accs/core/models/orders/VolumeOrder.java deleted file mode 100644 index f7000b8..0000000 --- a/src/main/java/cloud/fogbow/accs/core/models/orders/VolumeOrder.java +++ /dev/null @@ -1,32 +0,0 @@ -package cloud.fogbow.accs.core.models.orders; - -import org.apache.log4j.Logger; - -import javax.persistence.*; -import javax.validation.constraints.Size; - -@Entity -@Table(name = "volume_order_table") -public class VolumeOrder extends Order { - private static final long serialVersionUID = 1L; - - private static final String NAME_COLUMN_NAME = "name"; - - @Transient - private transient final Logger LOGGER = Logger.getLogger(VolumeOrder.class); - - @Column - private int volumeSize; - - @Size(max = FIELDS_MAX_SIZE) - @Column(name = NAME_COLUMN_NAME) - private String name; - - public int getVolumeSize() { - return volumeSize; - } - - public String getName() { - return name; - } -} diff --git a/src/main/java/cloud/fogbow/accs/core/models/specs/NetworkSpec.java b/src/main/java/cloud/fogbow/accs/core/models/specs/NetworkSpec.java index 417f75f..2e68abd 100644 --- a/src/main/java/cloud/fogbow/accs/core/models/specs/NetworkSpec.java +++ b/src/main/java/cloud/fogbow/accs/core/models/specs/NetworkSpec.java @@ -4,6 +4,8 @@ import javax.persistence.EnumType; import javax.persistence.Enumerated; +import cloud.fogbow.ras.core.models.NetworkAllocationMode; + @Entity public class NetworkSpec extends OrderSpec { diff --git a/src/main/java/cloud/fogbow/accs/core/processors/SyncProcessor.java b/src/main/java/cloud/fogbow/accs/core/processors/SyncProcessor.java index 6a3cd82..3f809c0 100644 --- a/src/main/java/cloud/fogbow/accs/core/processors/SyncProcessor.java +++ b/src/main/java/cloud/fogbow/accs/core/processors/SyncProcessor.java @@ -3,9 +3,9 @@ import cloud.fogbow.accs.constants.Messages; import cloud.fogbow.accs.core.datastore.DatabaseManager; import cloud.fogbow.accs.core.models.*; -import cloud.fogbow.accs.core.models.orders.AuditableOrderStateChange; -import cloud.fogbow.accs.core.models.orders.Order; -import cloud.fogbow.accs.core.models.orders.OrderState; +import cloud.fogbow.ras.core.datastore.orderstorage.AuditableOrderStateChange; +import cloud.fogbow.ras.core.models.orders.Order; +import cloud.fogbow.ras.core.models.orders.OrderState; import cloud.fogbow.accs.core.SpecFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -161,7 +161,8 @@ protected long getDuration(Timestamp intervalEnd, Timestamp intervalStart) { } protected boolean orderHasFinished(OrderState state) { - return state.equals((OrderState.CLOSED)) || state.equals(OrderState.FAILED_AFTER_SUCCESSFUL_REQUEST) || state.equals((OrderState.DEACTIVATED)); + return state.equals((OrderState.CLOSED)) || state + .equals(OrderState.FAILED_AFTER_SUCCESSFUL_REQUEST); } protected Timestamp extractDateFromTimestamp(Timestamp timestamp) { diff --git a/src/test/java/cloud/fogbow/accs/core/TestUtils.java b/src/test/java/cloud/fogbow/accs/core/TestUtils.java index f13358a..38276c8 100644 --- a/src/test/java/cloud/fogbow/accs/core/TestUtils.java +++ b/src/test/java/cloud/fogbow/accs/core/TestUtils.java @@ -4,12 +4,13 @@ import cloud.fogbow.accs.core.models.AccountingUser; import cloud.fogbow.accs.core.models.Record; import cloud.fogbow.accs.core.models.UserIdentity; -import cloud.fogbow.accs.core.models.orders.AuditableOrderStateChange; -import cloud.fogbow.accs.core.models.orders.Order; -import cloud.fogbow.accs.core.models.orders.OrderState; import cloud.fogbow.as.core.util.AuthenticationUtil; import cloud.fogbow.common.exceptions.FogbowException; import cloud.fogbow.common.models.SystemUser; +import cloud.fogbow.ras.core.datastore.orderstorage.AuditableOrderStateChange; +import cloud.fogbow.ras.core.models.orders.ComputeOrder; +import cloud.fogbow.ras.core.models.orders.Order; +import cloud.fogbow.ras.core.models.orders.OrderState; import org.mockito.BDDMockito; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; @@ -123,7 +124,7 @@ public DatabaseManager mockDbManager() { } public Order createOrder(String id) { - Order order = new Order(); + Order order = new ComputeOrder(); order.setId(id); return order; } diff --git a/src/test/java/cloud/fogbow/accs/core/datastore/services/RecordServiceTest.java b/src/test/java/cloud/fogbow/accs/core/datastore/services/RecordServiceTest.java index c2adc85..d621df6 100644 --- a/src/test/java/cloud/fogbow/accs/core/datastore/services/RecordServiceTest.java +++ b/src/test/java/cloud/fogbow/accs/core/datastore/services/RecordServiceTest.java @@ -8,8 +8,8 @@ import cloud.fogbow.accs.core.models.AccountingUser; import cloud.fogbow.accs.core.models.Record; import cloud.fogbow.accs.core.models.UserIdentity; -import cloud.fogbow.accs.core.models.orders.OrderState; import cloud.fogbow.common.models.SystemUser; +import cloud.fogbow.ras.core.models.orders.OrderState; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/cloud/fogbow/accs/core/processors/SyncProcessorTest.java b/src/test/java/cloud/fogbow/accs/core/processors/SyncProcessorTest.java index 57692d6..fbd93f4 100644 --- a/src/test/java/cloud/fogbow/accs/core/processors/SyncProcessorTest.java +++ b/src/test/java/cloud/fogbow/accs/core/processors/SyncProcessorTest.java @@ -4,9 +4,9 @@ import cloud.fogbow.accs.core.datastore.DatabaseManager; import cloud.fogbow.accs.core.models.AuditableOrderIdRecorder; import cloud.fogbow.accs.core.models.Record; -import cloud.fogbow.accs.core.models.orders.AuditableOrderStateChange; -import cloud.fogbow.accs.core.models.orders.Order; -import cloud.fogbow.accs.core.models.orders.OrderState; +import cloud.fogbow.ras.core.datastore.orderstorage.AuditableOrderStateChange; +import cloud.fogbow.ras.core.models.orders.Order; +import cloud.fogbow.ras.core.models.orders.OrderState; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -33,7 +33,6 @@ public void orderHasFinished() { // exercise/verify Assert.assertTrue(syncProcessor.orderHasFinished(OrderState.CLOSED)); Assert.assertTrue(syncProcessor.orderHasFinished(OrderState.FAILED_AFTER_SUCCESSFUL_REQUEST)); - Assert.assertTrue(syncProcessor.orderHasFinished(OrderState.DEACTIVATED)); Assert.assertFalse(syncProcessor.orderHasFinished(OrderState.FULFILLED)); }