aboutsummaryrefslogtreecommitdiffstats
path: root/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2021-02-18 15:01:28 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2021-02-18 15:07:11 +0000
commit708e8a0a2a38d72d274e65794411a3ef1e241069 (patch)
treea284a5052c45402b706c4f5acf2bd6ef512973d1 /so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test
parent4005922ca75a2e373d12ac264a889f76029fb38e (diff)
Removing so-etsi-nfvo module
Change-Id: I5ab5d409bad26abd83b2d8338c4c5ab5fa6be97c Issue-ID: SO-3485 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test')
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/TestApplication.java37
-rw-r--r--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.java133
-rw-r--r--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/NsLifecycleManagementControllerTest.java288
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml46
4 files changed, 0 insertions, 504 deletions
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/TestApplication.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/TestApplication.java
deleted file mode 100644
index d6f4a83811..0000000000
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/TestApplication.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.etsi.nfvo.ns.lcm;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
-
-/**
- * @author Waqas Ikram (waqas.ikram@est.tech)
- *
- */
-@SpringBootApplication(scanBasePackages = {"org.onap.so"})
-@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class})
-public class TestApplication {
- public static void main(final String[] args) {
- new SpringApplication(TestApplication.class).run(args);
- }
-}
diff --git a/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 b/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
deleted file mode 100644
index c5862569f2..0000000000
--- a/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
+++ /dev/null
@@ -1,133 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.etsi.nfvo.ns.lcm.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import java.time.LocalDateTime;
-import java.util.Optional;
-import java.util.UUID;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.so.etsi.nfvo.ns.lcm.Constants;
-import org.onap.so.etsi.nfvo.ns.lcm.TestApplication;
-import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpType;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
-import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
-import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400;
-import org.onap.so.etsi.nfvo.ns.lcm.model.NsLcmOpOccsNsLcmOpOcc;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.converter.json.GsonHttpMessageConverter;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
-import com.google.gson.Gson;
-
-/**
- * @author Waqas Ikram (waqas.ikram@est.tech)
- * @author Andrew Lamb (andrew.a.lamb@est.tech)
- *
- */
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class NsLcmOperationOccurrencesControllerTest {
-
- private static final String NS_LCM_OP_OCCS = "/ns_lcm_op_occs/";
-
- @LocalServerPort
- private int port;
-
- @Autowired
- private DatabaseServiceProvider databaseServiceProvider;
-
- @Autowired
- private GsonProvider gsonProvider;
-
- private TestRestTemplate testRestTemplate;
-
- @Before
- public void setUp() {
- final Gson gson = gsonProvider.getGson();
- testRestTemplate = new TestRestTemplate(
- new RestTemplateBuilder().additionalMessageConverters(new GsonHttpMessageConverter(gson)));
- }
-
- @Test
- public void testGetOperationStatus_validNsLcmOpOccId_returnsNsLcmOpOcc() {
- final String nsLcmOpOccId = addDummyNsLcmOpOccToDatabase();
- final String baseUrl = getNsLcmBaseUrl() + NS_LCM_OP_OCCS + nsLcmOpOccId;
- final HttpEntity<?> request = new HttpEntity<>(new HttpHeaders());
- final ResponseEntity<NsLcmOpOccsNsLcmOpOcc> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.GET, request, NsLcmOpOccsNsLcmOpOcc.class);
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
- assertTrue(responseEntity.hasBody());
- assertNotNull(responseEntity.getBody());
- }
-
- @Test
- public void testGetOperationStatus_nsLcmOpOccIdNotFound_returnsInlineResponse400() {
- final String nsLcmOpOccId = UUID.randomUUID().toString();
- final Optional<NsLcmOpOcc> optionalNsLcmOpOcc = databaseServiceProvider.getNsLcmOpOcc(nsLcmOpOccId);
- assertTrue(optionalNsLcmOpOcc.isEmpty());
- final String baseUrl = getNsLcmBaseUrl() + NS_LCM_OP_OCCS + nsLcmOpOccId;
- final HttpEntity<?> request = new HttpEntity<>(new HttpHeaders());
- final ResponseEntity<InlineResponse400> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.GET, request, InlineResponse400.class);
- assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
- assertTrue(responseEntity.hasBody());
- assertNotNull(responseEntity.getBody());
- }
-
- private String addDummyNsLcmOpOccToDatabase() {
- final LocalDateTime currentDateTime = LocalDateTime.now();
-
- final NfvoNsInst nsInst = new NfvoNsInst().name("name").nsdId("id").status(State.NOT_INSTANTIATED)
- .nsdInvariantId("id").statusUpdatedTime(currentDateTime);
- databaseServiceProvider.saveNfvoNsInst(nsInst);
-
- final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().nfvoNsInst(nsInst).operationState(OperationStateEnum.PROCESSING)
- .isCancelPending(false).isAutoInvocation(false).operation(NsLcmOpType.INSTANTIATE)
- .startTime(currentDateTime).stateEnteredTime(currentDateTime).operationParams("");
- databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
-
- return nsLcmOpOcc.getId();
- }
-
- private String getNsLcmBaseUrl() {
- return "http://localhost:" + port + Constants.NS_LIFE_CYCLE_MANAGEMENT_BASE_URL;
- }
-}
-
diff --git a/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/NsLifecycleManagementControllerTest.java b/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/NsLifecycleManagementControllerTest.java
deleted file mode 100644
index 585b0e1811..0000000000
--- a/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/NsLifecycleManagementControllerTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.etsi.nfvo.ns.lcm.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.when;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.UUID;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.so.etsi.nfvo.ns.lcm.Constants;
-import org.onap.so.etsi.nfvo.ns.lcm.TestApplication;
-import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider;
-import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingException;
-import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.JobExecutorService;
-import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest;
-import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400;
-import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest;
-import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance;
-import org.onap.so.etsi.nfvo.ns.lcm.model.TerminateNsRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.converter.json.GsonHttpMessageConverter;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
-import com.google.gson.Gson;
-
-/**
- * @author Waqas Ikram (waqas.ikram@est.tech)
- *
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class NsLifecycleManagementControllerTest {
- private static final String EXPECTED_BASE_URL =
- "http://so-etsi-nfvo-ns-lcm.onap:9095/so/so-etsi-nfvo-ns-lcm/v1/api/nslcm/v1";
- private static final String RANDOM_NS_LCM_OP_OCC_ID = UUID.randomUUID().toString();
- private static final String RANDOM_NS_INST_ID = UUID.randomUUID().toString();
- private static final String SERVICE_TYPE = "NetworkService";
- private static final String GLOBAL_CUSTOMER_ID = UUID.randomUUID().toString();
- private static final String EXPECTED_CREATE_REQ_LOCATION_URL =
- EXPECTED_BASE_URL + "/ns_instances/" + RANDOM_NS_INST_ID;
- private static final String EXPECTED_NS_LCM_OP_OCC_REQ_LOCATION_URL =
- EXPECTED_BASE_URL + "/ns_lcm_op_occs/" + RANDOM_NS_LCM_OP_OCC_ID;
-
- @LocalServerPort
- private int port;
-
- private TestRestTemplate testRestTemplate;
-
- @Autowired
- private GsonProvider gsonProvider;
-
- @MockBean
- private JobExecutorService mockedJobExecutorService;
-
- @Before
- public void setUp() {
- final Gson gson = gsonProvider.getGson();
- testRestTemplate = new TestRestTemplate(
- new RestTemplateBuilder().additionalMessageConverters(new GsonHttpMessageConverter(gson)));
- }
-
- @Test
- public void testCreateNs_ValidCreateNsRequest() throws URISyntaxException {
-
- final CreateNsRequest createNsRequest = getCreateNsRequest();
-
- when(mockedJobExecutorService.runCreateNsJob(eq(createNsRequest), eq(GLOBAL_CUSTOMER_ID), eq(SERVICE_TYPE)))
- .thenReturn(new NsInstancesNsInstance().id(RANDOM_NS_INST_ID));
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances";
- final HttpHeaders headers = new HttpHeaders();
- headers.add(Constants.HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, GLOBAL_CUSTOMER_ID);
- final HttpEntity<?> request = new HttpEntity<>(createNsRequest, headers);
- final ResponseEntity<NsInstancesNsInstance> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, NsInstancesNsInstance.class);
- assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
- assertTrue(responseEntity.hasBody());
- assertNotNull(responseEntity.getBody());
-
- final HttpHeaders httpHeaders = responseEntity.getHeaders();
- assertTrue(httpHeaders.containsKey(HttpHeaders.LOCATION));
- final List<String> actual = httpHeaders.get(HttpHeaders.LOCATION);
- assertEquals(1, actual.size());
- assertEquals(EXPECTED_CREATE_REQ_LOCATION_URL, actual.get(0));
- }
-
- @Test
- public void testCreateNs_createNsRequest_nsRequestProcessingExceptionThrown_returnInlineResponse400()
- throws URISyntaxException {
-
- final CreateNsRequest createNsRequest = getCreateNsRequest();
-
- final String message = "Unable to process request";
- when(mockedJobExecutorService.runCreateNsJob(eq(createNsRequest), eq(GLOBAL_CUSTOMER_ID), eq(SERVICE_TYPE)))
- .thenThrow(new NsRequestProcessingException(message, new InlineResponse400().detail(message)));
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances";
- final HttpHeaders headers = new HttpHeaders();
- headers.add(Constants.HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, GLOBAL_CUSTOMER_ID);
- final HttpEntity<?> request = new HttpEntity<>(createNsRequest, headers);
- final ResponseEntity<InlineResponse400> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, InlineResponse400.class);
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode());
- assertTrue(responseEntity.hasBody());
- assertNotNull(responseEntity.getBody());
-
- final InlineResponse400 body = responseEntity.getBody();
- assertEquals(message, body.getDetail());
-
- }
-
- @Test
- public void testCreateNs_createNsRequest_exceptionThrown_returnInlineResponse400() throws URISyntaxException {
-
- final CreateNsRequest createNsRequest = getCreateNsRequest();
-
- final String message = "Unable to process request";
- when(mockedJobExecutorService.runCreateNsJob(eq(createNsRequest), eq(GLOBAL_CUSTOMER_ID), eq(SERVICE_TYPE)))
- .thenThrow(new RuntimeException(message));
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances";
- final HttpHeaders headers = new HttpHeaders();
- headers.add(Constants.HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, GLOBAL_CUSTOMER_ID);
- final HttpEntity<?> request = new HttpEntity<>(createNsRequest, headers);
- final ResponseEntity<InlineResponse400> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, InlineResponse400.class);
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode());
- assertTrue(responseEntity.hasBody());
- assertNotNull(responseEntity.getBody());
-
- final InlineResponse400 body = responseEntity.getBody();
- assertEquals(message, body.getDetail());
-
- }
-
- @Test
- public void testDeleteNs_SuccessfulCase() {
- final String nsInstId = UUID.randomUUID().toString();
- doNothing().when(mockedJobExecutorService).runDeleteNsJob(eq(nsInstId));
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + nsInstId;
- final ResponseEntity<Void> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.DELETE, null, Void.class);
- assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode());
- }
-
- @Test
- public void testDeleteNs_nsRequestProcessingExceptionThrown_returnInlineResponse400() {
- final String nsInstId = UUID.randomUUID().toString();
- final String message = "Unable to process request";
- doThrow(new NsRequestProcessingException(message, new InlineResponse400().detail(message)))
- .when(mockedJobExecutorService).runDeleteNsJob(eq(nsInstId));
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + nsInstId;
- final ResponseEntity<InlineResponse400> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.DELETE, null, InlineResponse400.class);
-
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode());
- assertTrue(responseEntity.hasBody());
- assertNotNull(responseEntity.getBody());
- }
-
- @Test
- public void testInstantiateNs_ValidInstantiateNsRequest() {
-
- final InstantiateNsRequest instantiateNsRequest = getInstantiateNsRequest();
- when(mockedJobExecutorService.runInstantiateNsJob(eq(RANDOM_NS_INST_ID), eq(instantiateNsRequest)))
- .thenReturn(RANDOM_NS_LCM_OP_OCC_ID);
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + RANDOM_NS_INST_ID + "/instantiate";
- final HttpEntity<?> request = new HttpEntity<>(instantiateNsRequest);
- final ResponseEntity<Void> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, Void.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
-
- final HttpHeaders httpHeaders = responseEntity.getHeaders();
- assertTrue(httpHeaders.containsKey(HttpHeaders.LOCATION));
- final List<String> actual = httpHeaders.get(HttpHeaders.LOCATION);
- assertEquals(1, actual.size());
- assertEquals(EXPECTED_NS_LCM_OP_OCC_REQ_LOCATION_URL, actual.get(0));
- }
-
- @Test
- public void testInstantiateNs_instantiateNsRequest_nsRequestProcessingExceptionThrown_returnInlineResponse400() {
- final String message = "Unable to process request";
- final InstantiateNsRequest instantiateNsRequest = getInstantiateNsRequest();
- when(mockedJobExecutorService.runInstantiateNsJob(eq(RANDOM_NS_INST_ID), eq(instantiateNsRequest)))
- .thenThrow(new NsRequestProcessingException(message, new InlineResponse400().detail(message)));
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + RANDOM_NS_INST_ID + "/instantiate";
- final HttpEntity<?> request = new HttpEntity<>(instantiateNsRequest);
- final ResponseEntity<InlineResponse400> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, InlineResponse400.class);
-
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode());
- assertTrue(responseEntity.hasBody());
- assertNotNull(responseEntity.getBody());
- }
-
- @Test
- public void testTerminateNs_ValidTerminateNsRequest_Success() {
- final TerminateNsRequest terminateNsRequest = getTerminateNsRequest();
- when(mockedJobExecutorService.runTerminateNsJob(eq(RANDOM_NS_INST_ID), eq(terminateNsRequest)))
- .thenReturn(RANDOM_NS_LCM_OP_OCC_ID);
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + RANDOM_NS_INST_ID + "/terminate";
- final HttpEntity<?> request = new HttpEntity<>(terminateNsRequest);
- final ResponseEntity<Void> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, Void.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
-
- final HttpHeaders httpHeaders = responseEntity.getHeaders();
- assertTrue(httpHeaders.containsKey(HttpHeaders.LOCATION));
- final List<String> actual = httpHeaders.get(HttpHeaders.LOCATION);
- assertEquals(1, actual.size());
- assertEquals(EXPECTED_NS_LCM_OP_OCC_REQ_LOCATION_URL, actual.get(0));
- }
-
- @Test
- public void testTerminateNs_ValidTerminateNsRequest_nsRequestProcessingExceptionThrown_returnInlineResponse400() {
- final String errorMessage = "ERROR MESSAGE";
- final TerminateNsRequest terminateNsRequest = getTerminateNsRequest();
- when(mockedJobExecutorService.runTerminateNsJob(eq(RANDOM_NS_INST_ID), eq(terminateNsRequest)))
- .thenThrow(new NsRequestProcessingException(errorMessage));
-
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + RANDOM_NS_INST_ID + "/terminate";
- final HttpEntity<?> request = new HttpEntity<>(terminateNsRequest);
- final ResponseEntity<InlineResponse400> responseEntity =
- testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, InlineResponse400.class);
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode());
- assertTrue(responseEntity.hasBody());
- assertNotNull(responseEntity.getBody());
- }
-
- private TerminateNsRequest getTerminateNsRequest() {
- // Only support for the immediate Terminate request; i.e., terminateTime field is empty (not set)
- return new TerminateNsRequest();
- }
-
- private InstantiateNsRequest getInstantiateNsRequest() {
- return new InstantiateNsRequest().nsFlavourId("FLAVOUR_ID");
- }
-
- private CreateNsRequest getCreateNsRequest() {
- return new CreateNsRequest().nsdId(RANDOM_NS_INST_ID);
- }
-
- private String getNsLcmBaseUrl() {
- return "http://localhost:" + port + Constants.NS_LIFE_CYCLE_MANAGEMENT_BASE_URL;
- }
-}
-
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml
deleted file mode 100644
index 608cde2471..0000000000
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright © 2020 Nordix Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-spring:
- main:
- allow-bean-definition-overriding: true
- flyway:
- baseline-on-migrate: false
- datasource:
- hikari:
- camunda:
- jdbcUrl: jdbc:h2:mem:example-simple;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
- driver-class-name: org.h2.Driver
- pool-name: ns-lcm-bpmn-pool
- registerMbeans: true
- nfvo:
- jdbcUrl: jdbc:h2:mem:NFVO;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS NFVO;MODE=MYSQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE
- driver-class-name: org.h2.Driver
- pool-name: ns-lcm-nfvo-pool
- registerMbeans: true
- test:
- database:
- replace: NONE
- jpa:
- generate-ddl: true
- dialect: org.hibernate.dialect.MySQL5Dialect
- hibernate:
- ddl-auto: create
- database-platform: org.hibernate.dialect.MariaDBDialect
-logging:
- level:
- org.reflections.Reflections: ERROR
-
-etsi-catalog-manager:
- base:
- endpoint: http://modeling-etsicatalog.onap:8806/api