diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-06-05 14:32:37 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-06-06 13:29:49 +0000 |
commit | f010d3432b500258121a190ecf94d757c881390e (patch) | |
tree | d66a043185e31ee2897fd52ec2b8c76893220e98 /models/src/test | |
parent | a48f784beca5e7aa189217c52cfa83452cf8fc47 (diff) |
Remove Map in ACM-R for timeout Deploy/Undeploy
Issue-ID: POLICY-5040
Change-Id: I6aa5e93fc63cc865648096512487994fb2f48a54
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/test')
3 files changed, 22 insertions, 13 deletions
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 66554e7ec..b56e77801 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 @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.sql.Timestamp; +import java.time.Instant; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.UUID; @@ -35,6 +37,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; 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.StateChangeResult; +import org.onap.policy.clamp.models.acm.utils.TimestampHelper; import org.onap.policy.models.base.PfConceptKey; /** @@ -93,9 +96,9 @@ class JpaAutomationCompositionTest { @Test void testJpaAutomationComposition() { - var jpaAutomationComposition = createJpaAutomationCompositionInstance(); - var automationComposition = createAutomationCompositionInstance(); + var jpaAutomationComposition = new JpaAutomationComposition(automationComposition); + assertEquals(automationComposition, jpaAutomationComposition.toAuthorative()); var target = UUID.randomUUID(); @@ -125,7 +128,7 @@ class JpaAutomationCompositionTest { @Test void testJpaAutomationCompositionValidation() { - var testJpaAutomationComposition = createJpaAutomationCompositionInstance(); + var testJpaAutomationComposition = new JpaAutomationComposition(createAutomationCompositionInstance()); assertThatThrownBy(() -> testJpaAutomationComposition.validate(null)) .hasMessageMatching("fieldName is marked .*ull but is null"); @@ -135,7 +138,7 @@ class JpaAutomationCompositionTest { @Test void testJpaAutomationCompositionCompareTo() { - var jpaAutomationComposition = createJpaAutomationCompositionInstance(); + var jpaAutomationComposition = new JpaAutomationComposition(createAutomationCompositionInstance()); var otherJpaAutomationComposition = new JpaAutomationComposition(jpaAutomationComposition); assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); @@ -168,6 +171,16 @@ class JpaAutomationCompositionTest { jpaAutomationComposition.setVersion("0.0.1"); assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + jpaAutomationComposition.setLastMsg(Timestamp.from(Instant.EPOCH)); + assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + jpaAutomationComposition.setLastMsg(otherJpaAutomationComposition.getLastMsg()); + assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + + jpaAutomationComposition.setPhase(0); + assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + jpaAutomationComposition.setPhase(null); + assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); + jpaAutomationComposition.setDeployState(DeployState.DEPLOYED); assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition)); jpaAutomationComposition.setDeployState(DeployState.UNDEPLOYED); @@ -225,19 +238,12 @@ class JpaAutomationCompositionTest { assertEquals(ac2, ac0); } - private JpaAutomationComposition createJpaAutomationCompositionInstance() { - var testAutomationComposition = createAutomationCompositionInstance(); - var testJpaAutomationComposition = new JpaAutomationComposition(); - testJpaAutomationComposition.fromAuthorative(testAutomationComposition); - - return testJpaAutomationComposition; - } - private AutomationComposition createAutomationCompositionInstance() { var testAutomationComposition = new AutomationComposition(); testAutomationComposition.setName("automation-composition"); testAutomationComposition.setInstanceId(UUID.fromString(INSTANCE_ID)); testAutomationComposition.setVersion("0.0.1"); + testAutomationComposition.setLastMsg(TimestampHelper.now()); testAutomationComposition.setCompositionId(UUID.fromString(COMPOSITION_ID)); testAutomationComposition.setElements(new LinkedHashMap<>()); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java index 463e958f3..8e7e50de7 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java @@ -85,6 +85,7 @@ class AutomationCompositionProviderTest { var createdAutomationComposition = automationCompositionProvider.createAutomationComposition(inputAc); inputAc.setInstanceId(createdAutomationComposition.getInstanceId()); + inputAc.setLastMsg(createdAutomationComposition.getLastMsg()); assertEquals(inputAc, createdAutomationComposition); } diff --git a/models/src/test/resources/providers/TestAutomationCompositions.json b/models/src/test/resources/providers/TestAutomationCompositions.json index 24f5a4870..c75337bc1 100644 --- a/models/src/test/resources/providers/TestAutomationCompositions.json +++ b/models/src/test/resources/providers/TestAutomationCompositions.json @@ -5,6 +5,7 @@ "instanceId": "809c62b3-8918-41b9-a748-e21eb79c6c89", "deployState": "UNDEPLOYED", "lockState": "NONE", + "lastMsg": "2024-05-22 10:04:37.6020187", "elements": { "709c62b3-8918-41b9-a747-e21eb79c6c20": { "id": "709c62b3-8918-41b9-a747-e21eb79c6c20", @@ -56,6 +57,7 @@ "instanceId": "809c62b3-8918-41b9-a748-e21eb79c6c90", "deployState": "UNDEPLOYED", "lockState": "NONE", + "lastMsg": "2024-05-22 10:04:37.6020187", "elements": { "709c62b3-8918-41b9-a747-e21eb79c6c24": { "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", |