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.sdnc;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
27 import org.junit.AfterClass;
28 import org.junit.Before;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
32 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
33 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
34 import org.onap.policy.controlloop.policy.PolicyResult;
35 import org.onap.policy.sdnc.SdncRequest;
37 public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
39 private BandwidthOnDemandOperation oper;
41 public BandwidthOnDemandOperationTest() {
42 super(DEFAULT_ACTOR, BandwidthOnDemandOperation.NAME);
46 public static void setUpBeforeClass() throws Exception {
51 public static void tearDownAfterClass() {
59 public void setUp() throws Exception {
61 oper = new BandwidthOnDemandOperation(params, config);
65 public void testConstructor() {
66 assertEquals(DEFAULT_ACTOR, oper.getActorName());
67 assertEquals(BandwidthOnDemandOperation.NAME, oper.getName());
71 * Tests "success" case with simulator.
74 public void testSuccess() throws Exception {
75 HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT)
76 .path("GENERIC-RESOURCE-API:vf-module-topology-operation").build();
77 config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
79 params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
80 oper = new BandwidthOnDemandOperation(params, config);
82 outcome = oper.start().get();
83 assertEquals(PolicyResult.SUCCESS, outcome.getResult());
87 public void testMakeRequest() throws Exception {
88 SdncRequest request = oper.makeRequest(1);
89 assertEquals("my-service", request.getNsInstanceId());
90 assertEquals(REQ_ID, request.getRequestId());
91 assertEquals("/my-path/", request.getUrl());
92 assertNotNull(request.getHealRequest().getRequestHeaderInfo().getSvcRequestId());
94 verifyRequest("bod.json", request, IGNORE_FIELDS);
96 verifyMissing(BandwidthOnDemandOperation.SERVICE_ID_KEY, "service", BandwidthOnDemandOperation::new);
98 // perform the operation
100 verifyRequest("bod.json", verifyOperation(oper), IGNORE_FIELDS);
104 protected Map<String, String> makeEnrichment() {
105 return Map.of(BandwidthOnDemandOperation.SERVICE_ID_KEY, "my-service", BandwidthOnDemandOperation.VNF_ID,