summaryrefslogtreecommitdiffstats
path: root/runtime-acm
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-10-26 14:34:46 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2022-10-27 12:53:12 +0100
commit9082093f00a3f21b2f824251c5ce60b775ad312c (patch)
tree3c7321f71bc742982a5011012d140c4beebde1db /runtime-acm
parent75a69e67d03a55d3961d0f6a9f7925868dd39aa6 (diff)
Remove old implementation of statistics in ACM-runtime
The old implementation of statistics in ACM-runtime can be removed due the Prometheus metrics support. Issue-ID: POLICY-4419 Change-Id: Idecad04b4a5dd32ce2ebc1149eb99e4fdc6f0db1 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java6
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java334
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java247
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java30
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java314
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java242
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java32
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java11
8 files changed, 18 insertions, 1198 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java
index 94c8bce06..0918cea1c 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-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 +20,7 @@
package org.onap.policy.clamp.acm.runtime.config;
-import org.onap.policy.clamp.acm.runtime.main.rest.MonitoringQueryController;
+import org.onap.policy.clamp.acm.runtime.main.rest.CommissioningController;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
@@ -39,7 +39,7 @@ public class SpringFoxConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select()
- .apis(RequestHandlerSelectors.basePackage(MonitoringQueryController.class.getPackageName()))
+ .apis(RequestHandlerSelectors.basePackage(CommissioningController.class.getPackageName()))
.paths(PathSelectors.any()).build();
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java
deleted file mode 100644
index 30c1d5dc9..000000000
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/MonitoringQueryController.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.runtime.main.rest;
-
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.ResponseHeader;
-import java.time.Instant;
-import java.util.UUID;
-import lombok.RequiredArgsConstructor;
-import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController;
-import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList;
-import org.onap.policy.models.base.PfModelException;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * This class handles REST endpoints for ACM Statistics monitoring.
- */
-@RestController
-@RequiredArgsConstructor
-public class MonitoringQueryController extends AbstractRestController {
-
- private static final String TAGS = "Clamp Automation Composition Monitoring API";
- private final MonitoringProvider provider;
-
- /**
- * Queries details of automation composition participants statistics.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the participant to get, null for all participants statistics
- * @param version the version of the participant to get, null for all participants with the given name
- * @param recordCount the record count to be fetched
- * @param startTime the time from which to get statistics
- * @param endTime the time to which to get statistics
- * @return the participant statistics
- */
- // @formatter:off
- @GetMapping(value = "/monitoring/participant",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested participant stats",
- notes = "Queries details of the requested participant stats, returning all participant stats",
- response = ParticipantStatisticsList.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ParticipantStatisticsList> queryParticipantStatistics(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Automation composition participant name") @RequestParam(
- value = "name",
- required = false) final String name,
- @ApiParam(value = "Automation composition participant version", required = false) @RequestParam(
- value = "version",
- required = false) final String version,
- @ApiParam(value = "Record count", required = false) @RequestParam(
- value = "recordCount",
- required = false,
- defaultValue = "0") final int recordCount,
- @ApiParam(value = "start time", required = false) @RequestParam(
- value = "startTime",
- required = false) final String startTime,
- @ApiParam(value = "end time", required = false) @RequestParam(
- value = "endTime",
- required = false) final String endTime) {
-
- Instant startTimestamp = null;
- Instant endTimestamp = null;
-
- if (startTime != null) {
- startTimestamp = Instant.parse(startTime);
- }
- if (endTime != null) {
- endTimestamp = Instant.parse(endTime);
- }
- return ResponseEntity.ok().body(
- provider.fetchFilteredParticipantStatistics(name, version, recordCount, startTimestamp, endTimestamp));
- }
-
- /**
- * Queries details of all participant statistics per automation composition.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the automation composition
- * @param version version of the automation composition
- * @return the automation composition element statistics
- */
- // @formatter:off
- @GetMapping(value = "/monitoring/participants/automationcomposition",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of all the participant stats in a automation composition",
- notes = "Queries details of the participant stats, returning all participant stats",
- response = AcElementStatisticsList.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- })
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ParticipantStatisticsList> queryParticipantStatisticsPerAutomationComposition(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Automation composition name", required = true) @RequestParam(
- value = "name",
- required = false) final String name,
- @ApiParam(value = "Automation composition version", required = true) @RequestParam(
- value = "version",
- required = false) final String version) {
-
- return ResponseEntity.ok().body(provider.fetchParticipantStatsPerAutomationComposition(name, version));
- }
-
- /**
- * Queries details of all automation composition element statistics per automation composition.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the automation composition
- * @param version version of the automation composition
- * @return the automation composition element statistics
- */
- // @formatter:off
- @GetMapping(value = "/monitoring/acelements/automationcomposition",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested acElement stats in a automation composition",
- notes = "Queries details of the requested acElement stats, returning all acElement stats",
- response = AcElementStatisticsList.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- })
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<AcElementStatisticsList> queryElementStatisticsPerAutomationComposition(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Automation composition name", required = true) @RequestParam(
- value = "name",
- required = false) final String name,
- @ApiParam(value = "Automation composition version", required = true) @RequestParam(
- value = "version",
- required = false) final String version) {
-
- return ResponseEntity.ok().body(provider.fetchAcElementStatsPerAutomationComposition(name, version));
- }
-
- /**
- * Queries details of all automation composition element statistics per automation composition.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the automation composition
- * @param version version of the automation composition
- * @param id Id of the automation composition element
- * @param recordCount the record count to be fetched
- * @param startTime the time from which to get statistics
- * @param endTime the time to which to get statistics
- * @return the automation composition element statistics
- * @throws PfModelException on errors getting details of all automation composition element statistics per
- * automation composition
- */
- // @formatter:off
- @GetMapping(value = "/monitoring/acelement",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested acElement stats",
- notes = "Queries details of the requested acElement stats, returning all acElement stats",
- response = AcElementStatisticsList.class,
- tags = {TAGS},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- })
- @ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<AcElementStatisticsList> queryElementStatistics(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Participant name", required = true) @RequestParam(
- value = "name",
- required = false) final String name,
- @ApiParam(value = "Participant version", required = true) @RequestParam(
- value = "version",
- required = false) final String version,
- @ApiParam(value = "Record count", required = false) @RequestParam(
- value = "recordCount",
- required = false,
- defaultValue = "0") final int recordCount,
- @ApiParam(value = "Automation composition element id", required = false) @RequestParam(
- value = "id",
- required = false) final String id,
- @ApiParam(value = "start time", required = false) @RequestParam(
- value = "startTime",
- required = false) final String startTime,
- @ApiParam(value = "end time", required = false) @RequestParam(
- value = "endTime",
- required = false) final String endTime)
- throws PfModelException {
-
- Instant startTimestamp = null;
- Instant endTimestamp = null;
-
- if (startTime != null) {
- startTimestamp = Instant.parse(startTime);
- }
- if (endTime != null) {
- endTimestamp = Instant.parse(endTime);
- }
- return ResponseEntity.ok().body(
- provider.fetchFilteredAcElementStatistics(name, version, id, startTimestamp, endTimestamp, recordCount));
- }
-
-}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java
deleted file mode 100644
index 2950ad9da..000000000
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/monitoring/MonitoringProvider.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.runtime.monitoring;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import lombok.AllArgsConstructor;
-import lombok.NonNull;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList;
-import org.onap.policy.clamp.models.acm.persistence.provider.AcElementStatisticsProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantStatisticsProvider;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * This class provides information about statistics data of Automation Composition elements and Participants in database
- * to callers.
- */
-@Service
-@Transactional
-@AllArgsConstructor
-public class MonitoringProvider {
-
- private static final String DESC_ORDER = "DESC";
- private final ParticipantStatisticsProvider participantStatisticsProvider;
- private final AcElementStatisticsProvider acElementStatisticsProvider;
- private final AutomationCompositionProvider automationCompositionProvider;
-
- /**
- * Create participant statistics.
- *
- * @param participantStatistics the participant statistics
- * @return the result of create operation
- * @throws PfModelException on creation errors
- */
- public ParticipantStatisticsList createParticipantStatistics(List<ParticipantStatistics> participantStatistics)
- throws PfModelException {
- var participantStatisticsList = new ParticipantStatisticsList();
- participantStatisticsList
- .setStatisticsList(participantStatisticsProvider.createParticipantStatistics(participantStatistics));
-
- return participantStatisticsList;
- }
-
- /**
- * Create AcElement statistics.
- *
- * @param acElementStatisticsList the AcElement statistics
- * @return the result of create operation
- * @throws PfModelException on creation errors
- */
- public AcElementStatisticsList createAcElementStatistics(List<AcElementStatistics> acElementStatisticsList)
- throws PfModelException {
- var elementStatisticsList = new AcElementStatisticsList();
- elementStatisticsList
- .setAcElementStatistics(acElementStatisticsProvider.createAcElementStatistics(acElementStatisticsList));
-
- return elementStatisticsList;
- }
-
- /**
- * Get participant statistics based on specific filters.
- *
- * @param name the name of the participant statistics to get, null to get all statistics
- * @param version the version of the participant statistics to get, null to get all statistics
- * @param recordCount number of records to be fetched.
- * @param startTime start of the timestamp, from statistics to be filtered
- * @param endTime end of the timestamp up to which statistics to be filtered
- * @return the participant found
- */
- @Transactional(readOnly = true)
- public ParticipantStatisticsList fetchFilteredParticipantStatistics(@NonNull final String name,
- final String version, int recordCount, Instant startTime, Instant endTime) {
- var participantStatisticsList = new ParticipantStatisticsList();
-
- // Additional parameters can be added in filterMap for filtering data.
- Map<String, Object> filterMap = null;
- participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(name,
- version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
-
- return participantStatisticsList;
- }
-
- /**
- * Get all participant statistics records found for a specific automation composition.
- *
- * @param automationCompositionName name of the automation composition
- * @param automationCompositionVersion version of the automation composition
- * @return All the participant statistics found
- * @throws PfModelRuntimeException on errors getting participant statistics
- */
- @Transactional(readOnly = true)
- public ParticipantStatisticsList fetchParticipantStatsPerAutomationComposition(
- @NonNull final String automationCompositionName, @NonNull final String automationCompositionVersion) {
- var statisticsList = new ParticipantStatisticsList();
- List<ParticipantStatistics> participantStatistics = new ArrayList<>();
- try {
- // Fetch all participantIds for a specific automation composition
- List<ToscaConceptIdentifier> participantIds =
- getAllParticipantIdsPerAutomationComposition(automationCompositionName, automationCompositionVersion);
- for (ToscaConceptIdentifier id : participantIds) {
- participantStatistics.addAll(participantStatisticsProvider
- .getFilteredParticipantStatistics(id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0));
- }
- statisticsList.setStatisticsList(participantStatistics);
- } catch (PfModelException e) {
- throw new PfModelRuntimeException(e);
- }
- return statisticsList;
- }
-
- /**
- * Get AcElement statistics based on specific filters.
- *
- * @param name the name of the AcElement statistics to get, null to get all statistics
- * @param version the version of the AcElement statistics to get, null to get all statistics
- * @param id UUID of the automation composition element
- * @param startTime start of the timestamp, from statistics to be filtered
- * @param endTime end of the timestamp up to which statistics to be filtered
- * @param recordCount number of records to be fetched.
- * @return the participant found
- * @throws PfModelException on errors getting automation composition statistics
- */
- @Transactional(readOnly = true)
- public AcElementStatisticsList fetchFilteredAcElementStatistics(@NonNull final String name, final String version,
- final String id, Instant startTime, Instant endTime, int recordCount) throws PfModelException {
- var acElementStatisticsList = new AcElementStatisticsList();
- Map<String, Object> filterMap = new HashMap<>();
- // Adding UUID in filter if present
- if (id != null) {
- filterMap.put("localName", id);
- }
- acElementStatisticsList.setAcElementStatistics(acElementStatisticsProvider.getFilteredAcElementStatistics(name,
- version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
-
- return acElementStatisticsList;
- }
-
- /**
- * Get AcElement statistics per automation composition.
- *
- * @param name the name of the automation composition
- * @param version the version of the automation composition
- * @return the AcElement statistics found
- * @throws PfModelRuntimeException on errors getting automation composition statistics
- */
- @Transactional(readOnly = true)
- public AcElementStatisticsList fetchAcElementStatsPerAutomationComposition(@NonNull final String name,
- @NonNull final String version) {
- var acElementStatisticsList = new AcElementStatisticsList();
- List<AcElementStatistics> acElementStats = new ArrayList<>();
- try {
- List<AutomationCompositionElement> acElements = new ArrayList<>();
- // Fetch all automation composition elements for the automation composition
- var automationCompositionOpt =
- automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version));
- if (automationCompositionOpt.isPresent()) {
- acElements.addAll(automationCompositionOpt.get().getElements().values());
- // Collect automation composition element statistics for each acElement.
- for (AutomationCompositionElement acElement : acElements) {
- acElementStats.addAll(fetchFilteredAcElementStatistics(acElement.getParticipantId().getName(),
- acElement.getParticipantId().getVersion(), acElement.getId().toString(), null, null, 0)
- .getAcElementStatistics());
- }
- }
- acElementStatisticsList.setAcElementStatistics(acElementStats);
- } catch (PfModelException e) {
- throw new PfModelRuntimeException(e);
- }
- return acElementStatisticsList;
- }
-
- /**
- * If required, REST end point can be defined for this method to fetch associated participant Ids
- * for a automation composition.
- *
- * @param name the name of the automation composition
- * @param version the version of the automation composition
- * @return List of participant Id
- * @throws PfModelException on errors
- */
- @Transactional(readOnly = true)
- public List<ToscaConceptIdentifier> getAllParticipantIdsPerAutomationComposition(String name, String version)
- throws PfModelException {
- List<ToscaConceptIdentifier> participantIds = new ArrayList<>();
- var automationCompositionOpt =
- automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version));
- if (automationCompositionOpt.isPresent()) {
- for (AutomationCompositionElement acElement : automationCompositionOpt.get().getElements().values()) {
- participantIds.add(acElement.getParticipantId());
- }
- }
- return participantIds;
- }
-
- /**
- * If required, REST end point can be defined for this method to fetch associated automation composition element Ids
- * for a automation composition.
- *
- * @param name the name of the automation composition
- * @param version the version of the automation composition
- * @return Map of automation composition Id and participant details
- * @throws PfModelException on errors
- */
- @Transactional(readOnly = true)
- public Map<String, ToscaConceptIdentifier> getAllAcElementsIdPerAutomationComposition(String name, String version)
- throws PfModelException {
- Map<String, ToscaConceptIdentifier> acElementId = new HashMap<>();
- var automationCompositionOpt =
- automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version));
- if (automationCompositionOpt.isPresent()) {
- for (AutomationCompositionElement acElement : automationCompositionOpt.get().getElements().values()) {
- acElementId.put(acElement.getId().toString(), acElement.getParticipantId());
- }
- }
- return acElementId;
- }
-}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
index 6591655f6..219383ac5 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
@@ -30,7 +30,6 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
-import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
@@ -39,7 +38,6 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePubli
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
@@ -83,7 +81,6 @@ public class SupervisionHandler {
private final AutomationCompositionProvider automationCompositionProvider;
private final ParticipantProvider participantProvider;
- private final MonitoringProvider monitoringProvider;
private final ServiceTemplateProvider serviceTemplateProvider;
// Publishers for participant communication
@@ -143,13 +140,6 @@ public class SupervisionHandler {
superviseParticipant(participantStatusMessage);
} catch (PfModelException | AutomationCompositionException svExc) {
LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
- return;
- }
-
- try {
- superviseAutomationCompositions(participantStatusMessage);
- } catch (PfModelException | AutomationCompositionException svExc) {
- LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
}
}
@@ -499,26 +489,6 @@ public class SupervisionHandler {
checkParticipant(participantStatusMessage, participantStatusMessage.getState(),
participantStatusMessage.getHealthStatus());
-
- monitoringProvider.createParticipantStatistics(List.of(participantStatusMessage.getParticipantStatistics()));
- }
-
- private void superviseAutomationCompositions(ParticipantStatus participantStatusMessage)
- throws PfModelException, AutomationCompositionException {
- if (participantStatusMessage.getAutomationCompositionInfoList() != null) {
- for (AutomationCompositionInfo acEntry : participantStatusMessage.getAutomationCompositionInfoList()) {
- var dbAutomationComposition = automationCompositionProvider
- .getAutomationComposition(new ToscaConceptIdentifier(acEntry.getAutomationCompositionId()));
- if (dbAutomationComposition == null) {
- exceptionOccured(Response.Status.NOT_FOUND,
- "PARTICIPANT_STATUS automation composition not found in database: "
- + acEntry.getAutomationCompositionId());
- }
- dbAutomationComposition.setState(acEntry.getState());
- monitoringProvider.createAcElementStatistics(
- acEntry.getAutomationCompositionStatistics().getAcElementStatisticsList().getAcElementStatistics());
- }
- }
}
private void exceptionOccured(Response.Status status, String reason) throws AutomationCompositionException {
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java
deleted file mode 100644
index 9dc77e793..000000000
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.runtime.monitoring;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.time.Instant;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-import javax.ws.rs.core.Response;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList;
-import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList;
-import org.onap.policy.clamp.models.acm.persistence.provider.AcElementStatisticsProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantStatisticsProvider;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class TestMonitoringProvider {
-
- private static final String AC_PARTICIPANT_STATISTICS_JSON =
- "src/test/resources/rest/monitoring/TestParticipantStatistics.json";
- private static final String INVALID_PARTICIPANT_JSON_INPUT =
- "src/test/resources/rest/monitoring/TestParticipantStatistics_Invalid.json";
- private static final String AC_ELEMENT_STATISTICS_JSON =
- "src/test/resources/rest/monitoring/TestAcElementStatistics.json";
- private static final String INVALID_AC_ELEMENT_JSON_INPUT =
- "src/test/resources/rest/monitoring/TestAcElementStatistics_Invalid.json";
- private static final Coder CODER = new StandardCoder();
-
- private static final String STAT_LIST_IS_NULL = ".*StatisticsList is marked .*ull but is null";
- private static final String PARTICIPANT_STAT_LIST_IS_NULL =
- "participantStatisticsList is marked .*null but is null";
- private static final String NAME_IS_NULL = "name is marked .*null but is null";
- private static final String AC_LIST_IS_NULL = "acElementStatisticsList is marked .*null but is null";
- private static final String ID_VERSION1 = "1.001";
- private static final String ID_VERSION2 = "1.002";
- private static final String ID_NAME1 = "name1";
- private static final String ID_NAME2 = "name2";
- private static final String SORT_DESC = "DESC";
- private static final String ID_NAME3 = "testACName";
- private static final String ID_INVALID_NAME = "invalidACName";
- private static ParticipantStatisticsList inputParticipantStatistics;
- private static ParticipantStatisticsList invalidParticipantInput;
- private static AcElementStatisticsList inputAcElementStatistics;
- private static AcElementStatisticsList invalidAcElementInput;
-
- @BeforeAll
- public static void beforeSetupStatistics() throws CoderException {
- // Reading input json for statistics data
- inputParticipantStatistics =
- CODER.decode(new File(AC_PARTICIPANT_STATISTICS_JSON), ParticipantStatisticsList.class);
- invalidParticipantInput =
- CODER.decode(new File(INVALID_PARTICIPANT_JSON_INPUT), ParticipantStatisticsList.class);
- inputAcElementStatistics = CODER.decode(new File(AC_ELEMENT_STATISTICS_JSON), AcElementStatisticsList.class);
- invalidAcElementInput = CODER.decode(new File(INVALID_AC_ELEMENT_JSON_INPUT), AcElementStatisticsList.class);
- }
-
- @Test
- void testCreateParticipantStatistics() throws Exception {
- var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class);
- var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class);
- var acProvider = mock(AutomationCompositionProvider.class);
- MonitoringProvider provider =
- new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider);
-
- when(participantStatisticsProvider.createParticipantStatistics(any()))
- .thenReturn(inputParticipantStatistics.getStatisticsList());
-
- when(participantStatisticsProvider.createParticipantStatistics(eq(null)))
- .thenThrow(new PfModelRuntimeException(Response.Status.BAD_REQUEST, PARTICIPANT_STAT_LIST_IS_NULL));
-
- // Creating statistics data in db with null input
-
- assertThatThrownBy(() -> provider.createParticipantStatistics(null)).hasMessageMatching(STAT_LIST_IS_NULL);
-
- assertThatThrownBy(() -> provider.createParticipantStatistics(invalidParticipantInput.getStatisticsList()))
- .hasMessageMatching(PARTICIPANT_STAT_LIST_IS_NULL);
-
- // Creating statistics data from input json
- ParticipantStatisticsList createResponse =
- provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
-
- assertThat(createResponse.getStatisticsList()).hasSize(3);
- assertEquals(createResponse.getStatisticsList().toString().replaceAll("\\s+", ""),
- inputParticipantStatistics.getStatisticsList().toString().replaceAll("\\s+", ""));
- }
-
- @Test
- void testGetParticipantStatistics() throws Exception {
- var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class);
- when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), any(), any(), any(), eq(null),
- eq(SORT_DESC), eq(0))).thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(0)));
-
- when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), any(),
- eq(Instant.parse("2021-01-11T12:00:00.000Z")), eq(Instant.parse("2021-01-11T16:00:00.000Z")), eq(null),
- eq(SORT_DESC), eq(0))).thenReturn(List.of());
-
- when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME2), any(), any(), any(), eq(null),
- eq(SORT_DESC), eq(1))).thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(2)));
-
- var acProvider = mock(AutomationCompositionProvider.class);
- var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class);
- MonitoringProvider provider =
- new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider);
- provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
-
- assertThatThrownBy(() -> provider.fetchFilteredParticipantStatistics(null, null, 0, null, null))
- .hasMessageMatching(NAME_IS_NULL);
-
- // Fetch specific statistics record with name, version and record count
- ParticipantStatisticsList getResponse =
- provider.fetchFilteredParticipantStatistics(ID_NAME2, ID_VERSION1, 1, null, null);
- assertThat(getResponse.getStatisticsList()).hasSize(1);
- assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""),
- inputParticipantStatistics.getStatisticsList().get(2).toString().replaceAll("\\s+", ""));
-
- // Fetch statistics using timestamp
- getResponse = provider.fetchFilteredParticipantStatistics(ID_NAME1, ID_VERSION1, 0, null,
- Instant.parse("2021-01-10T15:00:00.000Z"));
- assertThat(getResponse.getStatisticsList()).hasSize(1);
-
- getResponse = provider.fetchFilteredParticipantStatistics(ID_NAME1, ID_VERSION1, 0,
- Instant.parse("2021-01-11T12:00:00.000Z"), Instant.parse("2021-01-11T16:00:00.000Z"));
-
- assertThat(getResponse.getStatisticsList()).isEmpty();
- }
-
- @Test
- void testCreateAcElementStatistics() throws Exception {
- var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class);
- when(acElementStatisticsProvider.createAcElementStatistics(any()))
- .thenReturn(inputAcElementStatistics.getAcElementStatistics());
-
- when(acElementStatisticsProvider.createAcElementStatistics(eq(null)))
- .thenThrow(new PfModelRuntimeException(Response.Status.BAD_REQUEST, AC_LIST_IS_NULL));
-
- var acProvider = mock(AutomationCompositionProvider.class);
-
- var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class);
- MonitoringProvider provider =
- new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider);
- // Creating statistics data in db with null input
- assertThatThrownBy(() -> provider.createAcElementStatistics(null)).hasMessageMatching(STAT_LIST_IS_NULL);
-
- assertThatThrownBy(() -> provider.createAcElementStatistics(invalidAcElementInput.getAcElementStatistics()))
- .hasMessageMatching(AC_LIST_IS_NULL);
-
- // Creating acElement statistics data from input json
- AcElementStatisticsList createResponse =
- provider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics());
-
- assertThat(createResponse.getAcElementStatistics()).hasSize(4);
- assertEquals(createResponse.getAcElementStatistics().toString().replaceAll("\\s+", ""),
- inputAcElementStatistics.getAcElementStatistics().toString().replaceAll("\\s+", ""));
- }
-
- @Test
- void testGetAcElementStatistics() throws Exception {
- var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class);
- var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class);
- var acProvider = mock(AutomationCompositionProvider.class);
-
- when(acElementStatisticsProvider.getFilteredAcElementStatistics(eq(ID_NAME1), any(), any(), any(), anyMap(),
- eq(SORT_DESC), eq(0)))
- .thenReturn(List.of(inputAcElementStatistics.getAcElementStatistics().get(0),
- inputAcElementStatistics.getAcElementStatistics().get(1)));
-
- when(acElementStatisticsProvider.getFilteredAcElementStatistics(eq(ID_NAME1), any(), any(), any(), anyMap(),
- eq(SORT_DESC), eq(0)))
- .thenReturn(List.of(inputAcElementStatistics.getAcElementStatistics().get(0),
- inputAcElementStatistics.getAcElementStatistics().get(1)));
-
- MonitoringProvider provider =
- new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider);
- assertThatThrownBy(() -> provider
- .fetchFilteredAcElementStatistics(null, null, null, null, null, 0))
- .hasMessageMatching(NAME_IS_NULL);
-
- provider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics());
-
- AcElementStatisticsList getResponse =
- provider.fetchFilteredAcElementStatistics(ID_NAME1, null, null, null, null, 0);
-
- assertThat(getResponse.getAcElementStatistics()).hasSize(2);
- assertEquals(getResponse.getAcElementStatistics().get(0).toString().replaceAll("\\s+", ""),
- inputAcElementStatistics.getAcElementStatistics().get(0).toString().replaceAll("\\s+", ""));
-
- // Fetch specific statistics record with name, id and record count
- getResponse = provider.fetchFilteredAcElementStatistics(ID_NAME1, ID_VERSION1,
- "709c62b3-8918-41b9-a747-d21eb79c6c20", null, null, 0);
- assertThat(getResponse.getAcElementStatistics()).hasSize(2);
-
- // Fetch statistics using timestamp
- getResponse = provider.fetchFilteredAcElementStatistics(ID_NAME1, ID_VERSION1, null,
- Instant.parse("2021-01-10T13:45:00.000Z"), null, 0);
- assertThat(getResponse.getAcElementStatistics()).hasSize(2);
- }
-
- @Test
- void testGetParticipantStatsPerAc() throws Exception {
- var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class);
- var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class);
- var mockAcProvider = Mockito.mock(AutomationCompositionProvider.class);
- var provider =
- new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, mockAcProvider);
-
- provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
-
- var automationComposition = new AutomationComposition();
- var element = new AutomationCompositionElement();
- element.setParticipantId(new ToscaConceptIdentifier(ID_NAME1, ID_VERSION1));
- automationComposition.setElements(Map.of(UUID.randomUUID(), element));
- when(mockAcProvider.findAutomationComposition(new ToscaConceptIdentifier(ID_NAME2, ID_VERSION1)))
- .thenReturn(Optional.of(automationComposition));
-
- when(participantStatisticsProvider.getFilteredParticipantStatistics(eq(ID_NAME1), eq(ID_VERSION1), any(), any(),
- eq(null), eq(SORT_DESC), eq(0)))
- .thenReturn(List.of(inputParticipantStatistics.getStatisticsList().get(0),
- inputParticipantStatistics.getStatisticsList().get(1)));
-
- ParticipantStatisticsList getResponse =
- provider.fetchParticipantStatsPerAutomationComposition(ID_NAME2, ID_VERSION1);
- assertThat(getResponse.getStatisticsList()).hasSize(2);
- assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""),
- inputParticipantStatistics.getStatisticsList().get(0).toString().replaceAll("\\s+", ""));
- assertThat(
- provider.fetchParticipantStatsPerAutomationComposition(ID_INVALID_NAME, ID_VERSION2).getStatisticsList())
- .isEmpty();
- }
-
- @Test
- void testAcElementStatsPerAc() throws Exception {
- // Setup a dummy automation composition data
- var mockAcElement = new AutomationCompositionElement();
- mockAcElement.setId(inputAcElementStatistics.getAcElementStatistics().get(0).getId());
- mockAcElement.setParticipantId(new ToscaConceptIdentifier(
- inputAcElementStatistics.getAcElementStatistics().get(0).getParticipantId().getName(),
- inputAcElementStatistics.getAcElementStatistics().get(0).getParticipantId().getVersion()));
- var mockAc = new AutomationComposition();
- mockAc.setElements(new LinkedHashMap<>());
- mockAc.getElements().put(mockAcElement.getId(), mockAcElement);
-
- var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class);
- var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class);
- var mockAcProvider = Mockito.mock(AutomationCompositionProvider.class);
- var monitoringProvider =
- new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, mockAcProvider);
-
- // Mock automation composition data to be returned for the given AC Id
- when(mockAcProvider.findAutomationComposition(new ToscaConceptIdentifier(ID_NAME3, ID_VERSION1)))
- .thenReturn(Optional.of(mockAc));
-
- when(acElementStatisticsProvider.getFilteredAcElementStatistics(eq(ID_NAME1), eq(ID_VERSION1), any(), any(),
- anyMap(), eq(SORT_DESC), eq(0)))
- .thenReturn(List.of(inputAcElementStatistics.getAcElementStatistics().get(0),
- inputAcElementStatistics.getAcElementStatistics().get(1)));
-
- monitoringProvider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics());
-
- AcElementStatisticsList getResponse =
- monitoringProvider.fetchAcElementStatsPerAutomationComposition(ID_NAME3, ID_VERSION1);
-
- assertThat(getResponse.getAcElementStatistics()).hasSize(2);
- assertEquals(getResponse.getAcElementStatistics().get(1).toString().replaceAll("\\s+", ""),
- inputAcElementStatistics.getAcElementStatistics().get(1).toString().replaceAll("\\s+", ""));
-
- assertThat(monitoringProvider.fetchAcElementStatsPerAutomationComposition(ID_INVALID_NAME, ID_VERSION2)
- .getAcElementStatistics()).isEmpty();
-
- Map<String, ToscaConceptIdentifier> acElementIds =
- monitoringProvider.getAllAcElementsIdPerAutomationComposition(ID_NAME3, ID_VERSION1);
- assertThat(acElementIds)
- .containsKey(inputAcElementStatistics.getAcElementStatistics().get(0).getId().toString());
- }
-}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java
deleted file mode 100644
index e8a8ad0c9..000000000
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.runtime.monitoring.rest;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.io.File;
-import java.time.Instant;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.Response;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider;
-import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-class MonitoringQueryControllerTest extends CommonRestController {
-
- private static final String AC_PARTICIPANT_STATISTICS_JSON =
- "src/test/resources/rest/monitoring/TestParticipantStatistics.json";
- private static final String AC_ELEMENT_STATISTICS_JSON =
- "src/test/resources/rest/monitoring/TestAcElementStatistics.json";
-
- private static final Coder CODER = new StandardCoder();
-
- private static ParticipantStatisticsList inputParticipantStatistics;
- private static AcElementStatisticsList inputAcElementStatistics;
-
- private static ParticipantStatisticsList participantStatisticsList;
- private static AcElementStatisticsList acElementStatisticsList;
-
- private static final String AC_ELEMENT_STATS_ENDPOINT = "monitoring/acelement";
- private static final String PARTICIPANT_STATS_ENDPOINT = "monitoring/participant";
- private static final String PARTICIPANT_STATS_PER_AC_ENDPOINT = "monitoring/participants/automationcomposition";
- private static final String AC_ELEMENT_STATS_PER_AC_ENDPOINT = "monitoring/acelements/automationcomposition";
-
- @Autowired
- private MonitoringProvider monitoringProvider;
-
- @LocalServerPort
- private int randomServerPort;
-
- /**
- * starts Main.
- *
- * @throws Exception if an error occurs
- */
- @BeforeAll
- public static void setUpBeforeAll() throws Exception {
-
- inputParticipantStatistics =
- CODER.decode(new File(AC_PARTICIPANT_STATISTICS_JSON), ParticipantStatisticsList.class);
- inputAcElementStatistics = CODER.decode(new File(AC_ELEMENT_STATISTICS_JSON), AcElementStatisticsList.class);
- }
-
- @BeforeEach
- public void setUpBeforeEach() throws Exception {
- super.setHttpPrefix(randomServerPort);
-
- // Insert Participant statistics to DB
- participantStatisticsList =
- monitoringProvider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
- // Insert AC Element statistics to DB
- acElementStatisticsList =
- monitoringProvider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics());
- }
-
- @Test
- void testQuery_Unauthorized_for_AcElementStats() {
- assertUnauthorizedGet(AC_ELEMENT_STATS_ENDPOINT);
- }
-
- @Test
- void testQuery_Unauthorized_for_AcParticipantStats() {
- assertUnauthorizedGet(PARTICIPANT_STATS_ENDPOINT);
- }
-
- @Test
- void testQuery_Unauthorized_for_ParticipantStatsPerAc() {
- assertUnauthorizedGet(PARTICIPANT_STATS_PER_AC_ENDPOINT);
- }
-
- @Test
- void testQuery_Unauthorized_for_AcElementStatsPerAc() {
- assertUnauthorizedGet(AC_ELEMENT_STATS_PER_AC_ENDPOINT);
- }
-
- @Test
- void testSwagger_AcStats() {
- super.testSwagger(AC_ELEMENT_STATS_ENDPOINT);
- super.testSwagger(PARTICIPANT_STATS_ENDPOINT);
- super.testSwagger(AC_ELEMENT_STATS_PER_AC_ENDPOINT);
- super.testSwagger(PARTICIPANT_STATS_PER_AC_ENDPOINT);
- }
-
- @Test
- void testAcElementStatisticsEndpoint() {
- // Filter statistics only based on participant Id and UUID
- Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?name="
- + acElementStatisticsList.getAcElementStatistics().get(0).getParticipantId().getName() + "&version="
- + acElementStatisticsList.getAcElementStatistics().get(0).getParticipantId().getVersion() + "&id="
- + acElementStatisticsList.getAcElementStatistics().get(0).getId());
- Response response1 = invokeRequest1.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
-
- AcElementStatisticsList result1 = response1.readEntity(AcElementStatisticsList.class);
-
- assertNotNull(result1);
- assertThat(result1.getAcElementStatistics()).hasSize(2);
-
- var acElementStat0 = acElementStatisticsList.getAcElementStatistics().get(0);
- for (var acElement : result1.getAcElementStatistics()) {
- assertEquals(acElement.getParticipantId().asConceptKey(), acElementStat0.getParticipantId().asConceptKey());
- assertEquals(acElement.getId(), acElementStat0.getId());
- }
-
- // Filter statistics based on timestamp
- Invocation.Builder invokeRequest2 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?name="
- + acElementStatisticsList.getAcElementStatistics().get(1).getParticipantId().getName() + "&version="
- + acElementStatisticsList.getAcElementStatistics().get(1).getParticipantId().getVersion()
- + "&startTime=" + Instant.parse("2021-01-10T13:00:00.000Z") + "&endTime="
- + Instant.parse("2021-01-10T14:00:00.000Z"));
- Response response2 = invokeRequest2.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), response2.getStatus());
- AcElementStatisticsList result2 = response2.readEntity(AcElementStatisticsList.class);
-
- assertNotNull(result2);
- assertThat(result2.getAcElementStatistics()).hasSize(1);
- assertEquals(result2.getAcElementStatistics().get(0), acElementStat0);
- }
-
- @Test
- void testAcElementStats_BadRequest() {
- Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?version=1.0.0");
- Response response1 = invokeRequest1.buildGet().invoke();
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
- }
-
- @Test
- void testParticipantStatisticsEndpoint() {
-
- // Filter statistics only based on participant Id
- Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name="
- + participantStatisticsList.getStatisticsList().get(0).getParticipantId().getName() + "&version="
- + participantStatisticsList.getStatisticsList().get(0).getParticipantId().getVersion());
- Response response1 = invokeRequest1.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
- ParticipantStatisticsList result1 = response1.readEntity(ParticipantStatisticsList.class);
-
- assertNotNull(result1);
- assertThat(result1.getStatisticsList()).hasSize(2);
- assertThat(result1.getStatisticsList()).contains(participantStatisticsList.getStatisticsList().get(0));
-
- // Filter statistics based on timestamp
- Invocation.Builder invokeRequest2 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name="
- + participantStatisticsList.getStatisticsList().get(1).getParticipantId().getName() + "&version="
- + participantStatisticsList.getStatisticsList().get(1).getParticipantId().getVersion() + "&startTime="
- + Instant.parse("2021-01-10T13:00:00.000Z") + "&endTime=" + Instant.parse("2021-01-10T14:00:00.000Z"));
- Response response2 = invokeRequest2.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), response2.getStatus());
- ParticipantStatisticsList result2 = response2.readEntity(ParticipantStatisticsList.class);
-
- assertNotNull(result2);
- assertThat(result2.getStatisticsList()).hasSize(1);
- assertEquals(result2.getStatisticsList().get(0), participantStatisticsList.getStatisticsList().get(0));
- }
-
- @Test
- void testParticipantStats_BadRequest() {
- Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?version=0.0");
- Response response1 = invokeRequest1.buildGet().invoke();
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
- }
-
- @Test
- void testParticipantStatsPerAcEndpoint() {
- Invocation.Builder invokeRequest1 =
- super.sendRequest(PARTICIPANT_STATS_PER_AC_ENDPOINT + "?name=dummyName&version=1.001");
- Response response1 = invokeRequest1.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
- ParticipantStatisticsList result1 = response1.readEntity(ParticipantStatisticsList.class);
- assertThat(result1.getStatisticsList()).isEmpty();
- }
-
- @Test
- void testParticipantStatsPerAc_BadRequest() {
- Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_PER_AC_ENDPOINT);
- Response response1 = invokeRequest1.buildGet().invoke();
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
- }
-
- @Test
- void testAcElementStatisticsPerAcEndpoint() {
- Invocation.Builder invokeRequest1 =
- super.sendRequest(AC_ELEMENT_STATS_PER_AC_ENDPOINT + "?name=dummyName&version=1.001");
- Response response1 = invokeRequest1.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
- AcElementStatisticsList result1 = response1.readEntity(AcElementStatisticsList.class);
- assertThat(result1.getAcElementStatistics()).isEmpty();
- }
-
- @Test
- void testAcElementStatsPerAc_BadRequest() {
- Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_PER_AC_ENDPOINT);
- Response response1 = invokeRequest1.buildGet().invoke();
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
- }
-}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
index a80d39ebc..7e9b102a8 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
@@ -22,7 +22,6 @@ package org.onap.policy.clamp.acm.runtime.supervision;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -37,7 +36,6 @@ import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
-import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
@@ -50,7 +48,6 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
@@ -87,7 +84,7 @@ class SupervisionHandlerTest {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionUpdatePublisher,
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -130,7 +127,7 @@ class SupervisionHandlerTest {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var handler = new SupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), serviceTemplateProvider, mock(AutomationCompositionUpdatePublisher.class),
+ serviceTemplateProvider, mock(AutomationCompositionUpdatePublisher.class),
automationCompositionStateChangePublisher, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class));
@@ -170,7 +167,7 @@ class SupervisionHandlerTest {
void testHandleAutomationCompositionStateChangeAckMessage() throws PfModelException, CoderException {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -194,7 +191,7 @@ class SupervisionHandlerTest {
automationCompositionAckMessage.setAutomationCompositionId(identifier);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -221,7 +218,7 @@ class SupervisionHandlerTest {
participantDeregisterMessage.setParticipantType(participantType);
var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
participantDeregisterAckPublisher, mock(AutomationCompositionUpdatePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -246,7 +243,7 @@ class SupervisionHandlerTest {
var participantProvider = mock(ParticipantProvider.class);
var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
- mock(MonitoringProvider.class), participantRegisterAckPublisher,
+ participantRegisterAckPublisher,
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -274,7 +271,7 @@ class SupervisionHandlerTest {
participantUpdateAckMessage.setParticipantType(participantType);
participantUpdateAckMessage.setState(ParticipantState.PASSIVE);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -291,19 +288,16 @@ class SupervisionHandlerTest {
participantStatusMessage.setParticipantType(participantType);
participantStatusMessage.setState(ParticipantState.PASSIVE);
participantStatusMessage.setHealthStatus(ParticipantHealthStatus.HEALTHY);
- participantStatusMessage.setParticipantStatistics(new ParticipantStatistics());
var participantProvider = mock(ParticipantProvider.class);
- var monitoringProvider = mock(MonitoringProvider.class);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
- monitoringProvider, mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
handler.handleParticipantMessage(participantStatusMessage);
verify(participantProvider).saveParticipant(any());
- verify(monitoringProvider).createParticipantStatistics(anyList());
}
@Test
@@ -311,7 +305,7 @@ class SupervisionHandlerTest {
var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var handler =
createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -326,7 +320,7 @@ class SupervisionHandlerTest {
var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var handler =
createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
@@ -338,13 +332,13 @@ class SupervisionHandlerTest {
private SupervisionHandler createSupervisionHandler(AutomationCompositionOrderedState orderedState,
AutomationCompositionState state) throws PfModelException, CoderException {
return createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
mock(ParticipantUpdatePublisher.class), orderedState, state);
}
private SupervisionHandler createSupervisionHandler(AutomationCompositionProvider automationCompositionProvider,
- ParticipantProvider participantProvider, MonitoringProvider monitoringProvider,
+ ParticipantProvider participantProvider,
ParticipantRegisterAckPublisher participantRegisterAckPublisher,
ParticipantDeregisterAckPublisher participantDeregisterAckPublisher,
AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher,
@@ -371,7 +365,7 @@ class SupervisionHandlerTest {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- return new SupervisionHandler(automationCompositionProvider, participantProvider, monitoringProvider,
+ return new SupervisionHandler(automationCompositionProvider, participantProvider,
serviceTemplateProvider, automationCompositionUpdatePublisher, automationCompositionStateChangePublisher,
participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
index 6545fe395..ad97201e2 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,7 +35,6 @@ import java.util.UUID;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.onap.policy.clamp.acm.runtime.monitoring.MonitoringProvider;
import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
@@ -44,10 +43,8 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDe
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
-import org.onap.policy.clamp.models.acm.persistence.provider.AcElementStatisticsProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantStatisticsProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ServiceTemplateProvider;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
@@ -70,10 +67,6 @@ class SupervisionMessagesTest extends CommonRestController {
@BeforeAll
public static void setupDbProviderParameters() throws PfModelException {
var acProvider = mock(AutomationCompositionProvider.class);
- var participantStatisticsProvider = mock(ParticipantStatisticsProvider.class);
- var acElementStatisticsProvider = mock(AcElementStatisticsProvider.class);
- var monitoringProvider =
- new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider);
var participantProvider = mock(ParticipantProvider.class);
var serviceTemplateProvider = Mockito.mock(ServiceTemplateProvider.class);
var automationCompositionUpdatePublisher = Mockito.mock(AutomationCompositionUpdatePublisher.class);
@@ -81,7 +74,7 @@ class SupervisionMessagesTest extends CommonRestController {
var participantRegisterAckPublisher = Mockito.mock(ParticipantRegisterAckPublisher.class);
var participantDeregisterAckPublisher = Mockito.mock(ParticipantDeregisterAckPublisher.class);
var participantUpdatePublisher = Mockito.mock(ParticipantUpdatePublisher.class);
- supervisionHandler = new SupervisionHandler(acProvider, participantProvider, monitoringProvider,
+ supervisionHandler = new SupervisionHandler(acProvider, participantProvider,
serviceTemplateProvider, automationCompositionUpdatePublisher, automationCompositionStateChangePublisher,
participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher);
}