2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation.
4 * ================================================================================
5 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.clamp.controlloop.runtime.supervision;
25 import static org.mockito.ArgumentMatchers.eq;
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.spy;
28 import static org.mockito.Mockito.timeout;
29 import static org.mockito.Mockito.verify;
31 import org.junit.jupiter.api.Test;
32 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
33 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
35 class SupervisionAspectTest {
38 void testSchedule() throws Exception {
39 var supervisionScanner = spy(mock(SupervisionScanner.class));
40 try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
41 supervisionAspect.schedule();
42 verify(supervisionScanner, timeout(500)).run(true);
47 void testDoCheck() throws Exception {
48 var supervisionScanner = spy(mock(SupervisionScanner.class));
49 try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
50 supervisionAspect.doCheck();
51 supervisionAspect.doCheck();
52 verify(supervisionScanner, timeout(500).times(2)).run(false);
57 void testHandleParticipantStatus() throws Exception {
58 var supervisionScanner = spy(mock(SupervisionScanner.class));
59 var participantStatusMessage = new ParticipantStatus();
60 var identifier = new ToscaConceptIdentifier("abc", "1.0.0");
61 participantStatusMessage.setParticipantId(identifier);
63 try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
64 supervisionAspect.handleParticipantStatus(participantStatusMessage);
65 verify(supervisionScanner, timeout(500)).handleParticipantStatus(identifier);