2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actor.appc;
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
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.onap.policy.appc.Request;
35 import org.onap.policy.appc.Response;
36 import org.onap.policy.common.utils.coder.CoderException;
37 import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
38 import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
39 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
40 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
42 public class ModifyConfigOperationTest extends BasicAppcOperation {
44 private ModifyConfigOperation oper;
47 public ModifyConfigOperationTest() {
48 super(DEFAULT_ACTOR, ModifyConfigOperation.NAME);
52 public static void setUpBeforeClass() throws Exception {
53 // use same topic name for both sides
54 initBeforeClass(MY_SINK, MY_SINK);
58 public static void tearDownAfterClass() {
64 public void setUp() throws Exception {
67 oper = new ModifyConfigOperation(params, config);
72 public void tearDown() {
77 * Tests "success" case with simulator.
80 public void testSuccess() throws Exception {
81 BidirectionalTopicParams opParams =
82 BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SINK).build();
83 config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcOperation.SELECTOR_KEYS);
85 params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
87 oper = new ModifyConfigOperation(params, config);
89 oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf);
91 outcome = oper.start().get();
92 assertEquals(OperationResult.SUCCESS, outcome.getResult());
93 assertTrue(outcome.getResponse() instanceof Response);
97 public void testConstructor() {
98 assertEquals(DEFAULT_ACTOR, oper.getActorName());
99 assertEquals(ModifyConfigOperation.NAME, oper.getName());
103 public void testGetPropertyNames() {
104 assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_RESOURCE_VNF));
108 public void testMakeRequest() throws CoderException {
109 oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf);
111 oper.generateSubRequestId(2);
112 Request request = oper.makeRequest(2);
113 assertNotNull(request);
114 assertEquals(MY_VNF, request.getPayload().get(ModifyConfigOperation.VNF_ID_KEY));
116 verifyRequest("modifyConfig.json", request, IGNORE_FIELDS);