aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java1
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java36
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java38
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java8
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java58
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java66
8 files changed, 36 insertions, 179 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java
index 1694b257b..64102e607 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java
@@ -64,5 +64,6 @@ public class AutomationCompositionStateChange extends ParticipantMessage {
this.deployOrderedState = source.deployOrderedState;
this.lockOrderedState = source.lockOrderedState;
this.startPhase = source.startPhase;
+ this.firstStartPhase = source.firstStartPhase;
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
index 2aacc74b6..33ec649f4 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
@@ -41,8 +41,6 @@ import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -83,14 +81,6 @@ public class JpaAutomationComposition extends Validated
@Column
@NotNull
- private AutomationCompositionState state;
-
- @Column
- @NotNull
- private AutomationCompositionOrderedState orderedState;
-
- @Column
- @NotNull
private DeployState deployState;
@Column
@@ -110,7 +100,7 @@ public class JpaAutomationComposition extends Validated
*/
public JpaAutomationComposition() {
this(UUID.randomUUID().toString(), new PfConceptKey(), UUID.randomUUID().toString(),
- AutomationCompositionState.UNINITIALISED, new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED);
+ new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED);
}
/**
@@ -119,18 +109,18 @@ public class JpaAutomationComposition extends Validated
* @param instanceId The UUID of the automation composition instance
* @param key the key
* @param compositionId the TOSCA compositionId of the automation composition definition
- * @param state the state of the automation composition
* @param elements the elements of the automation composition in participants
+ * @param deployState the Deploy State
+ * @param lockState the Lock State
*/
public JpaAutomationComposition(@NonNull final String instanceId, @NonNull final PfConceptKey key,
- @NonNull final String compositionId, @NonNull final AutomationCompositionState state,
+ @NonNull final String compositionId,
@NonNull final List<JpaAutomationCompositionElement> elements,
- @NonNull final DeployState deployState, @NonNull final LockState lockState) {
+ @NonNull final DeployState deployState, @NonNull final LockState lockState) {
this.instanceId = instanceId;
this.name = key.getName();
this.version = key.getVersion();
this.compositionId = compositionId;
- this.state = state;
this.deployState = deployState;
this.lockState = lockState;
this.elements = elements;
@@ -146,8 +136,6 @@ public class JpaAutomationComposition extends Validated
this.name = copyConcept.name;
this.version = copyConcept.version;
this.compositionId = copyConcept.compositionId;
- this.state = copyConcept.state;
- this.orderedState = copyConcept.orderedState;
this.deployState = copyConcept.deployState;
this.lockState = copyConcept.lockState;
this.description = copyConcept.description;
@@ -171,8 +159,6 @@ public class JpaAutomationComposition extends Validated
automationComposition.setName(name);
automationComposition.setVersion(version);
automationComposition.setCompositionId(UUID.fromString(compositionId));
- automationComposition.setState(state);
- automationComposition.setOrderedState(orderedState != null ? orderedState : state.asOrderedState());
automationComposition.setDeployState(deployState);
automationComposition.setLockState(lockState);
automationComposition.setDescription(description);
@@ -190,8 +176,6 @@ public class JpaAutomationComposition extends Validated
this.name = automationComposition.getName();
this.version = automationComposition.getVersion();
this.compositionId = automationComposition.getCompositionId().toString();
- this.state = automationComposition.getState();
- this.orderedState = automationComposition.getOrderedState();
this.deployState = automationComposition.getDeployState();
this.lockState = automationComposition.getLockState();
this.description = automationComposition.getDescription();
@@ -234,16 +218,6 @@ public class JpaAutomationComposition extends Validated
return result;
}
- result = ObjectUtils.compare(state, other.state);
- if (result != 0) {
- return result;
- }
-
- result = ObjectUtils.compare(orderedState, other.orderedState);
- if (result != 0) {
- return result;
- }
-
result = ObjectUtils.compare(deployState, other.deployState);
if (result != 0) {
return result;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java
index d0dcd797f..4c3a6a3be 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java
@@ -41,8 +41,6 @@ import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -75,7 +73,6 @@ public class JpaAutomationCompositionElement extends Validated
@NotNull
private String instanceId;
- // @formatter:off
@VerifyKey
@NotNull
@AttributeOverrides({
@@ -89,14 +86,6 @@ public class JpaAutomationCompositionElement extends Validated
@Column
@NotNull
- private AutomationCompositionState state;
-
- @Column
- @NotNull
- private AutomationCompositionOrderedState orderedState;
-
- @Column
- @NotNull
private DeployState deployState;
@Column
@@ -127,7 +116,7 @@ public class JpaAutomationCompositionElement extends Validated
*/
public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId) {
this(elementId, instanceId, new PfConceptKey(),
- AutomationCompositionState.UNINITIALISED, DeployState.UNDEPLOYED, LockState.LOCKED);
+ DeployState.UNDEPLOYED, LockState.LOCKED);
}
/**
@@ -136,16 +125,15 @@ public class JpaAutomationCompositionElement extends Validated
* @param elementId The id of the automation composition instance Element
* @param instanceId The id of the automation composition instance
* @param definition the TOSCA definition of the automation composition element
- * @param state the state of the automation composition
+ * @param deployState the Deploy State of the automation composition
+ * @param lockState the Lock State of the automation composition
*/
public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId,
@NonNull final PfConceptKey definition,
- @NonNull final AutomationCompositionState state,
- @NonNull final DeployState deployState, @NonNull final LockState lockState) {
+ @NonNull final DeployState deployState, @NonNull final LockState lockState) {
this.elementId = elementId;
this.instanceId = instanceId;
this.definition = definition;
- this.state = state;
this.deployState = deployState;
this.lockState = lockState;
}
@@ -160,8 +148,6 @@ public class JpaAutomationCompositionElement extends Validated
this.instanceId = copyConcept.instanceId;
this.definition = new PfConceptKey(copyConcept.definition);
this.participantId = copyConcept.participantId;
- this.state = copyConcept.state;
- this.orderedState = copyConcept.orderedState;
this.description = copyConcept.description;
this.properties = (copyConcept.properties != null ? new LinkedHashMap<>(copyConcept.properties) : null);
this.deployState = copyConcept.deployState;
@@ -184,8 +170,6 @@ public class JpaAutomationCompositionElement extends Validated
element.setId(UUID.fromString(elementId));
element.setDefinition(new ToscaConceptIdentifier(definition));
element.setParticipantId(UUID.fromString(participantId));
- element.setState(state);
- element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState());
element.setDescription(description);
element.setProperties(PfUtils.mapMap(properties, UnaryOperator.identity()));
element.setDeployState(deployState);
@@ -198,10 +182,8 @@ public class JpaAutomationCompositionElement extends Validated
public void fromAuthorative(@NonNull final AutomationCompositionElement element) {
this.definition = element.getDefinition().asConceptKey();
this.participantId = element.getParticipantId().toString();
- this.state = element.getState();
- this.orderedState = element.getOrderedState();
this.description = element.getDescription();
- properties = PfUtils.mapMap(element.getProperties(), UnaryOperator.identity());
+ this.properties = PfUtils.mapMap(element.getProperties(), UnaryOperator.identity());
this.deployState = element.getDeployState();
this.lockState = element.getLockState();
}
@@ -235,16 +217,6 @@ public class JpaAutomationCompositionElement extends Validated
return result;
}
- result = ObjectUtils.compare(state, other.state);
- if (result != 0) {
- return result;
- }
-
- result = ObjectUtils.compare(orderedState, other.orderedState);
- if (result != 0) {
- return result;
- }
-
result = ObjectUtils.compare(deployState, other.deployState);
if (result != 0) {
return result;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
index 197955d3a..058feae76 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
@@ -116,7 +116,6 @@ public class AutomationCompositionProvider {
*/
public AutomationComposition updateAutomationComposition(
@NonNull final AutomationComposition automationComposition) {
- AcmUtils.setCascadedState(automationComposition, DeployState.UNDEPLOYED, LockState.NONE);
var result = automationCompositionRepository.save(ProviderUtils.getJpaAndValidate(automationComposition,
JpaAutomationComposition::new, "automation composition"));
@@ -159,7 +158,6 @@ public class AutomationCompositionProvider {
example.setVersion(version);
example.setInstanceId(null);
example.setElements(null);
- example.setState(null);
example.setDeployState(null);
example.setLockState(null);
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java
index 76dcabf0e..5585e6896 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java
@@ -28,8 +28,8 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
import java.time.Instant;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
import org.onap.policy.clamp.models.acm.utils.CommonTestData;
import org.onap.policy.common.utils.coder.CoderException;
@@ -52,8 +52,8 @@ class AutomationCompositionStateChangeTest {
orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(CommonTestData.getParticipantId());
orig.setMessageId(UUID.randomUUID());
- orig.setOrderedState(AutomationCompositionOrderedState.RUNNING);
- orig.setCurrentState(AutomationCompositionState.PASSIVE);
+ orig.setDeployOrderedState(DeployOrder.DEPLOY);
+ orig.setLockOrderedState(LockOrder.NONE);
orig.setTimestamp(Instant.ofEpochMilli(3000));
assertEquals(removeVariableFields(orig.toString()),
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
index bbba9cbc2..711af2f81 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
@@ -31,7 +31,8 @@ import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.utils.CommonTestData;
@@ -77,7 +78,8 @@ class ParticipantStatusTest {
private AutomationCompositionInfo getAutomationCompositionInfo(UUID id) {
var acInfo = new AutomationCompositionInfo();
- acInfo.setState(AutomationCompositionState.PASSIVE2RUNNING);
+ acInfo.setDeployState(DeployState.DEPLOYED);
+ acInfo.setLockState(LockState.LOCKED);
acInfo.setAutomationCompositionId(id);
return acInfo;
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java
index 3274833ca..e9df9b7e5 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java
@@ -25,22 +25,16 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.File;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.utils.CommonTestData;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -78,38 +72,33 @@ class JpaAutomationCompositionElementTest {
}).hasMessageMatching(NULL_ELEMENT_ID_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement(null, null, null, null, null, null);
+ new JpaAutomationCompositionElement(null, null, null, null, null);
}).hasMessageMatching(NULL_ELEMENT_ID_ERROR);
assertThatThrownBy(() -> {
new JpaAutomationCompositionElement("key", null, null,
- AutomationCompositionState.UNINITIALISED, DeployState.UNDEPLOYED, LockState.LOCKED);
+ DeployState.UNDEPLOYED, LockState.LOCKED);
}).hasMessageMatching(NULL_INSTANCE_ID_ERROR);
assertThatThrownBy(() -> {
new JpaAutomationCompositionElement("key", "key", null,
- AutomationCompositionState.UNINITIALISED, DeployState.UNDEPLOYED, LockState.LOCKED);
- }).hasMessageMatching("definition" + NULL_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement("key", "key", new PfConceptKey(), null,
DeployState.UNDEPLOYED, LockState.LOCKED);
- }).hasMessageMatching("state" + NULL_ERROR);
+ }).hasMessageMatching("definition" + NULL_ERROR);
assertThatThrownBy(() -> {
new JpaAutomationCompositionElement("key", "key", new PfConceptKey(),
- AutomationCompositionState.UNINITIALISED, null, LockState.LOCKED);
+ null, LockState.LOCKED);
}).hasMessageMatching("deployState" + NULL_ERROR);
assertThatThrownBy(() -> {
new JpaAutomationCompositionElement("key", "key", new PfConceptKey(),
- AutomationCompositionState.UNINITIALISED, DeployState.UNDEPLOYED, null);
+ DeployState.UNDEPLOYED, null);
}).hasMessageMatching("lockState" + NULL_ERROR);
assertNotNull(new JpaAutomationCompositionElement());
assertNotNull(new JpaAutomationCompositionElement("key", "key"));
assertNotNull(new JpaAutomationCompositionElement("key", "key",
- new PfConceptKey(), AutomationCompositionState.UNINITIALISED, DeployState.UNDEPLOYED, LockState.LOCKED));
+ new PfConceptKey(), DeployState.UNDEPLOYED, LockState.LOCKED));
}
@Test
@@ -138,29 +127,6 @@ class JpaAutomationCompositionElementTest {
}
@Test
- void testJpaAutomationCompositionElementOrderedState() throws CoderException {
- var testAutomationCompositionElement = createAutomationCompositionElementInstance();
- var testJpaAutomationCompositionElement = createJpaAutomationCompositionElementInstance();
-
- testJpaAutomationCompositionElement.setOrderedState(null);
- assertEquals(testAutomationCompositionElement, testJpaAutomationCompositionElement.toAuthorative());
- testJpaAutomationCompositionElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
-
- var noOrderedStateAce = new StandardCoder().decode(
- new File("src/test/resources/json/AutomationCompositionElementNoOrderedState.json"),
- AutomationCompositionElement.class);
-
- var noOrderedStateJpaAce = new JpaAutomationCompositionElement(noOrderedStateAce);
- assertNull(noOrderedStateJpaAce.getOrderedState());
- noOrderedStateAce.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- noOrderedStateJpaAce = new JpaAutomationCompositionElement(noOrderedStateAce);
- noOrderedStateJpaAce.setInstanceId(testJpaAutomationCompositionElement.getInstanceId());
- noOrderedStateJpaAce.setElementId(testJpaAutomationCompositionElement.getElementId());
- noOrderedStateJpaAce.setParticipantId(testJpaAutomationCompositionElement.getParticipantId());
- assertEquals(testJpaAutomationCompositionElement, noOrderedStateJpaAce);
- }
-
- @Test
void testJpaAutomationCompositionElementValidation() {
var testJpaAutomationCompositionElement = createJpaAutomationCompositionElementInstance();
@@ -202,16 +168,6 @@ class JpaAutomationCompositionElementTest {
testJpaAutomationCompositionElement.setDescription(null);
assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
- testJpaAutomationCompositionElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
- assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
- testJpaAutomationCompositionElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
-
- testJpaAutomationCompositionElement.setState(AutomationCompositionState.PASSIVE);
- assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
- testJpaAutomationCompositionElement.setState(AutomationCompositionState.UNINITIALISED);
- assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
-
testJpaAutomationCompositionElement.setDeployState(DeployState.DEPLOYED);
assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
testJpaAutomationCompositionElement.setDeployState(DeployState.UNDEPLOYED);
@@ -244,8 +200,6 @@ class JpaAutomationCompositionElementTest {
ace1.setDefinition(new PfConceptKey("defName", "0.0.1"));
ace1.setDescription("Description");
- ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- ace1.setState(AutomationCompositionState.UNINITIALISED);
ace1.setParticipantId(CommonTestData.getJpaParticipantId());
assertThat(ace1.toString()).contains("AutomationCompositionElement(");
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
index 0f10c8c03..bc01e74be 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
@@ -22,25 +22,18 @@ package org.onap.policy.clamp.models.acm.persistence.concepts;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.base.PfConceptKey;
/**
@@ -64,43 +57,37 @@ class JpaAutomationCompositionTest {
}).hasMessageMatching("authorativeConcept is marked .*ull but is null");
assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, null, null, null, null, null, null);
+ new JpaAutomationComposition(null, null, null, null, null, null);
}).hasMessageMatching(NULL_INSTANCE_ID_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(INSTANCE_ID, null, null, null, new ArrayList<>(),
+ new JpaAutomationComposition(INSTANCE_ID, null, null, new ArrayList<>(),
DeployState.UNDEPLOYED, LockState.LOCKED);
}).hasMessageMatching("key" + NULL_TEXT_ERROR);
assertThatThrownBy(() -> {
new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), null,
- AutomationCompositionState.UNINITIALISED, new ArrayList<>(),
- DeployState.UNDEPLOYED, LockState.LOCKED);
+ new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED);
}).hasMessageMatching("compositionId" + NULL_TEXT_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(), null,
- new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED);
- }).hasMessageMatching("state" + NULL_TEXT_ERROR);
-
- assertThatThrownBy(() -> {
new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(),
- AutomationCompositionState.UNINITIALISED, null, DeployState.UNDEPLOYED, LockState.LOCKED);
+ null, DeployState.UNDEPLOYED, LockState.LOCKED);
}).hasMessageMatching("elements" + NULL_TEXT_ERROR);
assertThatThrownBy(() -> {
new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(),
- AutomationCompositionState.UNINITIALISED, new ArrayList<>(), null, LockState.LOCKED);
+ new ArrayList<>(), null, LockState.LOCKED);
}).hasMessageMatching("deployState" + NULL_TEXT_ERROR);
assertThatThrownBy(() -> {
new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(),
- AutomationCompositionState.UNINITIALISED, new ArrayList<>(), DeployState.UNDEPLOYED, null);
+ new ArrayList<>(), DeployState.UNDEPLOYED, null);
}).hasMessageMatching("lockState" + NULL_TEXT_ERROR);
assertNotNull(new JpaAutomationComposition());
assertNotNull(new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(),
- AutomationCompositionState.UNINITIALISED, new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED));
+ new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED));
}
@Test
@@ -131,36 +118,6 @@ class JpaAutomationCompositionTest {
}
@Test
- void testJpaAutomationCompositionElementOrderedState() throws CoderException {
- var testAutomationComposition = createAutomationCompositionInstance();
- var testJpaAutomationComposition = createJpaAutomationCompositionInstance();
-
- testJpaAutomationComposition.setOrderedState(null);
- assertEquals(testAutomationComposition, testJpaAutomationComposition.toAuthorative());
- testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
-
- var noOrderedStateAc =
- new StandardCoder().decode(new File("src/test/resources/json/AutomationCompositionNoOrderedState.json"),
- AutomationComposition.class);
-
- noOrderedStateAc.setInstanceId(UUID.fromString(INSTANCE_ID));
- var noOrderedStateJpaAc = new JpaAutomationComposition(noOrderedStateAc);
- assertNull(noOrderedStateJpaAc.getOrderedState());
- noOrderedStateAc.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- noOrderedStateJpaAc = new JpaAutomationComposition(noOrderedStateAc);
- assertEquals(testJpaAutomationComposition, noOrderedStateJpaAc);
-
- var acWithElements =
- new StandardCoder().decode(new File("src/test/resources/providers/TestAutomationCompositions.json"),
- AutomationCompositions.class).getAutomationCompositionList().get(0);
-
- acWithElements.setInstanceId(UUID.fromString(INSTANCE_ID));
- var jpaAutomationCompositionWithElements = new JpaAutomationComposition(acWithElements);
- assertEquals(4, jpaAutomationCompositionWithElements.getElements().size());
- assertEquals(acWithElements, jpaAutomationCompositionWithElements.toAuthorative());
- }
-
- @Test
void testJpaAutomationCompositionValidation() {
var testJpaAutomationComposition = createJpaAutomationCompositionInstance();
@@ -200,14 +157,14 @@ class JpaAutomationCompositionTest {
testJpaAutomationComposition.setVersion("0.0.1");
assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setState(AutomationCompositionState.PASSIVE);
+ testJpaAutomationComposition.setDeployState(DeployState.DEPLOYED);
assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setState(AutomationCompositionState.UNINITIALISED);
+ testJpaAutomationComposition.setDeployState(DeployState.UNDEPLOYED);
assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
+ testJpaAutomationComposition.setLockState(LockState.UNLOCKED);
assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ testJpaAutomationComposition.setLockState(LockState.NONE);
assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
testJpaAutomationComposition.setDescription("A description");
@@ -235,7 +192,6 @@ class JpaAutomationCompositionTest {
ac1.setDescription("Description");
ac1.setElements(new ArrayList<>());
ac1.setInstanceId(INSTANCE_ID);
- ac1.setState(AutomationCompositionState.UNINITIALISED);
assertThat(ac1.toString()).contains("AutomationComposition(");
assertNotEquals(0, ac1.hashCode());