aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-01-25 19:55:43 +0000
committerliamfallon <liam.fallon@est.tech>2022-02-18 15:54:40 +0000
commit43098043c4ef31d9d5dead66568d7d9482a6b165 (patch)
tree6f6ea4812ff93d65e7c64e12a3ec6ab4462a64e2 /models/src/test/java
parentf401b5099bcb64f3e21de608d0207dd69d8043cd (diff)
Rename TOSCA Control Loop to ACM
This commit renames the TOSCA Control Loop functionality in CLAMP to Automation Composition Management. This review is a direct renaming review and, as everything is renamed together it is large. Issue-ID: POLICY-3939 Change-Id: I28f0a6dd889bf3570a4c1365ae9e71fc58db6d6c Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models/src/test/java')
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java103
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java160
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java189
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java300
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java301
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java116
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java290
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java83
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java)44
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionConceptPojosTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java103
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java160
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtilsTest.java)47
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java83
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java)24
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java)34
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java)28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java)46
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java)4
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAckTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java)8
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java)4
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageUtils.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAckTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java)8
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java)8
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java)92
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java)28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/MessagesRestPojosTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java)8
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionChild.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionElementChild.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantChild.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java189
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java315
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java310
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java)28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java)8
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/PojosTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java116
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java305
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java)12
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java)12
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java)6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImplTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImplTest.java)35
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/rest/RestUtilsTest.java (renamed from models/src/test/java/org/onap/policy/clamp/controlloop/models/rest/RestUtilsTest.java)2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java149
54 files changed, 2010 insertions, 1812 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java
deleted file mode 100644
index ed579febb..000000000
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class ControlLoopElementTest {
- @Test
- void testControlLoopElement() {
- var cle0 = new ControlLoopElement();
- var cle1 = new ControlLoopElement(cle0);
- assertEquals(cle0, cle1);
-
- cle1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
- cle1.setDescription("Description");
- cle1.setId(UUID.randomUUID());
- cle1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- cle1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3"));
- cle1.setState(ControlLoopState.UNINITIALISED);
-
- var cle2 = new ControlLoopElement(cle1);
- assertEquals(cle1, cle2);
- }
-
- @Test
- void testControlLoopState() {
- var cle0 = new ControlLoopElement();
-
- assertTrue(
- cle0.getOrderedState()
- .equalsControlLoopState(ControlLoopState.UNINITIALISED));
-
- assertTrue(
- cle0.getOrderedState().asState()
- .equalsControlLoopOrderedState(ControlLoopOrderedState.UNINITIALISED));
- }
-
- @Test
- void testControlLoopElementLombok() {
- assertNotNull(new ControlLoopElement());
- var cle0 = new ControlLoopElement();
-
- assertThat(cle0.toString()).contains("ControlLoopElement(");
- assertThat(cle0.hashCode()).isNotZero();
- assertEquals(true, cle0.equals(cle0));
- assertEquals(false, cle0.equals(null));
-
- var cle1 = new ControlLoopElement();
-
- cle1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
- cle1.setDescription("Description");
- cle1.setId(UUID.randomUUID());
- cle1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- cle1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3"));
- cle1.setState(ControlLoopState.UNINITIALISED);
-
- assertThat(cle1.toString()).contains("ControlLoopElement(");
- assertEquals(false, cle1.hashCode() == 0);
- assertEquals(false, cle1.equals(cle0));
- assertEquals(false, cle1.equals(null));
-
- assertNotEquals(cle1, cle0);
-
- var cle2 = new ControlLoopElement();
-
- // @formatter:off
- assertThatThrownBy(() -> cle2.setDefinition(null)). isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> cle2.setId(null)). isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> cle2.setOrderedState(null)). isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> cle2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> cle2.setState(null)). isInstanceOf(NullPointerException.class);
- // @formatter:on
-
- assertNotEquals(cle2, cle0);
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java
deleted file mode 100644
index d9c518b53..000000000
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.time.Instant;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.models.base.PfKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class ControlLoopTest {
- @Test
- void testControlLoop() {
- var cl0 = new ControlLoop();
- cl0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3"));
- assertEquals("dfName", cl0.getType());
- assertEquals("1.2.3", cl0.getTypeVersion());
-
- var cl1 = new ControlLoop(cl0);
- assertEquals(cl0, cl1);
-
- assertEquals(0, cl0.compareTo(cl1));
- }
-
- @Test
- void testControlLoopLombok() {
- assertNotNull(new ControlLoop());
- var cl0 = new ControlLoop();
- cl0.setElements(new LinkedHashMap<>());
-
- assertThat(cl0.toString()).contains("ControlLoop(");
- assertThat(cl0.hashCode()).isNotZero();
- assertEquals(true, cl0.equals(cl0));
- assertEquals(false, cl0.equals(null));
-
- var cl1 = new ControlLoop();
-
- cl1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
- cl1.setDescription("Description");
- cl1.setElements(new LinkedHashMap<>());
- cl1.setName("Name");
- cl1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- cl1.setState(ControlLoopState.UNINITIALISED);
- cl1.setVersion("0.0.1");
-
- assertThat(cl1.toString()).contains("ControlLoop(");
- assertEquals(false, cl1.hashCode() == 0);
- assertEquals(false, cl1.equals(cl0));
- assertEquals(false, cl1.equals(null));
-
- assertNotEquals(cl1, cl0);
-
- var cl2 = new ControlLoop();
- cl2.setElements(new LinkedHashMap<>());
-
- // @formatter:off
- assertThatThrownBy(() -> cl2.setDefinition(null)). isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> cl2.setOrderedState(null)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> cl2.setState(null)). isInstanceOf(NullPointerException.class);
- // @formatter:on
-
- assertEquals(cl2, cl0);
-
- cl1.setCascadedOrderedState(ControlLoopOrderedState.PASSIVE);
- assertEquals(ControlLoopOrderedState.PASSIVE, cl1.getOrderedState());
-
- cl1.getElements().put(UUID.randomUUID(), new ControlLoopElement());
- cl1.setCascadedOrderedState(ControlLoopOrderedState.RUNNING);
- assertEquals(ControlLoopOrderedState.RUNNING, cl1.getOrderedState());
- assertEquals(ControlLoopOrderedState.RUNNING, cl1.getElements().values().iterator().next().getOrderedState());
-
- assertNull(cl0.getElements().get(UUID.randomUUID()));
- assertNull(cl1.getElements().get(UUID.randomUUID()));
-
- assertEquals(PfKey.NULL_KEY_NAME, cl0.getDefinition().getName());
-
- }
-
- @Test
- void testControlLoopElementStatisticsList() {
- var cl = new ControlLoop();
- List<ClElementStatistics> emptylist = cl.getControlLoopElementStatisticsList(cl);
- assertEquals(List.of(), emptylist);
-
- var cl1 = getControlLoopTest();
- List<ClElementStatistics> list = cl1.getControlLoopElementStatisticsList(cl1);
- assertNotNull(list);
- assertEquals(2, list.size());
- assertEquals(ControlLoopState.UNINITIALISED, list.get(0).getControlLoopState());
- }
-
- private ControlLoop getControlLoopTest() {
- var cl = new ControlLoop();
- cl.setDefinition(new ToscaConceptIdentifier("defName", "1.2.3"));
- cl.setDescription("Description");
- cl.setElements(new LinkedHashMap<>());
- cl.setName("Name");
- cl.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- cl.setState(ControlLoopState.UNINITIALISED);
- cl.setVersion("0.0.1");
-
- var uuid = UUID.randomUUID();
- var id = new ToscaConceptIdentifier(
- "org.onap.policy.controlloop.PolicyControlLoopParticipant", "1.0.1");
- var clElement = getControlLoopElementTest(uuid, id);
-
- var uuid2 = UUID.randomUUID();
- var id2 = new ToscaConceptIdentifier(
- "org.onap.policy.controlloop.PolicyControlLoopParticipantIntermediary", "0.0.1");
- var clElement2 = getControlLoopElementTest(uuid2, id2);
-
- cl.getElements().put(uuid, clElement);
- cl.getElements().put(uuid2, clElement2);
- return cl;
- }
-
- private ControlLoopElement getControlLoopElementTest(UUID uuid, ToscaConceptIdentifier id) {
- var clElement = new ControlLoopElement();
- clElement.setId(uuid);
- clElement.setParticipantId(id);
- clElement.setDefinition(id);
- clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
-
- var clElementStatistics = new ClElementStatistics();
- clElementStatistics.setParticipantId(id);
- clElementStatistics.setControlLoopState(ControlLoopState.UNINITIALISED);
- clElementStatistics.setTimeStamp(Instant.now());
-
- clElement.setClElementStatistics(clElementStatistics);
-
- return clElement;
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java
deleted file mode 100644
index 0e6fb8383..000000000
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatisticsTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.time.Instant;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfReferenceTimestampKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-/**
- * Test the {@link JpaClElementStatistics} class.
- */
-class JpaClElementStatisticsTest {
-
- private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
-
- @Test
- void testJpaClElementStatisticsConstructor() {
- assertThatThrownBy(() -> {
- new JpaClElementStatistics((JpaClElementStatistics) null);
- }).hasMessageMatching("copyConcept is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaClElementStatistics((PfReferenceTimestampKey) null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaClElementStatistics(null, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaClElementStatistics(null, new PfConceptKey());
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaClElementStatistics(new PfReferenceTimestampKey(), null);
- }).hasMessageMatching("participantId is marked .*ull but is null");
-
- assertNotNull(new JpaClElementStatistics());
- assertNotNull(new JpaClElementStatistics((new PfReferenceTimestampKey())));
- assertNotNull(new JpaClElementStatistics(new PfReferenceTimestampKey(), new PfConceptKey()));
- }
-
- @Test
- void testJpaClElementStatistics() {
- JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance();
-
- ClElementStatistics cles = createClElementStatisticsInstance();
- assertEquals(cles, testJpaClElementStatistics.toAuthorative());
-
- assertThatThrownBy(() -> {
- testJpaClElementStatistics.fromAuthorative(null);
- }).hasMessageMatching("clElementStatistics is marked .*ull but is null");
-
- assertThatThrownBy(() -> new JpaClElementStatistics((JpaClElementStatistics) null))
- .isInstanceOf(NullPointerException.class);
-
- JpaClElementStatistics testJpaClElementStatisticsFa = new JpaClElementStatistics();
- testJpaClElementStatisticsFa.setKey(null);
- testJpaClElementStatisticsFa.fromAuthorative(cles);
- assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
- testJpaClElementStatisticsFa.setKey(PfReferenceTimestampKey.getNullKey());
- testJpaClElementStatisticsFa.fromAuthorative(cles);
- assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
- testJpaClElementStatisticsFa.setKey(new PfReferenceTimestampKey("elementName", "0.0.1",
- "a95757ba-b34a-4049-a2a8-46773abcbe5e", Instant.ofEpochSecond(123456L)));
- testJpaClElementStatisticsFa.fromAuthorative(cles);
- assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
-
- testJpaClElementStatisticsFa = new JpaClElementStatistics(cles);
- assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
-
- assertEquals(1, testJpaClElementStatistics.getKeys().size());
-
- assertEquals("elementName", testJpaClElementStatistics.getKey().getReferenceKey().getParentKeyName());
-
- testJpaClElementStatistics.clean();
- assertEquals("elementName", testJpaClElementStatistics.getKey().getReferenceKey().getParentKeyName());
-
- JpaClElementStatistics testJpaClElementStatistics2 = new JpaClElementStatistics(testJpaClElementStatistics);
- assertEquals(testJpaClElementStatistics, testJpaClElementStatistics2);
- }
-
- @Test
- void testJpaClElementStatisticsValidation() {
- JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance();
-
- assertThatThrownBy(() -> {
- testJpaClElementStatistics.validate(null);
- }).hasMessageMatching("fieldName is marked .*ull but is null");
-
- assertTrue(testJpaClElementStatistics.validate("").isValid());
- }
-
- @Test
- void testJpaClElementStatisticsCompareTo() {
- JpaClElementStatistics testJpaClElementStatistics = createJpaClElementStatisticsInstance();
-
- JpaClElementStatistics otherJpaClElementStatistics = new JpaClElementStatistics(testJpaClElementStatistics);
- assertEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics));
- assertEquals(-1, testJpaClElementStatistics.compareTo(null));
- assertEquals(0, testJpaClElementStatistics.compareTo(testJpaClElementStatistics));
- assertNotEquals(0, testJpaClElementStatistics.compareTo(new DummyJpaClElementStatisticsChild()));
-
- testJpaClElementStatistics.setState(ControlLoopState.PASSIVE);
- assertNotEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics));
- testJpaClElementStatistics.setState(ControlLoopState.UNINITIALISED);
- assertEquals(0, testJpaClElementStatistics.compareTo(otherJpaClElementStatistics));
-
- assertEquals(testJpaClElementStatistics, new JpaClElementStatistics(testJpaClElementStatistics));
- }
-
- @Test
- void testJpaClElementStatisticsLombok() {
- assertNotNull(new Participant());
- JpaClElementStatistics cles0 = new JpaClElementStatistics();
-
- assertThat(cles0.toString()).contains("JpaClElementStatistics(");
- assertThat(cles0.hashCode()).isNotZero();
- assertEquals(true, cles0.equals(cles0));
- assertEquals(false, cles0.equals(null));
-
-
- JpaClElementStatistics cles11 = new JpaClElementStatistics();
-
- cles11.setState(ControlLoopState.UNINITIALISED);
-
- assertThat(cles11.toString()).contains("JpaClElementStatistics(");
- assertEquals(false, cles11.hashCode() == 0);
- assertEquals(false, cles11.equals(cles0));
- assertEquals(false, cles11.equals(null));
-
- assertNotEquals(cles11, cles0);
-
- JpaClElementStatistics cles2 = new JpaClElementStatistics();
- assertEquals(cles2, cles0);
- }
-
- private JpaClElementStatistics createJpaClElementStatisticsInstance() {
- ClElementStatistics testCles = createClElementStatisticsInstance();
- JpaClElementStatistics testJpaClElementStatistics = new JpaClElementStatistics();
- testJpaClElementStatistics.setKey(null);
- testJpaClElementStatistics.fromAuthorative(testCles);
- testJpaClElementStatistics.setKey(PfReferenceTimestampKey.getNullKey());
- testJpaClElementStatistics.fromAuthorative(testCles);
-
- return testJpaClElementStatistics;
- }
-
- private ClElementStatistics createClElementStatisticsInstance() {
- ClElementStatistics clElementStatistics = new ClElementStatistics();
- clElementStatistics.setParticipantId(new ToscaConceptIdentifier("elementName", "0.0.1"));
- clElementStatistics.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e"));
- clElementStatistics.setTimeStamp(Instant.ofEpochSecond(123456L));
- clElementStatistics.setControlLoopState(ControlLoopState.UNINITIALISED);
-
- return clElementStatistics;
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java
deleted file mode 100644
index 63c5ea3ab..000000000
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElementTest.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-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.base.PfKey;
-import org.onap.policy.models.base.PfReferenceKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-/**
- * Test the {@link JpaControlLoopElement} class.
- */
-class JpaControlLoopElementTest {
-
- private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
-
- @Test
- void testJpaControlLoopElementConstructor() {
- assertThatThrownBy(() -> {
- new JpaControlLoopElement((JpaControlLoopElement) null);
- }).hasMessageMatching("copyConcept is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement((PfReferenceKey) null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(null, null, null, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(null, null, null, ControlLoopState.UNINITIALISED);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(null, null, new PfConceptKey("participant", "0.0.1"), null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(null, null, new PfConceptKey("participant", "0.0.1"),
- ControlLoopState.UNINITIALISED);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(null, new PfConceptKey(), null, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(null, new PfConceptKey(), null, ControlLoopState.UNINITIALISED);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"), null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"),
- ControlLoopState.UNINITIALISED);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(new PfReferenceKey(), null, null, null);
- }).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(new PfReferenceKey(), null, null, ControlLoopState.UNINITIALISED);
- }).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"), null);
- }).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"),
- ControlLoopState.UNINITIALISED);
- }).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(), null, null);
- }).hasMessageMatching("participantType is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(), null, ControlLoopState.UNINITIALISED);
- }).hasMessageMatching("participantType is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(),
- new PfConceptKey("participant", "0.0.1"), null);
- }).hasMessageMatching("state is marked .*ull but is null");
-
- assertNotNull(new JpaControlLoopElement());
- assertNotNull(new JpaControlLoopElement((new PfReferenceKey())));
- assertNotNull(new JpaControlLoopElement(new PfReferenceKey(), new PfConceptKey(),
- new PfConceptKey("participant", "0.0.1"), ControlLoopState.UNINITIALISED));
- }
-
- @Test
- void testJpaControlLoopElement() {
- JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance();
-
- ControlLoopElement cle = createControlLoopElementInstance();
- assertEquals(cle, testJpaControlLoopElement.toAuthorative());
-
- assertThatThrownBy(() -> {
- testJpaControlLoopElement.fromAuthorative(null);
- }).hasMessageMatching("element is marked .*ull but is null");
-
- assertThatThrownBy(() -> new JpaControlLoopElement((JpaControlLoopElement) null))
- .isInstanceOf(NullPointerException.class);
-
- JpaControlLoopElement testJpaControlLoopElementFa = new JpaControlLoopElement();
- testJpaControlLoopElementFa.setKey(null);
- testJpaControlLoopElementFa.fromAuthorative(cle);
- assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa);
- testJpaControlLoopElementFa.setKey(PfReferenceKey.getNullKey());
- testJpaControlLoopElementFa.fromAuthorative(cle);
- assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa);
- testJpaControlLoopElementFa.setKey(new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION,
- "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
- testJpaControlLoopElementFa.fromAuthorative(cle);
- assertEquals(testJpaControlLoopElement, testJpaControlLoopElementFa);
-
- assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", testJpaControlLoopElement.getKey().getLocalName());
- assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e",
- new JpaControlLoopElement(createControlLoopElementInstance()).getKey().getLocalName());
- assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e",
- ((PfReferenceKey) new JpaControlLoopElement(createControlLoopElementInstance()).getKeys().get(0))
- .getLocalName());
-
- testJpaControlLoopElement.clean();
- assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e", testJpaControlLoopElement.getKey().getLocalName());
-
- testJpaControlLoopElement.setDescription(" A Message ");
- testJpaControlLoopElement.clean();
- assertEquals("A Message", testJpaControlLoopElement.getDescription());
-
- JpaControlLoopElement testJpaControlLoopElement2 = new JpaControlLoopElement(testJpaControlLoopElement);
- assertEquals(testJpaControlLoopElement, testJpaControlLoopElement2);
- }
-
- @Test
- void testJpaControlLoopElementOrderedState() throws CoderException {
- ControlLoopElement testControlLoopElement = createControlLoopElementInstance();
- JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance();
-
- testJpaControlLoopElement.setOrderedState(null);
- assertEquals(testControlLoopElement, testJpaControlLoopElement.toAuthorative());
- testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
-
- ControlLoopElement noOrderedStateCle = new StandardCoder().decode(
- new File("src/test/resources/json/ControlLoopElementNoOrderedState.json"), ControlLoopElement.class);
-
- JpaControlLoopElement noOrderedStateJpaCle = new JpaControlLoopElement(noOrderedStateCle);
- assertNull(noOrderedStateJpaCle.getOrderedState());
- noOrderedStateCle.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- noOrderedStateJpaCle = new JpaControlLoopElement(noOrderedStateCle);
- assertEquals(testJpaControlLoopElement, noOrderedStateJpaCle);
- }
-
- @Test
- void testJpaControlLoopElementValidation() {
- JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance();
-
- assertThatThrownBy(() -> {
- testJpaControlLoopElement.validate(null);
- }).hasMessageMatching("fieldName is marked .*ull but is null");
-
- assertTrue(testJpaControlLoopElement.validate("").isValid());
- }
-
- @Test
- void testJpaControlLoopElementCompareTo() {
- JpaControlLoopElement testJpaControlLoopElement = createJpaControlLoopElementInstance();
-
- JpaControlLoopElement otherJpaControlLoopElement = new JpaControlLoopElement(testJpaControlLoopElement);
- assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
- assertEquals(-1, testJpaControlLoopElement.compareTo(null));
- assertEquals(0, testJpaControlLoopElement.compareTo(testJpaControlLoopElement));
- assertNotEquals(0, testJpaControlLoopElement.compareTo(new DummyJpaControlLoopElementChild()));
-
- testJpaControlLoopElement
- .setKey(new PfReferenceKey("BadValue", "0.0.1", "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
- assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
- testJpaControlLoopElement.setKey(new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION,
- "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
- assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
-
- testJpaControlLoopElement.setDefinition(new PfConceptKey("BadValue", "0.0.1"));
- assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
- testJpaControlLoopElement.setDefinition(new PfConceptKey("cleDef", "0.0.1"));
- assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
-
- testJpaControlLoopElement.setDescription("Description");
- assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
- testJpaControlLoopElement.setDescription(null);
- assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
-
- testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.PASSIVE);
- assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
- testJpaControlLoopElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
-
- testJpaControlLoopElement.setState(ControlLoopState.PASSIVE);
- assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
- testJpaControlLoopElement.setState(ControlLoopState.UNINITIALISED);
- assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
-
- testJpaControlLoopElement.setParticipantType(new PfConceptKey("dummy", "0.0.1"));
- assertNotEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
- testJpaControlLoopElement.setParticipantType(new PfConceptKey("participantType", "0.0.1"));
- assertEquals(0, testJpaControlLoopElement.compareTo(otherJpaControlLoopElement));
-
- assertEquals(testJpaControlLoopElement, new JpaControlLoopElement(testJpaControlLoopElement));
- }
-
- @Test
- void testJpaControlLoopElementLombok() {
- assertNotNull(new Participant());
- JpaControlLoopElement cle0 = new JpaControlLoopElement();
-
- assertThat(cle0.toString()).contains("JpaControlLoopElement(");
- assertThat(cle0.hashCode()).isNotZero();
- assertEquals(true, cle0.equals(cle0));
- assertEquals(false, cle0.equals(null));
-
-
- JpaControlLoopElement cle1 = new JpaControlLoopElement();
-
- cle1.setDefinition(new PfConceptKey("defName", "0.0.1"));
- cle1.setDescription("Description");
- cle1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- cle1.setState(ControlLoopState.UNINITIALISED);
- cle1.setParticipantId(new PfConceptKey("participant", "0.0.1"));
-
- assertThat(cle1.toString()).contains("ControlLoopElement(");
- assertEquals(false, cle1.hashCode() == 0);
- assertEquals(false, cle1.equals(cle0));
- assertEquals(false, cle1.equals(null));
-
- assertNotEquals(cle1, cle0);
-
- JpaControlLoopElement cle2 = new JpaControlLoopElement();
- assertEquals(cle2, cle0);
- }
-
- private JpaControlLoopElement createJpaControlLoopElementInstance() {
- ControlLoopElement testCle = createControlLoopElementInstance();
- JpaControlLoopElement testJpaControlLoopElement = new JpaControlLoopElement();
- testJpaControlLoopElement.setKey(null);
- testJpaControlLoopElement.fromAuthorative(testCle);
- testJpaControlLoopElement.setKey(PfReferenceKey.getNullKey());
- testJpaControlLoopElement.fromAuthorative(testCle);
-
- return testJpaControlLoopElement;
- }
-
- private ControlLoopElement createControlLoopElementInstance() {
- ControlLoopElement controlLoopElement = new ControlLoopElement();
- controlLoopElement.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e"));
- controlLoopElement.setDefinition(new ToscaConceptIdentifier("cleDef", "0.0.1"));
- controlLoopElement.setParticipantType(new ToscaConceptIdentifier("participantType", "0.0.1"));
-
- return controlLoopElement;
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java
deleted file mode 100644
index d705c49b5..000000000
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.util.LinkedHashMap;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-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;
-
-/**
- * Test the {@link JpaControlLoopTest} class.
- */
-class JpaControlLoopTest {
-
- private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
-
- @Test
- void testJpaControlLoopConstructor() {
- assertThatThrownBy(() -> {
- new JpaControlLoop((JpaControlLoop) null);
- }).hasMessageMatching("copyConcept is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoop((PfConceptKey) null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(null, null, null, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(null, null, null, new LinkedHashMap<>());
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(null, null, ControlLoopState.UNINITIALISED, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(null, null, ControlLoopState.UNINITIALISED, new LinkedHashMap<>());
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(null, new PfConceptKey(), null, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(null, new PfConceptKey(), null, new LinkedHashMap<>());
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(null, new PfConceptKey(), ControlLoopState.UNINITIALISED, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(null, new PfConceptKey(), ControlLoopState.UNINITIALISED, new LinkedHashMap<>());
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(new PfConceptKey(), null, null, null);
- }).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(new PfConceptKey(), null, null, new LinkedHashMap<>());
- }).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(new PfConceptKey(), null, ControlLoopState.UNINITIALISED, null);
- }).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(new PfConceptKey(), null, ControlLoopState.UNINITIALISED, new LinkedHashMap<>());
- }).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), null, null);
- }).hasMessageMatching("state is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), null, new LinkedHashMap<>());
- }).hasMessageMatching("state is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED, null);
- }).hasMessageMatching("elements is marked .*ull but is null");
-
- assertNotNull(new JpaControlLoop());
- assertNotNull(new JpaControlLoop((new PfConceptKey())));
- assertNotNull(new JpaControlLoop(new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED,
- new LinkedHashMap<>()));
- }
-
- @Test
- void testJpaControlLoop() {
- JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance();
-
- ControlLoop participant = createControlLoopInstance();
- assertEquals(participant, testJpaControlLoop.toAuthorative());
-
- assertThatThrownBy(() -> {
- testJpaControlLoop.fromAuthorative(null);
- }).hasMessageMatching("controlLoop is marked .*ull but is null");
-
- assertThatThrownBy(() -> new JpaControlLoop((JpaControlLoop) null)).isInstanceOf(NullPointerException.class);
-
- JpaControlLoop testJpaControlLoopFa = new JpaControlLoop();
- testJpaControlLoopFa.setKey(null);
- testJpaControlLoopFa.fromAuthorative(participant);
- assertEquals(testJpaControlLoop, testJpaControlLoopFa);
- testJpaControlLoopFa.setKey(PfConceptKey.getNullKey());
- testJpaControlLoopFa.fromAuthorative(participant);
- assertEquals(testJpaControlLoop, testJpaControlLoopFa);
- testJpaControlLoopFa.setKey(new PfConceptKey("control-loop", "0.0.1"));
- testJpaControlLoopFa.fromAuthorative(participant);
- assertEquals(testJpaControlLoop, testJpaControlLoopFa);
-
- assertEquals("control-loop", testJpaControlLoop.getKey().getName());
- assertEquals("control-loop", new JpaControlLoop(createControlLoopInstance()).getKey().getName());
- assertEquals("control-loop",
- ((PfConceptKey) new JpaControlLoop(createControlLoopInstance()).getKeys().get(0)).getName());
-
- testJpaControlLoop.clean();
- assertEquals("control-loop", testJpaControlLoop.getKey().getName());
-
- testJpaControlLoop.setDescription(" A Message ");
- testJpaControlLoop.clean();
- assertEquals("A Message", testJpaControlLoop.getDescription());
-
- JpaControlLoop testJpaControlLoop2 = new JpaControlLoop(testJpaControlLoop);
- assertEquals(testJpaControlLoop, testJpaControlLoop2);
- }
-
- @Test
- void testJpaControlLoopElementOrderedState() throws CoderException {
- ControlLoop testControlLoop = createControlLoopInstance();
- JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance();
-
- testJpaControlLoop.setOrderedState(null);
- assertEquals(testControlLoop, testJpaControlLoop.toAuthorative());
- testJpaControlLoop.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
-
- ControlLoop noOrderedStateCl = new StandardCoder()
- .decode(new File("src/test/resources/json/ControlLoopNoOrderedState.json"), ControlLoop.class);
-
- JpaControlLoop noOrderedStateJpaCl = new JpaControlLoop(noOrderedStateCl);
- assertNull(noOrderedStateJpaCl.getOrderedState());
- noOrderedStateCl.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- noOrderedStateJpaCl = new JpaControlLoop(noOrderedStateCl);
- assertEquals(testJpaControlLoop, noOrderedStateJpaCl);
-
- ControlLoops controlLoopsWithElements = new StandardCoder()
- .decode(new File("src/test/resources/providers/TestControlLoops.json"), ControlLoops.class);
-
- JpaControlLoop jpaControlLoopWithElements =
- new JpaControlLoop(controlLoopsWithElements.getControlLoopList().get(0));
- assertEquals(4, jpaControlLoopWithElements.getElements().size());
- assertEquals(18, jpaControlLoopWithElements.getKeys().size());
- assertThatCode(() -> jpaControlLoopWithElements.clean()).doesNotThrowAnyException();
-
- assertEquals(controlLoopsWithElements.getControlLoopList().get(0), jpaControlLoopWithElements.toAuthorative());
- }
-
- @Test
- void testJpaControlLoopValidation() {
- JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance();
-
- assertThatThrownBy(() -> {
- testJpaControlLoop.validate(null);
- }).hasMessageMatching("fieldName is marked .*ull but is null");
-
- assertTrue(testJpaControlLoop.validate("").isValid());
- }
-
- @Test
- void testJpaControlLoopCompareTo() {
- JpaControlLoop testJpaControlLoop = createJpaControlLoopInstance();
-
- JpaControlLoop otherJpaControlLoop = new JpaControlLoop(testJpaControlLoop);
- assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
- assertEquals(-1, testJpaControlLoop.compareTo(null));
- assertEquals(0, testJpaControlLoop.compareTo(testJpaControlLoop));
- assertNotEquals(0, testJpaControlLoop.compareTo(new DummyJpaControlLoopChild()));
-
- testJpaControlLoop.setKey(new PfConceptKey("BadValue", "0.0.1"));
- assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
- testJpaControlLoop.setKey(new PfConceptKey("control-loop", "0.0.1"));
- assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
-
- testJpaControlLoop.setDefinition(new PfConceptKey("BadValue", "0.0.1"));
- assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
- testJpaControlLoop.setDefinition(new PfConceptKey("controlLoopDefinitionName", "0.0.1"));
- assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
-
- testJpaControlLoop.setState(ControlLoopState.PASSIVE);
- assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
- testJpaControlLoop.setState(ControlLoopState.UNINITIALISED);
- assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
-
- testJpaControlLoop.setOrderedState(ControlLoopOrderedState.PASSIVE);
- assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
- testJpaControlLoop.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
-
- testJpaControlLoop.setDescription("A description");
- assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
- testJpaControlLoop.setDescription(null);
- assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
-
- testJpaControlLoop.setPrimed(true);
- assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
- testJpaControlLoop.setPrimed(false);
- assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop));
-
- assertEquals(testJpaControlLoop, new JpaControlLoop(testJpaControlLoop));
- }
-
- @Test
- void testJpaControlLoopLombok() {
- assertNotNull(new ControlLoop());
- JpaControlLoop cl0 = new JpaControlLoop();
-
- assertThat(cl0.toString()).contains("JpaControlLoop(");
- assertThat(cl0.hashCode()).isNotZero();
- assertEquals(true, cl0.equals(cl0));
- assertEquals(false, cl0.equals(null));
-
-
- JpaControlLoop cl1 = new JpaControlLoop();
-
- cl1.setDefinition(new PfConceptKey("defName", "0.0.1"));
- cl1.setDescription("Description");
- cl1.setElements(new LinkedHashMap<>());
- cl1.setKey(new PfConceptKey("participant", "0.0.1"));
- cl1.setState(ControlLoopState.UNINITIALISED);
-
- assertThat(cl1.toString()).contains("ControlLoop(");
- assertEquals(false, cl1.hashCode() == 0);
- assertEquals(false, cl1.equals(cl0));
- assertEquals(false, cl1.equals(null));
-
- assertNotEquals(cl1, cl0);
-
- JpaControlLoop cl2 = new JpaControlLoop();
- assertEquals(cl2, cl0);
- }
-
- private JpaControlLoop createJpaControlLoopInstance() {
- ControlLoop testControlLoop = createControlLoopInstance();
- JpaControlLoop testJpaControlLoop = new JpaControlLoop();
- testJpaControlLoop.setKey(null);
- testJpaControlLoop.fromAuthorative(testControlLoop);
- testJpaControlLoop.setKey(PfConceptKey.getNullKey());
- testJpaControlLoop.fromAuthorative(testControlLoop);
-
- return testJpaControlLoop;
- }
-
- private ControlLoop createControlLoopInstance() {
- ControlLoop testControlLoop = new ControlLoop();
- testControlLoop.setName("control-loop");
- testControlLoop.setVersion("0.0.1");
- testControlLoop.setDefinition(new ToscaConceptIdentifier("controlLoopDefinitionName", "0.0.1"));
- testControlLoop.setElements(new LinkedHashMap<>());
-
- return testControlLoop;
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
deleted file mode 100644
index 82ce8d789..000000000
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.time.Instant;
-import java.util.List;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ClElementStatisticsRepository;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class ClElementStatisticsProviderTest {
- private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
- private static final Coder CODER = new StandardCoder();
- private static final String CL_ELEMENT_STATS_JSON = "src/test/resources/providers/TestClElementStatistics.json";
-
- private ClElementStatisticsProvider clElementStatisticsProvider;
- private ClElementStatisticsList inputClElementStats;
- private String originalJson = ResourceUtils.getResourceAsString(CL_ELEMENT_STATS_JSON);
-
- /**
- * Set up test ClElement statistics provider.
- *
- * @throws Exception on errors
- */
- @BeforeEach
- void beforeSetupDao() throws Exception {
-
- inputClElementStats = CODER.decode(originalJson, ClElementStatisticsList.class);
- var clElementStatisticsRepository = mock(ClElementStatisticsRepository.class);
-
- var jpaClElementStatisticsList =
- ProviderUtils.getJpaAndValidateList(inputClElementStats.getClElementStatistics(),
- JpaClElementStatistics::new, "control loop element statistics");
-
- for (var clElementStat : jpaClElementStatisticsList) {
- when(clElementStatisticsRepository.getById(eq(clElementStat.getKey()))).thenReturn(clElementStat);
- when(clElementStatisticsRepository.findAllById(eq(List.of(clElementStat.getKey()))))
- .thenReturn(List.of(clElementStat));
- }
-
- when(clElementStatisticsRepository.saveAll(anyList())).thenReturn(jpaClElementStatisticsList);
-
- when(clElementStatisticsRepository.getFiltered(eq(JpaClElementStatistics.class), any()))
- .thenReturn(List.of(jpaClElementStatisticsList.get(0)));
-
- clElementStatisticsProvider = new ClElementStatisticsProvider(clElementStatisticsRepository);
- }
-
- @Test
- void testClElementStatisticsCreate() throws Exception {
- assertThatThrownBy(() -> {
- clElementStatisticsProvider.createClElementStatistics(null);
- }).hasMessageMatching(LIST_IS_NULL);
-
- ClElementStatisticsList createdClElementStats = new ClElementStatisticsList();
- createdClElementStats.setClElementStatistics(
- clElementStatisticsProvider.createClElementStatistics(inputClElementStats.getClElementStatistics()));
-
- assertEquals(inputClElementStats.toString().replaceAll("\\s+", ""),
- createdClElementStats.toString().replaceAll("\\s+", ""));
- }
-
- @Test
- void testGetClElementStatistics() throws Exception {
-
- List<ClElementStatistics> getResponse;
-
- // Return empty list when no data present in db
- getResponse = clElementStatisticsProvider.getClElementStatistics(null, null, null, null);
- assertThat(getResponse).isEmpty();
-
- clElementStatisticsProvider.createClElementStatistics(inputClElementStats.getClElementStatistics());
- ToscaConceptIdentifier identifier = inputClElementStats.getClElementStatistics().get(0).getParticipantId();
- Instant instant = inputClElementStats.getClElementStatistics().get(0).getTimeStamp();
- String id = inputClElementStats.getClElementStatistics().get(0).getId().toString();
- assertEquals(1, clElementStatisticsProvider
- .getClElementStatistics(identifier.getName(), identifier.getVersion(), id, instant).size());
-
- assertEquals(1, clElementStatisticsProvider
- .getFilteredClElementStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size());
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
deleted file mode 100644
index 4b8617b3d..000000000
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-import java.util.Optional;
-import javax.persistence.EntityNotFoundException;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ControlLoopRepository;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaNodeTemplateRepository;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaNodeTemplatesRepository;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.coder.YamlJsonTranslator;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
-
-class ControlLoopProviderTest {
-
- private static final String LIST_IS_NULL = "controlLoops is marked .*ull but is null";
- private static final String OBJECT_IS_NULL = "controlLoop is marked non-null but is null";
-
- private static final String ID_NAME = "PMSHInstance1";
- private static final String ID_VERSION = "1.0.1";
- private static final String ID_NAME_NOT_EXTST = "not_exist";
- private static final String ID_NAME_NOT_VALID = "not_valid";
-
- private static final Coder CODER = new StandardCoder();
- private static final String CONTROL_LOOP_JSON = "src/test/resources/providers/TestControlLoops.json";
- private static final String TOSCA_TEMPLATE_YAML = "examples/controlloop/PMSubscriptionHandling.yaml";
-
- private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
-
- private ControlLoops inputControlLoops;
- private List<JpaControlLoop> inputControlLoopsJpa;
- private String originalJson = ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON);
-
- @BeforeEach
- void beforeSetupDao() throws Exception {
- inputControlLoops = CODER.decode(originalJson, ControlLoops.class);
- inputControlLoopsJpa = ProviderUtils.getJpaAndValidateList(inputControlLoops.getControlLoopList(),
- JpaControlLoop::new, "control loops");
- }
-
- @Test
- void testControlLoopsSave() throws Exception {
- var controlLoopRepository = mock(ControlLoopRepository.class);
- var controlLoopProvider = new ControlLoopProvider(controlLoopRepository,
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
-
- assertThatThrownBy(() -> {
- controlLoopProvider.saveControlLoops(null);
- }).hasMessageMatching(LIST_IS_NULL);
-
- when(controlLoopRepository.saveAll(inputControlLoopsJpa)).thenReturn(inputControlLoopsJpa);
-
- var createdControlLoops = new ControlLoops();
- createdControlLoops
- .setControlLoopList(controlLoopProvider.saveControlLoops(inputControlLoops.getControlLoopList()));
-
- assertEquals(inputControlLoops, createdControlLoops);
-
- when(controlLoopRepository.saveAll(any())).thenThrow(IllegalArgumentException.class);
-
- assertThatThrownBy(() -> {
- controlLoopProvider.saveControlLoops(inputControlLoops.getControlLoopList());
- }).hasMessageMatching("Error in save ControlLoops");
- }
-
- @Test
- void testControlLoopSave() throws Exception {
- var controlLoopRepository = mock(ControlLoopRepository.class);
- var controlLoopProvider = new ControlLoopProvider(controlLoopRepository,
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
-
- assertThatThrownBy(() -> {
- controlLoopProvider.saveControlLoop(null);
- }).hasMessageMatching(OBJECT_IS_NULL);
-
- when(controlLoopRepository.save(inputControlLoopsJpa.get(0))).thenReturn(inputControlLoopsJpa.get(0));
-
- var createdControlLoop = controlLoopProvider.saveControlLoop(inputControlLoops.getControlLoopList().get(0));
-
- assertEquals(inputControlLoops.getControlLoopList().get(0), createdControlLoop);
-
- when(controlLoopRepository.save(any())).thenThrow(IllegalArgumentException.class);
-
- assertThatThrownBy(() -> {
- controlLoopProvider.saveControlLoop(inputControlLoops.getControlLoopList().get(0));
- }).hasMessageMatching("Error in save controlLoop");
- }
-
- @Test
- void testGetControlLoops() throws Exception {
- var controlLoopRepository = mock(ControlLoopRepository.class);
- var controlLoopProvider = new ControlLoopProvider(controlLoopRepository,
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
-
- // Return empty list when no data present in db
- List<ControlLoop> getResponse = controlLoopProvider.getControlLoops();
- assertThat(getResponse).isEmpty();
-
- controlLoopProvider.saveControlLoops(inputControlLoops.getControlLoopList());
-
- var controlLoop0 = inputControlLoops.getControlLoopList().get(1);
- var name = controlLoop0.getName();
- var version = controlLoop0.getVersion();
- var controlLoop1 = inputControlLoops.getControlLoopList().get(1);
-
- when(controlLoopRepository.getFiltered(eq(JpaControlLoop.class), any(), any()))
- .thenReturn(List.of(new JpaControlLoop(controlLoop0), new JpaControlLoop(controlLoop1)));
- when(controlLoopRepository.findById(controlLoop0.getKey().asIdentifier().asConceptKey()))
- .thenReturn(Optional.of(new JpaControlLoop(controlLoop0)));
- when(controlLoopRepository.getById(controlLoop0.getKey().asIdentifier().asConceptKey()))
- .thenReturn(new JpaControlLoop(controlLoop0));
- when(controlLoopRepository.getFiltered(JpaControlLoop.class, name, version))
- .thenReturn(List.of(new JpaControlLoop(controlLoop0)));
- when(controlLoopRepository.findById(controlLoop1.getKey().asIdentifier().asConceptKey()))
- .thenReturn(Optional.of(new JpaControlLoop(controlLoop1)));
-
- assertEquals(1, controlLoopProvider.getControlLoops(name, version).size());
-
- var cl = controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(ID_NAME, ID_VERSION)).get();
- assertEquals(inputControlLoops.getControlLoopList().get(1), cl);
-
- cl = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(ID_NAME, ID_VERSION));
- assertEquals(inputControlLoops.getControlLoopList().get(1), cl);
-
- when(controlLoopRepository.getById(any())).thenThrow(EntityNotFoundException.class);
-
- assertThatThrownBy(() -> {
- controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION));
- }).hasMessageMatching("ControlLoop not found");
-
- cl = controlLoopProvider.findControlLoop(ID_NAME, ID_VERSION).get();
- assertEquals(inputControlLoops.getControlLoopList().get(1), cl);
-
- assertThat(controlLoopProvider.findControlLoop(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION)))
- .isEmpty();
-
- when(controlLoopRepository.findById(any())).thenThrow(IllegalArgumentException.class);
-
- assertThatThrownBy(() -> {
- controlLoopProvider.findControlLoop(ID_NAME_NOT_VALID, ID_VERSION);
- }).hasMessageMatching("Not valid parameter");
- }
-
- @Test
- void testDeleteControlLoop() throws Exception {
- var controlLoopRepository = mock(ControlLoopRepository.class);
- var controlLoopProvider = new ControlLoopProvider(controlLoopRepository,
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
-
- assertThatThrownBy(() -> {
- controlLoopProvider.deleteControlLoop(ID_NAME_NOT_EXTST, ID_VERSION);
- }).hasMessageMatching(".*.failed, control loop does not exist");
-
- var controlLoop = inputControlLoops.getControlLoopList().get(0);
- var name = controlLoop.getName();
- var version = controlLoop.getVersion();
-
- when(controlLoopRepository.findById(new PfConceptKey(name, version)))
- .thenReturn(Optional.of(inputControlLoopsJpa.get(0)));
-
- ControlLoop deletedCl = controlLoopProvider.deleteControlLoop(name, version);
- assertEquals(controlLoop, deletedCl);
- }
-
- @Test
- void testDeleteAllInstanceProperties() throws Exception {
- var controlLoopProvider = new ControlLoopProvider(mock(ControlLoopRepository.class),
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
- var toscaServiceTemplate = testControlLoopRead();
- controlLoopProvider.deleteInstanceProperties(controlLoopProvider.saveInstanceProperties(toscaServiceTemplate),
- controlLoopProvider.getAllNodeTemplates());
- assertThat(controlLoopProvider.getControlLoops()).isEmpty();
- }
-
- @Test
- void testSaveAndDeleteInstanceProperties() throws Exception {
- var toscaNodeTemplatesRepository = mock(ToscaNodeTemplatesRepository.class);
- var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class);
- var controlLoopProvider = new ControlLoopProvider(mock(ControlLoopRepository.class),
- toscaNodeTemplateRepository, toscaNodeTemplatesRepository);
- var toscaServiceTest = testControlLoopRead();
-
- controlLoopProvider.saveInstanceProperties(toscaServiceTest);
- verify(toscaNodeTemplatesRepository).save(any());
-
- var name = "org.onap.policy.controlloop.PolicyControlLoopParticipant";
- var version = "2.3.1";
- var elem = toscaServiceTest.getToscaTopologyTemplate().getNodeTemplates().get(name);
- when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version))
- .thenReturn(List.of(new JpaToscaNodeTemplate(elem)));
-
- var filtered = controlLoopProvider.getNodeTemplates(name, version);
- verify(toscaNodeTemplateRepository).getFiltered(JpaToscaNodeTemplate.class, name, version);
-
- controlLoopProvider.deleteInstanceProperties(controlLoopProvider.saveInstanceProperties(toscaServiceTest),
- filtered);
-
- verify(toscaNodeTemplateRepository).delete(any());
- }
-
- @Test
- void testGetNodeTemplates() throws Exception {
- var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class);
- var controlLoopProvider = new ControlLoopProvider(mock(ControlLoopRepository.class),
- toscaNodeTemplateRepository, mock(ToscaNodeTemplatesRepository.class));
-
- var toscaNodeTemplate0 = new JpaToscaNodeTemplate(new PfConceptKey(ID_NAME, ID_VERSION));
- var toscaNodeTemplate1 = new JpaToscaNodeTemplate(new PfConceptKey("PMSHInstance2", ID_VERSION));
-
- when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, null, null))
- .thenReturn(List.of(toscaNodeTemplate0, toscaNodeTemplate1));
- when(toscaNodeTemplateRepository.findAll()).thenReturn(List.of(toscaNodeTemplate0, toscaNodeTemplate1));
- when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, ID_NAME, ID_VERSION))
- .thenReturn(List.of(toscaNodeTemplate0));
-
- // Getting all nodes
- var listNodes = controlLoopProvider.getAllNodeTemplates();
- assertNotNull(listNodes);
- assertThat(listNodes).hasSize(2);
-
- listNodes = controlLoopProvider.getNodeTemplates(ID_NAME, ID_VERSION);
- assertNotNull(listNodes);
- assertThat(listNodes).hasSize(1);
-
- listNodes = controlLoopProvider.getAllNodeTemplates();
- assertNotNull(listNodes);
- assertThat(listNodes).hasSize(2);
-
- var nodeTemplateFilter =
- ToscaTypedEntityFilter.<ToscaNodeTemplate>builder().name(ID_NAME).version(ID_VERSION).build();
-
- listNodes = controlLoopProvider.getFilteredNodeTemplates(nodeTemplateFilter);
- assertNotNull(listNodes);
- assertThat(listNodes).hasSize(1);
-
- assertThatThrownBy(() -> {
- controlLoopProvider.getFilteredNodeTemplates(null);
- }).hasMessageMatching("filter is marked non-null but is null");
- }
-
- private static ToscaServiceTemplate testControlLoopRead() {
- return testControlLoopYamlSerialization(TOSCA_TEMPLATE_YAML);
- }
-
- private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) {
- var controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath);
- return yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class);
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java
deleted file mode 100644
index bf2e2fa0a..000000000
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotificationTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-
-class ControlLoopNotificationTest {
-
- @Test
- void testControlLoopNotification() {
- ControlLoopNotification cln0 = new ControlLoopNotification();
-
- List<ControlLoopStatus> addedList = new ArrayList<>();
- addedList.add(new ControlLoopStatus());
-
- List<ControlLoopStatus> deletedList = new ArrayList<>();
- deletedList.add(new ControlLoopStatus());
-
- assertEquals(true, cln0.isEmpty());
-
- cln0.setAdded(addedList);
- assertEquals(false, cln0.isEmpty());
- cln0.setAdded(null);
- assertEquals(true, cln0.isEmpty());
-
- cln0.setDeleted(deletedList);
- assertEquals(false, cln0.isEmpty());
- cln0.setDeleted(null);
- assertEquals(true, cln0.isEmpty());
-
- cln0.setAdded(addedList);
- cln0.setDeleted(deletedList);
- assertEquals(false, cln0.isEmpty());
- cln0.setAdded(null);
- cln0.setDeleted(null);
- assertEquals(true, cln0.isEmpty());
- }
-
- @Test
- void testControlLoopNotificationLombok() {
- assertNotNull(new ControlLoopNotification());
- assertNotNull(new ControlLoopNotification(new ArrayList<>(), new ArrayList<>()));
-
- ControlLoopNotification cln0 = new ControlLoopNotification();
-
- assertThat(cln0.toString()).contains("ControlLoopNotification(");
- assertEquals(false, cln0.hashCode() == 0);
- assertEquals(true, cln0.equals(cln0));
- assertEquals(false, cln0.equals(null));
-
-
- ControlLoopNotification cln1 = new ControlLoopNotification();
-
- assertThat(cln1.toString()).contains("ControlLoopNotification(");
- assertEquals(false, cln1.hashCode() == 0);
- assertEquals(true, cln1.equals(cln0));
- assertEquals(false, cln1.equals(null));
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java
index 3bb0050c8..ee79b27b7 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
+package org.onap.policy.clamp.models.acm.concepts;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -31,37 +31,37 @@ import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-class ClElementStatisticsTest {
+class AcElementStatisticsTest {
@Test
- void testClElementStatisticsLombok() {
- assertNotNull(new ClElementStatistics());
- ClElementStatistics cles0 = new ClElementStatistics();
+ void testAcElementStatisticsLombok() {
+ assertNotNull(new AcElementStatistics());
+ AcElementStatistics aces0 = new AcElementStatistics();
- assertThat(cles0.toString()).contains("ClElementStatistics(");
- assertThat(cles0.hashCode()).isNotZero();
- assertEquals(true, cles0.equals(cles0));
- assertEquals(false, cles0.equals(null));
+ assertThat(aces0.toString()).contains("AcElementStatistics(");
+ assertThat(aces0.hashCode()).isNotZero();
+ assertEquals(true, aces0.equals(aces0));
+ assertEquals(false, aces0.equals(null));
- ClElementStatistics cles1 = new ClElementStatistics();
- cles1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
- cles1.setTimeStamp(Instant.now());
+ AcElementStatistics aces1 = new AcElementStatistics();
+ aces1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
+ aces1.setTimeStamp(Instant.now());
- assertThat(cles1.toString()).contains("ClElementStatistics(");
- assertEquals(false, cles1.hashCode() == 0);
- assertEquals(false, cles1.equals(cles0));
- assertEquals(false, cles1.equals(null));
+ assertThat(aces1.toString()).contains("AcElementStatistics(");
+ assertEquals(false, aces1.hashCode() == 0);
+ assertEquals(false, aces1.equals(aces0));
+ assertEquals(false, aces1.equals(null));
- assertNotEquals(cles1, cles0);
+ assertNotEquals(aces1, aces0);
- ClElementStatistics cles2 = new ClElementStatistics();
- cles2.setId(UUID.randomUUID());
+ AcElementStatistics aces2 = new AcElementStatistics();
+ aces2.setId(UUID.randomUUID());
// @formatter:off
- assertThatThrownBy(() -> cles2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> cles2.setTimeStamp(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> aces2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> aces2.setTimeStamp(null)).isInstanceOf(NullPointerException.class);
// @formatter:on
- assertNotEquals(cles2, cles0);
+ assertNotEquals(aces2, aces0);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionConceptPojosTest.java
index daade4d52..1d45e5919 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopConceptPojosTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionConceptPojosTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
+package org.onap.policy.clamp.models.acm.concepts;
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
@@ -37,12 +37,12 @@ import org.onap.policy.common.utils.test.ToStringTester;
/**
* Class to perform unit tests of all pojos.
*/
-class ControlLoopConceptPojosTest {
+class AutomationCompositionConceptPojosTest {
@Test
void testPojos() {
List<PojoClass> pojoClasses =
- PojoClassFactory.getPojoClasses(ControlLoopConceptPojosTest.class.getPackageName());
+ PojoClassFactory.getPojoClasses(AutomationCompositionConceptPojosTest.class.getPackageName());
// @formatter:off
final Validator validator = ValidatorBuilder
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java
new file mode 100644
index 000000000..4e739db52
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+class AutomationCompositionElementTest {
+ @Test
+ void testAutomationCompositionElement() {
+ var ace0 = new AutomationCompositionElement();
+ var ace1 = new AutomationCompositionElement(ace0);
+ assertEquals(ace0, ace1);
+
+ ace1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
+ ace1.setDescription("Description");
+ ace1.setId(UUID.randomUUID());
+ ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ ace1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3"));
+ ace1.setState(AutomationCompositionState.UNINITIALISED);
+
+ var ace2 = new AutomationCompositionElement(ace1);
+ assertEquals(ace1, ace2);
+ }
+
+ @Test
+ void testAutomationCompositionState() {
+ var ace0 = new AutomationCompositionElement();
+
+ assertTrue(
+ ace0.getOrderedState()
+ .equalsAutomationCompositionState(AutomationCompositionState.UNINITIALISED));
+
+ assertTrue(
+ ace0.getOrderedState().asState()
+ .equalsAutomationCompositionOrderedState(AutomationCompositionOrderedState.UNINITIALISED));
+ }
+
+ @Test
+ void testAutomationCompositionElementLombok() {
+ assertNotNull(new AutomationCompositionElement());
+ var ace0 = new AutomationCompositionElement();
+
+ assertThat(ace0.toString()).contains("AutomationCompositionElement(");
+ assertThat(ace0.hashCode()).isNotZero();
+ assertEquals(true, ace0.equals(ace0));
+ assertEquals(false, ace0.equals(null));
+
+ var ace1 = new AutomationCompositionElement();
+
+ ace1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
+ ace1.setDescription("Description");
+ ace1.setId(UUID.randomUUID());
+ ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ ace1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3"));
+ ace1.setState(AutomationCompositionState.UNINITIALISED);
+
+ assertThat(ace1.toString()).contains("AutomationCompositionElement(");
+ assertEquals(false, ace1.hashCode() == 0);
+ assertEquals(false, ace1.equals(ace0));
+ assertEquals(false, ace1.equals(null));
+
+ assertNotEquals(ace1, ace0);
+
+ var ace2 = new AutomationCompositionElement();
+
+ // @formatter:off
+ assertThatThrownBy(() -> ace2.setDefinition(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> ace2.setId(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> ace2.setOrderedState(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> ace2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> ace2.setState(null)). isInstanceOf(NullPointerException.class);
+ // @formatter:on
+
+ assertNotEquals(ace2, ace0);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java
new file mode 100644
index 000000000..ad8a1bbea
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.time.Instant;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+class AutomationCompositionTest {
+ @Test
+ void testAutomationComposition() {
+ var ac0 = new AutomationComposition();
+ ac0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3"));
+ assertEquals("dfName", ac0.getType());
+ assertEquals("1.2.3", ac0.getTypeVersion());
+
+ var ac1 = new AutomationComposition(ac0);
+ assertEquals(ac0, ac1);
+
+ assertEquals(0, ac0.compareTo(ac1));
+ }
+
+ @Test
+ void testAutomationCompositionLombok() {
+ assertNotNull(new AutomationComposition());
+ var ac0 = new AutomationComposition();
+ ac0.setElements(new LinkedHashMap<>());
+
+ assertThat(ac0.toString()).contains("AutomationComposition(");
+ assertThat(ac0.hashCode()).isNotZero();
+ assertEquals(true, ac0.equals(ac0));
+ assertEquals(false, ac0.equals(null));
+
+ var ac1 = new AutomationComposition();
+
+ ac1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
+ ac1.setDescription("Description");
+ ac1.setElements(new LinkedHashMap<>());
+ ac1.setName("Name");
+ ac1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ ac1.setState(AutomationCompositionState.UNINITIALISED);
+ ac1.setVersion("0.0.1");
+
+ assertThat(ac1.toString()).contains("AutomationComposition(");
+ assertEquals(false, ac1.hashCode() == 0);
+ assertEquals(false, ac1.equals(ac0));
+ assertEquals(false, ac1.equals(null));
+
+ assertNotEquals(ac1, ac0);
+
+ var ac2 = new AutomationComposition();
+ ac2.setElements(new LinkedHashMap<>());
+
+ // @formatter:off
+ assertThatThrownBy(() -> ac2.setDefinition(null)). isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> ac2.setOrderedState(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> ac2.setState(null)). isInstanceOf(NullPointerException.class);
+ // @formatter:on
+
+ assertEquals(ac2, ac0);
+
+ ac1.setCascadedOrderedState(AutomationCompositionOrderedState.PASSIVE);
+ assertEquals(AutomationCompositionOrderedState.PASSIVE, ac1.getOrderedState());
+
+ ac1.getElements().put(UUID.randomUUID(), new AutomationCompositionElement());
+ ac1.setCascadedOrderedState(AutomationCompositionOrderedState.RUNNING);
+ assertEquals(AutomationCompositionOrderedState.RUNNING, ac1.getOrderedState());
+ assertEquals(AutomationCompositionOrderedState.RUNNING,
+ ac1.getElements().values().iterator().next().getOrderedState());
+
+ assertNull(ac0.getElements().get(UUID.randomUUID()));
+ assertNull(ac1.getElements().get(UUID.randomUUID()));
+
+ assertEquals(PfKey.NULL_KEY_NAME, ac0.getDefinition().getName());
+
+ }
+
+ @Test
+ void testAutomationCompositionElementStatisticsList() {
+ var ac = new AutomationComposition();
+ List<AcElementStatistics> emptylist = ac.getAutomationCompositionElementStatisticsList(ac);
+ assertEquals(List.of(), emptylist);
+
+ var ac1 = getAutomationCompositionTest();
+ List<AcElementStatistics> list = ac1.getAutomationCompositionElementStatisticsList(ac1);
+ assertNotNull(list);
+ assertEquals(2, list.size());
+ assertEquals(AutomationCompositionState.UNINITIALISED, list.get(0).getState());
+ }
+
+ private AutomationComposition getAutomationCompositionTest() {
+ var ac = new AutomationComposition();
+ ac.setDefinition(new ToscaConceptIdentifier("defName", "1.2.3"));
+ ac.setDescription("Description");
+ ac.setElements(new LinkedHashMap<>());
+ ac.setName("Name");
+ ac.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ ac.setState(AutomationCompositionState.UNINITIALISED);
+ ac.setVersion("0.0.1");
+
+ var uuid = UUID.randomUUID();
+ var id = new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "1.0.1");
+ var acElement = getAutomationCompositionElementTest(uuid, id);
+
+ var uuid2 = UUID.randomUUID();
+ var id2 = new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipantIntermediary",
+ "0.0.1");
+ var acElement2 = getAutomationCompositionElementTest(uuid2, id2);
+
+ ac.getElements().put(uuid, acElement);
+ ac.getElements().put(uuid2, acElement2);
+ return ac;
+ }
+
+ private AutomationCompositionElement getAutomationCompositionElementTest(UUID uuid, ToscaConceptIdentifier id) {
+ var acElement = new AutomationCompositionElement();
+ acElement.setId(uuid);
+ acElement.setParticipantId(id);
+ acElement.setDefinition(id);
+ acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+
+ var acElementStatistics = new AcElementStatistics();
+ acElementStatistics.setParticipantId(id);
+ acElementStatistics.setState(AutomationCompositionState.UNINITIALISED);
+ acElementStatistics.setTimeStamp(Instant.now());
+
+ acElement.setAcElementStatistics(acElementStatistics);
+
+ return acElement;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java
index f55f624bf..de9b884d3 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
+package org.onap.policy.clamp.models.acm.concepts;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
index 5c429b96c..164c7c1a0 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
+package org.onap.policy.clamp.models.acm.concepts;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java
index 3fb8b6d7f..5252221a8 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtilsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtilsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
+package org.onap.policy.clamp.models.acm.concepts;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,12 +36,14 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
class ParticipantUtilsTest {
private static final Coder CODER = new StandardCoder();
- private static final String TOSCA_TEMPLATE_YAML = "examples/controlloop/PMSubscriptionHandling.yaml";
- private static final String CONTROL_LOOP_JSON = "src/test/resources/providers/TestControlLoops.json";
- private static final String CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.ControlLoopElement";
- private static final String POLICY_CONTROL_LOOP_ELEMENT =
- "org.onap.policy.clamp.controlloop.PolicyControlLoopElement";
- private static final String PARTICIPANT_CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.Participant";
+ private static final String TOSCA_TEMPLATE_YAML = "examples/acm/PMSubscriptionHandling.yaml";
+ private static final String AUTOMATION_COMPOSITION_JSON =
+ "src/test/resources/providers/TestAutomationCompositions.json";
+ private static final String AUTOMATION_COMPOSITION_ELEMENT =
+ "org.onap.policy.clamp.acm.AutomationCompositionElement";
+ private static final String POLICY_AUTOMATION_COMPOSITION_ELEMENT =
+ "org.onap.policy.clamp.acm.PolicyAutomationCompositionElement";
+ private static final String PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT = "org.onap.policy.clamp.acm.Participant";
private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder();
@Test
@@ -60,25 +62,30 @@ class ParticipantUtilsTest {
@Test
void testGetFirstStartPhase() throws CoderException {
- var serviceTemplate = YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(TOSCA_TEMPLATE_YAML),
- ToscaServiceTemplate.class);
- var controlLoops = CODER.decode(ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON), ControlLoops.class);
- var result = ParticipantUtils.getFirstStartPhase(controlLoops.getControlLoopList().get(0), serviceTemplate);
+ var serviceTemplate =
+ YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(TOSCA_TEMPLATE_YAML), ToscaServiceTemplate.class);
+ var automationCompositions =
+ CODER.decode(ResourceUtils.getResourceAsString(AUTOMATION_COMPOSITION_JSON), AutomationCompositions.class);
+ var result = ParticipantUtils.getFirstStartPhase(automationCompositions.getAutomationCompositionList().get(0),
+ serviceTemplate);
assertThat(result).isZero();
}
@Test
- void testCheckIfNodeTemplateIsControlLoopElement() throws CoderException {
- var serviceTemplate = YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(TOSCA_TEMPLATE_YAML),
- ToscaServiceTemplate.class);
+ void testCheckIfNodeTemplateIsAutomationCompositionElement() throws CoderException {
+ var serviceTemplate =
+ YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(TOSCA_TEMPLATE_YAML), ToscaServiceTemplate.class);
var nodeTemplate = new ToscaNodeTemplate();
- nodeTemplate.setType(CONTROL_LOOP_ELEMENT);
- assertThat(ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(nodeTemplate, serviceTemplate)).isTrue();
+ nodeTemplate.setType(AUTOMATION_COMPOSITION_ELEMENT);
+ assertThat(ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate))
+ .isTrue();
- nodeTemplate.setType(POLICY_CONTROL_LOOP_ELEMENT);
- assertThat(ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(nodeTemplate, serviceTemplate)).isTrue();
+ nodeTemplate.setType(POLICY_AUTOMATION_COMPOSITION_ELEMENT);
+ assertThat(ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate))
+ .isTrue();
- nodeTemplate.setType(PARTICIPANT_CONTROL_LOOP_ELEMENT);
- assertThat(ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(nodeTemplate, serviceTemplate)).isFalse();
+ nodeTemplate.setType(PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT);
+ assertThat(ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate))
+ .isFalse();
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java
new file mode 100644
index 000000000..49bb719ac
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.messages.dmaap.notification;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.jupiter.api.Test;
+
+class AutomationCompositionNotificationTest {
+
+ @Test
+ void testAutomationCompositionNotification() {
+ AutomationCompositionNotification acn0 = new AutomationCompositionNotification();
+
+ List<AutomationCompositionStatus> addedList = new ArrayList<>();
+ addedList.add(new AutomationCompositionStatus());
+
+ List<AutomationCompositionStatus> deletedList = new ArrayList<>();
+ deletedList.add(new AutomationCompositionStatus());
+
+ assertEquals(true, acn0.isEmpty());
+
+ acn0.setAdded(addedList);
+ assertEquals(false, acn0.isEmpty());
+ acn0.setAdded(null);
+ assertEquals(true, acn0.isEmpty());
+
+ acn0.setDeleted(deletedList);
+ assertEquals(false, acn0.isEmpty());
+ acn0.setDeleted(null);
+ assertEquals(true, acn0.isEmpty());
+
+ acn0.setAdded(addedList);
+ acn0.setDeleted(deletedList);
+ assertEquals(false, acn0.isEmpty());
+ acn0.setAdded(null);
+ acn0.setDeleted(null);
+ assertEquals(true, acn0.isEmpty());
+ }
+
+ @Test
+ void testAutomationCompositionNotificationLombok() {
+ assertNotNull(new AutomationCompositionNotification());
+ assertNotNull(new AutomationCompositionNotification(new ArrayList<>(), new ArrayList<>()));
+
+ AutomationCompositionNotification acn0 = new AutomationCompositionNotification();
+
+ assertThat(acn0.toString()).contains("AutomationCompositionNotification(");
+ assertEquals(false, acn0.hashCode() == 0);
+ assertEquals(true, acn0.equals(acn0));
+ assertEquals(false, acn0.equals(null));
+
+
+ AutomationCompositionNotification acn1 = new AutomationCompositionNotification();
+
+ assertThat(acn1.toString()).contains("AutomationCompositionNotification(");
+ assertEquals(false, acn1.hashCode() == 0);
+ assertEquals(true, acn1.equals(acn0));
+ assertEquals(false, acn1.equals(null));
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java
index cca5e8554..028566888 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatusTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification;
+package org.onap.policy.clamp.models.acm.messages.dmaap.notification;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
@@ -28,21 +28,21 @@ import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-class ControlLoopStatusTest {
+class AutomationCompositionStatusTest {
@Test
- void testControlLoopStatusLombok() {
- assertNotNull(new ControlLoopStatus());
- assertNotNull(new ControlLoopStatus(UUID.randomUUID(), new ToscaConceptIdentifier()));
+ void testAutomationCompositionStatusLombok() {
+ assertNotNull(new AutomationCompositionStatus());
+ assertNotNull(new AutomationCompositionStatus(UUID.randomUUID(), new ToscaConceptIdentifier()));
- ControlLoopStatus cln0 = new ControlLoopStatus();
+ AutomationCompositionStatus acn0 = new AutomationCompositionStatus();
- assertThat(cln0.toString()).contains("ControlLoopStatus(");
- assertEquals(false, cln0.hashCode() == 0);
- assertEquals(true, cln0.equals(cln0));
- assertEquals(false, cln0.equals(null));
+ assertThat(acn0.toString()).contains("AutomationCompositionStatus(");
+ assertEquals(false, acn0.hashCode() == 0);
+ assertEquals(true, acn0.equals(acn0));
+ assertEquals(false, acn0.equals(null));
- ControlLoopStatus cln1 = new ControlLoopStatus();
- assertEquals(true, cln1.equals(cln0));
+ AutomationCompositionStatus acn1 = new AutomationCompositionStatus();
+ assertEquals(true, acn1.equals(acn0));
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java
index 1a89a1b3e..494252acc 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/NotificationPojosTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification;
+package org.onap.policy.clamp.models.acm.messages.dmaap.notification;
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java
index f312c4863..383a55115 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java
@@ -18,51 +18,51 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementAck;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-class ControlLoopAckTest {
+class AutomationCompositionAckTest {
@Test
void testCopyConstructor() throws CoderException {
- assertThatThrownBy(() -> new ControlLoopAck((ControlLoopAck) null))
+ assertThatThrownBy(() -> new AutomationCompositionAck((AutomationCompositionAck) null))
.isInstanceOf(NullPointerException.class);
- final var orig = new ControlLoopAck(ParticipantMessageType.CONTROL_LOOP_UPDATE);
+ final var orig = new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE);
// verify with null values
assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ControlLoopAck(orig).toString()));
+ removeVariableFields(new AutomationCompositionAck(orig).toString()));
// verify with all values
var id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setControlLoopId(id);
+ orig.setAutomationCompositionId(id);
orig.setParticipantId(id);
orig.setParticipantType(id);
- var clElementResult = new ControlLoopElementAck(ControlLoopState.UNINITIALISED,
- true, "ControlLoopElement result");
- final var controlLoopResultMap = Map.of(UUID.randomUUID(), clElementResult);
- orig.setControlLoopResultMap(controlLoopResultMap);
+ var acElementResult = new AutomationCompositionElementAck(AutomationCompositionState.UNINITIALISED,
+ true, "AutomationCompositionElement result");
+ final var automationCompositionResultMap = Map.of(UUID.randomUUID(), acElementResult);
+ orig.setAutomationCompositionResultMap(automationCompositionResultMap);
orig.setResponseTo(UUID.randomUUID());
orig.setResult(true);
- orig.setMessage("Successfully processed ControlLoopUpdate message");
+ orig.setMessage("Successfully processed AutomationCompositionUpdate message");
assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ControlLoopAck(orig).toString()));
+ removeVariableFields(new AutomationCompositionAck(orig).toString()));
- assertSerializable(orig, ControlLoopAck.class);
+ assertSerializable(orig, AutomationCompositionAck.class);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java
index 1bf155e9a..6c48afad2 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java
@@ -18,48 +18,48 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Test the copy constructor and other methods.
*/
-class ControlLoopStateChangeTest {
+class AutomationCompositionStateChangeTest {
@Test
void testCopyConstructor() throws CoderException {
- assertThatThrownBy(() -> new ControlLoopStateChange(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new AutomationCompositionStateChange(null)).isInstanceOf(NullPointerException.class);
- ControlLoopStateChange orig = new ControlLoopStateChange();
+ AutomationCompositionStateChange orig = new AutomationCompositionStateChange();
// verify with null values
assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ControlLoopStateChange(orig).toString()));
+ removeVariableFields(new AutomationCompositionStateChange(orig).toString()));
// verify with all values
ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setControlLoopId(id);
+ orig.setAutomationCompositionId(id);
orig.setParticipantId(id);
orig.setMessageId(UUID.randomUUID());
- orig.setOrderedState(ControlLoopOrderedState.RUNNING);
- orig.setCurrentState(ControlLoopState.PASSIVE);
+ orig.setOrderedState(AutomationCompositionOrderedState.RUNNING);
+ orig.setCurrentState(AutomationCompositionState.PASSIVE);
orig.setTimestamp(Instant.ofEpochMilli(3000));
assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ControlLoopStateChange(orig).toString()));
+ removeVariableFields(new AutomationCompositionStateChange(orig).toString()));
- assertSerializable(orig, ControlLoopStateChange.class);
+ assertSerializable(orig, AutomationCompositionStateChange.class);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java
index ce56d582a..809256d40 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java
@@ -18,22 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
+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.ParticipantUpdates;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
@@ -41,42 +41,42 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
/**
* Test the copy constructor.
*/
-class ControlLoopUpdateTest {
+class AutomationCompositionUpdateTest {
@Test
void testCopyConstructor() throws CoderException {
- assertThatThrownBy(() -> new ControlLoopUpdate(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new AutomationCompositionUpdate(null)).isInstanceOf(NullPointerException.class);
- ControlLoopUpdate orig = new ControlLoopUpdate();
+ AutomationCompositionUpdate orig = new AutomationCompositionUpdate();
// verify with all values
ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setControlLoopId(id);
+ orig.setAutomationCompositionId(id);
orig.setParticipantId(null);
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
- ControlLoopElement clElement = new ControlLoopElement();
- clElement.setId(UUID.randomUUID());
- clElement.setDefinition(id);
- clElement.setDescription("Description");
- clElement.setOrderedState(ControlLoopOrderedState.PASSIVE);
- clElement.setState(ControlLoopState.PASSIVE);
- clElement.setParticipantId(id);
- clElement.setParticipantType(id);
+ AutomationCompositionElement acElement = new AutomationCompositionElement();
+ acElement.setId(UUID.randomUUID());
+ acElement.setDefinition(id);
+ acElement.setDescription("Description");
+ acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
+ acElement.setState(AutomationCompositionState.PASSIVE);
+ acElement.setParticipantId(id);
+ acElement.setParticipantType(id);
ToscaProperty property = new ToscaProperty();
property.setName("test");
property.setType("testType");
Map<String, ToscaProperty> propertiesMap = Map.of("Prop1", property);
- clElement.setPropertiesMap(propertiesMap);
+ acElement.setPropertiesMap(propertiesMap);
ParticipantUpdates participantUpdates = new ParticipantUpdates();
participantUpdates.setParticipantId(id);
- participantUpdates.setControlLoopElementList(List.of(clElement));
+ participantUpdates.setAutomationCompositionElementList(List.of(acElement));
orig.setParticipantUpdatesList(List.of(participantUpdates));
- ControlLoopUpdate other = new ControlLoopUpdate(orig);
+ AutomationCompositionUpdate other = new AutomationCompositionUpdate(orig);
assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
- assertSerializable(orig, ControlLoopUpdate.class);
+ assertSerializable(orig, AutomationCompositionUpdate.class);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java
index df82ab071..89a34e33d 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import java.util.UUID;
import org.junit.jupiter.api.Test;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAckTest.java
index f1ae5f709..59a6d826b 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAckTest.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.util.UUID;
import org.junit.jupiter.api.Test;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java
index 89546890a..873257696 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.UUID;
@@ -47,7 +47,7 @@ class ParticipantDeregisterTest {
ToscaConceptIdentifier id = new ToscaConceptIdentifier();
id.setName("id");
id.setVersion("1.2.3");
- orig.setControlLoopId(id);
+ orig.setAutomationCompositionId(id);
orig.setParticipantId(id);
orig.setParticipantType(id);
orig.setMessageId(UUID.randomUUID());
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java
index 58d3afebc..fa16d145d 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import java.time.Instant;
import java.util.UUID;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageUtils.java
index 78c278f98..4ff4f3b35 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageUtils.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.junit.Assert.assertEquals;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java
index e67fbc143..ce23a821f 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
@@ -46,8 +46,8 @@ class ParticipantPojosTest {
pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class));
pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class));
pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class));
- pojoClasses.remove(PojoClassFactory.getPojoClass(ControlLoopAck.class));
- pojoClasses.remove(PojoClassFactory.getPojoClass(ControlLoopAckTest.class));
+ pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionAck.class));
+ pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionAckTest.class));
// @formatter:off
final Validator validator = ValidatorBuilder
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAckTest.java
index 886933aba..10200d86f 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAckTest.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.util.UUID;
import org.junit.jupiter.api.Test;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java
index e86d9e885..d08acda47 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.UUID;
@@ -47,7 +47,7 @@ class ParticipantRegisterTest {
ToscaConceptIdentifier id = new ToscaConceptIdentifier();
id.setName("id");
id.setVersion("1.2.3");
- orig.setControlLoopId(id);
+ orig.setAutomationCompositionId(id);
orig.setParticipantId(id);
orig.setParticipantType(id);
orig.setMessageId(UUID.randomUUID());
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java
index 98c127107..92025a707 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.UUID;
@@ -43,7 +43,7 @@ class ParticipantStatusReqTest {
// verify with all values
ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
orig.setParticipantId(id);
- orig.setControlLoopId(null);
+ orig.setAutomationCompositionId(null);
orig.setParticipantType(null);
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
index b2bce05cc..a33c12f2e 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
@@ -18,27 +18,27 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList;
+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.AutomationCompositionStatistics;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
@@ -58,7 +58,7 @@ class ParticipantStatusTest {
// verify with all values
ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setControlLoopId(id);
+ orig.setAutomationCompositionId(id);
orig.setParticipantId(id);
ToscaConceptIdentifier type = new ToscaConceptIdentifier("type", "2.3.4");
orig.setParticipantType(type);
@@ -67,14 +67,14 @@ class ParticipantStatusTest {
orig.setHealthStatus(ParticipantHealthStatus.HEALTHY);
orig.setTimestamp(Instant.ofEpochMilli(3000));
- ControlLoopInfo clInfo = getControlLoopInfo(id);
- orig.setControlLoopInfoList(List.of(clInfo));
+ AutomationCompositionInfo acInfo = getAutomationCompositionInfo(id);
+ orig.setAutomationCompositionInfoList(List.of(acInfo));
ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition();
participantDefinitionUpdate.setParticipantId(id);
participantDefinitionUpdate.setParticipantType(type);
- ControlLoopElementDefinition clDefinition = getClElementDefinition(id);
- participantDefinitionUpdate.setControlLoopElementDefinitionList(List.of(clDefinition));
+ AutomationCompositionElementDefinition acDefinition = getAcElementDefinition(id);
+ participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
assertEquals(removeVariableFields(orig.toString()),
@@ -83,47 +83,47 @@ class ParticipantStatusTest {
assertSerializable(orig, ParticipantStatus.class);
}
- private ControlLoopInfo getControlLoopInfo(ToscaConceptIdentifier id) {
- ControlLoopInfo clInfo = new ControlLoopInfo();
- clInfo.setState(ControlLoopState.PASSIVE2RUNNING);
- clInfo.setControlLoopId(id);
-
- ControlLoopStatistics clStatistics = new ControlLoopStatistics();
- clStatistics.setControlLoopId(id);
- clStatistics.setAverageExecutionTime(12345);
- clStatistics.setEventCount(12345);
- clStatistics.setLastEnterTime(12345);
- clStatistics.setLastExecutionTime(12345);
- clStatistics.setLastStart(12345);
- clStatistics.setTimeStamp(Instant.ofEpochMilli(3000));
- clStatistics.setUpTime(12345);
- ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
- ClElementStatistics clElementStatistics = new ClElementStatistics();
- clElementStatistics.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
- clElementStatistics.setTimeStamp(Instant.now());
- clElementStatisticsList.setClElementStatistics(List.of(clElementStatistics));
- clStatistics.setClElementStatisticsList(clElementStatisticsList);
-
- clInfo.setControlLoopStatistics(clStatistics);
- return clInfo;
+ private AutomationCompositionInfo getAutomationCompositionInfo(ToscaConceptIdentifier id) {
+ AutomationCompositionInfo acInfo = new AutomationCompositionInfo();
+ acInfo.setState(AutomationCompositionState.PASSIVE2RUNNING);
+ acInfo.setAutomationCompositionId(id);
+
+ AutomationCompositionStatistics acStatistics = new AutomationCompositionStatistics();
+ acStatistics.setAutomationCompositionId(id);
+ acStatistics.setAverageExecutionTime(12345);
+ acStatistics.setEventCount(12345);
+ acStatistics.setLastEnterTime(12345);
+ acStatistics.setLastExecutionTime(12345);
+ acStatistics.setLastStart(12345);
+ acStatistics.setTimeStamp(Instant.ofEpochMilli(3000));
+ acStatistics.setUpTime(12345);
+ AcElementStatisticsList acElementStatisticsList = new AcElementStatisticsList();
+ AcElementStatistics acElementStatistics = new AcElementStatistics();
+ acElementStatistics.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
+ acElementStatistics.setTimeStamp(Instant.now());
+ acElementStatisticsList.setAcElementStatistics(List.of(acElementStatistics));
+ acStatistics.setAcElementStatisticsList(acElementStatisticsList);
+
+ acInfo.setAutomationCompositionStatistics(acStatistics);
+ return acInfo;
}
- private ControlLoopElementDefinition getClElementDefinition(ToscaConceptIdentifier id) {
+ private AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) {
ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
toscaNodeTemplate.setName("nodeTemplate");
toscaNodeTemplate.setDerivedFrom("parentNodeTemplate");
toscaNodeTemplate.setDescription("Description of nodeTemplate");
toscaNodeTemplate.setVersion("1.2.3");
- ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
- clDefinition.setClElementDefinitionId(id);
- clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate);
+ AutomationCompositionElementDefinition acDefinition = new AutomationCompositionElementDefinition();
+ acDefinition.setAcElementDefinitionId(id);
+ acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate);
ToscaProperty property = new ToscaProperty();
property.setName("test");
property.setType("testType");
Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
- clDefinition.setCommonPropertiesMap(commonPropertiesMap);
- return clDefinition;
+ acDefinition.setCommonPropertiesMap(commonPropertiesMap);
+ return acDefinition;
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java
index d2a191018..9f011a383 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.util.UUID;
import org.junit.jupiter.api.Test;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
index d7023d0c1..f8aaffe11 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
@@ -18,20 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
@@ -49,7 +49,7 @@ class ParticipantUpdateTest {
ParticipantUpdate orig = new ParticipantUpdate();
// verify with all values
ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setControlLoopId(id);
+ orig.setAutomationCompositionId(id);
orig.setParticipantId(id);
orig.setParticipantType(id);
orig.setMessageId(UUID.randomUUID());
@@ -69,8 +69,8 @@ class ParticipantUpdateTest {
ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition();
participantDefinitionUpdate.setParticipantType(id);
- ControlLoopElementDefinition clDefinition = getClElementDefinition(id);
- participantDefinitionUpdate.setControlLoopElementDefinitionList(List.of(clDefinition));
+ AutomationCompositionElementDefinition acDefinition = getAcElementDefinition(id);
+ participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
ParticipantUpdate other = new ParticipantUpdate(orig);
@@ -80,22 +80,22 @@ class ParticipantUpdateTest {
assertSerializable(orig, ParticipantUpdate.class);
}
- private ControlLoopElementDefinition getClElementDefinition(ToscaConceptIdentifier id) {
+ private AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) {
ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
toscaNodeTemplate.setName("nodeTemplate");
toscaNodeTemplate.setDerivedFrom("parentNodeTemplate");
toscaNodeTemplate.setDescription("Description of nodeTemplate");
toscaNodeTemplate.setVersion("1.2.3");
- ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
- clDefinition.setClElementDefinitionId(id);
- clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate);
+ AutomationCompositionElementDefinition acDefinition = new AutomationCompositionElementDefinition();
+ acDefinition.setAcElementDefinitionId(id);
+ acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate);
ToscaProperty property = new ToscaProperty();
property.setName("test");
property.setType("testType");
Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
- clDefinition.setCommonPropertiesMap(commonPropertiesMap);
- return clDefinition;
+ acDefinition.setCommonPropertiesMap(commonPropertiesMap);
+ return acDefinition;
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/MessagesRestPojosTest.java
index 435cce8ef..4503be783 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/MessagesRestPojosTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/MessagesRestPojosTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.rest;
+package org.onap.policy.clamp.models.acm.messages.rest;
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java
index c9902753f..348359743 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommandTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation;
+package org.onap.policy.clamp.models.acm.messages.rest.instantiation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
class InstantiationCommandTest {
@Test
@@ -43,8 +43,8 @@ class InstantiationCommandTest {
InstantiationCommand ic1 = new InstantiationCommand();
- ic1.setControlLoopIdentifierList(new ArrayList<>());
- ic1.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ ic1.setAutomationCompositionIdentifierList(new ArrayList<>());
+ ic1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
assertThat(ic1.toString()).contains("InstantiationCommand(");
assertEquals(false, ic1.hashCode() == 0);
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java
index 10150cf59..ebbaf1d42 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
+package org.onap.policy.clamp.models.acm.persistence.concepts;
/**
- * Test class for {@link JpaControlLoop} comparisons.
+ * Test class for {@link JpaAcElementStatistics} comparisons.
*/
-class DummyJpaControlLoopChild extends JpaControlLoop {
+class DummyJpaAcElementStatisticsChild extends JpaAcElementStatistics {
private static final long serialVersionUID = -5101743610779424064L;
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionChild.java
index 4bacb9255..c7f4351c7 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionChild.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
+package org.onap.policy.clamp.models.acm.persistence.concepts;
/**
- * Test class for {@link JpaControlLoopElement} comparisons.
+ * Test class for {@link JpaAutomationComposition} comparisons.
*/
-class DummyJpaControlLoopElementChild extends JpaControlLoopElement {
+class DummyJpaAutomationCompositionChild extends JpaAutomationComposition {
private static final long serialVersionUID = -5101743610779424064L;
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionElementChild.java
index 94b0b13c7..86723d98f 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAutomationCompositionElementChild.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
+package org.onap.policy.clamp.models.acm.persistence.concepts;
/**
- * Test class for {@link JpaClElementStatistics} comparisons.
+ * Test class for {@link JpaAutomationCompositionElement} comparisons.
*/
-class DummyJpaClElementStatisticsChild extends JpaClElementStatistics {
+class DummyJpaAutomationCompositionElementChild extends JpaAutomationCompositionElement {
private static final long serialVersionUID = -5101743610779424064L;
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantChild.java
index 68dcc319b..6b34cc44e 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantChild.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
+package org.onap.policy.clamp.models.acm.persistence.concepts;
/**
* Test class for {@link JpaParticipant} comparisons.
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java
index 2c1f04ea1..95082cac7 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
+package org.onap.policy.clamp.models.acm.persistence.concepts;
/**
* Test class for {@link JpaParticipantStatistics} comparisons.
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java
new file mode 100644
index 000000000..4cf7b8af0
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java
@@ -0,0 +1,189 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+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.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceTimestampKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the {@link JpaAcElementStatistics} class.
+ */
+class JpaAcElementStatisticsTest {
+
+ private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+
+ @Test
+ void testJpaAcElementStatisticsConstructor() {
+ assertThatThrownBy(() -> {
+ new JpaAcElementStatistics((JpaAcElementStatistics) null);
+ }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAcElementStatistics((PfReferenceTimestampKey) null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAcElementStatistics(null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAcElementStatistics(null, new PfConceptKey());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAcElementStatistics(new PfReferenceTimestampKey(), null);
+ }).hasMessageMatching("participantId is marked .*ull but is null");
+
+ assertNotNull(new JpaAcElementStatistics());
+ assertNotNull(new JpaAcElementStatistics((new PfReferenceTimestampKey())));
+ assertNotNull(new JpaAcElementStatistics(new PfReferenceTimestampKey(), new PfConceptKey()));
+ }
+
+ @Test
+ void testJpaAcElementStatistics() {
+ JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance();
+
+ AcElementStatistics aces = createAcElementStatisticsInstance();
+ assertEquals(aces, testJpaAcElementStatistics.toAuthorative());
+
+ assertThatThrownBy(() -> {
+ testJpaAcElementStatistics.fromAuthorative(null);
+ }).hasMessageMatching("acElementStatistics is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaAcElementStatistics((JpaAcElementStatistics) null))
+ .isInstanceOf(NullPointerException.class);
+
+ JpaAcElementStatistics testJpaAcElementStatisticsFa = new JpaAcElementStatistics();
+ testJpaAcElementStatisticsFa.setKey(null);
+ testJpaAcElementStatisticsFa.fromAuthorative(aces);
+ assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa);
+ testJpaAcElementStatisticsFa.setKey(PfReferenceTimestampKey.getNullKey());
+ testJpaAcElementStatisticsFa.fromAuthorative(aces);
+ assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa);
+ testJpaAcElementStatisticsFa.setKey(new PfReferenceTimestampKey("elementName", "0.0.1",
+ "a95757ba-b34a-4049-a2a8-46773abcbe5e", Instant.ofEpochSecond(123456L)));
+ testJpaAcElementStatisticsFa.fromAuthorative(aces);
+ assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa);
+
+ testJpaAcElementStatisticsFa = new JpaAcElementStatistics(aces);
+ assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa);
+
+ assertEquals(1, testJpaAcElementStatistics.getKeys().size());
+
+ assertEquals("elementName", testJpaAcElementStatistics.getKey().getReferenceKey().getParentKeyName());
+
+ testJpaAcElementStatistics.clean();
+ assertEquals("elementName", testJpaAcElementStatistics.getKey().getReferenceKey().getParentKeyName());
+
+ JpaAcElementStatistics testJpaAcElementStatistics2 = new JpaAcElementStatistics(testJpaAcElementStatistics);
+ assertEquals(testJpaAcElementStatistics, testJpaAcElementStatistics2);
+ }
+
+ @Test
+ void testJpaAcElementStatisticsValidation() {
+ JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance();
+
+ assertThatThrownBy(() -> {
+ testJpaAcElementStatistics.validate(null);
+ }).hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(testJpaAcElementStatistics.validate("").isValid());
+ }
+
+ @Test
+ void testJpaAcElementStatisticsCompareTo() {
+ JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance();
+
+ JpaAcElementStatistics otherJpaAcElementStatistics = new JpaAcElementStatistics(testJpaAcElementStatistics);
+ assertEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics));
+ assertEquals(-1, testJpaAcElementStatistics.compareTo(null));
+ assertEquals(0, testJpaAcElementStatistics.compareTo(testJpaAcElementStatistics));
+ assertNotEquals(0, testJpaAcElementStatistics.compareTo(new DummyJpaAcElementStatisticsChild()));
+
+ testJpaAcElementStatistics.setState(AutomationCompositionState.PASSIVE);
+ assertNotEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics));
+ testJpaAcElementStatistics.setState(AutomationCompositionState.UNINITIALISED);
+ assertEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics));
+
+ assertEquals(testJpaAcElementStatistics, new JpaAcElementStatistics(testJpaAcElementStatistics));
+ }
+
+ @Test
+ void testJpaAcElementStatisticsLombok() {
+ assertNotNull(new Participant());
+ JpaAcElementStatistics aces0 = new JpaAcElementStatistics();
+
+ assertThat(aces0.toString()).contains("JpaAcElementStatistics(");
+ assertThat(aces0.hashCode()).isNotZero();
+ assertEquals(true, aces0.equals(aces0));
+ assertEquals(false, aces0.equals(null));
+
+
+ JpaAcElementStatistics aces11 = new JpaAcElementStatistics();
+
+ aces11.setState(AutomationCompositionState.UNINITIALISED);
+
+ assertThat(aces11.toString()).contains("JpaAcElementStatistics(");
+ assertEquals(false, aces11.hashCode() == 0);
+ assertEquals(false, aces11.equals(aces0));
+ assertEquals(false, aces11.equals(null));
+
+ assertNotEquals(aces11, aces0);
+
+ JpaAcElementStatistics aces2 = new JpaAcElementStatistics();
+ assertEquals(aces2, aces0);
+ }
+
+ private JpaAcElementStatistics createJpaAcElementStatisticsInstance() {
+ AcElementStatistics testAces = createAcElementStatisticsInstance();
+ JpaAcElementStatistics testJpaAcElementStatistics = new JpaAcElementStatistics();
+ testJpaAcElementStatistics.setKey(null);
+ testJpaAcElementStatistics.fromAuthorative(testAces);
+ testJpaAcElementStatistics.setKey(PfReferenceTimestampKey.getNullKey());
+ testJpaAcElementStatistics.fromAuthorative(testAces);
+
+ return testJpaAcElementStatistics;
+ }
+
+ private AcElementStatistics createAcElementStatisticsInstance() {
+ AcElementStatistics acElementStatistics = new AcElementStatistics();
+ acElementStatistics.setParticipantId(new ToscaConceptIdentifier("elementName", "0.0.1"));
+ acElementStatistics.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ acElementStatistics.setTimeStamp(Instant.ofEpochSecond(123456L));
+ acElementStatistics.setState(AutomationCompositionState.UNINITIALISED);
+
+ return acElementStatistics;
+ }
+}
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
new file mode 100644
index 000000000..f4257bdd2
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java
@@ -0,0 +1,315 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+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.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+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.Participant;
+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.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the {@link JpaAutomationCompositionElement} class.
+ */
+class JpaAutomationCompositionElementTest {
+
+ private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+
+ @Test
+ void testJpaAutomationCompositionElementConstructor() {
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement((JpaAutomationCompositionElement) null);
+ }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement((PfReferenceKey) null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(null, null, null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(null, null, null, AutomationCompositionState.UNINITIALISED);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(null, null, new PfConceptKey("participant", "0.0.1"), null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(null, null, new PfConceptKey("participant", "0.0.1"),
+ AutomationCompositionState.UNINITIALISED);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(null, new PfConceptKey(), null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(null, new PfConceptKey(), null,
+ AutomationCompositionState.UNINITIALISED);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"),
+ null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(null, new PfConceptKey(), new PfConceptKey("participant", "0.0.1"),
+ AutomationCompositionState.UNINITIALISED);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(new PfReferenceKey(), null, null, null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(new PfReferenceKey(), null, null,
+ AutomationCompositionState.UNINITIALISED);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"),
+ null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(new PfReferenceKey(), null, new PfConceptKey("participant", "0.0.1"),
+ AutomationCompositionState.UNINITIALISED);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(new PfReferenceKey(), new PfConceptKey(), null, null);
+ }).hasMessageMatching("participantType is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(new PfReferenceKey(), new PfConceptKey(), null,
+ AutomationCompositionState.UNINITIALISED);
+ }).hasMessageMatching("participantType is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationCompositionElement(new PfReferenceKey(), new PfConceptKey(),
+ new PfConceptKey("participant", "0.0.1"), null);
+ }).hasMessageMatching("state is marked .*ull but is null");
+
+ assertNotNull(new JpaAutomationCompositionElement());
+ assertNotNull(new JpaAutomationCompositionElement((new PfReferenceKey())));
+ assertNotNull(new JpaAutomationCompositionElement(new PfReferenceKey(), new PfConceptKey(),
+ new PfConceptKey("participant", "0.0.1"), AutomationCompositionState.UNINITIALISED));
+ }
+
+ @Test
+ void testJpaAutomationCompositionElement() {
+ JpaAutomationCompositionElement testJpaAutomationCompositionElement =
+ createJpaAutomationCompositionElementInstance();
+
+ AutomationCompositionElement ace = createAutomationCompositionElementInstance();
+ assertEquals(ace, testJpaAutomationCompositionElement.toAuthorative());
+
+ assertThatThrownBy(() -> {
+ testJpaAutomationCompositionElement.fromAuthorative(null);
+ }).hasMessageMatching("element is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaAutomationCompositionElement((JpaAutomationCompositionElement) null))
+ .isInstanceOf(NullPointerException.class);
+
+ JpaAutomationCompositionElement testJpaAutomationCompositionElementFa = new JpaAutomationCompositionElement();
+ testJpaAutomationCompositionElementFa.setKey(null);
+ testJpaAutomationCompositionElementFa.fromAuthorative(ace);
+ assertEquals(testJpaAutomationCompositionElement, testJpaAutomationCompositionElementFa);
+ testJpaAutomationCompositionElementFa.setKey(PfReferenceKey.getNullKey());
+ testJpaAutomationCompositionElementFa.fromAuthorative(ace);
+ assertEquals(testJpaAutomationCompositionElement, testJpaAutomationCompositionElementFa);
+ testJpaAutomationCompositionElementFa.setKey(
+ new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ testJpaAutomationCompositionElementFa.fromAuthorative(ace);
+ assertEquals(testJpaAutomationCompositionElement, testJpaAutomationCompositionElementFa);
+
+ assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e",
+ testJpaAutomationCompositionElement.getKey().getLocalName());
+ assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e",
+ new JpaAutomationCompositionElement(createAutomationCompositionElementInstance()).getKey().getLocalName());
+ assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e",
+ ((PfReferenceKey) new JpaAutomationCompositionElement(createAutomationCompositionElementInstance())
+ .getKeys().get(0)).getLocalName());
+
+ testJpaAutomationCompositionElement.clean();
+ assertEquals("a95757ba-b34a-4049-a2a8-46773abcbe5e",
+ testJpaAutomationCompositionElement.getKey().getLocalName());
+
+ testJpaAutomationCompositionElement.setDescription(" A Message ");
+ testJpaAutomationCompositionElement.clean();
+ assertEquals("A Message", testJpaAutomationCompositionElement.getDescription());
+
+ JpaAutomationCompositionElement testJpaAutomationCompositionElement2 =
+ new JpaAutomationCompositionElement(testJpaAutomationCompositionElement);
+ assertEquals(testJpaAutomationCompositionElement, testJpaAutomationCompositionElement2);
+ }
+
+ @Test
+ void testJpaAutomationCompositionElementOrderedState() throws CoderException {
+ AutomationCompositionElement testAutomationCompositionElement = createAutomationCompositionElementInstance();
+ JpaAutomationCompositionElement testJpaAutomationCompositionElement =
+ createJpaAutomationCompositionElementInstance();
+
+ testJpaAutomationCompositionElement.setOrderedState(null);
+ assertEquals(testAutomationCompositionElement, testJpaAutomationCompositionElement.toAuthorative());
+ testJpaAutomationCompositionElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+
+ AutomationCompositionElement noOrderedStateAce = new StandardCoder().decode(
+ new File("src/test/resources/json/AutomationCompositionElementNoOrderedState.json"),
+ AutomationCompositionElement.class);
+
+ JpaAutomationCompositionElement noOrderedStateJpaAce = new JpaAutomationCompositionElement(noOrderedStateAce);
+ assertNull(noOrderedStateJpaAce.getOrderedState());
+ noOrderedStateAce.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ noOrderedStateJpaAce = new JpaAutomationCompositionElement(noOrderedStateAce);
+ assertEquals(testJpaAutomationCompositionElement, noOrderedStateJpaAce);
+ }
+
+ @Test
+ void testJpaAutomationCompositionElementValidation() {
+ JpaAutomationCompositionElement testJpaAutomationCompositionElement =
+ createJpaAutomationCompositionElementInstance();
+
+ assertThatThrownBy(() -> {
+ testJpaAutomationCompositionElement.validate(null);
+ }).hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(testJpaAutomationCompositionElement.validate("").isValid());
+ }
+
+ @Test
+ void testJpaAutomationCompositionElementCompareTo() {
+ JpaAutomationCompositionElement testJpaAutomationCompositionElement =
+ createJpaAutomationCompositionElementInstance();
+
+ JpaAutomationCompositionElement otherJpaAutomationCompositionElement =
+ new JpaAutomationCompositionElement(testJpaAutomationCompositionElement);
+ assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+ assertEquals(-1, testJpaAutomationCompositionElement.compareTo(null));
+ assertEquals(0, testJpaAutomationCompositionElement.compareTo(testJpaAutomationCompositionElement));
+ assertNotEquals(0,
+ testJpaAutomationCompositionElement.compareTo(new DummyJpaAutomationCompositionElementChild()));
+
+ testJpaAutomationCompositionElement
+ .setKey(new PfReferenceKey("BadValue", "0.0.1", "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+ testJpaAutomationCompositionElement.setKey(
+ new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, "a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+
+ testJpaAutomationCompositionElement.setDefinition(new PfConceptKey("BadValue", "0.0.1"));
+ assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+ testJpaAutomationCompositionElement.setDefinition(new PfConceptKey("aceDef", "0.0.1"));
+ assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+
+ testJpaAutomationCompositionElement.setDescription("Description");
+ assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+ 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.setParticipantType(new PfConceptKey("dummy", "0.0.1"));
+ assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+ testJpaAutomationCompositionElement.setParticipantType(new PfConceptKey("participantType", "0.0.1"));
+ assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+
+ assertEquals(testJpaAutomationCompositionElement,
+ new JpaAutomationCompositionElement(testJpaAutomationCompositionElement));
+ }
+
+ @Test
+ void testJpaAutomationCompositionElementLombok() {
+ assertNotNull(new Participant());
+ JpaAutomationCompositionElement ace0 = new JpaAutomationCompositionElement();
+
+ assertThat(ace0.toString()).contains("JpaAutomationCompositionElement(");
+ assertThat(ace0.hashCode()).isNotZero();
+ assertEquals(true, ace0.equals(ace0));
+ assertEquals(false, ace0.equals(null));
+
+ JpaAutomationCompositionElement ace1 = new JpaAutomationCompositionElement();
+
+ ace1.setDefinition(new PfConceptKey("defName", "0.0.1"));
+ ace1.setDescription("Description");
+ ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ ace1.setState(AutomationCompositionState.UNINITIALISED);
+ ace1.setParticipantId(new PfConceptKey("participant", "0.0.1"));
+
+ assertThat(ace1.toString()).contains("AutomationCompositionElement(");
+ assertEquals(false, ace1.hashCode() == 0);
+ assertEquals(false, ace1.equals(ace0));
+ assertEquals(false, ace1.equals(null));
+
+ assertNotEquals(ace1, ace0);
+
+ JpaAutomationCompositionElement ace2 = new JpaAutomationCompositionElement();
+ assertEquals(ace2, ace0);
+ }
+
+ private JpaAutomationCompositionElement createJpaAutomationCompositionElementInstance() {
+ AutomationCompositionElement testAce = createAutomationCompositionElementInstance();
+ JpaAutomationCompositionElement testJpaAutomationCompositionElement = new JpaAutomationCompositionElement();
+ testJpaAutomationCompositionElement.setKey(null);
+ testJpaAutomationCompositionElement.fromAuthorative(testAce);
+ testJpaAutomationCompositionElement.setKey(PfReferenceKey.getNullKey());
+ testJpaAutomationCompositionElement.fromAuthorative(testAce);
+
+ return testJpaAutomationCompositionElement;
+ }
+
+ private AutomationCompositionElement createAutomationCompositionElementInstance() {
+ AutomationCompositionElement automationCompositionElement = new AutomationCompositionElement();
+ automationCompositionElement.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e"));
+ automationCompositionElement.setDefinition(new ToscaConceptIdentifier("aceDef", "0.0.1"));
+ automationCompositionElement.setParticipantType(new ToscaConceptIdentifier("participantType", "0.0.1"));
+
+ return 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
new file mode 100644
index 000000000..a016d1202
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
@@ -0,0 +1,310 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.persistence.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.LinkedHashMap;
+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.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;
+
+/**
+ * Test the {@link JpaAutomationCompositionTest} class.
+ */
+class JpaAutomationCompositionTest {
+
+ private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+
+ @Test
+ void testJpaAutomationCompositionConstructor() {
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition((JpaAutomationComposition) null);
+ }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition((PfConceptKey) null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(null, null, null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(null, null, null, new LinkedHashMap<>());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(null, null, AutomationCompositionState.UNINITIALISED, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(null, null, AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(null, new PfConceptKey(), null, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(null, new PfConceptKey(), null, new LinkedHashMap<>());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(null, new PfConceptKey(), AutomationCompositionState.UNINITIALISED, null);
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(null, new PfConceptKey(), AutomationCompositionState.UNINITIALISED,
+ new LinkedHashMap<>());
+ }).hasMessageMatching(NULL_KEY_ERROR);
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(new PfConceptKey(), null, null, null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(new PfConceptKey(), null, null, new LinkedHashMap<>());
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(new PfConceptKey(), null, AutomationCompositionState.UNINITIALISED, null);
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(new PfConceptKey(), null, AutomationCompositionState.UNINITIALISED,
+ new LinkedHashMap<>());
+ }).hasMessageMatching("definition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(new PfConceptKey(), new PfConceptKey(), null, null);
+ }).hasMessageMatching("state is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(new PfConceptKey(), new PfConceptKey(), null, new LinkedHashMap<>());
+ }).hasMessageMatching("state is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
+ new JpaAutomationComposition(new PfConceptKey(), new PfConceptKey(),
+ AutomationCompositionState.UNINITIALISED, null);
+ }).hasMessageMatching("elements is marked .*ull but is null");
+
+ assertNotNull(new JpaAutomationComposition());
+ assertNotNull(new JpaAutomationComposition((new PfConceptKey())));
+ assertNotNull(new JpaAutomationComposition(new PfConceptKey(), new PfConceptKey(),
+ AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>()));
+ }
+
+ @Test
+ void testJpaAutomationComposition() {
+ JpaAutomationComposition testJpaAutomationComposition = createJpaAutomationCompositionInstance();
+
+ AutomationComposition participant = createAutomationCompositionInstance();
+ assertEquals(participant, testJpaAutomationComposition.toAuthorative());
+
+ assertThatThrownBy(() -> {
+ testJpaAutomationComposition.fromAuthorative(null);
+ }).hasMessageMatching("automationComposition is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaAutomationComposition((JpaAutomationComposition) null))
+ .isInstanceOf(NullPointerException.class);
+
+ JpaAutomationComposition testJpaAutomationCompositionFa = new JpaAutomationComposition();
+ testJpaAutomationCompositionFa.setKey(null);
+ testJpaAutomationCompositionFa.fromAuthorative(participant);
+ assertEquals(testJpaAutomationComposition, testJpaAutomationCompositionFa);
+ testJpaAutomationCompositionFa.setKey(PfConceptKey.getNullKey());
+ testJpaAutomationCompositionFa.fromAuthorative(participant);
+ assertEquals(testJpaAutomationComposition, testJpaAutomationCompositionFa);
+ testJpaAutomationCompositionFa.setKey(new PfConceptKey("automation-composition", "0.0.1"));
+ testJpaAutomationCompositionFa.fromAuthorative(participant);
+ assertEquals(testJpaAutomationComposition, testJpaAutomationCompositionFa);
+
+ assertEquals("automation-composition", testJpaAutomationComposition.getKey().getName());
+ assertEquals("automation-composition",
+ new JpaAutomationComposition(createAutomationCompositionInstance()).getKey().getName());
+ assertEquals("automation-composition",
+ ((PfConceptKey) new JpaAutomationComposition(createAutomationCompositionInstance()).getKeys().get(0))
+ .getName());
+
+ testJpaAutomationComposition.clean();
+ assertEquals("automation-composition", testJpaAutomationComposition.getKey().getName());
+
+ testJpaAutomationComposition.setDescription(" A Message ");
+ testJpaAutomationComposition.clean();
+ assertEquals("A Message", testJpaAutomationComposition.getDescription());
+
+ JpaAutomationComposition testJpaAutomationComposition2 =
+ new JpaAutomationComposition(testJpaAutomationComposition);
+ assertEquals(testJpaAutomationComposition, testJpaAutomationComposition2);
+ }
+
+ @Test
+ void testJpaAutomationCompositionElementOrderedState() throws CoderException {
+ AutomationComposition testAutomationComposition = createAutomationCompositionInstance();
+ JpaAutomationComposition testJpaAutomationComposition = createJpaAutomationCompositionInstance();
+
+ testJpaAutomationComposition.setOrderedState(null);
+ assertEquals(testAutomationComposition, testJpaAutomationComposition.toAuthorative());
+ testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+
+ AutomationComposition noOrderedStateAc = new StandardCoder().decode(
+ new File("src/test/resources/json/AutomationCompositionNoOrderedState.json"), AutomationComposition.class);
+
+ JpaAutomationComposition noOrderedStateJpaAc = new JpaAutomationComposition(noOrderedStateAc);
+ assertNull(noOrderedStateJpaAc.getOrderedState());
+ noOrderedStateAc.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ noOrderedStateJpaAc = new JpaAutomationComposition(noOrderedStateAc);
+ assertEquals(testJpaAutomationComposition, noOrderedStateJpaAc);
+
+ AutomationCompositions automationCompositionsWithElements = new StandardCoder().decode(
+ new File("src/test/resources/providers/TestAutomationCompositions.json"), AutomationCompositions.class);
+
+ JpaAutomationComposition jpaAutomationCompositionWithElements =
+ new JpaAutomationComposition(automationCompositionsWithElements.getAutomationCompositionList().get(0));
+ assertEquals(4, jpaAutomationCompositionWithElements.getElements().size());
+ assertEquals(18, jpaAutomationCompositionWithElements.getKeys().size());
+ assertThatCode(() -> jpaAutomationCompositionWithElements.clean()).doesNotThrowAnyException();
+
+ assertEquals(automationCompositionsWithElements.getAutomationCompositionList().get(0),
+ jpaAutomationCompositionWithElements.toAuthorative());
+ }
+
+ @Test
+ void testJpaAutomationCompositionValidation() {
+ JpaAutomationComposition testJpaAutomationComposition = createJpaAutomationCompositionInstance();
+
+ assertThatThrownBy(() -> {
+ testJpaAutomationComposition.validate(null);
+ }).hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(testJpaAutomationComposition.validate("").isValid());
+ }
+
+ @Test
+ void testJpaAutomationCompositionCompareTo() {
+ JpaAutomationComposition testJpaAutomationComposition = createJpaAutomationCompositionInstance();
+
+ JpaAutomationComposition otherJpaAutomationComposition =
+ new JpaAutomationComposition(testJpaAutomationComposition);
+ assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ assertEquals(-1, testJpaAutomationComposition.compareTo(null));
+ assertEquals(0, testJpaAutomationComposition.compareTo(testJpaAutomationComposition));
+ assertNotEquals(0, testJpaAutomationComposition.compareTo(new DummyJpaAutomationCompositionChild()));
+
+ testJpaAutomationComposition.setKey(new PfConceptKey("BadValue", "0.0.1"));
+ assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ testJpaAutomationComposition.setKey(new PfConceptKey("automation-composition", "0.0.1"));
+ assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ testJpaAutomationComposition.setDefinition(new PfConceptKey("BadValue", "0.0.1"));
+ assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ testJpaAutomationComposition.setDefinition(new PfConceptKey("automationCompositionDefinitionName", "0.0.1"));
+ assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ testJpaAutomationComposition.setState(AutomationCompositionState.PASSIVE);
+ assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ testJpaAutomationComposition.setState(AutomationCompositionState.UNINITIALISED);
+ assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
+ assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ testJpaAutomationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ testJpaAutomationComposition.setDescription("A description");
+ assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ testJpaAutomationComposition.setDescription(null);
+ assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ testJpaAutomationComposition.setPrimed(true);
+ assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ testJpaAutomationComposition.setPrimed(false);
+ assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ assertEquals(testJpaAutomationComposition, new JpaAutomationComposition(testJpaAutomationComposition));
+ }
+
+ @Test
+ void testJpaAutomationCompositionLombok() {
+ assertNotNull(new AutomationComposition());
+ JpaAutomationComposition ac0 = new JpaAutomationComposition();
+
+ assertThat(ac0.toString()).contains("JpaAutomationComposition(");
+ assertThat(ac0.hashCode()).isNotZero();
+ assertEquals(true, ac0.equals(ac0));
+ assertEquals(false, ac0.equals(null));
+
+ JpaAutomationComposition ac1 = new JpaAutomationComposition();
+
+ ac1.setDefinition(new PfConceptKey("defName", "0.0.1"));
+ ac1.setDescription("Description");
+ ac1.setElements(new LinkedHashMap<>());
+ ac1.setKey(new PfConceptKey("participant", "0.0.1"));
+ ac1.setState(AutomationCompositionState.UNINITIALISED);
+
+ assertThat(ac1.toString()).contains("AutomationComposition(");
+ assertEquals(false, ac1.hashCode() == 0);
+ assertEquals(false, ac1.equals(ac0));
+ assertEquals(false, ac1.equals(null));
+
+ assertNotEquals(ac1, ac0);
+
+ JpaAutomationComposition ac2 = new JpaAutomationComposition();
+ assertEquals(ac2, ac0);
+ }
+
+ private JpaAutomationComposition createJpaAutomationCompositionInstance() {
+ AutomationComposition testAutomationComposition = createAutomationCompositionInstance();
+ JpaAutomationComposition testJpaAutomationComposition = new JpaAutomationComposition();
+ testJpaAutomationComposition.setKey(null);
+ testJpaAutomationComposition.fromAuthorative(testAutomationComposition);
+ testJpaAutomationComposition.setKey(PfConceptKey.getNullKey());
+ testJpaAutomationComposition.fromAuthorative(testAutomationComposition);
+
+ return testJpaAutomationComposition;
+ }
+
+ private AutomationComposition createAutomationCompositionInstance() {
+ AutomationComposition testAutomationComposition = new AutomationComposition();
+ testAutomationComposition.setName("automation-composition");
+ testAutomationComposition.setVersion("0.0.1");
+ testAutomationComposition
+ .setDefinition(new ToscaConceptIdentifier("automationCompositionDefinitionName", "0.0.1"));
+ testAutomationComposition.setElements(new LinkedHashMap<>());
+
+ return testAutomationComposition;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java
index aff365515..284d13374 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatisticsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
+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;
@@ -29,10 +29,10 @@ import static org.junit.Assert.assertTrue;
import java.time.Instant;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfTimestampKey;
@@ -76,8 +76,8 @@ class JpaParticipantStatisticsTest {
void testJpaParticipantStatistics() {
JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance();
- ParticipantStatistics cles = createParticipantStatisticsInstance();
- assertEquals(cles, testJpaParticipantStatistics.toAuthorative());
+ ParticipantStatistics aces = createParticipantStatisticsInstance();
+ assertEquals(aces, testJpaParticipantStatistics.toAuthorative());
assertThatThrownBy(() -> {
testJpaParticipantStatistics.fromAuthorative(null);
@@ -88,17 +88,17 @@ class JpaParticipantStatisticsTest {
JpaParticipantStatistics testJpaParticipantStatisticsFa = new JpaParticipantStatistics();
testJpaParticipantStatisticsFa.setKey(null);
- testJpaParticipantStatisticsFa.fromAuthorative(cles);
+ testJpaParticipantStatisticsFa.fromAuthorative(aces);
assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
testJpaParticipantStatisticsFa.setKey(PfTimestampKey.getNullKey());
- testJpaParticipantStatisticsFa.fromAuthorative(cles);
+ testJpaParticipantStatisticsFa.fromAuthorative(aces);
assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
testJpaParticipantStatisticsFa
.setKey(new PfTimestampKey("participantName", "0.0.1", Instant.ofEpochMilli(123456L)));
- testJpaParticipantStatisticsFa.fromAuthorative(cles);
+ testJpaParticipantStatisticsFa.fromAuthorative(aces);
assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
- testJpaParticipantStatisticsFa = new JpaParticipantStatistics(cles);
+ testJpaParticipantStatisticsFa = new JpaParticipantStatistics(aces);
assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
assertEquals(2, testJpaParticipantStatistics.getKeys().size());
@@ -171,12 +171,12 @@ class JpaParticipantStatisticsTest {
}
private JpaParticipantStatistics createJpaParticipantStatisticsInstance() {
- ParticipantStatistics testCles = createParticipantStatisticsInstance();
+ ParticipantStatistics testAces = createParticipantStatisticsInstance();
JpaParticipantStatistics testJpaParticipantStatistics = new JpaParticipantStatistics();
testJpaParticipantStatistics.setKey(null);
- testJpaParticipantStatistics.fromAuthorative(testCles);
+ testJpaParticipantStatistics.fromAuthorative(testAces);
testJpaParticipantStatistics.setKey(PfTimestampKey.getNullKey());
- testJpaParticipantStatistics.fromAuthorative(testCles);
+ testJpaParticipantStatistics.fromAuthorative(testAces);
return testJpaParticipantStatistics;
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
index 087292354..776aafa2e 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
+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;
@@ -28,9 +28,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/PojosTest.java
index c877f9696..1f40fae5f 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/PojosTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/PojosTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
+package org.onap.policy.clamp.models.acm.persistence.concepts;
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java
new file mode 100644
index 000000000..15d1d845d
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.persistence.provider;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.time.Instant;
+import java.util.List;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList;
+import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAcElementStatistics;
+import org.onap.policy.clamp.models.acm.persistence.repository.AcElementStatisticsRepository;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+class AcElementStatisticsProviderTest {
+ private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
+ private static final Coder CODER = new StandardCoder();
+ private static final String AC_ELEMENT_STATS_JSON = "src/test/resources/providers/TestAcElementStatistics.json";
+
+ private AcElementStatisticsProvider acElementStatisticsProvider;
+ private AcElementStatisticsList inputAcElementStats;
+ private String originalJson = ResourceUtils.getResourceAsString(AC_ELEMENT_STATS_JSON);
+
+ /**
+ * Set up test AcElement statistics provider.
+ *
+ * @throws Exception on errors
+ */
+ @BeforeEach
+ void beforeSetupDao() throws Exception {
+
+ inputAcElementStats = CODER.decode(originalJson, AcElementStatisticsList.class);
+ var acElementStatisticsRepository = mock(AcElementStatisticsRepository.class);
+
+ var jpaAcElementStatisticsList =
+ ProviderUtils.getJpaAndValidateList(inputAcElementStats.getAcElementStatistics(),
+ JpaAcElementStatistics::new, "automation composition element statistics");
+
+ for (var acElementStat : jpaAcElementStatisticsList) {
+ when(acElementStatisticsRepository.getById(eq(acElementStat.getKey()))).thenReturn(acElementStat);
+ when(acElementStatisticsRepository.findAllById(eq(List.of(acElementStat.getKey()))))
+ .thenReturn(List.of(acElementStat));
+ }
+
+ when(acElementStatisticsRepository.saveAll(anyList())).thenReturn(jpaAcElementStatisticsList);
+
+ when(acElementStatisticsRepository.getFiltered(eq(JpaAcElementStatistics.class), any()))
+ .thenReturn(List.of(jpaAcElementStatisticsList.get(0)));
+
+ acElementStatisticsProvider = new AcElementStatisticsProvider(acElementStatisticsRepository);
+ }
+
+ @Test
+ void testAcElementStatisticsCreate() throws Exception {
+ assertThatThrownBy(() -> {
+ acElementStatisticsProvider.createAcElementStatistics(null);
+ }).hasMessageMatching(LIST_IS_NULL);
+
+ AcElementStatisticsList createdAcElementStats = new AcElementStatisticsList();
+ createdAcElementStats.setAcElementStatistics(
+ acElementStatisticsProvider.createAcElementStatistics(inputAcElementStats.getAcElementStatistics()));
+
+ assertEquals(inputAcElementStats.toString().replaceAll("\\s+", ""),
+ createdAcElementStats.toString().replaceAll("\\s+", ""));
+ }
+
+ @Test
+ void testGetAcElementStatistics() throws Exception {
+
+ List<AcElementStatistics> getResponse;
+
+ // Return empty list when no data present in db
+ getResponse = acElementStatisticsProvider.getAcElementStatistics(null, null, null, null);
+ assertThat(getResponse).isEmpty();
+
+ acElementStatisticsProvider.createAcElementStatistics(inputAcElementStats.getAcElementStatistics());
+ ToscaConceptIdentifier identifier = inputAcElementStats.getAcElementStatistics().get(0).getParticipantId();
+ Instant instant = inputAcElementStats.getAcElementStatistics().get(0).getTimeStamp();
+ String id = inputAcElementStats.getAcElementStatistics().get(0).getId().toString();
+ assertEquals(1, acElementStatisticsProvider
+ .getAcElementStatistics(identifier.getName(), identifier.getVersion(), id, instant).size());
+
+ assertEquals(1, acElementStatisticsProvider
+ .getFilteredAcElementStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size());
+ }
+}
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
new file mode 100644
index 000000000..0a367eed8
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java
@@ -0,0 +1,305 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.persistence.provider;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import java.util.Optional;
+import javax.persistence.EntityNotFoundException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
+import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition;
+import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository;
+import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplateRepository;
+import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplatesRepository;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
+
+class AutomationCompositionProviderTest {
+
+ private static final String LIST_IS_NULL = "automationCompositions is marked .*ull but is null";
+ private static final String OBJECT_IS_NULL = "automationComposition is marked non-null but is null";
+
+ private static final String ID_NAME = "PMSHInstance1";
+ private static final String ID_VERSION = "1.0.1";
+ private static final String ID_NAME_NOT_EXTST = "not_exist";
+ private static final String ID_NAME_NOT_VALID = "not_valid";
+
+ private static final Coder CODER = new StandardCoder();
+ private static final String AUTOMATION_COMPOSITION_JSON =
+ "src/test/resources/providers/TestAutomationCompositions.json";
+ private static final String TOSCA_TEMPLATE_YAML = "examples/acm/PMSubscriptionHandling.yaml";
+
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+
+ private AutomationCompositions inputAutomationCompositions;
+ private List<JpaAutomationComposition> inputAutomationCompositionsJpa;
+ private String originalJson = ResourceUtils.getResourceAsString(AUTOMATION_COMPOSITION_JSON);
+
+ @BeforeEach
+ void beforeSetupDao() throws Exception {
+ inputAutomationCompositions = CODER.decode(originalJson, AutomationCompositions.class);
+ inputAutomationCompositionsJpa =
+ ProviderUtils.getJpaAndValidateList(inputAutomationCompositions.getAutomationCompositionList(),
+ JpaAutomationComposition::new, "automation compositions");
+ }
+
+ @Test
+ void testAutomationCompositionsSave() throws Exception {
+ var automationCompositionRepository = mock(AutomationCompositionRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository,
+ mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+
+ assertThatThrownBy(() -> {
+ automationCompositionProvider.saveAutomationCompositions(null);
+ }).hasMessageMatching(LIST_IS_NULL);
+
+ when(automationCompositionRepository.saveAll(inputAutomationCompositionsJpa))
+ .thenReturn(inputAutomationCompositionsJpa);
+
+ var createdAutomationCompositions = new AutomationCompositions();
+ createdAutomationCompositions.setAutomationCompositionList(automationCompositionProvider
+ .saveAutomationCompositions(inputAutomationCompositions.getAutomationCompositionList()));
+
+ assertEquals(inputAutomationCompositions, createdAutomationCompositions);
+
+ when(automationCompositionRepository.saveAll(any())).thenThrow(IllegalArgumentException.class);
+
+ assertThatThrownBy(() -> {
+ automationCompositionProvider
+ .saveAutomationCompositions(inputAutomationCompositions.getAutomationCompositionList());
+ }).hasMessageMatching("Error in save AutomationCompositions");
+ }
+
+ @Test
+ void testAutomationCompositionSave() throws Exception {
+ var automationCompositionRepository = mock(AutomationCompositionRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository,
+ mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+
+ assertThatThrownBy(() -> {
+ automationCompositionProvider.saveAutomationComposition(null);
+ }).hasMessageMatching(OBJECT_IS_NULL);
+
+ when(automationCompositionRepository.save(inputAutomationCompositionsJpa.get(0)))
+ .thenReturn(inputAutomationCompositionsJpa.get(0));
+
+ var createdAutomationComposition = automationCompositionProvider
+ .saveAutomationComposition(inputAutomationCompositions.getAutomationCompositionList().get(0));
+
+ assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(0), createdAutomationComposition);
+
+ when(automationCompositionRepository.save(any())).thenThrow(IllegalArgumentException.class);
+
+ assertThatThrownBy(() -> {
+ automationCompositionProvider
+ .saveAutomationComposition(inputAutomationCompositions.getAutomationCompositionList().get(0));
+ }).hasMessageMatching("Error in save automationComposition");
+ }
+
+ @Test
+ void testGetAutomationCompositions() throws Exception {
+ var automationCompositionRepository = mock(AutomationCompositionRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository,
+ mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+
+ // Return empty list when no data present in db
+ List<AutomationComposition> getResponse = automationCompositionProvider.getAutomationCompositions();
+ assertThat(getResponse).isEmpty();
+
+ automationCompositionProvider
+ .saveAutomationCompositions(inputAutomationCompositions.getAutomationCompositionList());
+
+ var automationComposition0 = inputAutomationCompositions.getAutomationCompositionList().get(1);
+ var name = automationComposition0.getName();
+ var version = automationComposition0.getVersion();
+ var automationComposition1 = inputAutomationCompositions.getAutomationCompositionList().get(1);
+
+ when(automationCompositionRepository.getFiltered(eq(JpaAutomationComposition.class), any(), any()))
+ .thenReturn(List.of(new JpaAutomationComposition(automationComposition0),
+ new JpaAutomationComposition(automationComposition1)));
+ when(automationCompositionRepository.findById(automationComposition0.getKey().asIdentifier().asConceptKey()))
+ .thenReturn(Optional.of(new JpaAutomationComposition(automationComposition0)));
+ when(automationCompositionRepository.getById(automationComposition0.getKey().asIdentifier().asConceptKey()))
+ .thenReturn(new JpaAutomationComposition(automationComposition0));
+ when(automationCompositionRepository.getFiltered(JpaAutomationComposition.class, name, version))
+ .thenReturn(List.of(new JpaAutomationComposition(automationComposition0)));
+ when(automationCompositionRepository.findById(automationComposition1.getKey().asIdentifier().asConceptKey()))
+ .thenReturn(Optional.of(new JpaAutomationComposition(automationComposition1)));
+
+ assertEquals(1, automationCompositionProvider.getAutomationCompositions(name, version).size());
+
+ var ac = automationCompositionProvider
+ .findAutomationComposition(new ToscaConceptIdentifier(ID_NAME, ID_VERSION)).get();
+ assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(1), ac);
+
+ ac = automationCompositionProvider.getAutomationComposition(new ToscaConceptIdentifier(ID_NAME, ID_VERSION));
+ assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(1), ac);
+
+ when(automationCompositionRepository.getById(any())).thenThrow(EntityNotFoundException.class);
+
+ assertThatThrownBy(() -> {
+ automationCompositionProvider
+ .getAutomationComposition(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION));
+ }).hasMessageMatching("AutomationComposition not found");
+
+ ac = automationCompositionProvider.findAutomationComposition(ID_NAME, ID_VERSION).get();
+ assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(1), ac);
+
+ assertThat(automationCompositionProvider
+ .findAutomationComposition(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION))).isEmpty();
+
+ when(automationCompositionRepository.findById(any())).thenThrow(IllegalArgumentException.class);
+
+ assertThatThrownBy(() -> {
+ automationCompositionProvider.findAutomationComposition(ID_NAME_NOT_VALID, ID_VERSION);
+ }).hasMessageMatching("Not valid parameter");
+ }
+
+ @Test
+ void testDeleteAutomationComposition() throws Exception {
+ var automationCompositionRepository = mock(AutomationCompositionRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository,
+ mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+
+ assertThatThrownBy(() -> {
+ automationCompositionProvider.deleteAutomationComposition(ID_NAME_NOT_EXTST, ID_VERSION);
+ }).hasMessageMatching(".*.failed, automation composition does not exist");
+
+ var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0);
+ var name = automationComposition.getName();
+ var version = automationComposition.getVersion();
+
+ when(automationCompositionRepository.findById(new PfConceptKey(name, version)))
+ .thenReturn(Optional.of(inputAutomationCompositionsJpa.get(0)));
+
+ AutomationComposition deletedAc = automationCompositionProvider.deleteAutomationComposition(name, version);
+ assertEquals(automationComposition, deletedAc);
+ }
+
+ @Test
+ void testDeleteAllInstanceProperties() throws Exception {
+ var automationCompositionProvider =
+ new AutomationCompositionProvider(mock(AutomationCompositionRepository.class),
+ mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+ var toscaServiceTemplate = testAutomationCompositionRead();
+ automationCompositionProvider.deleteInstanceProperties(
+ automationCompositionProvider.saveInstanceProperties(toscaServiceTemplate),
+ automationCompositionProvider.getAllNodeTemplates());
+ assertThat(automationCompositionProvider.getAutomationCompositions()).isEmpty();
+ }
+
+ @Test
+ void testSaveAndDeleteInstanceProperties() throws Exception {
+ var toscaNodeTemplatesRepository = mock(ToscaNodeTemplatesRepository.class);
+ var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(
+ mock(AutomationCompositionRepository.class), toscaNodeTemplateRepository, toscaNodeTemplatesRepository);
+ var toscaServiceTest = testAutomationCompositionRead();
+
+ automationCompositionProvider.saveInstanceProperties(toscaServiceTest);
+ verify(toscaNodeTemplatesRepository).save(any());
+
+ var name = "org.onap.policy.acm.PolicyAutomationCompositionParticipant";
+ var version = "2.3.1";
+ var elem = toscaServiceTest.getToscaTopologyTemplate().getNodeTemplates().get(name);
+ when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version))
+ .thenReturn(List.of(new JpaToscaNodeTemplate(elem)));
+
+ var filtered = automationCompositionProvider.getNodeTemplates(name, version);
+ verify(toscaNodeTemplateRepository).getFiltered(JpaToscaNodeTemplate.class, name, version);
+
+ automationCompositionProvider
+ .deleteInstanceProperties(automationCompositionProvider.saveInstanceProperties(toscaServiceTest), filtered);
+
+ verify(toscaNodeTemplateRepository).delete(any());
+ }
+
+ @Test
+ void testGetNodeTemplates() throws Exception {
+ var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class);
+ var automationCompositionProvider =
+ new AutomationCompositionProvider(mock(AutomationCompositionRepository.class), toscaNodeTemplateRepository,
+ mock(ToscaNodeTemplatesRepository.class));
+
+ var toscaNodeTemplate0 = new JpaToscaNodeTemplate(new PfConceptKey(ID_NAME, ID_VERSION));
+ var toscaNodeTemplate1 = new JpaToscaNodeTemplate(new PfConceptKey("PMSHInstance2", ID_VERSION));
+
+ when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, null, null))
+ .thenReturn(List.of(toscaNodeTemplate0, toscaNodeTemplate1));
+ when(toscaNodeTemplateRepository.findAll()).thenReturn(List.of(toscaNodeTemplate0, toscaNodeTemplate1));
+ when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, ID_NAME, ID_VERSION))
+ .thenReturn(List.of(toscaNodeTemplate0));
+
+ // Getting all nodes
+ var listNodes = automationCompositionProvider.getAllNodeTemplates();
+ assertNotNull(listNodes);
+ assertThat(listNodes).hasSize(2);
+
+ listNodes = automationCompositionProvider.getNodeTemplates(ID_NAME, ID_VERSION);
+ assertNotNull(listNodes);
+ assertThat(listNodes).hasSize(1);
+
+ listNodes = automationCompositionProvider.getAllNodeTemplates();
+ assertNotNull(listNodes);
+ assertThat(listNodes).hasSize(2);
+
+ var nodeTemplateFilter =
+ ToscaTypedEntityFilter.<ToscaNodeTemplate>builder().name(ID_NAME).version(ID_VERSION).build();
+
+ listNodes = automationCompositionProvider.getFilteredNodeTemplates(nodeTemplateFilter);
+ assertNotNull(listNodes);
+ assertThat(listNodes).hasSize(1);
+
+ assertThatThrownBy(() -> {
+ automationCompositionProvider.getFilteredNodeTemplates(null);
+ }).hasMessageMatching("filter is marked non-null but is null");
+ }
+
+ private static ToscaServiceTemplate testAutomationCompositionRead() {
+ return testAutomationCompositionYamlSerialization(TOSCA_TEMPLATE_YAML);
+ }
+
+ private static ToscaServiceTemplate testAutomationCompositionYamlSerialization(
+ String automationCompositionFilePath) {
+ var automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath);
+ return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
index 9b48735f6..f537e2cd7 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider;
+package org.onap.policy.clamp.models.acm.persistence.provider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -33,9 +33,9 @@ import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantRepository;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant;
+import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantRepository;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -84,7 +84,7 @@ class ParticipantProviderTest {
}
@Test
- void testGetControlLoops() throws Exception {
+ void testGetAutomationCompositions() throws Exception {
var participantRepository = mock(ParticipantRepository.class);
var participantProvider = new ParticipantProvider(participantRepository);
@@ -119,7 +119,7 @@ class ParticipantProviderTest {
.thenReturn(jpaParticipantList);
final ToscaTypedEntityFilter<Participant> filter = ToscaTypedEntityFilter.<Participant>builder()
- .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
+ .type("org.onap.domain.pmsh.PMSHAutomationCompositionDefinition").build();
assertEquals(1, participantProvider.getFilteredParticipants(filter).size());
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java
index 16f4958a9..3c6b1eb83 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider;
+package org.onap.policy.clamp.models.acm.persistence.provider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -33,10 +33,10 @@ import java.time.Instant;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantStatisticsRepository;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList;
+import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantStatistics;
+import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantStatisticsRepository;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -89,7 +89,7 @@ class ParticipantStatisticsProviderTest {
}
@Test
- void testGetControlLoops() throws Exception {
+ void testGetAutomationCompositions() throws Exception {
// Return empty list when no data present in db
List<ParticipantStatistics> getResponse =
participantStatisticsProvider.getParticipantStatistics(null, null, null);
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java
index 523a4fb88..4d998717e 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider;
+package org.onap.policy.clamp.models.acm.persistence.provider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -32,7 +32,7 @@ import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaServiceTemplateRepository;
+import org.onap.policy.clamp.models.acm.persistence.repository.ToscaServiceTemplateRepository;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -117,7 +117,7 @@ class ServiceTemplateProviderTest {
var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository);
assertThatThrownBy(() -> serviceTemplateProvider.getToscaServiceTemplate("Name", "1.0.0"))
- .hasMessage("Control Loop definitions not found");
+ .hasMessage("Automation composition definitions not found");
}
@Test
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImplTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImplTest.java
index 8b5357457..7210a6afd 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImplTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImplTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository;
+package org.onap.policy.clamp.models.acm.persistence.repository;
import static org.assertj.core.api.Assertions.assertThat;
@@ -26,9 +26,9 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ProviderUtils;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
+import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition;
+import org.onap.policy.clamp.models.acm.persistence.provider.ProviderUtils;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -38,11 +38,12 @@ import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.provider.impl.ModelsProvider;
class FilterRepositoryImplTest {
- private static final String CONTROL_LOOP_JSON = "src/test/resources/providers/TestControlLoops.json";
+ private static final String AUTOMATION_COMPOSITION_JSON =
+ "src/test/resources/providers/TestAutomationCompositions.json";
private static final Coder CODER = new StandardCoder();
private static final AtomicInteger dbNameCounter = new AtomicInteger();
- private static final String originalJson = ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON);
- private static List<JpaControlLoop> jpaControlLoops;
+ private static final String originalJson = ResourceUtils.getResourceAsString(AUTOMATION_COMPOSITION_JSON);
+ private static List<JpaAutomationComposition> jpaAutomationCompositions;
private PfDao pfDao;
@BeforeEach
@@ -51,17 +52,18 @@ class FilterRepositoryImplTest {
parameters.setDatabaseDriver("org.h2.Driver");
parameters.setName("PolicyProviderParameterGroup");
parameters.setImplementation("org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
- parameters.setDatabaseUrl("jdbc:h2:mem:controlLoopProviderTestDb" + dbNameCounter.getAndDecrement());
+ parameters.setDatabaseUrl("jdbc:h2:mem:automationCompositionProviderTestDb" + dbNameCounter.getAndDecrement());
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword("P01icY");
parameters.setPersistenceUnit("ToscaConceptTest");
pfDao = ModelsProvider.init(parameters);
- var inputControlLoops = CODER.decode(originalJson, ControlLoops.class);
- jpaControlLoops = ProviderUtils.getJpaAndValidateList(inputControlLoops.getControlLoopList(),
- JpaControlLoop::new, "ControlLoops");
+ var inputAutomationCompositions = CODER.decode(originalJson, AutomationCompositions.class);
+ jpaAutomationCompositions =
+ ProviderUtils.getJpaAndValidateList(inputAutomationCompositions.getAutomationCompositionList(),
+ JpaAutomationComposition::new, "AutomationCompositions");
- pfDao.createCollection(jpaControlLoops);
+ pfDao.createCollection(jpaAutomationCompositions);
}
@Test
@@ -77,10 +79,11 @@ class FilterRepositoryImplTest {
return pfDao;
}
};
- var result = filterRepositoryImpl.getFiltered(JpaControlLoop.class, null, null);
+ var result = filterRepositoryImpl.getFiltered(JpaAutomationComposition.class, null, null);
assertThat(result).hasSize(2);
- result = filterRepositoryImpl.getFiltered(JpaControlLoop.class, jpaControlLoops.get(0).getName(), null);
+ result = filterRepositoryImpl.getFiltered(JpaAutomationComposition.class,
+ jpaAutomationCompositions.get(0).getName(), null);
assertThat(result).hasSize(1);
}
@@ -96,11 +99,11 @@ class FilterRepositoryImplTest {
// @formatter:off
PfFilterParameters filterParams = PfFilterParameters
.builder()
- .name(jpaControlLoops.get(0).getName())
+ .name(jpaAutomationCompositions.get(0).getName())
.build();
// @formatter:on
- var result = filterRepositoryImpl.getFiltered(JpaControlLoop.class, filterParams);
+ var result = filterRepositoryImpl.getFiltered(JpaAutomationComposition.class, filterParams);
assertThat(result).hasSize(1);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/rest/RestUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/rest/RestUtilsTest.java
index 4dedae200..a62f78ba2 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/rest/RestUtilsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/rest/RestUtilsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.models.rest;
+package org.onap.policy.clamp.models.acm.rest;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
new file mode 100644
index 000000000..a5434240a
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.utils;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
+
+class AcmUtilsTest {
+
+ private ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.0.0");
+ private ToscaConceptIdentifier idNode =
+ new ToscaConceptIdentifier("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", "0.0.0");
+
+ @Test
+ void testCommonUtilsParticipantUpdate() {
+ var acElement = new AutomationCompositionElement();
+ List<ParticipantUpdates> participantUpdates = new ArrayList<>();
+ assertThat(participantUpdates).isEmpty();
+
+ AcmUtils.prepareParticipantUpdate(acElement, participantUpdates);
+ assertThat(participantUpdates).isNotEmpty();
+ assertEquals(acElement, participantUpdates.get(0).getAutomationCompositionElementList().get(0));
+
+ AcmUtils.prepareParticipantUpdate(acElement, participantUpdates);
+ assertNotEquals(id, participantUpdates.get(0).getParticipantId());
+
+ acElement.setParticipantId(id);
+ acElement.setParticipantType(id);
+ AcmUtils.prepareParticipantUpdate(acElement, participantUpdates);
+ assertEquals(id, participantUpdates.get(1).getParticipantId());
+ }
+
+ @Test
+ void testCommonUtilsServiceTemplate() {
+ var acElement = new AutomationCompositionElement();
+ var toscaServiceTemplate = getDummyToscaServiceTemplate();
+ AcmUtils.setServiceTemplatePolicyInfo(acElement, toscaServiceTemplate);
+ assertEquals(getDummyToscaDataTypeMap(), acElement.getToscaServiceTemplateFragment().getDataTypes());
+ }
+
+ @Test
+ void testCommonUtilsDefinitionUpdate() {
+ var toscaServiceTemplate = getDummyToscaServiceTemplate();
+ List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
+ assertThat(participantDefinitionUpdates).isEmpty();
+
+ checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates);
+ assertThat(participantDefinitionUpdates).isNotEmpty();
+ assertEquals(id, participantDefinitionUpdates.get(0).getParticipantType());
+
+ checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates);
+ assertEquals(idNode, participantDefinitionUpdates.get(0).getAutomationCompositionElementDefinitionList().get(0)
+ .getAcElementDefinitionId());
+ }
+
+ private ToscaServiceTemplate getDummyToscaServiceTemplate() {
+ var toscaServiceTemplate = new ToscaServiceTemplate();
+ var policyTypes = getDummyPolicyTypesMap();
+ toscaServiceTemplate.setPolicyTypes(policyTypes);
+
+ var dataTypes = getDummyToscaDataTypeMap();
+ dataTypes.put("onap.datatypes.ToscaConceptIdentifier", new ToscaDataType());
+ toscaServiceTemplate.setDataTypes(dataTypes);
+
+ var toscaTopologyTemplate = new ToscaTopologyTemplate();
+ Map<String, ToscaPolicy> policy = new HashMap<>();
+ toscaTopologyTemplate.setPolicies(List.of(policy));
+ var nodeTemplates = getDummyNodeTemplates();
+ toscaTopologyTemplate.setNodeTemplates(nodeTemplates);
+
+ toscaServiceTemplate.setToscaTopologyTemplate(toscaTopologyTemplate);
+ toscaServiceTemplate.setDerivedFrom("tosca.nodetypes.Root");
+ toscaServiceTemplate.setDescription("description");
+ toscaServiceTemplate.setMetadata(null);
+ toscaServiceTemplate.setName("name");
+ toscaServiceTemplate.setToscaDefinitionsVersion("1.0.0");
+ toscaServiceTemplate.setVersion("1.0.1");
+ return toscaServiceTemplate;
+ }
+
+ private Map<String, ToscaPolicyType> getDummyPolicyTypesMap() {
+ Map<String, ToscaPolicyType> policyTypes = new HashMap<>();
+ policyTypes.put("onap.policies.Match", new ToscaPolicyType());
+ return policyTypes;
+ }
+
+ private Map<String, ToscaDataType> getDummyToscaDataTypeMap() {
+ Map<String, ToscaDataType> dataTypes = new HashMap<>();
+ dataTypes.put("onap.datatypes.ToscaConceptIdentifier", new ToscaDataType());
+ return dataTypes;
+ }
+
+ private Map<String, ToscaNodeTemplate> getDummyNodeTemplates() {
+ Map<String, ToscaNodeTemplate> nodeTemplates = new HashMap<>();
+ var nodeTemplate = new ToscaNodeTemplate();
+ nodeTemplate.setType("org.onap.policy.clamp.acm.AutomationCompositionElement");
+ nodeTemplates.put("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", nodeTemplate);
+ return nodeTemplates;
+ }
+
+ private void checkParticipantDefinitionUpdate(ToscaServiceTemplate toscaServiceTemplate,
+ List<ParticipantDefinition> participantDefinitionUpdates) {
+
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate()
+ .getNodeTemplates().entrySet()) {
+ if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
+ toscaServiceTemplate)) {
+ AcmUtils.prepareParticipantDefinitionUpdate(id, toscaInputEntry.getKey(), toscaInputEntry.getValue(),
+ participantDefinitionUpdates, null);
+ }
+ }
+ }
+}