/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
import static org.junit.Assert.assertEquals;
import java.time.Instant;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
-import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantDeregisterAckListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantRegisterAckListener;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
ParticipantMessagePublisher participantMessagePublisher =
new ParticipantMessagePublisher();
participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- participantMessagePublisher.sendParticipantRegister(participantRegisterMsg);
+ assertThatCode(() -> participantMessagePublisher.sendParticipantRegister(participantRegisterMsg))
+ .doesNotThrowAnyException();
}
}
synchronized (lockit) {
ParticipantRegisterAckListener participantRegisterAckListener =
new ParticipantRegisterAckListener(participantHandler);
- participantRegisterAckListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterAckMsg);
+ assertThatCode(() -> participantRegisterAckListener.onTopicEvent(INFRA, TOPIC, null,
+ participantRegisterAckMsg)).doesNotThrowAnyException();
}
}
ParticipantMessagePublisher participantMessagePublisher =
new ParticipantMessagePublisher();
participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- participantMessagePublisher.sendParticipantDeregister(participantDeregisterMsg);
+ assertThatCode(() -> participantMessagePublisher.sendParticipantDeregister(participantDeregisterMsg))
+ .doesNotThrowAnyException();
}
}
synchronized (lockit) {
ParticipantDeregisterAckListener participantDeregisterAckListener =
- new ParticipantDeregisterAckListener(participantHandler);
- participantDeregisterAckListener.onTopicEvent(INFRA, TOPIC, null, participantDeregisterAckMsg);
+ new ParticipantDeregisterAckListener(participantHandler);
+ assertThatCode(() -> participantDeregisterAckListener.onTopicEvent(INFRA, TOPIC, null,
+ participantDeregisterAckMsg)).doesNotThrowAnyException();
}
}
synchronized (lockit) {
ParticipantMessagePublisher participantMessagePublisher = new ParticipantMessagePublisher();
participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- participantMessagePublisher.sendParticipantUpdateAck(participantUpdateAckMsg);
+ assertThatCode(() -> participantMessagePublisher.sendParticipantUpdateAck(participantUpdateAckMsg))
+ .doesNotThrowAnyException();
}
}
private ToscaConceptIdentifier getParticipantType() {
return new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1");
}
-
- private ToscaConceptIdentifier getControlLoopId() {
- return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
- }
-
- private ControlLoopInfo getControlLoopInfo(ToscaConceptIdentifier id) {
- ControlLoopInfo clInfo = new ControlLoopInfo();
- clInfo.setState(ControlLoopState.PASSIVE2RUNNING);
-
- ControlLoopStatistics clStatistics = new ControlLoopStatistics();
- clStatistics.setControlLoopId(id);
- clStatistics.setAverageExecutionTime(12345);
- clStatistics.setEventCount(12345);
- clStatistics.setLastEnterTime(12345);
- clStatistics.setLastExecutionTime(12345);
- clStatistics.setLastStart(12345);
- clStatistics.setTimeStamp(Instant.ofEpochMilli(3000));
- clStatistics.setUpTime(12345);
- ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
- ClElementStatistics clElementStatistics = new ClElementStatistics();
- clElementStatistics.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
- clElementStatistics.setTimeStamp(Instant.now());
- clElementStatisticsList.setClElementStatistics(List.of(clElementStatistics));
- clStatistics.setClElementStatisticsList(clElementStatisticsList);
-
- clInfo.setControlLoopStatistics(clStatistics);
- return clInfo;
- }
-
- private ControlLoopElementDefinition getClElementDefinition() {
- ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
- toscaNodeTemplate.setName("serviceTemplate");
- toscaNodeTemplate.setDerivedFrom("parentServiceTemplate");
- toscaNodeTemplate.setDescription("Description of serviceTemplate");
- toscaNodeTemplate.setVersion("1.2.3");
-
- ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
- clDefinition.setCommonPropertiesMap(Map.of("Prop1", "Prop1Value"));
- clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate);
- Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
- clDefinition.setCommonPropertiesMap(commonPropertiesMap);
- return clDefinition;
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* This interface is used by participant implementations to use the participant intermediary.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.stereotype.Component;
/**
@Override
public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState currentState,
ControlLoopState newState, ParticipantMessageType messageType) {
- return participantHandler.getControlLoopHandler().updateControlLoopElementState(id, currentState, newState,
- messageType);
+ return participantHandler.getControlLoopHandler().updateControlLoopElementState(id, currentState, newState);
}
@Override
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
@Component
public class ParticipantMessagePublisher implements Publisher {
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantMessagePublisher.class);
+ private static final String NOT_ACTIVE_TEXT = "Not Active!";
private boolean active = false;
private TopicSinkClient topicSinkClient;
*/
public void sendParticipantStatus(final ParticipantStatus participantStatus) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantStatus);
LOGGER.debug("Sent Participant Status message to CLAMP - {}", participantStatus);
*/
public void sendParticipantRegister(final ParticipantRegister participantRegister) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantRegister);
LOGGER.debug("Sent Participant Register message to CLAMP - {}", participantRegister);
*/
public void sendParticipantDeregister(final ParticipantDeregister participantDeregister) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantDeregister);
LOGGER.debug("Sent Participant Deregister message to CLAMP - {}", participantDeregister);
*/
public void sendParticipantUpdateAck(final ParticipantUpdateAck participantUpdateAck) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantUpdateAck);
LOGGER.debug("Sent Participant Update Ack message to CLAMP - {}", participantUpdateAck);
*/
public void sendControlLoopAck(final ControlLoopAck controlLoopAck) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(controlLoopAck);
LOGGER.debug("Sent ControlLoop Update/StateChange Ack to runtime - {}", controlLoopAck);
*/
public void sendHeartbeat(final ParticipantStatus participantStatus) {
if (!active) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
}
topicSinkClient.send(participantStatus);
LOGGER.debug("Sent Participant heartbeat to CLAMP - {}", participantStatus);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * 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.
* @return controlLoopElement the updated controlloop element
*/
public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState orderedState,
- ControlLoopState newState, ParticipantMessageType messageType) {
+ ControlLoopState newState) {
if (id == null) {
LOGGER.warn("Cannot update Control loop element state, id is null");
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
*
* @return true if exists instance properties
*/
- private Boolean verifyIfInstancePropertiesExists() {
+ private boolean verifyIfInstancePropertiesExists() {
return clProvider.getNodeTemplates(null, null).stream()
.anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains("_Instance"));
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
@Component
@AllArgsConstructor
public class ControlLoopInstantiationProvider {
+ private static final String INSTANCE_TEXT = "_Instance";
+
private final ControlLoopProvider controlLoopProvider;
private final CommissioningProvider commissioningProvider;
private final SupervisionHandler supervisionHandler;
int instanceNumber =
nodeTemplates.stream().map(ToscaNodeTemplate::getName)
- .filter(name -> name.contains("_Instance")).map(n -> {
- String[] defNameArr = n.split("_Instance");
+ .filter(name -> name.contains(INSTANCE_TEXT)).map(n -> {
+ String[] defNameArr = n.split(INSTANCE_TEXT);
return Integer.parseInt(defNameArr[1]);
}).reduce(0, Math::max);
- return "_Instance" + (instanceNumber + 1);
+ return INSTANCE_TEXT + (instanceNumber + 1);
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
@RequestHeader(
name = REQUEST_ID_NAME,
required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body)
- throws PfModelException {
+ @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body) {
return ResponseEntity.ok().body(provider.saveInstanceProperties(body));
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * 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.
* Supervise a control loop, performing whatever actions need to be performed on the control loop.
*
* @param controlLoop the control loop to supervises
- * @throws PfModelException on accessing models in the database
* @throws ControlLoopException on supervision errors
*/
- private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
+ private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException {
switch (controlLoop.getOrderedState()) {
case UNINITIALISED:
superviseControlLoopUninitialization(controlLoop);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
- Map<String, Class> sections = Map.of(
+ Map<String, Class<?>> sections = Map.of(
"all", ToscaServiceTemplate.class,
"data_types", ToscaDataType.class,
"capability_types", ToscaCapabilityType.class,
"topology_template", ToscaTopologyTemplate.class,
"node_templates", List.class);
- for (Map.Entry<String, Class> entry : sections.entrySet()) {
+ for (Map.Entry<String, Class<?>> entry : sections.entrySet()) {
String returnedServiceTemplateSchema = provider.getToscaServiceTemplateSchema(entry.getKey());
assertThat(returnedServiceTemplateSchema).isNotNull();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
+ "/getCommonOrInstanceProperties" + "?common=true&name=ToscaServiceTemplateSimple&version=1.0.0");
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+
+ @SuppressWarnings("unchecked")
Map<String, ToscaNodeTemplate> commonProperties = rawresp.readEntity(Map.class);
+
assertNotNull(commonProperties);
assertThat(commonProperties).hasSize(6);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
/**
* Class to perform unit test of {@link ControlLoopInstantiationProvider}}.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.core.Response;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * 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.
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.eq;
import static org.mockito.Mockito.when;
import java.io.File;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * 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.
package org.onap.policy.clamp.controlloop.runtime.supervision;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 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.
package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
private static final Object lockit = new Object();
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
private static final String TOPIC = "my-topic";
- private static final long interval = 1000;
private static SupervisionHandler supervisionHandler;
private static CommissioningProvider commissioningProvider;
private static ControlLoopProvider clProvider;
private static PolicyModelsProvider modelsProvider;
private static ParticipantProvider participantProvider;
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
- private static final String TOSCA_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
private static final String CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.ControlLoopElement";
private static final Coder CODER = new StandardCoder();
// List<ToscaNodeTemplate> listOfTemplates = commissioningProvider.getControlLoopDefinitions(null, null);
commissioningProvider.createControlLoopDefinitions(serviceTemplate);
- participantRegisterListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterMsg);
+ assertThatCode(() -> participantRegisterListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterMsg))
+ .doesNotThrowAnyException();
}
}
synchronized (lockit) {
ParticipantRegisterAckPublisher clRegisterAckPublisher = new ParticipantRegisterAckPublisher();
clRegisterAckPublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- clRegisterAckPublisher.send(participantRegisterAckMsg);
+ assertThatCode(() -> clRegisterAckPublisher.send(participantRegisterAckMsg)).doesNotThrowAnyException();
}
}
synchronized (lockit) {
ParticipantDeregisterListener participantDeregisterListener =
- new ParticipantDeregisterListener(supervisionHandler);
- participantDeregisterListener.onTopicEvent(INFRA, TOPIC, null, participantDeregisterMsg);
+ new ParticipantDeregisterListener(supervisionHandler);
+ assertThatCode(() -> participantDeregisterListener.onTopicEvent(INFRA, TOPIC, null,
+ participantDeregisterMsg)).doesNotThrowAnyException();
}
}
synchronized (lockit) {
ParticipantDeregisterAckPublisher clDeregisterAckPublisher = new ParticipantDeregisterAckPublisher();
clDeregisterAckPublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- clDeregisterAckPublisher.send(participantDeregisterAckMsg);
+ assertThatCode(() -> clDeregisterAckPublisher.send(participantDeregisterAckMsg)).doesNotThrowAnyException();
}
}
ParticipantUpdatePublisher participantUpdatePublisher =
new ParticipantUpdatePublisher(modelsProvider);
participantUpdatePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- participantUpdatePublisher.send(participantUpdateMsg);
+ assertThatCode(() -> participantUpdatePublisher.send(participantUpdateMsg)).doesNotThrowAnyException();
}
}
synchronized (lockit) {
ParticipantUpdateAckListener participantUpdateAckListener =
- new ParticipantUpdateAckListener(supervisionHandler);
- participantUpdateAckListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateAckMsg);
+ new ParticipantUpdateAckListener(supervisionHandler);
+ assertThatCode(() -> participantUpdateAckListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateAckMsg))
+ .doesNotThrowAnyException();
}
}