diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-04-05 16:32:38 +0100 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-04-11 10:06:21 +0100 |
commit | 9f1fdf9f419c1724a9cf75a20fdd24df191766bd (patch) | |
tree | 16db3d01d45ae45a4fc776d9d23596ec2c6bcc58 /models | |
parent | 2ca7552978f5389ef5ed2e5d4be3cb43e446f7c6 (diff) |
Add UseState and OperationalState support in ACM
Issue-ID: POLICY-4639
Change-Id: Iac5249c054bf41d830463826a8f61f477c48235b
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models')
10 files changed, 210 insertions, 56 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java index 8f8a54f39..611336058 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java @@ -37,6 +37,10 @@ public class AcElementDeployAck { // State of the AutomationCompositionElement private LockState lockState; + private String operationalState; + + private String useState; + // Result: Success/Fail. private Boolean result; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java index 018031624..edc9e1c5f 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java @@ -54,6 +54,10 @@ public class AutomationCompositionElement { @NonNull private LockState lockState = LockState.LOCKED; + private String operationalState; + + private String useState; + private String description; // A map indexed by the property name. Each map entry is the serialized value of the property, @@ -73,5 +77,7 @@ public class AutomationCompositionElement { this.properties = PfUtils.mapMap(otherElement.properties, UnaryOperator.identity()); this.deployState = otherElement.deployState; this.lockState = otherElement.lockState; + this.operationalState = otherElement.operationalState; + this.useState = otherElement.useState; } } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementInfo.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementInfo.java new file mode 100644 index 000000000..1eb4bf8cb --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementInfo.java @@ -0,0 +1,58 @@ +/*- + * ============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.concepts; + +import java.util.UUID; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * Class to represent a automation composition element info instance. + */ +@NoArgsConstructor +@Data +@ToString +public class AutomationCompositionElementInfo { + + private UUID automationCompositionElementId; + + private DeployState deployState = DeployState.UNDEPLOYED; + + private LockState lockState = LockState.LOCKED; + + private String operationalState; + + private String useState; + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param otherElement the other element to copy from + */ + public AutomationCompositionElementInfo(AutomationCompositionElementInfo otherElement) { + this.automationCompositionElementId = otherElement.automationCompositionElementId; + this.deployState = otherElement.deployState; + this.lockState = otherElement.lockState; + this.operationalState = otherElement.operationalState; + this.useState = otherElement.useState; + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java index 17875c429..64cfa8034 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java @@ -20,10 +20,13 @@ package org.onap.policy.clamp.models.acm.concepts; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; +import org.onap.policy.models.base.PfUtils; /** * Class to represent a automation composition info instance. @@ -39,6 +42,8 @@ public class AutomationCompositionInfo { private LockState lockState = LockState.LOCKED; + private List<AutomationCompositionElementInfo> elements = new ArrayList<>(); + /** * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. * @@ -48,5 +53,6 @@ public class AutomationCompositionInfo { this.automationCompositionId = otherElement.automationCompositionId; this.deployState = otherElement.deployState; this.lockState = otherElement.lockState; + this.elements = PfUtils.mapList(otherElement.elements, AutomationCompositionElementInfo::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java index 4c3a6a3be..4ba336edf 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java @@ -93,6 +93,12 @@ public class JpaAutomationCompositionElement extends Validated private LockState lockState; @Column + private String operationalState; + + @Column + private String useState; + + @Column private String description; @Lob @@ -152,6 +158,8 @@ public class JpaAutomationCompositionElement extends Validated this.properties = (copyConcept.properties != null ? new LinkedHashMap<>(copyConcept.properties) : null); this.deployState = copyConcept.deployState; this.lockState = copyConcept.lockState; + this.operationalState = copyConcept.operationalState; + this.useState = copyConcept.useState; } /** @@ -174,6 +182,8 @@ public class JpaAutomationCompositionElement extends Validated element.setProperties(PfUtils.mapMap(properties, UnaryOperator.identity())); element.setDeployState(deployState); element.setLockState(lockState); + element.setOperationalState(operationalState); + element.setUseState(useState); return element; } @@ -186,6 +196,8 @@ public class JpaAutomationCompositionElement extends Validated this.properties = PfUtils.mapMap(element.getProperties(), UnaryOperator.identity()); this.deployState = element.getDeployState(); this.lockState = element.getLockState(); + this.operationalState = element.getOperationalState(); + this.useState = element.getUseState(); } @Override @@ -227,6 +239,16 @@ public class JpaAutomationCompositionElement extends Validated return result; } + result = ObjectUtils.compare(useState, other.useState); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(operationalState, other.operationalState); + if (result != 0) { + return result; + } + return ObjectUtils.compare(description, other.description); } } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java index 058feae76..959fd7637 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java @@ -22,6 +22,7 @@ package org.onap.policy.clamp.models.acm.persistence.provider; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -30,9 +31,12 @@ import javax.ws.rs.core.Response.Status; import lombok.AllArgsConstructor; import lombok.NonNull; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationCompositionElement; +import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionElementRepository; import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository; import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.models.base.PfModelRuntimeException; @@ -50,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional; public class AutomationCompositionProvider { private final AutomationCompositionRepository automationCompositionRepository; + private final AutomationCompositionElementRepository acElementRepository; /** * Get automation composition. @@ -182,4 +187,25 @@ public class AutomationCompositionProvider { return jpaDeleteAutomationComposition.get().toAuthorative(); } + + /** + * Upgrade States. + * + * @param automationCompositionInfoList list of AutomationCompositionInfo + */ + public void upgradeStates(@NonNull final List<AutomationCompositionInfo> automationCompositionInfoList) { + if (automationCompositionInfoList.isEmpty()) { + return; + } + List<JpaAutomationCompositionElement> jpaList = new ArrayList<>(); + for (var acInstance : automationCompositionInfoList) { + for (var element : acInstance.getElements()) { + var jpa = acElementRepository.getReferenceById(element.getAutomationCompositionElementId().toString()); + jpa.setUseState(element.getUseState()); + jpa.setOperationalState(element.getOperationalState()); + jpaList.add(jpa); + } + } + acElementRepository.saveAll(jpaList); + } } 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 index 8c50b01b6..95a169960 100644 --- 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 @@ -50,7 +50,7 @@ class AutomationCompositionDeployAckTest { // verify with all values orig.setAutomationCompositionId(UUID.randomUUID()); orig.setParticipantId(CommonTestData.getParticipantId()); - var acElementResult = new AcElementDeployAck(DeployState.DEPLOYED, LockState.LOCKED, + var acElementResult = new AcElementDeployAck(DeployState.DEPLOYED, LockState.LOCKED, "", "", true, "AutomationCompositionElement result"); final var automationCompositionResultMap = Map.of(UUID.randomUUID(), acElementResult); orig.setAutomationCompositionResultMap(automationCompositionResultMap); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java index 711af2f81..894d67daf 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementInfo; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.LockState; @@ -54,6 +55,7 @@ class ParticipantStatusTest { // verify with all values var automationCompositionId = UUID.randomUUID(); + var acElementId = UUID.randomUUID(); orig.setAutomationCompositionId(automationCompositionId); var participantId = CommonTestData.getParticipantId(); orig.setParticipantId(participantId); @@ -61,7 +63,7 @@ class ParticipantStatusTest { orig.setState(ParticipantState.ON_LINE); orig.setTimestamp(Instant.ofEpochMilli(3000)); - var acInfo = getAutomationCompositionInfo(automationCompositionId); + var acInfo = getAutomationCompositionInfo(automationCompositionId, acElementId); orig.setAutomationCompositionInfoList(List.of(acInfo)); var participantDefinitionUpdate = new ParticipantDefinition(); @@ -76,12 +78,19 @@ class ParticipantStatusTest { assertSerializable(orig, ParticipantStatus.class); } - private AutomationCompositionInfo getAutomationCompositionInfo(UUID id) { + private AutomationCompositionInfo getAutomationCompositionInfo(UUID id, UUID acElementId) { var acInfo = new AutomationCompositionInfo(); acInfo.setDeployState(DeployState.DEPLOYED); acInfo.setLockState(LockState.LOCKED); acInfo.setAutomationCompositionId(id); + var acInfoElement = new AutomationCompositionElementInfo(); + acInfoElement.setAutomationCompositionElementId(acElementId); + acInfoElement.setDeployState(DeployState.DEPLOYED); + acInfoElement.setLockState(LockState.LOCKED); + acInfoElement.setOperationalState("DEFAULT"); + acInfoElement.setUseState("IDLE"); + acInfo.getElements().add(acInfoElement); return acInfo; } diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java index e9df9b7e5..2a79aee08 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java @@ -122,8 +122,13 @@ class JpaAutomationCompositionElementTest { assertEquals(ELEMENT_ID, testJpaAcElement.getElementId()); - var testJpaAutomationCompositionElement2 = new JpaAutomationCompositionElement(testJpaAcElement); - assertEquals(testJpaAcElement, testJpaAutomationCompositionElement2); + var testJpaAcElement2 = new JpaAutomationCompositionElement(testJpaAcElement); + assertEquals(testJpaAcElement, testJpaAcElement2); + + testJpaAcElement2 = new JpaAutomationCompositionElement(testJpaAcElement.toAuthorative()); + testJpaAcElement2.setElementId(ELEMENT_ID); + testJpaAcElement2.setInstanceId(INSTANCE_ID); + assertEquals(testJpaAcElement, testJpaAcElement2); } @Test @@ -138,52 +143,60 @@ class JpaAutomationCompositionElementTest { @Test void testJpaAutomationCompositionElementCompareTo() { - var testJpaAutomationCompositionElement = createJpaAutomationCompositionElementInstance(); + var testJpaAcElement = createJpaAutomationCompositionElementInstance(); - var otherJpaAutomationCompositionElement = - new JpaAutomationCompositionElement(testJpaAutomationCompositionElement); - assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - assertEquals(-1, testJpaAutomationCompositionElement.compareTo(null)); - assertEquals(0, testJpaAutomationCompositionElement.compareTo(testJpaAutomationCompositionElement)); + var otherJpaAcElement = + new JpaAutomationCompositionElement(testJpaAcElement); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + assertEquals(-1, testJpaAcElement.compareTo(null)); + assertEquals(0, testJpaAcElement.compareTo(testJpaAcElement)); assertNotEquals(0, - testJpaAutomationCompositionElement.compareTo(new DummyJpaAutomationCompositionElementChild())); - - testJpaAutomationCompositionElement.setElementId("BadValue"); - assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - testJpaAutomationCompositionElement.setElementId(ELEMENT_ID); - assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - - testJpaAutomationCompositionElement.setInstanceId("BadValue"); - assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - testJpaAutomationCompositionElement.setInstanceId(INSTANCE_ID); - 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.setDeployState(DeployState.DEPLOYED); - assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - testJpaAutomationCompositionElement.setDeployState(DeployState.UNDEPLOYED); - assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - - testJpaAutomationCompositionElement.setLockState(LockState.UNLOCKED); - assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - testJpaAutomationCompositionElement.setLockState(LockState.LOCKED); - assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - - assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - testJpaAutomationCompositionElement.setParticipantId(UUID.randomUUID().toString()); - assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement)); - - assertEquals(testJpaAutomationCompositionElement, - new JpaAutomationCompositionElement(testJpaAutomationCompositionElement)); + testJpaAcElement.compareTo(new DummyJpaAutomationCompositionElementChild())); + + testJpaAcElement.setElementId("BadValue"); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + testJpaAcElement.setElementId(ELEMENT_ID); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + testJpaAcElement.setInstanceId("BadValue"); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + testJpaAcElement.setInstanceId(INSTANCE_ID); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + testJpaAcElement.setDefinition(new PfConceptKey("BadValue", "0.0.1")); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + testJpaAcElement.setDefinition(new PfConceptKey("aceDef", "0.0.1")); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + testJpaAcElement.setDescription("Description"); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + testJpaAcElement.setDescription(null); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + testJpaAcElement.setDeployState(DeployState.DEPLOYED); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + testJpaAcElement.setDeployState(DeployState.UNDEPLOYED); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + testJpaAcElement.setLockState(LockState.UNLOCKED); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + testJpaAcElement.setLockState(LockState.LOCKED); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + testJpaAcElement.setUseState("BadValue"); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + testJpaAcElement.setUseState("IDLE"); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + testJpaAcElement.setOperationalState("BadValue"); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + testJpaAcElement.setOperationalState("DEFAULT"); + assertEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + testJpaAcElement.setParticipantId(UUID.randomUUID().toString()); + assertNotEquals(0, testJpaAcElement.compareTo(otherJpaAcElement)); + + assertEquals(testJpaAcElement, new JpaAutomationCompositionElement(testJpaAcElement)); } @Test @@ -229,6 +242,8 @@ class JpaAutomationCompositionElementTest { automationCompositionElement.setDefinition(new ToscaConceptIdentifier("aceDef", "0.0.1")); automationCompositionElement.setParticipantId(CommonTestData.getParticipantId()); automationCompositionElement.setProperties(Map.of("key", "{}")); + automationCompositionElement.setUseState("IDLE"); + automationCompositionElement.setOperationalState("DEFAULT"); return automationCompositionElement; } diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java index ba1e33c27..0991c1bd0 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java @@ -35,6 +35,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; 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.AutomationCompositionElementRepository; import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.StandardCoder; @@ -64,7 +65,8 @@ class AutomationCompositionProviderTest { @Test void testAutomationCompositionCreate() { var automationCompositionRepository = mock(AutomationCompositionRepository.class); - var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(AutomationCompositionElementRepository.class)); when(automationCompositionRepository.save(any(JpaAutomationComposition.class))) .thenReturn(inputAutomationCompositionsJpa.get(0)); @@ -78,7 +80,8 @@ class AutomationCompositionProviderTest { @Test void testAutomationCompositionUpdate() { var automationCompositionRepository = mock(AutomationCompositionRepository.class); - var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(AutomationCompositionElementRepository.class)); assertThatThrownBy(() -> automationCompositionProvider.updateAutomationComposition(null)) .hasMessageMatching(OBJECT_IS_NULL); @@ -95,7 +98,8 @@ class AutomationCompositionProviderTest { @Test void testGetAutomationCompositions() throws Exception { var automationCompositionRepository = mock(AutomationCompositionRepository.class); - var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(AutomationCompositionElementRepository.class)); var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0); var acList = automationCompositionProvider.getAutomationCompositions(UUID.randomUUID(), @@ -112,7 +116,8 @@ class AutomationCompositionProviderTest { @Test void testGetAutomationComposition() { var automationCompositionRepository = mock(AutomationCompositionRepository.class); - var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(AutomationCompositionElementRepository.class)); var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0); assertThatThrownBy( @@ -128,7 +133,8 @@ class AutomationCompositionProviderTest { @Test void testFindAutomationComposition() { var automationCompositionRepository = mock(AutomationCompositionRepository.class); - var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(AutomationCompositionElementRepository.class)); var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0); var acOpt = automationCompositionProvider.findAutomationComposition(automationComposition.getInstanceId()); @@ -151,7 +157,8 @@ class AutomationCompositionProviderTest { @Test void testGetAcInstancesByCompositionId() { var automationCompositionRepository = mock(AutomationCompositionRepository.class); - var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(AutomationCompositionElementRepository.class)); var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0); when(automationCompositionRepository.findByCompositionId(automationComposition.getCompositionId().toString())) @@ -164,7 +171,8 @@ class AutomationCompositionProviderTest { @Test void testDeleteAutomationComposition() { var automationCompositionRepository = mock(AutomationCompositionRepository.class); - var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository); + var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository, + mock(AutomationCompositionElementRepository.class)); assertThatThrownBy(() -> automationCompositionProvider.deleteAutomationComposition(UUID.randomUUID())) .hasMessageMatching(".*.failed, automation composition does not exist"); |