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.sdnc;
24 import static org.assertj.core.api.Assertions.assertThat;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertTrue;
28 import java.util.List;
29 import org.junit.AfterClass;
30 import org.junit.Before;
31 import org.junit.BeforeClass;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.junit.MockitoJUnitRunner;
35 import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
36 import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
37 import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
38 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
39 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
40 import org.onap.policy.sdnc.SdncResponse;
42 @RunWith(MockitoJUnitRunner.class)
43 public class RerouteOperationTest extends BasicSdncOperation {
44 private static final String MY_SERVICE = "my-service";
45 private static final String MY_NETWORK = "my-network";
47 private RerouteOperation oper;
49 public RerouteOperationTest() {
50 super(DEFAULT_ACTOR, RerouteOperation.NAME);
54 public static void setUpBeforeClass() throws Exception {
59 public static void tearDownAfterClass() {
68 public void setUp() throws Exception {
70 oper = new RerouteOperation(params, config);
74 * Tests "success" case with simulator.
77 public void testSuccess() throws Exception {
78 HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT)
79 .path("GENERIC-RESOURCE-API:network-topology-operation").build();
80 config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
82 params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
83 oper = new RerouteOperation(params, config);
85 oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
86 oper.setProperty(OperationProperties.ENRICHMENT_NETWORK_ID, MY_NETWORK);
88 outcome = oper.start().get();
89 assertEquals(OperationResult.SUCCESS, outcome.getResult());
90 assertTrue(outcome.getResponse() instanceof SdncResponse);
94 public void testConstructor() {
95 assertEquals(DEFAULT_ACTOR, oper.getActorName());
96 assertEquals(RerouteOperation.NAME, oper.getName());
100 public void testGetPropertyNames() {
102 assertThat(oper.getPropertyNames()).isEqualTo(
104 OperationProperties.ENRICHMENT_SERVICE_ID,
105 OperationProperties.ENRICHMENT_NETWORK_ID));
110 public void testMakeRequest() throws Exception {
111 oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
112 oper.setProperty(OperationProperties.ENRICHMENT_NETWORK_ID, MY_NETWORK);
114 verifyRequest("reroute.json", verifyOperation(oper), IGNORE_FIELDS);