Implementing Create NS
[so.git] / so-etsi-nfvo / so-etsi-nfvo-ns-lcm / so-etsi-nfvo-ns-lcm-service / src / test / java / org / onap / so / etsi / nfvo / ns / lcm / rest / NsLcmOperationOccurrencesControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.etsi.nfvo.ns.lcm.rest;
21
22 import static org.junit.Assert.assertEquals;
23 import java.util.UUID;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.onap.so.etsi.nfvo.ns.lcm.Constants;
28 import org.onap.so.etsi.nfvo.ns.lcm.JSON;
29 import org.onap.so.etsi.nfvo.ns.lcm.TestApplication;
30 import org.springframework.boot.test.context.SpringBootTest;
31 import org.springframework.boot.test.web.client.TestRestTemplate;
32 import org.springframework.boot.web.client.RestTemplateBuilder;
33 import org.springframework.boot.web.server.LocalServerPort;
34 import org.springframework.http.HttpEntity;
35 import org.springframework.http.HttpHeaders;
36 import org.springframework.http.HttpMethod;
37 import org.springframework.http.HttpStatus;
38 import org.springframework.http.ResponseEntity;
39 import org.springframework.http.converter.json.GsonHttpMessageConverter;
40 import org.springframework.test.context.ActiveProfiles;
41 import org.springframework.test.context.junit4.SpringRunner;
42 import com.google.gson.Gson;
43
44 /**
45  * 
46  * @author Waqas Ikram (waqas.ikram@est.tech)
47  */
48
49 @RunWith(SpringRunner.class)
50 @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
51 @ActiveProfiles("test")
52 public class NsLcmOperationOccurrencesControllerTest {
53     @LocalServerPort
54     private int port;
55     private TestRestTemplate testRestTemplate;
56
57     @Before
58     public void setUp() {
59         final Gson gson = JSON.createGson().create();
60         testRestTemplate = new TestRestTemplate(
61                 new RestTemplateBuilder().additionalMessageConverters(new GsonHttpMessageConverter(gson)));
62     }
63
64     @Test
65     public void testGetOperationStatusS_ValidNsLcmOpOccId() {
66         final String baseUrl = getNsLcmBaseUrl() + "/ns_lcm_op_occs/" + UUID.randomUUID().toString();
67         final HttpEntity<?> request = new HttpEntity<>(new HttpHeaders());
68         final ResponseEntity<Void> responseEntity =
69                 testRestTemplate.exchange(baseUrl, HttpMethod.GET, request, Void.class);
70         assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
71     }
72
73     private String getNsLcmBaseUrl() {
74         return "http://localhost:" + port + Constants.NS_LIFE_CYCLE_MANAGEMENT_BASE_URL;
75     }
76 }
77