diff options
Diffstat (limited to 'adapters')
6 files changed, 93 insertions, 14 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java index c1cc7428ee..5261f8ae19 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java @@ -23,8 +23,6 @@ package org.onap.so.adapters.inventory.create; import javax.annotation.PostConstruct; import org.camunda.bpm.client.ExternalTaskClient; import org.onap.so.utils.ExternalTaskServiceUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; @@ -34,8 +32,6 @@ import org.springframework.stereotype.Component; @Profile("!test") public class CreateInventoryService { - private static final Logger logger = LoggerFactory.getLogger(CreateInventoryService.class); - @Autowired public Environment env; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 2769f1c9b8..9adcdcb47a 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -1074,6 +1074,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (backout == null) { backout = true; } + if (failIfExists == null) { + failIfExists = false; + } if (msoHeatUtils != null) { heatStack = msoHeatUtils.createStack(cloudSiteId, cloudOwner, tenantId, vfModuleName, null, template, goldenInputs, true, heatTemplate.getTimeoutMinutes(), newEnvironmentString, diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java index 0d972bb4d2..f3cad76c9d 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java @@ -85,6 +85,20 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { } @Test + public void createVnfTest_NullFailIfExists() throws Exception { + mockOpenStackResponseAccess(wireMockServer, wireMockPort); + mockOpenStackGetStackVfModule_200(wireMockServer); + + MsoRequest msoRequest = getMsoRequest(); + + Map<String, Object> map = new HashMap<>(); + map.put("key1", "value1"); + instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", + "VFMOD", null, null, "b4ea86b4-253f-11e7-93ae-92361f002671", map, null, Boolean.TRUE, Boolean.FALSE, + msoRequest, new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>()); + } + + @Test public void createVnfTest_HeatStatusFailed() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); wireMockServer.stubFor(get( diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java index f6a0aec86f..28e931a3e1 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java @@ -74,4 +74,9 @@ public class InfraActiveRequestsRepositoryCustomController { @RequestParam(value = "maxResult", required = false) Integer maxResult) { return infraActiveRequestsRepository.getInfraActiveRequests(filters, startTime, endTime, maxResult); } + + @RequestMapping(method = RequestMethod.GET, value = "/infraActiveRequests/getInProgressVolumeGroupsAndVfModules") + public List<InfraActiveRequests> getInProgressVolumeGroupsAndVfModules() { + return infraActiveRequestsRepository.getInProgressVolumeGroupsAndVfModules(); + } } diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java index 4ed3285a70..896138f955 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java @@ -21,8 +21,13 @@ package org.onap.so.adapters.requestsdb; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import java.sql.Timestamp; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -33,6 +38,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; +import org.onap.so.serviceinstancebeans.ModelType; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.web.server.LocalServerPort; @@ -91,14 +97,6 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA @Before public void setup() { - - headers = new HttpHeaders(); - restTemplate = new TestRestTemplate("test", "test"); - - headers.set("Accept", MediaType.APPLICATION_JSON); - headers.set("Content-Type", MediaType.APPLICATION_JSON); - headers.set("Authorization", msoAdaptersAuth); - infraActiveRequests = new InfraActiveRequests(); infraActiveRequests.setRequestId(UUID.randomUUID().toString()); @@ -126,12 +124,22 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA infraActiveRequests .setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances"); - HttpEntity<String> entity = new HttpEntity(infraActiveRequests, headers); + saveInfraActiveRequest(infraActiveRequests); + } + + public void saveInfraActiveRequest(InfraActiveRequests request) { + headers = new HttpHeaders(); + restTemplate = new TestRestTemplate("test", "test"); + + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + headers.set("Authorization", msoAdaptersAuth); + + HttpEntity<String> entity = new HttpEntity(request, headers); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests")); ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class); - assertEquals(201, response.getStatusCodeValue()); } @@ -297,4 +305,38 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA assertEquals(200, response.getStatusCodeValue()); assertEquals(null, response.getBody()); } + + @Test + public void getInProgressVolumeGroupsAndVfModulesTest() { + boolean expectedReturned = false; + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId(UUID.randomUUID().toString()); + request.setVfModuleId(UUID.randomUUID().toString()); + request.setRequestStatus("IN_PROGRESS"); + request.setRequestScope(ModelType.vfModule.toString()); + Instant startInstant = Instant.now().minus(3, ChronoUnit.MINUTES); + request.setStartTime(Timestamp.from(startInstant)); + request.setRequestAction("create"); + saveInfraActiveRequest(request); + + UriComponentsBuilder builder = UriComponentsBuilder + .fromHttpUrl(createURLWithPort("/infraActiveRequests/getInProgressVolumeGroupsAndVfModules")); + + HttpEntity<String> entity = new HttpEntity<String>(headers); + + ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(builder.toUriString(), + HttpMethod.GET, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}); + + List<InfraActiveRequests> responseList = response.getBody(); + + assertEquals(200, response.getStatusCodeValue()); + + for (InfraActiveRequests result : responseList) { + if (result.getRequestId().equals(request.getRequestId())) { + assertThat(request, sameBeanAs(result).ignoring("modifyTime")); + expectedReturned = true; + } + } + assertTrue(expectedReturned); + } } diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java index 49291b6863..67887378ef 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java @@ -27,6 +27,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import java.sql.Timestamp; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -41,6 +43,7 @@ import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; import org.onap.so.db.request.beans.RequestProcessingData; +import org.onap.so.serviceinstancebeans.ModelType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.server.LocalServerPort; @@ -314,4 +317,20 @@ public class RequestsDbClientTest extends RequestsAdapterBase { verifyInfraActiveRequests(infraActiveRequestsResponse.get(0)); } + + @Test + public void getInProgressVolumeGroupsAndVfModulesTest() { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId(UUID.randomUUID().toString()); + request.setVfModuleId(UUID.randomUUID().toString()); + request.setRequestStatus("IN_PROGRESS"); + request.setRequestScope(ModelType.vfModule.toString()); + Instant startInstant = Instant.now().minus(3, ChronoUnit.MINUTES); + request.setStartTime(Timestamp.from(startInstant)); + request.setRequestAction("create"); + requestsDbClient.save(request); + + List<InfraActiveRequests> infraActiveRequests = requestsDbClient.getInProgressVolumeGroupsAndVfModules(); + assertThat(request, sameBeanAs(infraActiveRequests.get(0)).ignoring("modifyTime")); + } } |