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;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.onap.so.adapters.sdnc.SDNCAdapterApplication;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.boot.test.context.SpringBootTest;
30 import org.springframework.test.context.ActiveProfiles;
31 import org.springframework.test.context.junit4.SpringRunner;
33 @RunWith(SpringRunner.class)
34 @SpringBootTest(classes = SDNCAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
35 @ActiveProfiles("test")
36 public class MapRequestTunablesTest {
39 private MapRequestTunables tunableMapper;
42 public void test_setTunables() {
43 RequestTunables expectedResult = new RequestTunables("testReqId", "", "vnf-topology-operation", "assign");
44 expectedResult.setAsyncInd("N");
45 expectedResult.setSdncUrl("https://localhost:8443/restconf/operations/VNF-API:vnf-topology-operation");
46 expectedResult.setTimeout("270000");
47 expectedResult.setReqMethod("POST");
48 expectedResult.setHeaderName("sdnc-request-header");
49 expectedResult.setNamespace("org:openecomp:sdnctl:vnf");
51 RequestTunables testMapper = new RequestTunables("testReqId", "", "vnf-topology-operation", "assign");
53 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
55 assertThat(mappedTunable, sameBeanAs(expectedResult));
59 public void test_setTunables_EmptyOperation_EmptyMSOAction() {
60 RequestTunables expectedResult = new RequestTunables("testReqId", "", "", "query");
61 expectedResult.setAsyncInd("N");
62 expectedResult.setSdncUrl("http://localhost:8443/restconf/operations/GENERIC-RESOURCE-API:");
63 expectedResult.setTimeout("60000");
64 expectedResult.setReqMethod("GET");
65 expectedResult.setHeaderName("sdnc-request-header");
66 expectedResult.setNamespace("");
68 RequestTunables testMapper = new RequestTunables("testReqId", "", "", "query");
70 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
72 assertThat(mappedTunable, sameBeanAs(expectedResult));
76 public void test_setTunables_EmptyOperation() {
77 RequestTunables expectedResult = new RequestTunables("testReqId", "infra", "", "query");
78 expectedResult.setAsyncInd("N");
79 expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
80 expectedResult.setTimeout("60000");
81 expectedResult.setReqMethod("GET");
82 expectedResult.setHeaderName("sdnc-request-header");
83 expectedResult.setNamespace("");
85 RequestTunables testMapper = new RequestTunables("testReqId", "infra", "", "query");
87 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
89 assertThat(mappedTunable, sameBeanAs(expectedResult));
93 public void test_setTunables_EmptyOperation_EmptyMSOActionPUT() {
94 RequestTunables expectedResult = new RequestTunables("testReqId", "", "", "put");
95 expectedResult.setAsyncInd("N");
96 expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
97 expectedResult.setTimeout("60000");
98 expectedResult.setReqMethod("PUT");
99 expectedResult.setHeaderName("sdnc-request-header");
100 expectedResult.setNamespace("");
102 RequestTunables testMapper = new RequestTunables("testReqId", "", "", "put");
104 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
106 assertThat(mappedTunable, sameBeanAs(expectedResult));
111 public void test_setTunables_EmptyOperation_EmptyMSOActionRESTDELETE() {
112 RequestTunables expectedResult = new RequestTunables("testReqId", "", "", "restdelete");
113 expectedResult.setAsyncInd("N");
114 expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
115 expectedResult.setTimeout("60000");
116 expectedResult.setReqMethod("DELETE");
117 expectedResult.setHeaderName("sdnc-request-header");
118 expectedResult.setNamespace("");
120 RequestTunables testMapper = new RequestTunables("testReqId", "", "", "restdelete");
122 RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
124 assertThat(mappedTunable, sameBeanAs(expectedResult));