From 7f762dfa19f673241f8ea1b2ff3d56d2d58bdcdb Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Mon, 30 Jan 2023 13:43:10 +0000 Subject: Refactor ACM Update message to ACM Deploy message in ACM Refactor ACM Update message to ACM Deploy message in ACM and add AcElementDeploy in Deploy message. AutomationCompositionElement will be removed from the message after POLICY-4506 and POLICY-4507. Issue-ID: POLICY-4543 Change-Id: I8444e15b3b4cb1209ffd083fb965e0707fbd9625 Signed-off-by: FrancescoFioraEst --- .../participant/AutomationCompositionAckTest.java | 66 ---------------- .../AutomationCompositionDeployAckTest.java | 66 ++++++++++++++++ .../AutomationCompositionDeployTest.java | 87 ++++++++++++++++++++++ .../AutomationCompositionUpdateTest.java | 87 ---------------------- .../dmaap/participant/ParticipantPojosTest.java | 13 ++-- .../clamp/models/acm/utils/AcmUtilsTest.java | 4 +- 6 files changed, 160 insertions(+), 163 deletions(-) delete mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java (limited to 'models/src/test') diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java deleted file mode 100644 index 8c5528cc6..000000000 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 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.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertEquals; -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.models.acm.concepts.AutomationCompositionElementAck; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; -import org.onap.policy.clamp.models.acm.utils.CommonTestData; -import org.onap.policy.common.utils.coder.CoderException; - -class AutomationCompositionAckTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new AutomationCompositionAck((AutomationCompositionAck) null)) - .isInstanceOf(NullPointerException.class); - - final var orig = new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new AutomationCompositionAck(orig).toString())); - - // verify with all values - orig.setAutomationCompositionId(UUID.randomUUID()); - orig.setParticipantId(CommonTestData.getParticipantId()); - 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 AutomationCompositionUpdate message"); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new AutomationCompositionAck(orig).toString())); - - assertSerializable(orig, AutomationCompositionAck.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java new file mode 100644 index 000000000..038c140ed --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 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.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +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.models.acm.concepts.AcElementDeployAck; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.utils.CommonTestData; +import org.onap.policy.common.utils.coder.CoderException; + +class AutomationCompositionDeployAckTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new AutomationCompositionDeployAck((AutomationCompositionDeployAck) null)) + .isInstanceOf(NullPointerException.class); + + final var orig = new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new AutomationCompositionDeployAck(orig).toString())); + + // verify with all values + orig.setAutomationCompositionId(UUID.randomUUID()); + orig.setParticipantId(CommonTestData.getParticipantId()); + var acElementResult = new AcElementDeployAck(AutomationCompositionState.UNINITIALISED, null, + 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 AutomationCompositionDeploy message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new AutomationCompositionDeployAck(orig).toString())); + + assertSerializable(orig, AutomationCompositionDeployAck.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployTest.java new file mode 100644 index 000000000..2912dee9b --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 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.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +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.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.ParticipantDeploy; +import org.onap.policy.clamp.models.acm.utils.CommonTestData; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; + +/** + * Test the copy constructor. + */ +class AutomationCompositionDeployTest { + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new AutomationCompositionDeploy(null)).isInstanceOf(NullPointerException.class); + + var orig = new AutomationCompositionDeploy(); + // verify with all values + orig.setAutomationCompositionId(UUID.randomUUID()); + orig.setParticipantId(null); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + var acElement = new AutomationCompositionElement(); + acElement.setId(UUID.randomUUID()); + var id = new ToscaConceptIdentifier("id", "1.2.3"); + acElement.setDefinition(id); + acElement.setDescription("Description"); + acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + acElement.setState(AutomationCompositionState.PASSIVE); + + var participantId = CommonTestData.getParticipantId(); + acElement.setParticipantId(participantId); + + var property = new ToscaProperty(); + property.setName("test"); + property.setType("testType"); + var standardCoder = new StandardCoder(); + var json = standardCoder.encode(property); + var propertiesMap = Map.of("Prop1", (Object) json); + acElement.setProperties(propertiesMap); + + var participantDeploy = new ParticipantDeploy(); + participantDeploy.setParticipantId(participantId); + participantDeploy.setAutomationCompositionElementList(List.of(acElement)); + orig.setParticipantUpdatesList(List.of(participantDeploy)); + + var other = new AutomationCompositionDeploy(orig); + + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); + assertSerializable(orig, AutomationCompositionDeploy.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java deleted file mode 100644 index c1be28958..000000000 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 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.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertEquals; -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.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.clamp.models.acm.utils.CommonTestData; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; - -/** - * Test the copy constructor. - */ -class AutomationCompositionUpdateTest { - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new AutomationCompositionUpdate(null)).isInstanceOf(NullPointerException.class); - - var orig = new AutomationCompositionUpdate(); - // verify with all values - orig.setAutomationCompositionId(UUID.randomUUID()); - orig.setParticipantId(null); - orig.setMessageId(UUID.randomUUID()); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - var acElement = new AutomationCompositionElement(); - acElement.setId(UUID.randomUUID()); - var id = new ToscaConceptIdentifier("id", "1.2.3"); - acElement.setDefinition(id); - acElement.setDescription("Description"); - acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); - acElement.setState(AutomationCompositionState.PASSIVE); - - var participantId = CommonTestData.getParticipantId(); - acElement.setParticipantId(participantId); - - var property = new ToscaProperty(); - property.setName("test"); - property.setType("testType"); - var standardCoder = new StandardCoder(); - var json = standardCoder.encode(property); - var propertiesMap = Map.of("Prop1", (Object) json); - acElement.setProperties(propertiesMap); - - var participantUpdates = new ParticipantUpdates(); - participantUpdates.setParticipantId(participantId); - participantUpdates.setAutomationCompositionElementList(List.of(acElement)); - orig.setParticipantUpdatesList(List.of(participantUpdates)); - - var other = new AutomationCompositionUpdate(orig); - - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); - assertSerializable(orig, AutomationCompositionUpdate.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java index ce23a821f..4a1a2d9de 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,15 +20,12 @@ package org.onap.policy.clamp.models.acm.messages.dmaap.participant; -import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; import com.openpojo.validation.ValidatorBuilder; import com.openpojo.validation.rule.impl.GetterMustExistRule; import com.openpojo.validation.rule.impl.SetterMustExistRule; import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; -import java.util.List; import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.test.ToStringTester; @@ -39,18 +36,18 @@ class ParticipantPojosTest { @Test void testPojos() { - List pojoClasses = + var pojoClasses = PojoClassFactory.getPojoClasses(ParticipantPojosTest.class.getPackageName()); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessage.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionAck.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionAckTest.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionDeployAck.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionDeployAckTest.class)); // @formatter:off - final Validator validator = ValidatorBuilder + final var validator = ValidatorBuilder .create() .with(new ToStringTester()) .with(new SetterMustExistRule()) 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 index c23c38c5b..413139999 100644 --- 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 @@ -39,7 +39,7 @@ import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; -import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy; import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -60,7 +60,7 @@ class AcmUtilsTest { @Test void testCommonUtilsParticipantUpdate() { var acElement = new AutomationCompositionElement(); - List participantUpdates = new ArrayList<>(); + List participantUpdates = new ArrayList<>(); assertThat(participantUpdates).isEmpty(); AcmUtils.prepareParticipantUpdate(acElement, participantUpdates); -- cgit 1.2.3-korg