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.appc;
24 import static org.assertj.core.api.Assertions.assertThat;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
28 import java.util.List;
29 import org.junit.After;
30 import org.junit.AfterClass;
31 import org.junit.Before;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
35 import org.mockito.junit.MockitoJUnitRunner;
36 import org.onap.policy.appc.Request;
37 import org.onap.policy.common.utils.coder.CoderException;
38 import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
39 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
40 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
42 @RunWith(MockitoJUnitRunner.class)
43 public class ModifyConfigOperationTest extends BasicAppcOperation {
45 private ModifyConfigOperation oper;
48 public ModifyConfigOperationTest() {
49 super(DEFAULT_ACTOR, ModifyConfigOperation.NAME);
53 public static void setUpBeforeClass() throws Exception {
54 // use same topic name for both sides
55 initBeforeClass(MY_SINK, MY_SINK);
59 public static void tearDownAfterClass() {
65 public void setUp() throws Exception {
68 oper = new ModifyConfigOperation(params, config);
73 public void tearDown() {
78 * Tests "success" case with simulator.
81 public void testSuccess() throws Exception {
82 BidirectionalTopicParams opParams =
83 BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SINK).build();
84 config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcOperation.SELECTOR_KEYS);
86 params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
88 oper = new ModifyConfigOperation(params, config);
90 oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf);
92 outcome = oper.start().get();
93 // assertEquals(OperationResult.SUCCESS, outcome.getResult());
94 // assertTrue(outcome.getResponse() instanceof Response);
95 assertNotNull(outcome);
99 public void testConstructor() {
100 assertEquals(DEFAULT_ACTOR, oper.getActorName());
101 assertEquals(ModifyConfigOperation.NAME, oper.getName());
105 public void testGetPropertyNames() {
106 assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_RESOURCE_VNF));
110 public void testMakeRequest() throws CoderException {
111 oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf);
113 oper.generateSubRequestId(2);
114 Request request = oper.makeRequest(2);
115 assertNotNull(request);
116 assertEquals(MY_VNF, request.getPayload().get(ModifyConfigOperation.VNF_ID_KEY));
118 verifyRequest("modifyConfig.json", request, IGNORE_FIELDS);