2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2023, 2024 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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.policy.controlloop.actor.test;
24 import static org.junit.jupiter.api.Assertions.assertEquals;
25 import static org.junit.jupiter.api.Assertions.assertNotNull;
26 import static org.junit.jupiter.api.Assertions.assertNull;
27 import static org.junit.jupiter.api.Assertions.assertSame;
30 import org.junit.jupiter.api.BeforeEach;
31 import org.junit.jupiter.api.Test;
32 import org.junit.jupiter.api.extension.ExtendWith;
33 import org.junit.runner.RunWith;
34 import org.mockito.junit.MockitoJUnitRunner;
35 import org.mockito.junit.jupiter.MockitoExtension;
36 import org.onap.policy.common.utils.coder.CoderException;
37 import org.onap.policy.common.utils.resources.ResourceUtils;
38 import org.onap.policy.controlloop.actorserviceprovider.Util;
40 @ExtendWith(MockitoExtension.class)
41 class BasicOperationTest {
42 private static final String ACTOR = "my-actor";
43 private static final String OPERATION = "my-operation";
45 private BasicOperation oper;
49 void setUp() throws Exception {
50 oper = new BasicHttpOperation(ACTOR, OPERATION);
55 void testBasicHttpOperation() {
56 oper = new BasicHttpOperation();
57 assertEquals(BasicHttpOperation.DEFAULT_ACTOR, oper.actorName);
58 assertEquals(BasicHttpOperation.DEFAULT_OPERATION, oper.operationName);
62 void testBasicHttpOperationStringString() {
63 assertEquals(ACTOR, oper.actorName);
64 assertEquals(OPERATION, oper.operationName);
68 void testSetUp() throws Exception {
69 assertNotNull(oper.future);
70 assertNotNull(oper.outcome);
71 assertNotNull(oper.executor);
75 void testMakeContext() {
78 assertSame(oper.service, oper.params.getActorService());
79 assertSame(oper.executor, oper.params.getExecutor());
80 assertEquals(ACTOR, oper.params.getActor());
81 assertEquals(OPERATION, oper.params.getOperation());
82 assertSame(BasicHttpOperation.REQ_ID, oper.params.getRequestId());
86 void testMakePayload() {
87 assertNull(oper.makePayload());
91 void testVerifyRequest() throws CoderException {
92 Map<String, Object> map = Util.translateToMap("", ResourceUtils.getResourceAsString("actual.json"));
93 oper.verifyRequest("expected.json", map, "svc-request-id", "vnf-id");