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.appc;
24 import static org.assertj.core.api.Assertions.assertThat;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
29 import java.util.List;
30 import org.junit.After;
31 import org.junit.AfterClass;
32 import org.junit.Before;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.junit.MockitoJUnitRunner;
37 import org.onap.policy.appc.Request;
38 import org.onap.policy.appc.Response;
39 import org.onap.policy.common.utils.coder.CoderException;
40 import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
41 import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
42 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
43 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
45 @RunWith(MockitoJUnitRunner.class)
46 public class ModifyConfigOperationTest extends BasicAppcOperation {
48 private ModifyConfigOperation oper;
51 public ModifyConfigOperationTest() {
52 super(DEFAULT_ACTOR, ModifyConfigOperation.NAME);
56 public static void setUpBeforeClass() throws Exception {
57 // use same topic name for both sides
58 initBeforeClass(MY_SINK, MY_SINK);
62 public static void tearDownAfterClass() {
68 public void setUp() throws Exception {
71 oper = new ModifyConfigOperation(params, config);
76 public void tearDown() {
81 * Tests "success" case with simulator.
84 public void testSuccess() throws Exception {
85 BidirectionalTopicParams opParams =
86 BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SINK).build();
87 config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcOperation.SELECTOR_KEYS);
89 params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
91 oper = new ModifyConfigOperation(params, config);
93 oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf);
95 outcome = oper.start().get();
96 assertEquals(OperationResult.SUCCESS, outcome.getResult());
97 assertTrue(outcome.getResponse() instanceof Response);
101 public void testConstructor() {
102 assertEquals(DEFAULT_ACTOR, oper.getActorName());
103 assertEquals(ModifyConfigOperation.NAME, oper.getName());
107 public void testGetPropertyNames() {
108 assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_RESOURCE_VNF));
112 public void testMakeRequest() throws CoderException {
113 oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf);
115 oper.generateSubRequestId(2);
116 Request request = oper.makeRequest(2);
117 assertNotNull(request);
118 assertEquals(MY_VNF, request.getPayload().get(ModifyConfigOperation.VNF_ID_KEY));
120 verifyRequest("modifyConfig.json", request, IGNORE_FIELDS);