Fix sonars from depeendency upgrade
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / test / java / org / onap / policy / controlloop / actorserviceprovider / impl / OperatorPartialTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.controlloop.actorserviceprovider.impl;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.mockito.Mockito.spy;
26 import static org.mockito.Mockito.verify;
27
28 import java.util.Map;
29 import java.util.TreeMap;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.policy.controlloop.actorserviceprovider.Operation;
33 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
34
35 public class OperatorPartialTest {
36     private static final String ACTOR = "my-actor";
37     private static final String OPERATION = "my-name";
38
39     private OperatorPartial operator;
40
41     /**
42      * Initializes {@link #operator}.
43      */
44     @Before
45     public void setUp() {
46         operator = new OperatorPartial(ACTOR, OPERATION) {
47             @Override
48             public Operation buildOperation(ControlLoopOperationParams params) {
49                 return null;
50             }
51         };
52     }
53
54     @Test
55     public void testOperatorPartial_testGetActorName_testGetName() {
56         assertEquals(ACTOR, operator.getActorName());
57         assertEquals(OPERATION, operator.getName());
58         assertEquals(ACTOR + "." + OPERATION, operator.getFullName());
59     }
60
61     @Test
62     public void testDoStart() {
63         operator.configure(null);
64
65         operator = spy(operator);
66         operator.start();
67
68         verify(operator).doStart();
69     }
70
71     @Test
72     public void testDoStop() {
73         operator.configure(null);
74         operator.start();
75
76         operator = spy(operator);
77         operator.stop();
78
79         verify(operator).doStop();
80     }
81
82     @Test
83     public void testDoShutdown() {
84         operator.configure(null);
85         operator.start();
86
87         operator = spy(operator);
88         operator.shutdown();
89
90         verify(operator).doShutdown();
91     }
92
93     @Test
94     public void testDoConfigureMapOfStringObject() {
95         operator = spy(operator);
96
97         Map<String, Object> params = new TreeMap<>();
98         operator.configure(params);
99
100         verify(operator).doConfigure(params);
101     }
102
103     @Test
104     public void testGetBlockingExecutor() {
105         assertNotNull(operator.getBlockingExecutor());
106     }
107 }