diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2022-11-16 14:12:22 +0000 |
---|---|---|
committer | Adheli Tavares <adheli.tavares@est.tech> | 2022-11-17 13:01:39 +0000 |
commit | ce1e7de6148c00b00a2a48b0c2504fc8918db9dc (patch) | |
tree | f015efeb1c184c63a15bc795090fa921a830bee5 | |
parent | 6aa64b948942b402b496b84b89186bcd276ce04c (diff) |
Topic names in PAP should be configurable from application.yaml
- for using Kafka instead of dmaap, topics names need to be lowercase
- fix for unit/integration tests using default names and changed names
for topics and group
- fix for sonar lints found along the way
Issue-ID: POLICY-4455
Change-Id: I89e9e6f7dbb07462f1ae497755965cb5a3f223a3
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
35 files changed, 398 insertions, 261 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/PapConstants.java b/main/src/main/java/org/onap/policy/pap/main/PapConstants.java index 36d5eeb2..98859f10 100644 --- a/main/src/main/java/org/onap/policy/pap/main/PapConstants.java +++ b/main/src/main/java/org/onap/policy/pap/main/PapConstants.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,14 +36,7 @@ public final class PapConstants { public static final String REG_PDP_MODIFY_MAP = "object:pdp/modify/map"; public static final String REG_METER_REGISTRY = "object:meter/registry"; - // topic names - public static final String TOPIC_POLICY_PDP_PAP = "POLICY-PDP-PAP"; - public static final String TOPIC_POLICY_NOTIFICATION = "POLICY-NOTIFICATION"; - public static final String TOPIC_POLICY_HEARTBEAT = "POLICY-HEARTBEAT"; - // policy components names - public static final String POLICY_API = "api"; - public static final String POLICY_DISTRIBUTION = "distribution"; public static final String POLICY_PAP = "pap"; public static final String POLICY_PDPS = "pdps"; diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java index 255b93e0..7bf6b803 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java @@ -3,7 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021-2022 Nordix Foundation. * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,6 +24,7 @@ package org.onap.policy.pap.main.comm; import java.util.LinkedList; import java.util.List; +import lombok.Getter; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.base.PfModelException; @@ -43,6 +44,7 @@ import org.onap.policy.pap.main.service.ToscaServiceTemplateService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.event.EventListener; @@ -53,9 +55,7 @@ import org.springframework.context.event.EventListener; public class PdpMessageGenerator { private static final Logger LOGGER = LoggerFactory.getLogger(PdpMessageGenerator.class); - private static final String PAP_GROUP_PARAMS_NAME = "PapGroup"; - - private boolean includeHeartBeat; + private final boolean includeHeartBeat; /** * Lock used when updating PDPs. */ @@ -80,6 +80,10 @@ public class PdpMessageGenerator { @Autowired private PolicyNotifier policyNotifier; + @Getter + @Value("${pap.name}") + private String papGroupParamName = "PapGroup"; + /** * Constructs the object. * @@ -99,7 +103,7 @@ public class PdpMessageGenerator { requestMap = Registry.get(PapConstants.REG_PDP_MODIFY_MAP, PdpModifyRequestMap.class); if (includeHeartBeat) { - PapParameterGroup params = ParameterService.get(PAP_GROUP_PARAMS_NAME); + PapParameterGroup params = ParameterService.get(papGroupParamName); heartBeatMs = params.getPdpParameters().getHeartBeatMs(); } else { @@ -130,8 +134,8 @@ public class PdpMessageGenerator { * Method to return a list of policies. * * @param subGroup PdpSubGroup to retrieve policies from + * @return a list of ToscaPolicy * @throws PfModelException the exception - * @returns a list of ToscaPolicy **/ public List<ToscaPolicy> getToscaPolicies(final PdpSubGroup subGroup) throws PfModelException { @@ -167,7 +171,6 @@ public class PdpMessageGenerator { * @param pdpInstanceId the pdp instance * @param pdpState the new state as per the PDP_STATE_CHANGE change message * @param policies list of policies as per the PDP_UPDATE message - * @throws PfModelException the exception */ protected void updateDeploymentStatus(final String pdpGroupName, final String pdpType, final String pdpInstanceId, PdpState pdpState, List<ToscaPolicy> policies) { diff --git a/main/src/main/java/org/onap/policy/pap/main/config/WebConfig.java b/main/src/main/java/org/onap/policy/pap/main/config/WebConfig.java index d8aee3a7..a6cfdf67 100644 --- a/main/src/main/java/org/onap/policy/pap/main/config/WebConfig.java +++ b/main/src/main/java/org/onap/policy/pap/main/config/WebConfig.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 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,7 +21,6 @@ package org.onap.policy.pap.main.config; -import java.util.Arrays; import java.util.List; import org.onap.policy.common.spring.utils.YamlHttpMessageConverter; import org.springframework.context.annotation.Configuration; @@ -37,7 +37,7 @@ public class WebConfig implements WebMvcConfigurer { @Override public void extendMessageConverters(List<HttpMessageConverter<?>> converters) { var yamlConverter = new YamlHttpMessageConverter(); - yamlConverter.setSupportedMediaTypes(Arrays.asList(MediaType.parseMediaType("application/yaml"))); + yamlConverter.setSupportedMediaTypes(List.of(MediaType.parseMediaType("application/yaml"))); converters.add(yamlConverter); } }
\ No newline at end of file diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java index 53f05a15..4da802df 100644 --- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java +++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2020, 2022 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved. * ================================================================================ @@ -88,6 +88,9 @@ public class PolicyComponentsHealthCheckProvider { @Value("${server.port}") private int port; + @Value("${pap.topic.pdp-pap.name:POLICY-PDP-PAP}") + private String topicPolicyPdpPap; + /** * This method is used to initialize clients and executor. */ @@ -244,8 +247,8 @@ public class PolicyComponentsHealthCheckProvider { private HealthCheckReport verifyDmaapClient(HttpClient httpClient, Response resp) { DmaapGetTopicResponse dmaapResponse = resp.readEntity(DmaapGetTopicResponse.class); var topicVerificationStatus = (dmaapResponse.getTopics() != null - && dmaapResponse.getTopics().contains(PapConstants.TOPIC_POLICY_PDP_PAP)); - String message = (topicVerificationStatus ? "PAP to DMaaP connection check is successfull" + && dmaapResponse.getTopics().contains(topicPolicyPdpPap)); + String message = (topicVerificationStatus ? "PAP to DMaaP connection check is successful" : "PAP to DMaaP connection check failed"); int code = (topicVerificationStatus ? resp.getStatus() : 503); return createHealthCheckReport(httpClient.getName(), httpClient.getBaseUrl(), code, diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java b/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java index 2abce9b1..4cea257f 100644 --- a/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java +++ b/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java @@ -3,7 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021-2022 Nordix Foundation. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -96,12 +96,12 @@ public class SessionData { /** * Map's a policy's identifier to the policies for deployment. */ - private Map<ToscaConceptIdentifier, ToscaPolicy> policiesToBeDeployed = new HashMap<>(); + private final Map<ToscaConceptIdentifier, ToscaPolicy> policiesToBeDeployed = new HashMap<>(); /** * Set of policies to be undeployed. */ - private Set<ToscaConceptIdentifier> policiesToBeUndeployed = new HashSet<>(); + private final Set<ToscaConceptIdentifier> policiesToBeUndeployed = new HashSet<>(); /** * User starting requests. @@ -114,11 +114,11 @@ public class SessionData { */ private final DeploymentStatus deployStatus; - private PolicyAuditManager auditManager; + private final PolicyAuditManager auditManager; - private ToscaServiceTemplateService toscaService; + private final ToscaServiceTemplateService toscaService; - private PdpGroupService pdpGroupService; + private final PdpGroupService pdpGroupService; /** * Constructs the object. @@ -368,9 +368,8 @@ public class SessionData { * * @param type desired policy type * @return the active groups supporting the given policy - * @throws PfModelException if an error occurred */ - public List<PdpGroup> getActivePdpGroupsByPolicyType(ToscaConceptIdentifier type) throws PfModelException { + public List<PdpGroup> getActivePdpGroupsByPolicyType(ToscaConceptIdentifier type) { /* * Cannot use computeIfAbsent() because the enclosed code throws an unchecked exception and handling that would * obfuscate the code too much, thus disabling the sonar. @@ -392,7 +391,7 @@ public class SessionData { /** * Gets the list of policies to be deployed to the PDPs. * - * @returns a list of policies to be deployed + * @return a list of policies to be deployed */ public List<ToscaPolicy> getPoliciesToBeDeployed() { return new LinkedList<>(this.policiesToBeDeployed.values()); @@ -401,7 +400,7 @@ public class SessionData { /** * Gets the list of policies to be undeployed from the PDPs. * - * @returns a list of policies to be undeployed + * @return a list of policies to be undeployed */ public List<ToscaConceptIdentifier> getPoliciesToBeUndeployed() { return new LinkedList<>(this.policiesToBeUndeployed); diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java index f8c4fb32..19b3c672 100644 --- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java +++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2022 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ @@ -28,6 +28,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import lombok.Getter; import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSource; @@ -50,6 +51,7 @@ import org.onap.policy.pap.main.notification.PolicyNotifier; import org.onap.policy.pap.main.parameters.PapParameterGroup; import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams; import org.onap.policy.pap.main.rest.PapStatisticsManager; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.event.ContextClosedEvent; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.EventListener; @@ -63,15 +65,29 @@ import org.springframework.stereotype.Component; */ @Component public class PapActivator extends ServiceManagerContainer { + + // topic names + @Getter + @Value("${pap.topic.pdp-pap.name}") + private String topicPolicyPdpPap = "POLICY-PDP-PAP"; + + @Getter + @Value("${pap.topic.notification.name}") + private String topicPolicyNotification = "POLICY-NOTIFICATION"; + + @Getter + @Value("${pap.topic.heartbeat.name}") + private String topicPolicyHeartbeat = "POLICY-HEARTBEAT"; + private static final String[] MSG_TYPE_NAMES = { "messageName" }; private static final String[] REQ_ID_NAMES = { "response", "responseTo" }; /** - * Max number of heat beats that can be missed before PAP removes a PDP. + * Max number of heart beats that can be missed before PAP removes a PDP. */ private static final int MAX_MISSED_HEARTBEATS = 3; - private PapParameterGroup papParameterGroup; + private final PapParameterGroup papParameterGroup; /** * Listens for messages on the topic, decodes them into a {@link PdpStatus} message, and then dispatches them to @@ -142,12 +158,12 @@ public class PapActivator extends ServiceManagerContainer { () -> heartbeatMsgDispatcher.unregister(PdpMessageType.PDP_STATUS.name())); addAction("Response Message Dispatcher", - () -> registerMsgDispatcher(responseMsgDispatcher, PapConstants.TOPIC_POLICY_PDP_PAP), - () -> unregisterMsgDispatcher(responseMsgDispatcher, PapConstants.TOPIC_POLICY_PDP_PAP)); + () -> registerMsgDispatcher(responseMsgDispatcher, topicPolicyPdpPap), + () -> unregisterMsgDispatcher(responseMsgDispatcher, topicPolicyPdpPap)); addAction("Heartbeat Message Dispatcher", - () -> registerMsgDispatcher(heartbeatMsgDispatcher, PapConstants.TOPIC_POLICY_HEARTBEAT), - () -> unregisterMsgDispatcher(heartbeatMsgDispatcher, PapConstants.TOPIC_POLICY_HEARTBEAT)); + () -> registerMsgDispatcher(heartbeatMsgDispatcher, topicPolicyHeartbeat), + () -> unregisterMsgDispatcher(heartbeatMsgDispatcher, topicPolicyHeartbeat)); addAction("topics", TopicEndpointManager.getManager()::start, @@ -163,14 +179,14 @@ public class PapActivator extends ServiceManagerContainer { addAction("PDP publisher", () -> { - pdpPub.set(new Publisher<>(PapConstants.TOPIC_POLICY_PDP_PAP)); + pdpPub.set(new Publisher<>(topicPolicyPdpPap)); startThread(pdpPub.get()); }, () -> pdpPub.get().stop()); addAction("Policy Notification publisher", () -> { - notifyPub.set(new Publisher<>(PapConstants.TOPIC_POLICY_NOTIFICATION)); + notifyPub.set(new Publisher<>(topicPolicyNotification)); startThread(notifyPub.get()); policyNotifier.setPublisher(notifyPub.get()); }, diff --git a/main/src/main/resources/application.yaml b/main/src/main/resources/application.yaml index ebe94b89..2711e2d1 100644 --- a/main/src/main/resources/application.yaml +++ b/main/src/main/resources/application.yaml @@ -27,6 +27,10 @@ server: pap: name: PapGroup aaf: false + topic: + pdp-pap.name: POLICY-PDP-PAP + notification.name: POLICY-NOTIFICATION + heartbeat.name: POLICY-HEARTBEAT pdpParameters: heartBeatMs: 120000 updateParameters: @@ -38,24 +42,24 @@ pap: savePdpStatisticsInDb: true topicParameterGroup: topicSources: - - topic: POLICY-PDP-PAP + - topic: ${pap.topic.pdp-pap.name} servers: - message-router topicCommInfrastructure: dmaap fetchTimeout: 15000 - - topic: POLICY-HEARTBEAT - effectiveTopic: POLICY-PDP-PAP + - topic: ${pap.topic.heartbeat.name} + effectiveTopic: ${pap.topic.pdp-pap.name} consumerGroup: policy-pap servers: - message-router topicCommInfrastructure: dmaap fetchTimeout: 15000 topicSinks: - - topic: POLICY-PDP-PAP + - topic: ${pap.topic.pdp-pap.name} servers: - message-router topicCommInfrastructure: dmaap - - topic: POLICY-NOTIFICATION + - topic: ${pap.topic.notification.name} servers: - message-router topicCommInfrastructure: dmaap diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java b/main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java index 4086b6a1..2a4cdc4c 100644 --- a/main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java +++ b/main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java @@ -3,7 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021-2022 Nordix Foundation. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,6 @@ import java.util.function.Consumer; import org.junit.Before; import org.junit.BeforeClass; import org.mockito.ArgumentCaptor; -import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.listeners.RequestIdDispatcher; @@ -77,6 +76,7 @@ public class CommonRequestBase { protected static final PdpState MY_STATE = PdpState.SAFE; protected static final PdpState DIFF_STATE = PdpState.TERMINATED; protected static final int RETRIES = 1; + protected static final String PDP_PAP_TOPIC = "POLICY-PDP-PAP"; protected Publisher<PdpMessage> publisher; protected PolicyNotifier notifier; @@ -112,12 +112,9 @@ public class CommonRequestBase { listener = mock(RequestListener.class); PdpParameters pdpParams = mock(PdpParameters.class); - doAnswer(new Answer<Object>() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - queue.add(invocation.getArgument(0, QueueToken.class)); - return null; - } + doAnswer((Answer<Object>) invocation -> { + queue.add(invocation.getArgument(0, QueueToken.class)); + return null; }).when(publisher).enqueue(any()); when(timers.register(any(), any())).thenReturn(timer); @@ -151,7 +148,7 @@ public class CommonRequestBase { verify(dispatcher).register(any(), processResp.capture()); - processResp.getValue().onTopicEvent(CommInfrastructure.NOOP, PapConstants.TOPIC_POLICY_PDP_PAP, response); + processResp.getValue().onTopicEvent(CommInfrastructure.NOOP, PDP_PAP_TOPIC, response); } /** diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java index 51ced7bd..c33790aa 100644 --- a/main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +44,6 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.pdp.concepts.PdpMessage; import org.onap.policy.models.pdp.concepts.PdpStateChange; -import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.PolicyPapException; import org.onap.policy.pap.main.parameters.CommonTestData; import org.onap.policy.pap.main.parameters.PapParameterGroup; @@ -58,6 +58,8 @@ public class PublisherTest extends Threaded { private static final String JSON1; private static final String JSON2; + protected static final String PDP_PAP_TOPIC = "POLICY-PDP-PAP"; + static { try { Coder coder = new StandardCoder(); @@ -81,10 +83,9 @@ public class PublisherTest extends Threaded { /** * Configures the topic and attaches a listener. * - * @throws Exception if an error occurs */ @BeforeClass - public static void setUpBeforeClass() throws Exception { + public static void setUpBeforeClass() { final PapParameterGroup parameterGroup = new CommonTestData().getPapParameterGroup(6969); TopicEndpointManager.getManager().shutdown(); @@ -93,7 +94,7 @@ public class PublisherTest extends Threaded { } @AfterClass - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterClass() { TopicEndpointManager.getManager().shutdown(); } @@ -106,10 +107,10 @@ public class PublisherTest extends Threaded { public void setUp() throws Exception { super.setUp(); - pub = new Publisher<>(PapConstants.TOPIC_POLICY_PDP_PAP); + pub = new Publisher<>(PDP_PAP_TOPIC); listener = new MyListener(); - TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(listener); + TopicEndpointManager.getManager().getNoopTopicSink(PDP_PAP_TOPIC).register(listener); } /** @@ -119,7 +120,7 @@ public class PublisherTest extends Threaded { */ @After public void tearDown() throws Exception { - TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(listener); + TopicEndpointManager.getManager().getNoopTopicSink(PDP_PAP_TOPIC).unregister(listener); super.tearDown(); } @@ -143,7 +144,7 @@ public class PublisherTest extends Threaded { } @Test - public void testPublisher_Ex() throws Exception { + public void testPublisher_Ex() { assertThatThrownBy(() -> new Publisher<>("unknwon-topic")).isInstanceOf(PolicyPapException.class); } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java index 359f9cb8..14fa42d0 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2022 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ @@ -27,16 +27,19 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.SyncInvoker; import org.junit.Test; import org.onap.policy.common.endpoints.report.HealthCheckReport; import org.onap.policy.models.base.PfModelRuntimeException; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; /** - * Class to perform unit test of {@link PapRestServer}. + * Class to perform unit test of {@link HealthCheckRestControllerV1}. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ +@ActiveProfiles("test") public class TestHealthCheckRestControllerV1 extends CommonPapRestServer { private static final String HEALTHCHECK_ENDPOINT = "healthcheck"; @@ -53,10 +56,10 @@ public class TestHealthCheckRestControllerV1 extends CommonPapRestServer { public void testHealthCheckSuccess() throws Exception { final Invocation.Builder invocationBuilder = sendRequest(HEALTHCHECK_ENDPOINT); final HealthCheckReport report = invocationBuilder.get(HealthCheckReport.class); - validateHealthCheckReport(NAME, SELF, true, 200, ALIVE, report); + validateHealthCheckReport(true, 200, ALIVE, report); // verify it fails when no authorization info is included - checkUnauthRequest(HEALTHCHECK_ENDPOINT, req -> req.get()); + checkUnauthRequest(HEALTHCHECK_ENDPOINT, SyncInvoker::get); } @Test @@ -68,7 +71,7 @@ public class TestHealthCheckRestControllerV1 extends CommonPapRestServer { var response = invocationBuilder.get(); var report = response.readEntity(HealthCheckReport.class); assertThat(response.getStatus()).isEqualTo(503); - validateHealthCheckReport(NAME, SELF, false, 503, NOT_ALIVE, report); + validateHealthCheckReport(false, 503, NOT_ALIVE, report); } @Test @@ -78,13 +81,13 @@ public class TestHealthCheckRestControllerV1 extends CommonPapRestServer { var response = invocationBuilder.get(); var report = response.readEntity(HealthCheckReport.class); assertThat(response.getStatus()).isEqualTo(503); - validateHealthCheckReport(NAME, SELF, false, 503, NOT_ALIVE, report); + validateHealthCheckReport(false, 503, NOT_ALIVE, report); } - private void validateHealthCheckReport(final String name, final String url, final boolean healthy, final int code, - final String message, final HealthCheckReport report) { - assertEquals(name, report.getName()); - assertEquals(url, report.getUrl()); + private void validateHealthCheckReport(final boolean healthy, final int code, + final String message, final HealthCheckReport report) { + assertEquals(CommonPapRestServer.NAME, report.getName()); + assertEquals(CommonPapRestServer.SELF, report.getUrl()); assertEquals(healthy, report.isHealthy()); assertEquals(code, report.getCode()); assertEquals(message, report.getMessage()); diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java index 2b08b2ce..6649dc7b 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,12 @@ import org.onap.policy.models.pap.concepts.PdpGroupUpdateResponse; import org.onap.policy.models.pdp.concepts.PdpGroup; import org.onap.policy.models.pdp.concepts.PdpGroups; import org.onap.policy.models.pdp.concepts.PdpSubGroup; +import org.springframework.test.context.ActiveProfiles; /** * Note: this tests failure cases; success cases are tested by tests in the "e2e" package. */ +@ActiveProfiles("test") public class TestPdpGroupCreateOrUpdateControllerV1 extends CommonPapRestServer { private static final String CREATEORUPDATE_GROUPS_ENDPOINT = "pdps/groups/batch"; diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java index 0f1ab1f8..033461f7 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2022 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,13 +24,16 @@ package org.onap.policy.pap.main.rest; import static org.junit.Assert.assertEquals; import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.SyncInvoker; import javax.ws.rs.core.Response; import org.junit.Test; import org.onap.policy.models.pap.concepts.PdpGroupDeleteResponse; +import org.springframework.test.context.ActiveProfiles; /** * Note: this tests failure cases; success cases are tested by tests in the "e2e" package. */ +@ActiveProfiles("test") public class TestPdpGroupDeleteControllerV1 extends CommonPapRestServer { private static final String GROUP_NOT_FOUND = "group not found"; @@ -61,7 +64,7 @@ public class TestPdpGroupDeleteControllerV1 extends CommonPapRestServer { assertEquals(GROUP_NOT_FOUND, resp.getErrorDetails()); // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.delete()); + checkUnauthRequest(uri, SyncInvoker::delete); } @Test @@ -80,7 +83,7 @@ public class TestPdpGroupDeleteControllerV1 extends CommonPapRestServer { assertEquals("cannot find policy: my-name null", resp.getErrorDetails()); // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.delete()); + checkUnauthRequest(uri, SyncInvoker::delete); } @Test @@ -99,6 +102,6 @@ public class TestPdpGroupDeleteControllerV1 extends CommonPapRestServer { assertEquals("cannot find policy: my-name 3", resp.getErrorDetails()); // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.delete()); + checkUnauthRequest(uri, SyncInvoker::delete); } } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java index f2d33374..5d48ecc7 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2022 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,6 +25,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.Arrays; +import java.util.List; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.MediaType; @@ -36,10 +37,12 @@ import org.onap.policy.models.pdp.concepts.DeploymentGroup; import org.onap.policy.models.pdp.concepts.DeploymentGroups; import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; +import org.springframework.test.context.ActiveProfiles; /** * Note: this tests failure cases; success cases are tested by tests in the "e2e" package. */ +@ActiveProfiles("test") public class TestPdpGroupDeployControllerV1 extends CommonPapRestServer { private static final String DEPLOY_GROUP_ENDPOINT = "pdps/deployments/batch"; @@ -95,10 +98,10 @@ public class TestPdpGroupDeployControllerV1 extends CommonPapRestServer { DeploymentGroup group = new DeploymentGroup(); group.setName("drools-group"); - group.setDeploymentSubgroups(Arrays.asList(subgrp)); + group.setDeploymentSubgroups(List.of(subgrp)); DeploymentGroups groups = new DeploymentGroups(); - groups.setGroups(Arrays.asList(group)); + groups.setGroups(List.of(group)); return Entity.entity(groups, MediaType.APPLICATION_JSON); } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java index f61e8592..f149d3ed 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,15 +24,18 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.SyncInvoker; import javax.ws.rs.core.Response; import org.junit.Test; import org.onap.policy.models.pdp.concepts.Pdps; +import org.springframework.test.context.ActiveProfiles; /** * Class to perform unit test of {@link PdpGroupHealthCheckControllerV1}. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ +@ActiveProfiles("test") public class TestPdpGroupHealthCheckControllerV1 extends CommonPapRestServer { private static final String ENDPOINT = "pdps/healthcheck"; @@ -58,6 +61,6 @@ public class TestPdpGroupHealthCheckControllerV1 extends CommonPapRestServer { assertNotNull(resp); // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.get()); + checkUnauthRequest(uri, SyncInvoker::get); } } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java index e49ecbc6..255718b9 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,15 +24,18 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.SyncInvoker; import javax.ws.rs.core.Response; import org.junit.Test; import org.onap.policy.models.pdp.concepts.PdpGroups; +import org.springframework.test.context.ActiveProfiles; /** * Class to perform unit test of {@link PdpGroupQueryControllerV1}. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ +@ActiveProfiles("test") public class TestPdpGroupQueryControllerV1 extends CommonPapRestServer { private static final String GROUP_ENDPOINT = "pdps"; @@ -43,7 +46,7 @@ public class TestPdpGroupQueryControllerV1 extends CommonPapRestServer { } @Test - public void testchangeGroupState() throws Exception { + public void testChangeGroupState() throws Exception { final String uri = GROUP_ENDPOINT; final Invocation.Builder invocationBuilder = sendRequest(uri); @@ -58,6 +61,6 @@ public class TestPdpGroupQueryControllerV1 extends CommonPapRestServer { assertNotNull(resp); // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.get()); + checkUnauthRequest(uri, SyncInvoker::get); } } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java index 9e21d6e8..48009117 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,12 +28,15 @@ import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import org.junit.Test; import org.onap.policy.models.pap.concepts.PdpGroupStateChangeResponse; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ActiveProfiles; /** * Class to perform unit test of {@link PdpGroupStateChangeControllerV1}. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ +@ActiveProfiles("test") public class TestPdpGroupStateChangeControllerV1 extends CommonPapRestServer { private static final String GROUP_ENDPOINT = "pdps/groups"; @@ -44,7 +47,7 @@ public class TestPdpGroupStateChangeControllerV1 extends CommonPapRestServer { } @Test - public void testchangeGroupState() throws Exception { + public void testChangeGroupState() throws Exception { final String uri = GROUP_ENDPOINT + "/my-name?state=ACTIVE"; final Invocation.Builder invocationBuilder = sendRequest(uri); diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java index 56833520..8658b7d2 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +24,13 @@ import static org.junit.Assert.assertEquals; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import org.junit.Test; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ActiveProfiles; /** * Note: this tests failure cases; success cases are tested by tests in the "e2e" package. */ +@ActiveProfiles("test") public class TestPolicyAuditControllerV1 extends CommonPapRestServer { private static final String POLICY_AUDIT_ENDPOINT = "policies/audit"; diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java index e07d35c1..9eec5e1e 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2020, 2022 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Inc. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ @@ -35,12 +35,14 @@ import org.junit.Test; import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.pap.main.parameters.PapParameterGroup; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; /** * Class to perform unit test of {@link PolicyComponentsHealthCheckControllerV1}. * * @author Yehui Wang (yehui.wang@est.tech) */ +@ActiveProfiles("test") public class TestPolicyComponentsHealthCheckControllerV1 extends CommonPapRestServer { private static final String ENDPOINT = "components/healthcheck"; diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java index 04d4cf91..3db1ed83 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2022 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Corp. * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved. * ================================================================================ @@ -30,7 +30,6 @@ import static org.mockito.Mockito.when; import java.io.File; import java.net.HttpURLConnection; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import javax.ws.rs.core.Response; @@ -150,6 +149,7 @@ public class TestPolicyComponentsHealthCheckProvider { ReflectionTestUtils.setField(provider, "papParameterGroup", papParameterGroup); provider.initializeClientHealthCheckExecutorService(); ReflectionTestUtils.setField(provider, "clients", clients); + ReflectionTestUtils.setField(provider, "topicPolicyPdpPap", "POLICY-PDP-PAP"); } /** @@ -260,7 +260,7 @@ public class TestPolicyComponentsHealthCheckProvider { private DmaapGetTopicResponse createDmaapResponse() { DmaapGetTopicResponse response = new DmaapGetTopicResponse(); - response.setTopics(Arrays.asList(PapConstants.TOPIC_POLICY_PDP_PAP)); + response.setTopics(List.of("POLICY-PDP-PAP")); return response; } } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java index fc86fef1..907e6c5a 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019,2021 Nordix Foundation. + * Copyright (C) 2019, 2021-2022 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ @@ -26,12 +26,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.SyncInvoker; import javax.ws.rs.core.Response; import org.junit.Test; +import org.springframework.test.context.ActiveProfiles; /** * Note: this tests failure cases; success cases are tested by tests in the "e2e" package. */ +@ActiveProfiles("test") public class TestPolicyStatusControllerV1 extends CommonPapRestServer { private static final String POLICY_STATUS_ENDPOINT = "policies/deployed"; @@ -51,10 +54,8 @@ public class TestPolicyStatusControllerV1 extends CommonPapRestServer { @Test public void testQueryAllDeployedPolicies() throws Exception { - String uri = POLICY_STATUS_ENDPOINT; - // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.get()); + checkUnauthRequest(POLICY_STATUS_ENDPOINT, SyncInvoker::get); checkRequest(POLICY_STATUS_ENDPOINT); } @@ -73,10 +74,8 @@ public class TestPolicyStatusControllerV1 extends CommonPapRestServer { @Test public void testGetStatusOfAllPolicies() throws Exception { - String uri = POLICY_DEPLOYMENT_STATUS_ENDPOINT; - // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.get()); + checkUnauthRequest(POLICY_DEPLOYMENT_STATUS_ENDPOINT, SyncInvoker::get); } @Test @@ -102,7 +101,7 @@ public class TestPolicyStatusControllerV1 extends CommonPapRestServer { assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawresp.getStatus()); // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.get()); + checkUnauthRequest(uri, SyncInvoker::get); } private void checkInvalidRegexRequest(String uri) throws Exception { @@ -113,7 +112,7 @@ public class TestPolicyStatusControllerV1 extends CommonPapRestServer { assertThat(entity).contains("error parsing regexp"); // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.get()); + checkUnauthRequest(uri, SyncInvoker::get); } private void checkEmptyRegexRequest(String uri) throws Exception { @@ -124,6 +123,6 @@ public class TestPolicyStatusControllerV1 extends CommonPapRestServer { assertThat(entity).contains("empty string passed as a regex"); // verify it fails when no authorization info is included - checkUnauthRequest(uri, req -> req.get()); + checkUnauthRequest(uri, SyncInvoker::get); } } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java index 70deedc1..0ed36d58 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2020, 2022 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,12 +27,15 @@ import javax.ws.rs.client.Invocation; import org.junit.Test; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.pap.main.PapConstants; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ActiveProfiles; /** - * Class to perform unit test of {@link PapRestServer}. + * Class to perform unit test of {@link StatisticsRestControllerV1}. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ +@ActiveProfiles("test") public class TestStatisticsRestControllerV1 extends CommonPapRestServer { private static final String STATISTICS_ENDPOINT = "statistics"; diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java index 575e33ff..48bc1e05 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java @@ -3,7 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2022 Nordix Foundation. * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; import java.util.Optional; +import lombok.Getter; import org.junit.After; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.utils.coder.Coder; @@ -38,7 +39,6 @@ import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.PrometheusUtils; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.pdp.concepts.PdpGroup; import org.onap.policy.models.pdp.concepts.PdpGroups; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus; @@ -56,8 +56,10 @@ import org.onap.policy.pap.main.service.ToscaServiceTemplateService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; import org.yaml.snakeyaml.Yaml; +@ActiveProfiles("test-e2e") public abstract class End2EndBase extends CommonPapRestServer { private static final Logger logger = LoggerFactory.getLogger(End2EndBase.class); @@ -87,6 +89,12 @@ public abstract class End2EndBase extends CommonPapRestServer { @Autowired public MeterRegistry meterRegistry; + @Getter + private final String topicPolicyPdpPap = "pdp-pap-topic"; + + @Getter + private final String topicPolicyNotification = "notification-topic"; + public String deploymentsCounterName = "pap_" + PrometheusUtils.POLICY_DEPLOYMENTS_METRIC; public String[] deploymentSuccessTag = {PrometheusUtils.OPERATION_METRIC_LABEL, PrometheusUtils.DEPLOY_OPERATION, PrometheusUtils.STATUS_METRIC_LABEL, State.SUCCESS.name()}; @@ -115,9 +123,8 @@ public abstract class End2EndBase extends CommonPapRestServer { * Adds Tosca Policy Types to the DB. * * @param yamlFile name of the YAML file specifying the data to be loaded - * @throws PfModelException if a DAO error occurs */ - public void addToscaPolicyTypes(final String yamlFile) throws PfModelException { + public void addToscaPolicyTypes(final String yamlFile) { final ToscaServiceTemplate serviceTemplate = loadYamlFile(yamlFile, ToscaServiceTemplate.class); JpaToscaServiceTemplate jpaToscaServiceTemplate = mergeWithExistingTemplate(serviceTemplate); serviceTemplateRepository.save(jpaToscaServiceTemplate); @@ -127,9 +134,8 @@ public abstract class End2EndBase extends CommonPapRestServer { * Adds Tosca Policies to the DB. * * @param yamlFile name of the YAML file specifying the data to be loaded - * @throws PfModelException if a DAO error occurs */ - public void addToscaPolicies(final String yamlFile) throws PfModelException { + public void addToscaPolicies(final String yamlFile) { final ToscaServiceTemplate serviceTemplate = loadYamlFile(yamlFile, ToscaServiceTemplate.class); JpaToscaServiceTemplate jpaToscaServiceTemplate = mergeWithExistingTemplate(serviceTemplate); serviceTemplateRepository.save(jpaToscaServiceTemplate); @@ -139,7 +145,7 @@ public abstract class End2EndBase extends CommonPapRestServer { JpaToscaServiceTemplate jpaToscaServiceTemplate = new JpaToscaServiceTemplate(serviceTemplate); Optional<JpaToscaServiceTemplate> dbServiceTemplateOpt = serviceTemplateRepository .findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME, JpaToscaServiceTemplate.DEFAULT_VERSION)); - if (!dbServiceTemplateOpt.isEmpty()) { + if (dbServiceTemplateOpt.isPresent()) { JpaToscaServiceTemplate dbServiceTemplate = dbServiceTemplateOpt.get(); if (dbServiceTemplate.getPolicyTypes() != null) { jpaToscaServiceTemplate.setPolicyTypes(dbServiceTemplate.getPolicyTypes()); @@ -159,9 +165,8 @@ public abstract class End2EndBase extends CommonPapRestServer { * Adds PDP groups to the DB. * * @param jsonFile name of the JSON file specifying the data to be loaded - * @throws PfModelException if a DAO error occurs */ - public void addGroups(final String jsonFile) throws PfModelException { + public void addGroups(final String jsonFile) { final PdpGroups groups = loadJsonFile(jsonFile, PdpGroups.class); final ValidationResult result = groups.validatePapRest(); @@ -176,9 +181,8 @@ public abstract class End2EndBase extends CommonPapRestServer { * Fetch PDP groups from the DB. * * @param name name of the pdpGroup - * @throws PfModelException if a DAO error occurs */ - public List<PdpGroup> fetchGroups(final String name) throws PfModelException { + public List<PdpGroup> fetchGroups(final String name) { return pdpGroupService.getPdpGroups(name); } @@ -188,10 +192,9 @@ public abstract class End2EndBase extends CommonPapRestServer { * @param instanceId name of the pdpStatistics * @param groupName name of the pdpGroup * @param subGroupName name of the pdpSubGroup - * @throws PfModelException if a DAO error occurs */ public Map<String, Map<String, List<PdpStatistics>>> fetchPdpStatistics(final String instanceId, - final String groupName, final String subGroupName) throws PfModelException { + final String groupName, final String subGroupName) { return pdpStatisticsService.fetchDatabaseStatistics(groupName, subGroupName, instanceId, 100, null, null); } @@ -199,9 +202,8 @@ public abstract class End2EndBase extends CommonPapRestServer { * Adds PdpPolicyStatus records to the DB. * * @param jsonFile name of the JSON file specifying the data to be loaded - * @throws PfModelException if a DAO error occurs */ - public void addPdpPolicyStatus(final String jsonFile) throws PfModelException { + public void addPdpPolicyStatus(final String jsonFile) { final PolicyStatusRecords data = loadJsonFile(jsonFile, PolicyStatusRecords.class); policyStatusService.cudPolicyStatus(data.records, null, null); } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java index 38ffe8db..c910a7b4 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndContext.java @@ -3,6 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,14 +125,15 @@ public class End2EndContext { */ private TopicListener topicListener = (infra, topic, text) -> toPdps.add(text); + private String topicPolicyPdpPap = "pdp-pap-topic"; /** * Constructs the object. */ public End2EndContext() { - toPapTopic = TopicEndpointManager.getManager().getNoopTopicSource(PapConstants.TOPIC_POLICY_PDP_PAP); + toPapTopic = TopicEndpointManager.getManager().getNoopTopicSource(topicPolicyPdpPap); - TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).register(topicListener); + TopicEndpointManager.getManager().getNoopTopicSink(topicPolicyPdpPap).register(topicListener); dispatcher = new MessageTypeDispatcher("messageName"); dispatcher.register(PdpMessageType.PDP_UPDATE.name(), new UpdateListener()); @@ -200,7 +202,7 @@ public class End2EndContext { toPap.clear(); pdps.forEach(pdp -> toPap.add(DONE)); - TopicEndpointManager.getManager().getNoopTopicSink(PapConstants.TOPIC_POLICY_PDP_PAP).unregister(topicListener); + TopicEndpointManager.getManager().getNoopTopicSink(topicPolicyPdpPap).unregister(topicListener); } /** @@ -245,7 +247,7 @@ public class End2EndContext { break; } - dispatcher.onTopicEvent(CommInfrastructure.NOOP, PapConstants.TOPIC_POLICY_PDP_PAP, text); + dispatcher.onTopicEvent(CommInfrastructure.NOOP, topicPolicyPdpPap, text); } } } @@ -256,15 +258,11 @@ public class End2EndContext { * {@link End2EndContext#DONE} message <i>for each PDP</i>. */ private class ToPapThread extends Thread { - /** - * Number of DONE messages that have been received. - */ - private long ndone; @Override public void run() { // pretend we received DONE from PDPs that are already finished - ndone = pdps.stream().filter(pdp -> pdp.finished).count(); + long ndone = pdps.stream().filter(pdp -> pdp.finished).count(); while (ndone < pdps.size()) { String text; @@ -364,9 +362,8 @@ public class End2EndContext { * * @param reply reply to be added to the list * @return this PDP - * @throws CoderException if the reply cannot be encoded */ - public PseudoPdp addReply(PdpStatus reply) throws CoderException { + public PseudoPdp addReply(PdpStatus reply) { replies.add(reply); finished = false; return this; diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/HealthCheckTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/HealthCheckTest.java index f429afbd..296a6609 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/HealthCheckTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/HealthCheckTest.java @@ -3,6 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ package org.onap.policy.pap.main.rest.e2e; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.net.HttpURLConnection; import javax.ws.rs.client.Invocation; @@ -37,7 +39,7 @@ public class HealthCheckTest extends End2EndBase { assertEquals(NAME, report.getName()); assertEquals(SELF, report.getUrl()); - assertEquals(true, report.isHealthy()); + assertTrue(report.isHealthy()); assertEquals(HttpURLConnection.HTTP_OK, report.getCode()); assertEquals(ALIVE, report.getMessage()); } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java index a8387881..5e2ca38f 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java @@ -3,7 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021-2022 Nordix Foundation. * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,7 +44,6 @@ import org.onap.policy.models.pap.concepts.PolicyNotification; import org.onap.policy.models.pap.concepts.PolicyStatus; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.rest.PdpGroupDeployControllerV1; public class PdpGroupDeleteTest extends End2EndBase { @@ -119,10 +118,8 @@ public class PdpGroupDeleteTest extends End2EndBase { // arrange to catch notifications LinkedBlockingQueue<String> notifications = new LinkedBlockingQueue<>(); - NoopTopicSink notifier = NoopTopicFactories.getSinkFactory().get(PapConstants.TOPIC_POLICY_NOTIFICATION); - notifier.register((infra, topic, msg) -> { - notifications.add(msg); - }); + NoopTopicSink notifier = NoopTopicFactories.getSinkFactory().get(getTopicPolicyNotification()); + notifier.register((infra, topic, msg) -> notifications.add(msg)); String uri = DELETE_POLICIES_ENDPOINT + "/onap.restart.tcaB"; diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java index df749a88..f28ccd14 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java @@ -3,7 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021-2022 Nordix Foundation. * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +28,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import java.util.Arrays; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; @@ -50,7 +49,6 @@ import org.onap.policy.models.pdp.concepts.DeploymentGroups; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.rest.PdpGroupDeployControllerV1; public class PdpGroupDeployTest extends End2EndBase { @@ -83,7 +81,7 @@ public class PdpGroupDeployTest extends End2EndBase { status11.setPdpType(DEPLOY_SUBGROUP); status11.setPdpSubgroup(DEPLOY_SUBGROUP); - List<ToscaConceptIdentifier> idents = Arrays.asList(new ToscaConceptIdentifier("onap.restart.tca", "1.0.0")); + List<ToscaConceptIdentifier> idents = List.of(new ToscaConceptIdentifier("onap.restart.tca", "1.0.0")); status11.setPolicies(idents); PdpStatus status12 = new PdpStatus(); @@ -144,10 +142,10 @@ public class PdpGroupDeployTest extends End2EndBase { status11.setPdpType(DEPLOY_SUBGROUP); status11.setPdpSubgroup(DEPLOY_SUBGROUP); - final ToscaConceptIdentifier ident = new ToscaConceptIdentifier("onap.restart.tcaB", "1.0.0"); + final ToscaConceptIdentifier identifier = new ToscaConceptIdentifier("onap.restart.tcaB", "1.0.0"); - List<ToscaConceptIdentifier> idents = Arrays.asList(ident); - status11.setPolicies(idents); + List<ToscaConceptIdentifier> identifiers = List.of(identifier); + status11.setPolicies(identifiers); PdpStatus status12 = new PdpStatus(); status12.setName("pdpBA_2"); @@ -155,7 +153,7 @@ public class PdpGroupDeployTest extends End2EndBase { status12.setPdpGroup("deployPolicies"); status12.setPdpType(DEPLOY_SUBGROUP); status12.setPdpSubgroup(DEPLOY_SUBGROUP); - status12.setPolicies(idents); + status12.setPolicies(identifiers); context.addPdp("pdpBA_1", DEPLOY_SUBGROUP).addReply(status11); context.addPdp("pdpBA_2", DEPLOY_SUBGROUP).addReply(status12); @@ -165,12 +163,10 @@ public class PdpGroupDeployTest extends End2EndBase { // arrange to catch notifications LinkedBlockingQueue<String> notifications = new LinkedBlockingQueue<>(); - NoopTopicSink notifier = NoopTopicFactories.getSinkFactory().get(PapConstants.TOPIC_POLICY_NOTIFICATION); - notifier.register((infra, topic, msg) -> { - notifications.add(msg); - }); + NoopTopicSink notifier = NoopTopicFactories.getSinkFactory().get(getTopicPolicyNotification()); + notifier.register((infra, topic, msg) -> notifications.add(msg)); - assertThat(meterRegistry.counter(deploymentsCounterName, deploymentSuccessTag).count()).isEqualTo(0); + assertThat(meterRegistry.counter(deploymentsCounterName, deploymentSuccessTag).count()).isZero(); Invocation.Builder invocationBuilder = sendRequest(DEPLOY_POLICIES_ENDPOINT); @@ -197,7 +193,7 @@ public class PdpGroupDeployTest extends End2EndBase { assertEquals(2, added.getSuccessCount()); assertEquals(0, added.getFailureCount()); assertEquals(0, added.getIncompleteCount()); - assertEquals(ident, added.getPolicy()); + assertEquals(identifier, added.getPolicy()); // one of the PDPs should not have handled any requests assertEquals(1, context.getPdps().stream().filter(pdp -> pdp.getHandled().isEmpty()).count()); diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PolicyStatusTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PolicyStatusTest.java index 121318f5..09c8a2ac 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PolicyStatusTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PolicyStatusTest.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,13 +51,11 @@ public class PolicyStatusTest extends End2EndBase { @Test public void testQueryAllDeployedPolicies() throws Exception { - String uri = POLICY_STATUS_ENDPOINT; - - Invocation.Builder invocationBuilder = sendRequest(uri); + Invocation.Builder invocationBuilder = sendRequest(POLICY_STATUS_ENDPOINT); Response rawresp = invocationBuilder.get(); assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - List<PolicyStatus> resp = rawresp.readEntity(new GenericType<List<PolicyStatus>>() {}); + List<PolicyStatus> resp = rawresp.readEntity(new GenericType<>() {}); assertEquals(1, resp.size()); checkAssertions(resp.get(0)); } @@ -69,7 +68,7 @@ public class PolicyStatusTest extends End2EndBase { Response rawresp = invocationBuilder.get(); assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - List<PolicyStatus> resp = rawresp.readEntity(new GenericType<List<PolicyStatus>>() {}); + List<PolicyStatus> resp = rawresp.readEntity(new GenericType<>() {}); assertEquals(1, resp.size()); checkAssertions(resp.get(0)); } @@ -88,13 +87,11 @@ public class PolicyStatusTest extends End2EndBase { @Test public void testGetStatusOfAllDeployedPolicies() throws Exception { - String uri = POLICY_DEPLOYMENT_STATUS_ENDPOINT; - - Invocation.Builder invocationBuilder = sendRequest(uri); + Invocation.Builder invocationBuilder = sendRequest(POLICY_DEPLOYMENT_STATUS_ENDPOINT); Response rawresp = invocationBuilder.get(); assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - List<PdpPolicyStatus> resp = rawresp.readEntity(new GenericType<List<PdpPolicyStatus>>() {}); + List<PdpPolicyStatus> resp = rawresp.readEntity(new GenericType<>() {}); assertEquals(1, resp.size()); checkAssertionsForDeploymentStatus(resp.get(0)); } @@ -107,7 +104,7 @@ public class PolicyStatusTest extends End2EndBase { Response rawresp = invocationBuilder.get(); assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - List<PdpPolicyStatus> resp = rawresp.readEntity(new GenericType<List<PdpPolicyStatus>>() {}); + List<PdpPolicyStatus> resp = rawresp.readEntity(new GenericType<>() {}); assertEquals(1, resp.size()); checkAssertionsForDeploymentStatus(resp.get(0)); } diff --git a/main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java index 549eb96b..4edb05dc 100644 --- a/main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +40,9 @@ import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.pap.main.rest.CommonPapRestServer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +@ActiveProfiles("test") public class PdpGroupServiceTest extends CommonPapRestServer { private static final String FIELD_IS_NULL = "%s is marked non-null but is null"; @@ -97,7 +100,7 @@ public class PdpGroupServiceTest extends CommonPapRestServer { assertThat(activePdpGroups.get(0).getPdpSubgroups()).hasSize(3); assertThat(pdpGroupService.getPdpGroups(CREATE_GROUPS, PdpState.PASSIVE)).hasSize(1); - assertThat(pdpGroupService.getPdpGroups("invalid-group", PdpState.PASSIVE)).hasSize(0); + assertThat(pdpGroupService.getPdpGroups("invalid-group", PdpState.PASSIVE)).isEmpty(); assertThat(pdpGroupService.getPdpGroups(DEFAULT_GROUP, PdpState.ACTIVE)).hasSize(1); PdpGroupFilter filter = PdpGroupFilter.builder() diff --git a/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java index 7bfc9973..1d429ee8 100644 --- a/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +35,9 @@ import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.pap.main.repository.PdpStatisticsRepository; import org.onap.policy.pap.main.rest.CommonPapRestServer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +@ActiveProfiles("test") public class PdpStatisticsServiceTest extends CommonPapRestServer { private static final String NAME3 = "name3"; @@ -67,10 +70,10 @@ public class PdpStatisticsServiceTest extends CommonPapRestServer { @Before public void setUp() throws Exception { super.setUp(); - pdpStatistics1 = generatePdpStatistics(NAME1, TIMESTAMP1, GROUP, SUBGROUP); - pdpStatistics2 = generatePdpStatistics("name2", TIMESTAMP1, GROUP, SUBGROUP); - pdpStatistics3 = generatePdpStatistics(NAME1, TIMESTAMP2, GROUP, SUBGROUP); - pdpStatistics4 = generatePdpStatistics(NAME3, TIMESTAMP2, GROUP0, SUBGROUP); + pdpStatistics1 = generatePdpStatistics(NAME1, TIMESTAMP1, GROUP); + pdpStatistics2 = generatePdpStatistics("name2", TIMESTAMP1, GROUP); + pdpStatistics3 = generatePdpStatistics(NAME1, TIMESTAMP2, GROUP); + pdpStatistics4 = generatePdpStatistics(NAME3, TIMESTAMP2, GROUP0); } /** @@ -93,98 +96,90 @@ public class PdpStatisticsServiceTest extends CommonPapRestServer { @Test public void testCreatePdpStatisticsFailure() { - assertThatThrownBy(() -> { - pdpStatisticsService.createPdpStatistics(null); - }).hasMessageMatching(LIST_IS_NULL); + assertThatThrownBy(() -> pdpStatisticsService.createPdpStatistics(null)).hasMessageMatching(LIST_IS_NULL); PdpStatistics pdpStatisticsErr = new PdpStatistics(); pdpStatisticsErr.setPdpInstanceId("NULL"); pdpStatisticsErr.setPdpGroupName(GROUP); - assertThatThrownBy(() -> { - pdpStatisticsService.createPdpStatistics(List.of(pdpStatisticsErr)); - }).hasMessageContaining("item \"name\" value \"NULL\" INVALID, is null"); + assertThatThrownBy(() -> pdpStatisticsService.createPdpStatistics(List.of(pdpStatisticsErr))) + .hasMessageContaining("item \"name\" value \"NULL\" INVALID, is null"); } @Test public void testFetchDatabaseStatistics() { - List<PdpStatistics> createList = List.of(pdpStatistics1, pdpStatistics3, pdpStatistics4, pdpStatistics2); pdpStatisticsService.createPdpStatistics(createList); - Map<String, Map<String, List<PdpStatistics>>> created = - pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, null, null); - assertThat(created).hasSize(2); - assertThat(created.get(GROUP0)).hasSize(1); - assertThat(created.get(GROUP0).get(SUBGROUP)).hasSize(1); - assertThat(created.get(GROUP)).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).hasSize(3); - - created = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, TIMESTAMP2, TIMESTAMP2); - assertThat(created).hasSize(2); - assertThat(created.get(GROUP0)).hasSize(1); - assertThat(created.get(GROUP0).get(SUBGROUP)).isEqualTo(List.of(pdpStatistics4)); - assertThat(created.get(GROUP)).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).isEqualTo(List.of(pdpStatistics3)); - - created = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, null, TIMESTAMP1); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP)).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).hasSize(2); - - created = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, TIMESTAMP2, null); - assertThat(created).hasSize(2); - - created = pdpStatisticsService.fetchDatabaseStatistics(GROUP0, NUMBER_RECORDS, TIMESTAMP2, TIMESTAMP2); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP0)).hasSize(1); - assertThat(created.get(GROUP0).get(SUBGROUP)).isEqualTo(List.of(pdpStatistics4)); - - created = pdpStatisticsService.fetchDatabaseStatistics(GROUP, NUMBER_RECORDS, null, TIMESTAMP1); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP)).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).hasSize(2); - - created = pdpStatisticsService.fetchDatabaseStatistics(GROUP, NUMBER_RECORDS, TIMESTAMP2, null); - assertThat(created).hasSize(1); - - created = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, TIMESTAMP1, TIMESTAMP2); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP)).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).hasSize(3); - - created = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, null, TIMESTAMP1); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP)).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).hasSize(2); - - created = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, TIMESTAMP2, null); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).isEqualTo(List.of(pdpStatistics3)); - - created = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NAME1, NUMBER_RECORDS, TIMESTAMP1, + + Map<String, Map<String, List<PdpStatistics>>> statistics; + + statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, null, null); + assertGroupAndSubgroupSize(statistics, 2, GROUP0, 1); + assertGroupAndSubgroupSize(statistics, 2, GROUP, 3); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, TIMESTAMP2, TIMESTAMP2); + assertGroupAndSubgroupSize(statistics, 2, GROUP0, 1); + assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4)); + assertGroupAndSubgroupSize(statistics, 2, GROUP, 1); + assertThat(statistics.get(GROUP)).containsEntry(SUBGROUP, List.of(pdpStatistics3)); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, null, TIMESTAMP1); + assertGroupAndSubgroupSize(statistics, 1, GROUP, 2); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, TIMESTAMP2, null); + assertThat(statistics).hasSize(2); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP0, NUMBER_RECORDS, TIMESTAMP2, TIMESTAMP2); + assertThat(statistics).hasSize(1); + assertThat(statistics.get(GROUP0)).hasSize(1); + assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4)); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, NUMBER_RECORDS, null, TIMESTAMP1); + assertGroupAndSubgroupSize(statistics, 1, GROUP, 2); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, NUMBER_RECORDS, TIMESTAMP2, null); + assertThat(statistics).hasSize(1); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, TIMESTAMP1, + TIMESTAMP2); + assertGroupAndSubgroupSize(statistics, 1, GROUP, 3); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, null, TIMESTAMP1); + assertGroupAndSubgroupSize(statistics, 1, GROUP, 2); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, TIMESTAMP2, null); + assertThat(statistics).hasSize(1); + assertThat(statistics.get(GROUP)).containsEntry(SUBGROUP, List.of(pdpStatistics3)); + + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NAME1, NUMBER_RECORDS, TIMESTAMP1, TIMESTAMP2); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP)).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).hasSize(2); + assertGroupAndSubgroupSize(statistics, 1, GROUP, 2); - created = + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NAME1, NUMBER_RECORDS, null, TIMESTAMP1); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP)).hasSize(1); - assertThat(created.get(GROUP).get(SUBGROUP)).hasSize(1); + assertGroupAndSubgroupSize(statistics, 1, GROUP, 1); - created = + statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP0, SUBGROUP, NAME3, NUMBER_RECORDS, TIMESTAMP2, null); - assertThat(created).hasSize(1); - assertThat(created.get(GROUP0).get(SUBGROUP)).isEqualTo(List.of(pdpStatistics4)); + assertThat(statistics).hasSize(1); + assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4)); + } + + /** + * Asserts if statistics list is the expected size and the subgroup list is also the expected size. + */ + private void assertGroupAndSubgroupSize(Map<String, Map<String, List<PdpStatistics>>> statistics, int listSize, + String group, int subGroupSize) { + assertThat(statistics).hasSize(listSize); + assertThat(statistics.get(group)).hasSize(1); + assertThat(statistics.get(group).get(SUBGROUP)).hasSize(subGroupSize); } - private PdpStatistics generatePdpStatistics(String pdpInstanceId, Instant date, String group, - String subgroup) { + private PdpStatistics generatePdpStatistics(String pdpInstanceId, Instant date, String group) { PdpStatistics pdpStatistics11 = new PdpStatistics(); pdpStatistics11.setPdpInstanceId(pdpInstanceId); pdpStatistics11.setTimeStamp(date); pdpStatistics11.setPdpGroupName(group); - pdpStatistics11.setPdpSubGroupName(subgroup); + pdpStatistics11.setPdpSubGroupName(PdpStatisticsServiceTest.SUBGROUP); pdpStatistics11.setPolicyDeployCount(2); pdpStatistics11.setPolicyDeployFailCount(1); pdpStatistics11.setPolicyDeploySuccessCount(1); diff --git a/main/src/test/java/org/onap/policy/pap/main/service/PolicyAuditServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/PolicyAuditServiceTest.java index 68044ad7..8c351e24 100644 --- a/main/src/test/java/org/onap/policy/pap/main/service/PolicyAuditServiceTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/service/PolicyAuditServiceTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +37,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.pap.main.repository.PolicyAuditRepository; import org.onap.policy.pap.main.rest.CommonPapRestServer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +@ActiveProfiles("test") public class PolicyAuditServiceTest extends CommonPapRestServer { private static final String FIELD_IS_NULL = "%s is marked .*ull but is null"; @@ -74,14 +77,12 @@ public class PolicyAuditServiceTest extends CommonPapRestServer { PolicyAudit.builder().pdpType("pdpType").action(AuditAction.DEPLOYMENT).timestamp(Instant.now()).build()); assertThrows(PfModelRuntimeException.class, () -> policyAuditService.createAuditRecords(audits)); - assertThatThrownBy(() -> { - policyAuditService.createAuditRecords(audits); - }).isInstanceOf(PfModelRuntimeException.class) + assertThatThrownBy(() -> policyAuditService.createAuditRecords(audits)) + .isInstanceOf(PfModelRuntimeException.class) .hasMessageContaining("\"createAuditRecords\" INVALID, item has status INVALID"); - assertThatThrownBy(() -> { - policyAuditService.createAuditRecords(null); - }).hasMessageMatching(String.format(FIELD_IS_NULL, "audits")); + assertThatThrownBy(() -> policyAuditService.createAuditRecords(null)) + .hasMessageMatching(String.format(FIELD_IS_NULL, "audits")); } @Test @@ -109,9 +110,9 @@ public class PolicyAuditServiceTest extends CommonPapRestServer { NUMBER_RECORDS, null, null)).hasSize(2); assertThat( policyAuditService.getAuditRecords(GROUP_A, MY_POLICY.getName(), "9.9.9", NUMBER_RECORDS, null, null)) - .hasSize(0); + .isEmpty(); assertThat(policyAuditService.getAuditRecords(GROUP_B, MY_POLICY.getName(), MY_POLICY.getVersion(), - NUMBER_RECORDS, null, null)).hasSize(0); + NUMBER_RECORDS, null, null)).isEmpty(); assertThat(policyAuditService.getAuditRecords(GROUP_B, MY_POLICY2.getName(), MY_POLICY2.getVersion(), NUMBER_RECORDS, null, null)).hasSize(2); assertThat(policyAuditService.getAuditRecords(MY_POLICY2.getName(), MY_POLICY2.getVersion(), NUMBER_RECORDS, diff --git a/main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java index 2a354036..aeb2fdbb 100644 --- a/main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +34,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; import org.onap.policy.pap.main.rest.CommonPapRestServer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +@ActiveProfiles("test") public class PolicyStatusServiceTest extends CommonPapRestServer { private static final String GROUP_A = "groupA"; diff --git a/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java b/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java index c11af694..67921381 100644 --- a/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java +++ b/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2022 Nordix Foundation. * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ @@ -34,14 +34,15 @@ import java.io.File; import java.io.FileOutputStream; import java.nio.charset.StandardCharsets; import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.pap.main.PapConstants; -import org.onap.policy.pap.main.PolicyPapException; import org.onap.policy.pap.main.comm.PdpHeartbeatListener; import org.onap.policy.pap.main.comm.PdpModifyRequestMap; import org.onap.policy.pap.main.notification.PolicyNotifier; @@ -58,15 +59,13 @@ import org.onap.policy.pap.main.rest.PapStatisticsManager; public class TestPapActivator { private static final String CONFIG_FILE = "src/test/resources/parameters/TestConfigParams.json"; - private static int port; - private PapActivator activator; /** * Allocates a new DB name, server port, and creates a config file. */ @BeforeClass - public static void setUpBeforeClass() throws Exception { + public static void setUpBeforeClass() { CommonTestData.newDb(); } @@ -78,9 +77,10 @@ public class TestPapActivator { @Before public void setUp() throws Exception { Registry.newRegistry(); + TopicEndpointManager.getManager().shutdown(); HttpServletServerFactoryInstance.getServerFactory().destroy(); - port = NetworkUtil.allocPort(); + int port = NetworkUtil.allocPort(); String json = new CommonTestData().getPapParameterGroupAsString(port); @@ -110,8 +110,13 @@ public class TestPapActivator { } } + @AfterClass + public static void afterClass() { + Registry.newRegistry(); + } + @Test - public void testPapActivator() throws PolicyPapException { + public void testPapActivator() { assertFalse(activator.isAlive()); activator.start(); assertTrue(activator.isAlive()); @@ -130,7 +135,7 @@ public class TestPapActivator { } @Test - public void testTerminate() throws Exception { + public void testTerminate() { activator.start(); activator.stop(); assertFalse(activator.isAlive()); diff --git a/main/src/test/resources/application-test-e2e.yaml b/main/src/test/resources/application-test-e2e.yaml new file mode 100644 index 00000000..09a2ca6a --- /dev/null +++ b/main/src/test/resources/application-test-e2e.yaml @@ -0,0 +1,90 @@ +spring: + security: + user: + name: policyadmin + password: zb!XztG34 + http: + converters: + preferred-json-mapper: gson + datasource: + url: jdbc:h2:mem:testdb + driverClassName: org.h2.Driver + jpa: + properties: + hibernate: + dialect: org.hibernate.dialect.H2Dialect + hibernate: + ddl-auto: create-drop + naming: + physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy + +server: + port: 6969 + +pap: + name: "PapGroupE2E" + aaf: false + topic: + pdp-pap.name: pdp-pap-topic + notification.name: notification-topic + heartbeat.name: heartbeat-topic + pdpParameters: + updateParameters: + maxRetryCount: 1 + maxWaitMs: 3000 + stateChangeParameters: + maxRetryCount: 1 + maxWaitMs: 3000 + heartBeatMs: 6000 + maxMessageAgeMs: 20000 + savePdpStatisticsInDb: true + topicParameterGroup: + topicSources: + - topic: ${pap.topic.pdp-pap.name} + servers: + - message-router + topicCommInfrastructure: noop + - topic: ${pap.topic.heartbeat.name} + effectiveTopic: ${pap.topic.pdp-pap.name} + consumerGroup: policy-pap + servers: + - message-router + topicCommInfrastructure: noop + topicSinks: + - topic: ${pap.topic.pdp-pap.name} + servers: + - message-router + topicCommInfrastructure: noop + - topic: ${pap.topic.notification.name} + servers: + - message-router + topicCommInfrastructure: noop + healthCheckRestClientParameters: + - clientName: api + hostname: policy-api + port: 6969 + userName: policyadmin + password: zb!XztG34 + useHttps: true + basePath: policy/api/v1/healthcheck + - clientName: distribution + hostname: policy-distribution + port: 6969 + userName: healthcheck + password: zb!XztG34 + useHttps: true + basePath: healthcheck + - clientName: dmaap + hostname: message-router + port: 3905 + useHttps: true + basePath: topics + +management: + endpoints: + web: + base-path: / + exposure: + include: health, metrics, prometheus + path-mapping.prometheus: metrics diff --git a/main/src/test/resources/config/application.yaml b/main/src/test/resources/application-test.yaml index 2fb9514d..de32fc43 100644 --- a/main/src/test/resources/config/application.yaml +++ b/main/src/test/resources/application-test.yaml @@ -14,7 +14,7 @@ spring: hibernate: dialect: org.hibernate.dialect.H2Dialect hibernate: - ddl-auto: update + ddl-auto: create-drop naming: physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl implicit-strategy: org.onap.policy.common.spring.utils.CustomImplicitNamingStrategy @@ -25,6 +25,10 @@ server: pap: name: "PapGroup" aaf: false + topic: + pdp-pap.name: POLICY-PDP-PAP + notification.name: POLICY-NOTIFICATION + heartbeat.name: POLICY-HEARTBEAT pdpParameters: updateParameters: maxRetryCount: 1 @@ -37,22 +41,22 @@ pap: savePdpStatisticsInDb: true topicParameterGroup: topicSources: - - topic: POLICY-PDP-PAP + - topic: ${pap.topic.pdp-pap.name} servers: - message-router topicCommInfrastructure: noop - - topic: POLICY-HEARTBEAT - effectiveTopic: POLICY-PDP-PAP + - topic: ${pap.topic.heartbeat.name} + effectiveTopic: ${pap.topic.pdp-pap.name} consumerGroup: policy-pap servers: - message-router topicCommInfrastructure: noop topicSinks: - - topic: POLICY-PDP-PAP + - topic: ${pap.topic.pdp-pap.name} servers: - message-router topicCommInfrastructure: noop - - topic: POLICY-NOTIFICATION + - topic: ${pap.topic.notification.name} servers: - message-router topicCommInfrastructure: noop diff --git a/main/src/test/resources/e2e/PapConfigParameters.json b/main/src/test/resources/e2e/PapConfigParameters.json index b2e100a5..e7f33771 100644 --- a/main/src/test/resources/e2e/PapConfigParameters.json +++ b/main/src/test/resources/e2e/PapConfigParameters.json @@ -1,5 +1,5 @@ { - "name": "PapGroup", + "name": "PapGroupE2E", "restServerParameters": { "host": "0.0.0.0", "port": ${port}, @@ -29,23 +29,23 @@ }, "topicParameterGroup": { "topicSources" : [{ - "topic" : "POLICY-PDP-PAP", + "topic" : "pdp-pap-topic", "servers" : [ "message-router" ], "topicCommInfrastructure" : "noop" }, { - "topic" : "POLICY-HEARTBEAT", + "topic" : "heartbeat-topic", "effectiveTopic": "POLICY-PDP-PAP", "consumerGroup": "policy-pap", "servers" : [ "message-router" ], "topicCommInfrastructure" : "noop" }], "topicSinks" : [{ - "topic" : "POLICY-PDP-PAP", + "topic" : "pdp-pap-topic", "servers" : [ "message-router" ], "topicCommInfrastructure" : "noop" },{ - "topic" : "POLICY-NOTIFICATION", + "topic" : "notification-topic", "servers" : [ "message-router" ], "topicCommInfrastructure" : "noop" }] |