summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl')
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml78
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java11
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java7
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java15
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java26
5 files changed, 32 insertions, 105 deletions
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml b/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index d5eae7390..000000000
--- a/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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=========================================================
--->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
- <persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-
- <class>org.onap.policy.models.base.PfConceptKey</class>
- <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
- <class>org.onap.policy.models.dao.converters.Uuid2String</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
- <class>org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition</class>
- <class>org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationCompositionElement</class>
- <class>org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant</class>
- <class>org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantSupportedElementType</class>
- <properties>
- <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
- <property name="eclipselink.ddl-generation.output-mode" value="database" />
- <property name="eclipselink.logging.level" value="INFO" />
-
- <!-- property name="eclipselink.logging.level" value="ALL" />
- <property name="eclipselink.logging.level.jpa" value="ALL" />
- <property name="eclipselink.logging.level.ddl" value="ALL" />
- <property name="eclipselink.logging.level.connection" value="ALL" />
- <property name="eclipselink.logging.level.sql" value="ALL" />
- <property name="eclipselink.logging.level.transaction" value="ALL" />
- <property name="eclipselink.logging.level.sequencing" value="ALL" />
- <property name="eclipselink.logging.level.server" value="ALL" />
- <property name="eclipselink.logging.level.query" value="ALL" />
- <property name="eclipselink.logging.level.properties" value="ALL" /-->
- </properties>
- <shared-cache-mode>NONE</shared-cache-mode>
- </persistence-unit>
-</persistence>
-
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java
index 091e3c13c..6d52d7a94 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java
@@ -35,6 +35,7 @@ import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessag
import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantRegisterAckListener;
import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantUpdateListener;
import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.policy.main.parameters.CommonTestData;
import org.onap.policy.clamp.acm.participant.policy.main.utils.TestListenerUtils;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck;
@@ -67,7 +68,7 @@ class ParticipantMessagesTest {
@Test
void testSendParticipantRegisterMessage() {
final ParticipantRegister participantRegisterMsg = new ParticipantRegister();
- participantRegisterMsg.setParticipantId(getParticipantId());
+ participantRegisterMsg.setParticipantId(CommonTestData.getParticipantId());
participantRegisterMsg.setTimestamp(Instant.now());
participantRegisterMsg.setParticipantType(getParticipantType());
@@ -98,7 +99,7 @@ class ParticipantMessagesTest {
@Test
void testSendParticipantDeregisterMessage() {
final ParticipantDeregister participantDeregisterMsg = new ParticipantDeregister();
- participantDeregisterMsg.setParticipantId(getParticipantId());
+ participantDeregisterMsg.setParticipantId(CommonTestData.getParticipantId());
participantDeregisterMsg.setTimestamp(Instant.now());
participantDeregisterMsg.setParticipantType(getParticipantType());
@@ -136,7 +137,7 @@ class ParticipantMessagesTest {
}
// Verify the result of GET participants with what is stored
- assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName());
+ assertEquals(CommonTestData.getParticipantId(), participantHandler.getParticipantId());
}
@Test
@@ -164,10 +165,6 @@ class ParticipantMessagesTest {
}
}
- private ToscaConceptIdentifier getParticipantId() {
- return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
- }
-
private ToscaConceptIdentifier getParticipantType() {
return new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1");
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
index c28355d7f..4fc10b828 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
@@ -33,6 +33,7 @@ import org.mockito.Mockito;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
+import org.onap.policy.clamp.acm.participant.policy.main.parameters.CommonTestData;
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;
@@ -49,7 +50,7 @@ class AutomationCompositionElementHandlerTest {
private static final String ID_VERSION = "1.0.1";
private static final UUID automationCompositionElementId = UUID.randomUUID();
public static final UUID AC_ID = UUID.randomUUID();
- private static final ToscaConceptIdentifier PARTICIPANT_ID = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
+ private static final ToscaConceptIdentifier DEFINITION = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
private PolicyApiHttpClient api = Mockito.mock(PolicyApiHttpClient.class);
private PolicyPapHttpClient pap = Mockito.mock(PolicyPapHttpClient.class);
@@ -77,11 +78,11 @@ class AutomationCompositionElementHandlerTest {
private AutomationCompositionElement getTestingAcElement() {
var element = new AutomationCompositionElement();
- element.setDefinition(PARTICIPANT_ID);
+ element.setDefinition(DEFINITION);
element.setDescription("Description");
element.setId(automationCompositionElementId);
element.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- element.setParticipantId(PARTICIPANT_ID);
+ element.setParticipantId(CommonTestData.getParticipantId());
element.setState(AutomationCompositionState.UNINITIALISED);
var template = new ToscaServiceTemplate();
template.setToscaTopologyTemplate(new ToscaTopologyTemplate());
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
index bfba15551..b69c5c353 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
@@ -122,7 +122,7 @@ public class CommonTestData {
map.put("reportingTimeIntervalMs", TIME_INTERVAL);
map.put("description", DESCRIPTION);
map.put("participantId", getParticipantId());
- map.put("participantType", getParticipantId());
+ map.put("participantType", getParticipantType());
map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
map.put("participantSupportedElementTypes", new ArrayList<>());
}
@@ -159,12 +159,21 @@ public class CommonTestData {
}
/**
+ * Returns participantType for test cases.
+ *
+ * @return participant Type
+ */
+ public static ToscaConceptIdentifier getParticipantType() {
+ return new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
+ }
+
+
+ /**
* Returns participantId for test cases.
*
* @return participant Id
*/
public static ToscaConceptIdentifier getParticipantId() {
- return new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
+ return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
}
-
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
index 59d64e754..31d62c70e 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
@@ -25,10 +25,10 @@ import static org.junit.Assert.assertTrue;
import java.io.FileNotFoundException;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.Set;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.onap.policy.clamp.acm.participant.policy.main.parameters.CommonTestData;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -49,10 +49,10 @@ public final class TestListenerUtils {
* @return ParticipantUpdate message
*/
public static ParticipantUpdate createParticipantUpdateMsg() {
- final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate();
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
- ToscaConceptIdentifier participantType =
- new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1");
+ final var participantUpdateMsg = new ParticipantUpdate();
+ var participantId = CommonTestData.getParticipantId();
+ var participantType =
+ new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1");
participantUpdateMsg.setParticipantId(participantId);
participantUpdateMsg.setTimestamp(Instant.now());
@@ -60,7 +60,7 @@ public final class TestListenerUtils {
participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
participantUpdateMsg.setMessageId(UUID.randomUUID());
- ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead();
+ var toscaServiceTemplate = testAutomationCompositionRead();
// Add policies to the toscaServiceTemplate
TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate);
@@ -69,8 +69,7 @@ public final class TestListenerUtils {
}
private static ToscaServiceTemplate testAutomationCompositionRead() {
- Set<String> automationCompositionDirectoryContents =
- ResourceUtils.getDirectoryContents("clamp/acm/test");
+ var automationCompositionDirectoryContents = ResourceUtils.getDirectoryContents("clamp/acm/test");
boolean atLeastOneAutomationCompositionTested = false;
ToscaServiceTemplate toscaServiceTemplate = null;
@@ -91,13 +90,13 @@ public final class TestListenerUtils {
}
private static void addPolicyTypesToToscaServiceTemplate(ToscaServiceTemplate toscaServiceTemplate) {
- Set<String> policyTypeDirectoryContents = ResourceUtils.getDirectoryContents("policytypes");
+ var policyTypeDirectoryContents = ResourceUtils.getDirectoryContents("policytypes");
for (String policyTypeFilePath : policyTypeDirectoryContents) {
String policyTypeString = ResourceUtils.getResourceAsString(policyTypeFilePath);
- ToscaServiceTemplate foundPolicyTypeSt =
- yamlTranslator.fromYaml(policyTypeString, ToscaServiceTemplate.class);
+ var foundPolicyTypeSt =
+ yamlTranslator.fromYaml(policyTypeString, ToscaServiceTemplate.class);
toscaServiceTemplate.setDerivedFrom(foundPolicyTypeSt.getDerivedFrom());
toscaServiceTemplate.setDescription(foundPolicyTypeSt.getDescription());
@@ -138,8 +137,7 @@ public final class TestListenerUtils {
var policiesString = ResourceUtils.getResourceAsString(policiesFilePath);
- var foundPoliciesSt =
- yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class);
+ var foundPoliciesSt = yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class);
if (foundPoliciesSt.getToscaTopologyTemplate() != null
&& foundPoliciesSt.getToscaTopologyTemplate().getPolicies() != null) {
toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()
@@ -149,7 +147,7 @@ public final class TestListenerUtils {
}
private static ToscaServiceTemplate testAutomationCompositionYamlSerialization(
- String automationCompositionFilePath) {
+ String automationCompositionFilePath) {
try {
String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath);
if (automationCompositionString == null) {