diff options
Diffstat (limited to 'models/src/test/java/org')
4 files changed, 25 insertions, 113 deletions
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()); |