Upgrade and clean up dependencies
[policy/models.git] / models-interactions / model-actors / actor.test / src / test / java / org / onap / policy / controlloop / actor / test / BasicOperationTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2023 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.controlloop.actor.test;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27 import static org.junit.Assert.assertSame;
28
29 import java.util.Map;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.junit.MockitoJUnitRunner;
34 import org.onap.policy.common.utils.coder.CoderException;
35 import org.onap.policy.common.utils.resources.ResourceUtils;
36 import org.onap.policy.controlloop.actorserviceprovider.Util;
37
38 @RunWith(MockitoJUnitRunner.class)
39 public class BasicOperationTest {
40     private static final String ACTOR = "my-actor";
41     private static final String OPERATION = "my-operation";
42
43     private BasicOperation oper;
44
45
46     @Before
47     public void setUp() throws Exception {
48         oper = new BasicHttpOperation(ACTOR, OPERATION);
49         oper.setUpBasic();
50     }
51
52     @Test
53     public void testBasicHttpOperation() {
54         oper = new BasicHttpOperation();
55         assertEquals(BasicHttpOperation.DEFAULT_ACTOR, oper.actorName);
56         assertEquals(BasicHttpOperation.DEFAULT_OPERATION, oper.operationName);
57     }
58
59     @Test
60     public void testBasicHttpOperationStringString() {
61         assertEquals(ACTOR, oper.actorName);
62         assertEquals(OPERATION, oper.operationName);
63     }
64
65     @Test
66     public void testSetUp() throws Exception {
67         assertNotNull(oper.future);
68         assertNotNull(oper.outcome);
69         assertNotNull(oper.executor);
70     }
71
72     @Test
73     public void testMakeContext() {
74         oper.makeContext();
75
76         assertSame(oper.service, oper.params.getActorService());
77         assertSame(oper.executor, oper.params.getExecutor());
78         assertEquals(ACTOR, oper.params.getActor());
79         assertEquals(OPERATION, oper.params.getOperation());
80         assertSame(BasicHttpOperation.REQ_ID, oper.params.getRequestId());
81     }
82
83     @Test
84     public void testMakePayload() {
85         assertNull(oper.makePayload());
86     }
87
88     @Test
89     public void testVerifyRequest() throws CoderException {
90         Map<String, Object> map = Util.translateToMap("", ResourceUtils.getResourceAsString("actual.json"));
91         oper.verifyRequest("expected.json", map, "svc-request-id", "vnf-id");
92     }
93 }