From 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 30 Jul 2018 15:56:09 -0400 Subject: Containerization feature of SO Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) --- .../ArchiveInfraRequestsSchedulerTest.java | 106 +++++ .../adapters/HealthCheckHandlerTest.java | 73 ++++ .../requestsdb/adapters/MSORequestDBImplTest.java | 460 +++++++++++++++++++++ .../application/EmbeddedMariaDbConfig.java | 102 +++++ .../exceptions/MsoRequestsDbExceptionBeanTest.java | 43 ++ .../exceptions/MsoRequestsDbExceptionTest.java | 66 +++ .../requestsdb/HealthCheckHandlerTest.java | 67 --- .../requestsdb/MsoRequestsDbAdapterImplTest.java | 74 ---- .../exceptions/MsoRequestsDbExceptionBeanTest.java | 43 -- .../exceptions/MsoRequestsDbExceptionTest.java | 66 --- .../src/test/resources/application-test.yaml | 52 +++ .../test/resources/db/migration/afterMigrate.sql | 32 ++ .../src/test/resources/logback-test.xml | 33 ++ .../resources/wsdl/MsoRequestsDbAdapterImpl.wsdl | 295 +++++++++++++ 14 files changed, 1262 insertions(+), 250 deletions(-) create mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java create mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java create mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java create mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/EmbeddedMariaDbConfig.java create mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java create mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java delete mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java delete mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImplTest.java delete mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java delete mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java create mode 100644 adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml create mode 100644 adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql create mode 100644 adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml create mode 100644 adapters/mso-requests-db-adapter/src/test/resources/wsdl/MsoRequestsDbAdapterImpl.wsdl (limited to 'adapters/mso-requests-db-adapter/src/test') diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java new file mode 100644 index 0000000000..54debac36f --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository; +import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.PageRequest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@Transactional +public class ArchiveInfraRequestsSchedulerTest { + + @Autowired + private ArchiveInfraRequestsScheduler scheduler; + + @Autowired + private InfraActiveRequestsRepository iarRepo; + + @Autowired + private ArchivedInfraRequestsRepository archivedRepo; + + @Value("${mso.infra-requests.archived.period}") + private int archivedPeriod; + + @Test + public void testArchiveInfraRequests() { + String requestId1 = "requestId1"; + String requestId2 = "requestId2"; + + InfraActiveRequests iar1 = new InfraActiveRequests(); + iar1.setRequestId(requestId1); + iar1.setAction("action1"); + + InfraActiveRequests iar2 = new InfraActiveRequests(); + iar2.setRequestId(requestId2); + iar2.setAction("action2"); + + List requests = new ArrayList<>(); + requests.add(iar1); + requests.add(iar2); + iarRepo.save(requests); + + scheduler.archiveInfraRequests(requests); + + assertEquals(2, archivedRepo.count()); + assertEquals(requestId1, archivedRepo.findOne(requestId1).getRequestId()); + assertEquals(requestId2, archivedRepo.findOne(requestId2).getRequestId()); + } + + @Test + public void testInfraRequestsScheduledTask() { + Date currentDate= new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(currentDate); + calendar.add(Calendar.DATE, -archivedPeriod); + Date archivingDate = calendar.getTime(); + + List requests = iarRepo.findByEndTimeLessThan(archivingDate, new PageRequest(0, 100)); + List requests2 = iarRepo.findByStartTimeLessThanAndEndTime(archivingDate, null, new PageRequest(0, 100)); + + int total = requests.size() + requests2.size(); + + scheduler.infraRequestsScheduledTask(); + + assertTrue(archivedRepo.count() >= total); + assertTrue(iarRepo.count() < total); + } +} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java new file mode 100644 index 0000000000..005eba0ec2 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.adapters; + +import static org.junit.Assert.*; + + + +import javax.ws.rs.core.Response; + +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; + +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class HealthCheckHandlerTest { + + @LocalServerPort + private int port; + + TestRestTemplate restTemplate = new TestRestTemplate(); + + HttpHeaders headers = new HttpHeaders(); + + + @Test + public void testHealthcheck() throws JSONException { + + HttpEntity entity = new HttpEntity(null, headers); + + ResponseEntity response = restTemplate.exchange( + createURLWithPort("/manage/health"), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + } + + private String createURLWithPort(String uri) { + return "http://localhost:" + port + uri; + } +} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java new file mode 100644 index 0000000000..4d00421e6c --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java @@ -0,0 +1,460 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.adapters; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter; +import org.onap.so.adapters.requestsdb.RequestStatusType; +import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; +import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.OperationStatusRepository; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.onap.so.requestsdb.RequestsDbConstant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class MSORequestDBImplTest { + + @LocalServerPort + private int port; + + @Autowired + private MsoRequestsDbAdapter dbAdapter; + + @Autowired + private OperationStatusRepository operationStatusRepository; + + @Autowired + private ResourceOperationStatusRepository resourceOperationStatusRepo; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + public InfraActiveRequests setupTestEntities() { + return buildTestRequest(); + } + + private InfraActiveRequests buildTestRequest() { + InfraActiveRequests testRequest= new InfraActiveRequests(); + testRequest.setRequestId("00032ab7-3fb3-42e5-965d-8ea592502017"); + testRequest.setClientRequestId("00032ab7-3fb3-42e5-965d-8ea592502016"); + testRequest.setRequestStatus("COMPLETE"); + testRequest.setStatusMessage("Vf Module has been deleted successfully."); + testRequest.setProgress((long) 100); + testRequest.setSource("VID"); + testRequest.setTenantId("6accefef3cb442ff9e644d589fb04107"); + testRequest.setServiceInstanceId("e3b5744d-2ad1-4cdd-8390-c999a38829bc"); + testRequest.setRequestAction("deleteInstance"); + testRequest.setRequestScope("vfModule"); + testRequest.setAction("deleteInstance"); + testRequest.setAicCloudRegion("mtn6"); + testRequest.setLastModifiedBy("BPMN"); + testRequest.setVfModuleId("c7d527b1-7a91-49fd-b97d-1c8c0f4a7992"); + testRequest.setVfModuleModelName("vSAMP10aDEV::base::module-0"); + testRequest.setVnfId("b92f60c8-8de3-46c1-8dc1-e4390ac2b005"); + + return testRequest; + } + + + + + @Test + public void getByRequestId() throws MsoRequestsDbException { + InfraActiveRequests testRequest = setupTestEntities(); + // Given + String requestId = "00032ab7-3fb3-42e5-965d-8ea592502017"; + + // When + InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(requestId); + if(infraRequest ==null) + fail("Null infraRequest"); + + // Then + assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime")); + } + + + @Test + public void getByInvalidRequestId() throws MsoRequestsDbException { + // Given + String requestId = "invalidRequestId"; + + try { + dbAdapter.getInfraRequest(requestId); + fail("Expected MsoRequestsDbException to be thrown"); + } catch (MsoRequestsDbException e) { + assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId"); + } catch (Exception e) { + fail("Expected MsoRequestsDbException to be thrown, unknown exception thrown"); + } + } + + @Test + public void getByClientRequestId() throws MsoRequestsDbException { + InfraActiveRequests testRequest = setupTestEntities(); + // Given + String clientRequestId = "00032ab7-3fb3-42e5-965d-8ea592502016"; + + // When + InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(clientRequestId); + if(infraRequest ==null) + fail("Null infraRequest"); + + // Then + assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime")); + } + + + @Test + public void updateInfraRequest() throws MsoRequestsDbException { + InfraActiveRequests testRequest = setupTestEntities(); + // Given + String clientRequestId = "00032ab7-3fb3-42e5-965d-8ea592502016"; + + + // When + String lastModifiedBy = "UNIT TEST"; + String statusMessage = "TESTING THE UDPATES"; + String progress = "50"; + String vnfOutputs = "VNF OUTPUTS"; + String networkId = "New NetworkID"; + String vnfId = "NEWVNFID"; + String volumeGroupId = "NewVolumeGroupId"; + String serviceInstanceName = "NewServiceInstanceName"; + String configurationId = "NewConfigurationId"; + String configurationName = "NewConfigurationName"; + String vfModuleName = "VFModuleName"; + RequestStatusType requestStatus = RequestStatusType.COMPLETE ; + String responseBody = "NewResponseBody"; + String vfModuleId = "NEW VF MODULEID"; + String serviceInstanceId = " new serv ind"; + + + testRequest.setVolumeGroupId(volumeGroupId); + testRequest.setServiceInstanceName(serviceInstanceName); + testRequest.setConfigurationId(configurationId); + testRequest.setConfigurationName(configurationName); + testRequest.setNetworkId(networkId); + testRequest.setResponseBody(responseBody); + testRequest.setStatusMessage(statusMessage); + testRequest.setProgress((long) 50); + testRequest.setServiceInstanceId(lastModifiedBy); + testRequest.setLastModifiedBy(lastModifiedBy); + testRequest.setVfModuleId(vfModuleId); + testRequest.setVfModuleName(vfModuleName); + testRequest.setVnfId(vnfId); + testRequest.setServiceInstanceId(serviceInstanceId); + testRequest.setVfModuleName(vfModuleName); + testRequest.setVnfOutputs(vnfOutputs); + + + dbAdapter.updateInfraRequest ( testRequest.getRequestId(), + lastModifiedBy, + statusMessage, + responseBody, + requestStatus, + progress, + vnfOutputs, + serviceInstanceId, + networkId, + vnfId, + vfModuleId, + volumeGroupId, + serviceInstanceName, + configurationId, + configurationName, + vfModuleName); + InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(clientRequestId); + // Then + assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime")); + } + + @Test + public void UpdateByInvalidRequestId() throws MsoRequestsDbException { + // Given + String requestId = "invalidRequestId"; + + try { + dbAdapter.updateInfraRequest ( requestId, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + fail("Expected MsoRequestsDbException to be thrown"); + } catch (MsoRequestsDbException e) { + assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId"); + } catch (Exception e) { + fail("Expected MsoRequestsDbException to be thrown, unknown exception thrown"); + } + } + + + @Test + public void updateInfraRequestNulls() throws MsoRequestsDbException { + InfraActiveRequests testRequest = setupTestEntities(); + // Given + String clientRequestId = "00032ab7-3fb3-42e5-965d-8ea592502016"; + + // When + dbAdapter.updateInfraRequest ( testRequest.getRequestId(), + testRequest.getLastModifiedBy(), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(clientRequestId); + // Then + assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime")); + } + + @Test + public void getSiteStatusNotDisabled() throws MsoRequestsDbException { + setupTestEntities(); + // Given + String siteName = "siteName"; + + // When + boolean siteDisabled = dbAdapter.getSiteStatus(siteName); + + // Then + assertEquals(siteDisabled, true); + } + + @Test + public void getSiteStatusDisabled() throws MsoRequestsDbException { + setupTestEntities(); + // Given + String siteName = "testSite"; + + // When + boolean siteDisabled = dbAdapter.getSiteStatus(siteName); + + // Then + assertEquals(siteDisabled, false); + } + + @Test + public void updateServiceOperation() throws MsoRequestsDbException{ + String serviceId = "serviceid"; + String operationId = "operationid"; + String serviceName = "servicename"; + String operation = "newOperationType"; + String userId = "NewUserId"; + String result = "NewResult"; + String operationContent = "newOperationContent"; + String progress = "Newprogress"; + String reason = "NewReason"; + + OperationStatus updatedOperationStatus = new OperationStatus(); + + + + updatedOperationStatus.setServiceId(serviceId); + updatedOperationStatus.setServiceName(serviceName); + updatedOperationStatus.setOperationId(operationId); + updatedOperationStatus.setOperation(operation); + updatedOperationStatus.setUserId(userId); + updatedOperationStatus.setResult(result); + updatedOperationStatus.setProgress(progress); + updatedOperationStatus.setReason(reason); + updatedOperationStatus.setOperationContent(operationContent); + + dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation, userId, + result, operationContent, progress, reason); + OperationStatus dbOpStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId,operationId); + assertThat(dbOpStatus, sameBeanAs(updatedOperationStatus).ignoring("operateAt").ignoring("finishedAt")); + } + + + @Test + public void updateServiceOperation_Not_Found() throws MsoRequestsDbException{ + String serviceId = "badserviceId"; + String operationId = "operationid"; + String operation = "newOperationType"; + String userId = "NewUserId"; + String result = "NewResult"; + String operationContent = "newOperationContent"; + String progress = "Newprogress"; + String reason = "NewReason"; + + OperationStatus updatedOperationStatus = new OperationStatus(); + + + + updatedOperationStatus.setServiceId(serviceId); + updatedOperationStatus.setOperationId(operationId); + updatedOperationStatus.setOperation(operation); + updatedOperationStatus.setUserId(userId); + updatedOperationStatus.setResult(result); + updatedOperationStatus.setProgress(progress); + updatedOperationStatus.setReason(reason); + updatedOperationStatus.setOperationContent(operationContent); + + thrown.expect(MsoRequestsDbException.class); + thrown.expectMessage("Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId); + + dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation, userId, + result, operationContent, progress, reason); + + } + + @Test + public void initResourceOperationStatus() throws MsoRequestsDbException{ + String resourceTemplateUUIDs = "template1:template2:template3:"; + String serviceId = "serviceId"; + String operationId = "operationId"; + String operationType = "operationType"; + + ResourceOperationStatus resource1 = new ResourceOperationStatus(); + resource1.setOperationId(operationId); + resource1.setServiceId(serviceId); + resource1.setResourceTemplateUUID("template1"); + resource1.setOperType(operationType); + resource1.setStatus(RequestsDbConstant.Status.PROCESSING); + resource1.setStatusDescription("Waiting for start"); + + ResourceOperationStatus resource2 = new ResourceOperationStatus(); + resource2.setOperationId(operationId); + resource2.setServiceId(serviceId); + resource2.setResourceTemplateUUID("template2"); + resource2.setOperType(operationType); + resource2.setStatus(RequestsDbConstant.Status.PROCESSING); + resource2.setStatusDescription("Waiting for start"); + + ResourceOperationStatus resource3 = new ResourceOperationStatus(); + resource3.setOperationId(operationId); + resource3.setServiceId(serviceId); + resource3.setResourceTemplateUUID("template3"); + resource3.setOperType(operationType); + resource3.setStatus(RequestsDbConstant.Status.PROCESSING); + resource3.setStatusDescription("Waiting for start"); + + List expectedResult = new ArrayList(); + expectedResult.add(resource1); + expectedResult.add(resource2); + expectedResult.add(resource3); + + dbAdapter.initResourceOperationStatus(serviceId, operationId, operationType,resourceTemplateUUIDs); + List testList = resourceOperationStatusRepo.findByServiceIdAndOperationId(serviceId,operationId); + assertThat(testList, sameBeanAs(expectedResult)); + } + + @Test + public void getResourceOperationStatus() throws MsoRequestsDbException{ + String resourceTemplateUUIDs = "template1"; + String serviceId = "serviceId"; + String operationId = "operationId"; + String operationType = "operationType"; + + ResourceOperationStatus resource1 = new ResourceOperationStatus(); + resource1.setOperationId(operationId); + resource1.setServiceId(serviceId); + resource1.setResourceTemplateUUID("template1"); + resource1.setOperType(operationType); + resource1.setStatus(RequestsDbConstant.Status.PROCESSING); + resource1.setStatusDescription("Waiting for start"); + + + dbAdapter.initResourceOperationStatus(serviceId, operationId, operationType,resourceTemplateUUIDs); + + ResourceOperationStatus actualResource = dbAdapter.getResourceOperationStatus(serviceId, operationId,"template1"); + assertThat(actualResource, sameBeanAs(resource1)); + } + + @Test + public void updateResourceOperationStatus() throws MsoRequestsDbException{ + String resourceTemplateUUID = "template1"; + String serviceId = "serviceId"; + String operationId = "operationId"; + String operationType = "operationType"; + String resourceInstanceID = "resourceInstanceID"; + String jobId = "jobId"; + String status = RequestsDbConstant.Status.FINISHED; + String progress = "50"; + String errorCode = "errorCode"; + String statusDescription = "statusDescription"; + + + ResourceOperationStatus expectedResource = new ResourceOperationStatus(); + expectedResource.setOperationId(operationId); + expectedResource.setServiceId(serviceId); + expectedResource.setResourceTemplateUUID(resourceTemplateUUID); + expectedResource.setOperType(operationType); + expectedResource.setJobId(jobId); + expectedResource.setErrorCode(errorCode); + expectedResource.setStatus(RequestsDbConstant.Status.FINISHED); + expectedResource.setStatusDescription(statusDescription); + expectedResource.setProgress(progress); + expectedResource.setResourceInstanceID(resourceInstanceID); + + + dbAdapter.updateResourceOperationStatus(serviceId, operationId, resourceTemplateUUID, + operationType, resourceInstanceID, jobId, status, progress, + errorCode, statusDescription); + + ResourceOperationStatus actualResource = dbAdapter.getResourceOperationStatus(serviceId, operationId,"template1"); + assertThat(actualResource, sameBeanAs(expectedResource)); + } + + +} \ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/EmbeddedMariaDbConfig.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..cd07f6757f --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/EmbeddedMariaDbConfig.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.application; +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +@Configuration +@Profile({"test"}) +@EnableTransactionManagement +@EnableJpaRepositories( + entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", + basePackages = { "org.onap.so.db.request.data.repository"} + ) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + return new MariaDB4jSpringService(); + } + + @Primary + @Bean(name = "requestDataSource") + @ConfigurationProperties(prefix = "spring.datasource") + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + //Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder + .create() + .username(datasourceUsername) + .password(datasourcePassword) + .url(config.getURL(databaseName)) + .driverClassName(datasourceDriver) + .build(); + } + + @Primary + @Bean(name = "requestEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean + entityManagerFactory( + EntityManagerFactoryBuilder builder, + @Qualifier("requestDataSource") DataSource dataSource + ) { + return builder + .dataSource(dataSource) + .packages("org.onap.so.db.request.beans") + .persistenceUnit("requestDB") + .build(); + } + + @Primary + @Bean(name = "requestTransactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("requestEntityManagerFactory") EntityManagerFactory + entityManagerFactory + ) { + return new JpaTransactionManager(entityManagerFactory); + } +} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java new file mode 100644 index 0000000000..77821bfefd --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.exceptions; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class MsoRequestsDbExceptionBeanTest { + + private MsoRequestsDbExceptionBean soRequestsDbExceptionBean; + + @Before + public void setUp() { + soRequestsDbExceptionBean = new MsoRequestsDbExceptionBean(); + } + + @Test + public void testGetMessage() { + soRequestsDbExceptionBean.setMessage("message"); + Assert.assertNotNull(soRequestsDbExceptionBean.getMessage()); + Assert.assertEquals(soRequestsDbExceptionBean.getMessage(), "message"); + } + +} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java new file mode 100644 index 0000000000..04f597f9b2 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ +package org.onap.so.adapters.requestsdb.exceptions; + +import org.junit.Assert; +import org.junit.Test; + +public class MsoRequestsDbExceptionTest { + @Test + public void testConstructorWithMessaqge() throws Exception { + String message = "testing message"; + MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(message); + Assert.assertTrue(msoRequestsDbException.getCause() == null); + Assert.assertEquals(message, msoRequestsDbException.getLocalizedMessage()); + Assert.assertEquals(message, msoRequestsDbException.getMessage()); + } + + @Test + public void testConstructorWithThrowable() throws Exception { + String message = "testing message"; + Throwable throwable = new Throwable(message); + MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(throwable); + Assert.assertEquals(throwable, msoRequestsDbException.getCause()); + Assert.assertTrue(msoRequestsDbException.getLocalizedMessage().contains(message)); + Assert.assertTrue(msoRequestsDbException.getMessage().contains(message)); + } + + @Test + public void testConstructorWithMessageAndThrowable() throws Exception { + String message = "testing message"; + String tMessage = "throwable message"; + Throwable throwable = new Throwable(tMessage); + MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(message, throwable); + Assert.assertEquals(throwable, msoRequestsDbException.getCause()); + Assert.assertTrue(msoRequestsDbException.getLocalizedMessage().contains(message)); + Assert.assertTrue(msoRequestsDbException.getMessage().contains(message)); + } + + /* test method */ + @Test + public void testGetFaultInfo() { + MsoRequestsDbExceptionBean faultInfo = new MsoRequestsDbExceptionBean(); + MsoRequestsDbException soRequestsDbException = new MsoRequestsDbException("message"); + soRequestsDbException.setFaultInfo(faultInfo); + Assert.assertNotNull(soRequestsDbException.getFaultInfo()); + Assert.assertEquals(soRequestsDbException.getFaultInfo(), faultInfo); + } + +} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java deleted file mode 100644 index 87e2a87138..0000000000 --- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.requestsdb; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.openecomp.mso.HealthCheckUtils; -import org.openecomp.mso.logger.MsoLogger; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import javax.ws.rs.core.Response; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(HealthCheckHandler.class) -public class HealthCheckHandlerTest { - - HealthCheckHandler hcH; - - @Before - public void init(){ - - hcH = new HealthCheckHandler(); - } - - @Test - public void testNoServiceResp() { - - HealthCheckUtils test = PowerMockito.mock(HealthCheckUtils.class); - try { - PowerMockito.whenNew(HealthCheckUtils.class).withNoArguments().thenReturn(test); - when(test.siteStatusCheck(any(MsoLogger.class))).thenReturn(true); - - } catch (Exception e) { - e.printStackTrace(); - } - Response response = hcH.healthcheck("request"); - assertEquals(503,response.getStatus()); - } - -} - - diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImplTest.java deleted file mode 100644 index 506b3bd95f..0000000000 --- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImplTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.adapters.requestsdb; - -import org.junit.Test; - -public class MsoRequestsDbAdapterImplTest { - - // TODO: following test case is done for coverage - // later it should be modified for proper test. - MsoRequestsDbAdapterImpl msoRequestsDbAdapter = new MsoRequestsDbAdapterImpl(); - - @Test(expected = NullPointerException.class) - public void updateInfraRequest() throws Exception { - msoRequestsDbAdapter.updateInfraRequest("test", "test", - "test", "test", RequestStatusType.COMPLETE, "test", - "test", "test", "test", "test", - "test", "test", "test", - "test", "test", "tets"); - } - - @Test(expected = NullPointerException.class) - public void getInfraRequest() throws Exception { - msoRequestsDbAdapter.getInfraRequest("test"); - } - - @Test(expected = NullPointerException.class) - public void getSiteStatus() throws Exception { - msoRequestsDbAdapter.getSiteStatus("test"); - } - - @Test(expected = NullPointerException.class) - public void updateServiceOperationStatus() throws Exception { - msoRequestsDbAdapter.updateServiceOperationStatus("test", "test", - "test", "test", "test", "test", - "test", "test"); - } - - @Test(expected = NullPointerException.class) - public void initResourceOperationStatus() throws Exception { - msoRequestsDbAdapter.initResourceOperationStatus("test", "test", "test", "uuid"); - } - - @Test(expected = NullPointerException.class) - public void getResourceOperationStatus() throws Exception { - msoRequestsDbAdapter.getResourceOperationStatus("test", "test", "uuid"); - } - - @Test(expected = NullPointerException.class) - public void updateResourceOperationStatus() throws Exception { - msoRequestsDbAdapter.updateResourceOperationStatus("test", "test", - "uuid", "type", "instance-id", - "jobid", "test", "progress", "errorcode", - "status-desc"); - } - -} \ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java deleted file mode 100644 index 159dd91541..0000000000 --- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 TechMahindra - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.requestsdb.exceptions; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class MsoRequestsDbExceptionBeanTest { - - private MsoRequestsDbExceptionBean soRequestsDbExceptionBean; - - @Before - public void setUp() { - soRequestsDbExceptionBean = new MsoRequestsDbExceptionBean(); - } - - @Test - public void testGetMessage() { - soRequestsDbExceptionBean.setMessage("message"); - Assert.assertNotNull(soRequestsDbExceptionBean.getMessage()); - Assert.assertEquals(soRequestsDbExceptionBean.getMessage(), "message"); - } - -} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java deleted file mode 100644 index b946349037..0000000000 --- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 TechMahindra - * ================================================================================ - * 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 - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.adapters.requestsdb.exceptions; - -import org.junit.Assert; -import org.junit.Test; - -public class MsoRequestsDbExceptionTest { - @Test - public void testConstructorWithMessaqge() throws Exception { - String message = "testing message"; - MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(message); - Assert.assertTrue(msoRequestsDbException.getCause() == null); - Assert.assertEquals(message, msoRequestsDbException.getLocalizedMessage()); - Assert.assertEquals(message, msoRequestsDbException.getMessage()); - } - - @Test - public void testConstructorWithThrowable() throws Exception { - String message = "testing message"; - Throwable throwable = new Throwable(message); - MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(throwable); - Assert.assertEquals(throwable, msoRequestsDbException.getCause()); - Assert.assertTrue(msoRequestsDbException.getLocalizedMessage().contains(message)); - Assert.assertTrue(msoRequestsDbException.getMessage().contains(message)); - } - - @Test - public void testConstructorWithMessageAndThrowable() throws Exception { - String message = "testing message"; - String tMessage = "throwable message"; - Throwable throwable = new Throwable(tMessage); - MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(message, throwable); - Assert.assertEquals(throwable, msoRequestsDbException.getCause()); - Assert.assertTrue(msoRequestsDbException.getLocalizedMessage().contains(message)); - Assert.assertTrue(msoRequestsDbException.getMessage().contains(message)); - } - - /* test method */ - @Test - public void testGetFaultInfo() { - MsoRequestsDbExceptionBean faultInfo = new MsoRequestsDbExceptionBean(); - MsoRequestsDbException soRequestsDbException = new MsoRequestsDbException("message"); - soRequestsDbException.setFaultInfo(faultInfo); - Assert.assertNotNull(soRequestsDbException.getFaultInfo()); - Assert.assertEquals(soRequestsDbException.getFaultInfo(), faultInfo); - } - -} diff --git a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..c3be9323fb --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml @@ -0,0 +1,52 @@ +# will be used as entry in DB to say SITE OFF/ON for healthcheck + +server: + port: 8080 + tomcat: + max-threads: 50 +ssl-enable: false +mso: + logPath: logs + site-name: localSite + infra-requests: + archived: + period: 1 +spring: + datasource: + url: jdbc:mariadb://localhost:3307/requestdb + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialize: true + initialization-mode: never + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: validate + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + security: + usercredentials: + - + username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client +mariaDB4j: + dataDir: + port: 3307 + databaseName: requestdb + +#Actuator +management: + security: + enabled: false + basic: + enabled: false + +flyway: + baseline-on-migrate: false + url: jdbc:mariadb://localhost:3307/requestdb + user: root + password: password diff --git a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql new file mode 100644 index 0000000000..ec02ac0734 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -0,0 +1,32 @@ +use requestdb; + +insert into operation_status(service_id, operation_id, service_name, user_id, result, operation_content, progress, reason, operate_at, finished_at) values +('serviceid', 'operationid', 'servicename', 'userid', 'result', 'operationcontent', 'progress', 'reason', '2016-11-24 13:19:10', '2016-11-24 13:19:10'); + + +insert into infra_active_requests(request_id, client_request_id, action, request_status, status_message, progress, start_time, end_time, source, vnf_id, vnf_name, vnf_type, service_type, aic_node_clli, tenant_id, prov_status, vnf_params, vnf_outputs, request_body, response_body, last_modified_by, modify_time, request_type, volume_group_id, volume_group_name, vf_module_id, vf_module_name, vf_module_model_name, aai_service_id, aic_cloud_region, callback_url, correlator, network_id, network_name, network_type, request_scope, request_action, service_instance_id, service_instance_name, requestor_id, configuration_id, configuration_name, operational_env_id, operational_env_name) values +('00032ab7-3fb3-42e5-965d-8ea592502017', '00032ab7-3fb3-42e5-965d-8ea592502016', 'deleteInstance', 'COMPLETE', 'Vf Module has been deleted successfully.', '100', '2016-12-22 18:59:54', '2016-12-22 19:00:28', 'VID', 'b92f60c8-8de3-46c1-8dc1-e4390ac2b005', null, null, null, null, '6accefef3cb442ff9e644d589fb04107', null, null, null, '{"requestDetails":{"modelInfo":{"modelType":"vfModule","modelName":"vSAMP10aDEV::base::module-0"},"requestInfo":{"source":"VID"},"cloudConfiguration":{"tenantId":"6accefef3cb442ff9e644d589fb04107","lcpCloudRegionId":"mtn6"}}}', null, 'BPMN', '2016-12-22 19:00:28', null, null, null, 'c7d527b1-7a91-49fd-b97d-1c8c0f4a7992', null, 'vSAMP10aDEV::base::module-0', null, 'mtn6', null, null, null, null, null, 'vfModule', 'deleteInstance', 'e3b5744d-2ad1-4cdd-8390-c999a38829bc', null, null, null, null, null, null), +('00093944-bf16-4373-ab9a-3adfe730ff2d', null, 'createInstance', 'FAILED', 'Error: Locked instance - This service (MSODEV_1707_SI_vSAMP10a_011-4) already has a request being worked with a status of IN_PROGRESS (RequestId - 278e83b1-4f9f-450e-9e7d-3700a6ed22f4). The existing request must finish or be cleaned up before proceeding.', '100', '2017-07-11 18:33:26', '2017-07-11 18:33:26', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"requestDetails":{"modelInfo":{"modelInvariantId":"9647dfc4-2083-11e7-93ae-92361f002671","modelType":"service","modelName":"MSOTADevInfra_vSAMP10a_Service","modelVersion":"1.0","modelVersionId":"5df8b6de-2083-11e7-93ae-92361f002671"},"requestInfo":{"source":"VID","instanceName":"MSODEV_1707_SI_vSAMP10a_011-4","suppressRollback":false,"requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarteSet":true,"alaCarte":true}}}', null, 'APIH', '2016-12-22 19:00:28', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', null, 'MSODEV_1707_SI_vSAMP10a_011-4', 'xxxxxx', null, null, null, null), +('001619d2-a297-4a4b-a9f5-e2823c88458f', '001619d2-a297-4a4b-a9f5-e2823c88458f', 'CREATE_VF_MODULE', 'COMPLETE', 'COMPLETED', '100', '2016-07-01 14:11:42', '2017-05-02 16:03:34', 'PORTAL', null, 'test-vscp', 'elena_test21', null, null, '381b9ff6c75e4625b7a4182f90fc68d3', null, null, null, '\n\n \n 001619d2-a297-4a4b-a9f5-e2823c88458f\n CREATE_VF_MODULE\n PORTAL\n \n \n test-vscp\n moduleName\n elena_test21\n moduleModelName\n 1.0\n a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\n mtn9\n 381b9ff6c75e4625b7a4182f90fc68d3\n \n \n false\n \n \n\n', 'NONE', 'RDBTEST', '2016-07-01 14:11:42', 'VNF', null, null, null, 'MODULENAME1', 'moduleModelName', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb', 'mtn9', null, null, null, null, null, 'vfModule', 'createInstance', null, null, null, null, null, null, null), +('00164b9e-784d-48a8-8973-bbad6ef818ed', null, 'createInstance', 'COMPLETE', 'Service Instance was created successfully.', '100', '2017-09-28 12:45:51', '2017-09-28 12:45:53', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"requestDetails":{"requestDetails":{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f","modelType":"service","modelNameVersionId":null,"modelName":"MSO Test Network","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":"DEV-MTN6-3100-0927-1","suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":null,"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"aicNodeClli":null,"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":true},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}}}', null, 'CreateGenericALaCarteServiceInstance', '2017-09-28 12:45:52', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', 'b2f59173-b7e5-4e0f-8440-232fd601b865', 'DEV-MTN6-3100-0927-1', 'xxxxxx', null, null, null, null), +('00173cc9-5ce2-4673-a810-f87fefb2829e', null, 'createInstance', 'FAILED', 'Error parsing request. No valid instanceName is specified', '100', '2017-04-14 21:08:46', '2017-04-14 21:08:46', 'VID', null, null, null, null, null, 'a259ae7b7c3f493cb3d91f95a7c18149', null, null, null, '{"requestDetails":{"modelInfo":{"modelInvariantId":"ff6163d4-7214-459e-9f76-507b4eb00f51","modelType":"service","modelName":"ConstraintsSrvcVID","modelVersion":"2.0","modelVersionId":"722d256c-a374-4fba-a14f-a59b76bb7656"},"requestInfo":{"productFamilyId":"LRSI-OSPF","source":"VID","requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"},"cloudConfiguration":{"tenantId":"a259ae7b7c3f493cb3d91f95a7c18149","lcpCloudRegionId":"mtn16"},"requestParameters":{"subscriptionServiceType":"Mobility","userParams":[{"name":"neutronport6_name","value":"8"},{"name":"neutronnet5_network_name","value":"8"},{"name":"contrailv2vlansubinterface3_name","value":"false"}]}}}', null, 'APIH', '2016-12-22 19:00:28', null, null, null, null, null, null, null, 'mtn16', null, null, null, null, null, 'service', 'createInstance', null, null, null, null, null, null, null), +('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', null, 'activateInstance', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', '2017-09-28 12:45:53', 'VID', null, null, null, null, null, null, null, null, null, '{"requestDetails":{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null); + +insert into watchdog_distributionid_status(distribution_id, distribution_id_status, create_time, modify_time) values +('1533c4bd-a3e3-493f-a16d-28c20614415e', '', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', '', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); + +insert into watchdog_per_component_distribution_status(distribution_id, component_name, component_distribution_status, create_time, modify_time) values +('1533c4bd-a3e3-493f-a16d-28c20614415e', 'MSO', 'COMPONENT_DONE_OK', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', 'MSO', 'COMPONENT_DONE_ERROR', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', 'MSO', 'COMPONENT_DONE_OK', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); + +insert into watchdog_service_mod_ver_id_lookup(distribution_id, service_model_version_id, create_time, modify_time) values +('1533c4bd-a3e3-493f-a16d-28c20614415e', '7e813ab5-88d3-4fcb-86c0-498c5d7eef9a', '2017-11-30 15:48:08', '2017-11-30 15:48:08'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', 'cc031e75-4442-4d1a-b774-8a2b434e0a50', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', 'eade1e9d-c1ec-4ef3-bc31-60570fba1573', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); + + +insert into site_status(site_name, status, creation_timestamp) values +('testsite', 0, '2017-11-30 15:48:09'); \ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..54fa1cdd65 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,33 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/resources/wsdl/MsoRequestsDbAdapterImpl.wsdl b/adapters/mso-requests-db-adapter/src/test/resources/wsdl/MsoRequestsDbAdapterImpl.wsdl new file mode 100644 index 0000000000..b22acdae75 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/resources/wsdl/MsoRequestsDbAdapterImpl.wsdl @@ -0,0 +1,295 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg