2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.so.adapters.sdnc.impl;
23 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
24 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.onap.so.adapters.sdnc.SDNCAdapterApplication;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.boot.test.context.SpringBootTest;
31 import org.springframework.test.context.ActiveProfiles;
32 import org.springframework.test.context.junit4.SpringRunner;
34 @RunWith(SpringRunner.class)
35 @SpringBootTest(classes = SDNCAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
36 @ActiveProfiles("test")
37 public class MapRequestTunablesTest {
40 private MapRequestTunables tunableMapper;
43 public void test_setTunables(){
44 RequestTunables expectedResult = new RequestTunables("testReqId", "","vnf-topology-operation","assign");
45 expectedResult.setAsyncInd("N");
46 expectedResult.setSdncUrl("https://localhost:8443/restconf/operations/VNF-API:vnf-topology-operation");
47 expectedResult.setTimeout("270000");
48 expectedResult.setReqMethod("POST");
49 expectedResult.setHeaderName("sdnc-request-header");
50 expectedResult.setNamespace("org:openecomp:sdnctl:vnf");
52 RequestTunables testMapper = new RequestTunables("testReqId", "","vnf-topology-operation","assign");
54 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
56 assertThat(mappedTunable, sameBeanAs(expectedResult));
60 public void test_setTunables_EmptyOperation_EmptyMSOAction(){
61 RequestTunables expectedResult = new RequestTunables("testReqId", "","","query");
62 expectedResult.setAsyncInd("N");
63 expectedResult.setSdncUrl("http://localhost:8443/restconf/operations/GENERIC-RESOURCE-API:");
64 expectedResult.setTimeout("60000");
65 expectedResult.setReqMethod("GET");
66 expectedResult.setHeaderName("sdnc-request-header");
67 expectedResult.setNamespace("");
69 RequestTunables testMapper = new RequestTunables("testReqId", "","","query");
71 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
73 assertThat(mappedTunable, sameBeanAs(expectedResult));
77 public void test_setTunables_EmptyOperation(){
78 RequestTunables expectedResult = new RequestTunables("testReqId", "infra","","query");
79 expectedResult.setAsyncInd("N");
80 expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
81 expectedResult.setTimeout("60000");
82 expectedResult.setReqMethod("GET");
83 expectedResult.setHeaderName("sdnc-request-header");
84 expectedResult.setNamespace("");
86 RequestTunables testMapper = new RequestTunables("testReqId", "infra","","query");
88 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
90 assertThat(mappedTunable, sameBeanAs(expectedResult));
94 public void test_setTunables_EmptyOperation_EmptyMSOActionPUT(){
95 RequestTunables expectedResult = new RequestTunables("testReqId", "","","put");
96 expectedResult.setAsyncInd("N");
97 expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
98 expectedResult.setTimeout("60000");
99 expectedResult.setReqMethod("PUT");
100 expectedResult.setHeaderName("sdnc-request-header");
101 expectedResult.setNamespace("");
103 RequestTunables testMapper = new RequestTunables("testReqId", "","","put");
105 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
107 assertThat(mappedTunable, sameBeanAs(expectedResult));
112 public void test_setTunables_EmptyOperation_EmptyMSOActionRESTDELETE(){
113 RequestTunables expectedResult = new RequestTunables("testReqId", "","","restdelete");
114 expectedResult.setAsyncInd("N");
115 expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
116 expectedResult.setTimeout("60000");
117 expectedResult.setReqMethod("DELETE");
118 expectedResult.setHeaderName("sdnc-request-header");
119 expectedResult.setNamespace("");
121 RequestTunables testMapper = new RequestTunables("testReqId", "","","restdelete");
123 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
125 assertThat(mappedTunable, sameBeanAs(expectedResult));