2 * ============LICENSE_START=======================================================
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
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.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27 import static org.junit.Assert.assertSame;
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;
38 @RunWith(MockitoJUnitRunner.class)
39 public class BasicOperationTest {
40 private static final String ACTOR = "my-actor";
41 private static final String OPERATION = "my-operation";
43 private BasicOperation oper;
47 public void setUp() throws Exception {
48 oper = new BasicHttpOperation(ACTOR, OPERATION);
53 public void testBasicHttpOperation() {
54 oper = new BasicHttpOperation();
55 assertEquals(BasicHttpOperation.DEFAULT_ACTOR, oper.actorName);
56 assertEquals(BasicHttpOperation.DEFAULT_OPERATION, oper.operationName);
60 public void testBasicHttpOperationStringString() {
61 assertEquals(ACTOR, oper.actorName);
62 assertEquals(OPERATION, oper.operationName);
66 public void testSetUp() throws Exception {
67 assertNotNull(oper.future);
68 assertNotNull(oper.outcome);
69 assertNotNull(oper.executor);
73 public void testMakeContext() {
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());
84 public void testMakePayload() {
85 assertNull(oper.makePayload());
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");