diff options
Diffstat (limited to 'adapters/mso-requests-db-adapter/src/test')
12 files changed, 1156 insertions, 144 deletions
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<InfraActiveRequests> 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<InfraActiveRequests> requests = iarRepo.findByEndTimeLessThan(archivingDate, new PageRequest(0, 100)); + List<InfraActiveRequests> 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<String> entity = new HttpEntity<String>(null, headers); + + ResponseEntity<String> 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<ResourceOperationStatus> expectedResult = new ArrayList<ResourceOperationStatus>(); + expectedResult.add(resource1); + expectedResult.add(resource2); + expectedResult.add(resource3); + + dbAdapter.initResourceOperationStatus(serviceId, operationId, operationType,resourceTemplateUUIDs); + List<ResourceOperationStatus> 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/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java index 159dd91541..77821bfefd 100644 --- 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/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.requestsdb.exceptions; +package org.onap.so.adapters.requestsdb.exceptions; import org.junit.Assert; import org.junit.Before; 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/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java index b946349037..04f597f9b2 100644 --- 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/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java @@ -14,10 +14,10 @@ * 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 + * limitations under the License. * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.requestsdb.exceptions; +package org.onap.so.adapters.requestsdb.exceptions; import org.junit.Assert; import org.junit.Test; 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/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, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<vnf-request xmlns=\"http://org.onap.so/mso/infra/vnf-request/v1\">\n <request-info>\n <request-id>001619d2-a297-4a4b-a9f5-e2823c88458f</request-id>\n <action>CREATE_VF_MODULE</action>\n <source>PORTAL</source>\n </request-info>\n <vnf-inputs>\n <vnf-name>test-vscp</vnf-name>\n <vf-module-name>moduleName</vf-module-name>\n <vnf-type>elena_test21</vnf-type>\n <vf-module-model-name>moduleModelName</vf-module-model-name>\n <asdc-service-model-version>1.0</asdc-service-model-version>\n <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id>\n <aic-cloud-region>mtn9</aic-cloud-region>\n <tenant-id>381b9ff6c75e4625b7a4182f90fc68d3</tenant-id>\n <persona-model-id></persona-model-id>\n <persona-model-version></persona-model-version>\n <is-base-vf-module>false</is-base-vf-module>\n </vnf-inputs>\n <vnf-params xmlns:tns=\"http://org.onap.so/mso/infra/vnf-request/v1\"/>\n</vnf-request>\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 @@ +<configuration> + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.ecomp.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + <logger name="org.flywaydb" level="DEBUG" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + <root level="WARN"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<wsdl:definitions name="RequestsDbAdapter" targetNamespace="http://org.onap.so/requestsdb" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://org.onap.so/requestsdb" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> + <wsdl:types> +<xs:schema xmlns:tns="http://org.onap.so/requestsdb" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://org.onap.so/requestsdb"> + <xs:element name="getInfraRequest" type="tns:getInfraRequest"/> + <xs:element name="getInfraRequestResponse" type="tns:getInfraRequestResponse"/> + <xs:element name="getSiteStatus" type="tns:getSiteStatus"/> + <xs:element name="getSiteStatusResponse" type="tns:getSiteStatusResponse"/> + <xs:element name="initResourceOperationStatus" type="tns:initResourceOperationStatus"/> + <xs:element name="initResourceOperationStatusResponse" type="tns:initResourceOperationStatusResponse"/> + <xs:element name="updateInfraRequest" type="tns:updateInfraRequest"/> + <xs:element name="updateInfraRequestResponse" type="tns:updateInfraRequestResponse"/> + <xs:element name="updateServiceOperationStatus" type="tns:updateServiceOperationStatus"/> + <xs:element name="updateServiceOperationStatusResponse" type="tns:updateServiceOperationStatusResponse"/> + <xs:complexType name="getInfraRequest"> + <xs:sequence> + <xs:element name="requestId" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="getInfraRequestResponse"> + <xs:sequence> + <xs:element minOccurs="0" name="return" type="tns:infraActiveRequests"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="infraActiveRequests"> + <xs:sequence> + <xs:element minOccurs="0" name="aaiServiceId" type="xs:string"/> + <xs:element minOccurs="0" name="action" type="xs:string"/> + <xs:element minOccurs="0" name="aicCloudRegion" type="xs:string"/> + <xs:element minOccurs="0" name="aicNodeClli" type="xs:string"/> + <xs:element minOccurs="0" name="callBackUrl" type="xs:string"/> + <xs:element minOccurs="0" name="clientRequestId" type="xs:string"/> + <xs:element minOccurs="0" name="configurationId" type="xs:string"/> + <xs:element minOccurs="0" name="configurationName" type="xs:string"/> + <xs:element minOccurs="0" name="correlator" type="xs:string"/> + <xs:element minOccurs="0" name="endTime" type="xs:long"/> + <xs:element minOccurs="0" name="lastModifiedBy" type="xs:string"/> + <xs:element minOccurs="0" name="networkId" type="xs:string"/> + <xs:element minOccurs="0" name="networkName" type="xs:string"/> + <xs:element minOccurs="0" name="networkType" type="xs:string"/> + <xs:element minOccurs="0" name="operationalEnvId" type="xs:string"/> + <xs:element minOccurs="0" name="operationalEnvName" type="xs:string"/> + <xs:element minOccurs="0" name="progress" type="xs:long"/> + <xs:element minOccurs="0" name="provStatus" type="xs:string"/> + <xs:element minOccurs="0" name="requestAction" type="xs:string"/> + <xs:element minOccurs="0" name="requestBody" type="xs:string"/> + <xs:element minOccurs="0" name="requestId" type="xs:string"/> + <xs:element minOccurs="0" name="requestScope" type="xs:string"/> + <xs:element minOccurs="0" name="requestStatus" type="xs:string"/> + <xs:element minOccurs="0" name="requestType" type="xs:string"/> + <xs:element minOccurs="0" name="requestorId" type="xs:string"/> + <xs:element minOccurs="0" name="responseBody" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceId" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceName" type="xs:string"/> + <xs:element minOccurs="0" name="serviceType" type="xs:string"/> + <xs:element minOccurs="0" name="source" type="xs:string"/> + <xs:element minOccurs="0" name="startTime" type="xs:long"/> + <xs:element minOccurs="0" name="statusMessage" type="xs:string"/> + <xs:element minOccurs="0" name="tenantId" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleId" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleModelName" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleName" type="xs:string"/> + <xs:element minOccurs="0" name="vnfId" type="xs:string"/> + <xs:element minOccurs="0" name="vnfName" type="xs:string"/> + <xs:element minOccurs="0" name="vnfOutputs" type="xs:string"/> + <xs:element minOccurs="0" name="vnfParams" type="xs:string"/> + <xs:element minOccurs="0" name="vnfType" type="xs:string"/> + <xs:element minOccurs="0" name="volumeGroupId" type="xs:string"/> + <xs:element minOccurs="0" name="volumeGroupName" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="msoRequestsDbExceptionBean"> + <xs:sequence> + <xs:element minOccurs="0" name="message" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="getSiteStatus"> + <xs:sequence> + <xs:element name="siteName" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="getSiteStatusResponse"> + <xs:sequence> + <xs:element name="return" type="xs:boolean"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="updateInfraRequest"> + <xs:sequence> + <xs:element name="requestId" type="xs:string"/> + <xs:element name="lastModifiedBy" type="xs:string"/> + <xs:element minOccurs="0" name="statusMessage" type="xs:string"/> + <xs:element minOccurs="0" name="responseBody" type="xs:string"/> + <xs:element minOccurs="0" name="requestStatus" type="tns:request-status-type"/> + <xs:element minOccurs="0" name="progress" type="xs:string"/> + <xs:element minOccurs="0" name="vnfOutputs" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceId" type="xs:string"/> + <xs:element minOccurs="0" name="networkId" type="xs:string"/> + <xs:element minOccurs="0" name="vnfId" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleId" type="xs:string"/> + <xs:element minOccurs="0" name="volumeGroupId" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceName" type="xs:string"/> + <xs:element minOccurs="0" name="configurationId" type="xs:string"/> + <xs:element minOccurs="0" name="configurationName" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleName" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="updateInfraRequestResponse"> + <xs:sequence/> + </xs:complexType> + <xs:complexType name="initResourceOperationStatus"> + <xs:sequence> + <xs:element name="serviceId" type="xs:string"/> + <xs:element name="operationId" type="xs:string"/> + <xs:element name="operationType" type="xs:string"/> + <xs:element name="resourceTemplateUUIDs" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="initResourceOperationStatusResponse"> + <xs:sequence/> + </xs:complexType> + <xs:complexType name="updateServiceOperationStatus"> + <xs:sequence> + <xs:element name="serviceId" type="xs:string"/> + <xs:element minOccurs="0" name="operationId" type="xs:string"/> + <xs:element minOccurs="0" name="operationType" type="xs:string"/> + <xs:element minOccurs="0" name="userId" type="xs:string"/> + <xs:element minOccurs="0" name="result" type="xs:string"/> + <xs:element minOccurs="0" name="operationContent" type="xs:string"/> + <xs:element minOccurs="0" name="progress" type="xs:string"/> + <xs:element minOccurs="0" name="reason" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="updateServiceOperationStatusResponse"> + <xs:sequence/> + </xs:complexType> + <xs:simpleType name="request-status-type"> + <xs:restriction base="xs:string"> + <xs:enumeration value="COMPLETE"/> + <xs:enumeration value="FAILED"/> + <xs:enumeration value="IN_PROGRESS"/> + </xs:restriction> + </xs:simpleType> + <xs:element name="MsoRequestsDbException" nillable="true" type="tns:msoRequestsDbExceptionBean"/> +</xs:schema> + </wsdl:types> + <wsdl:message name="getInfraRequest"> + <wsdl:part name="parameters" element="tns:getInfraRequest"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="getSiteStatus"> + <wsdl:part name="parameters" element="tns:getSiteStatus"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="updateServiceOperationStatus"> + <wsdl:part name="parameters" element="tns:updateServiceOperationStatus"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="updateServiceOperationStatusResponse"> + <wsdl:part name="parameters" element="tns:updateServiceOperationStatusResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="MsoRequestsDbException"> + <wsdl:part name="MsoRequestsDbException" element="tns:MsoRequestsDbException"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="updateInfraRequest"> + <wsdl:part name="parameters" element="tns:updateInfraRequest"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="updateInfraRequestResponse"> + <wsdl:part name="parameters" element="tns:updateInfraRequestResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="initResourceOperationStatus"> + <wsdl:part name="parameters" element="tns:initResourceOperationStatus"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="initResourceOperationStatusResponse"> + <wsdl:part name="parameters" element="tns:initResourceOperationStatusResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="getSiteStatusResponse"> + <wsdl:part name="parameters" element="tns:getSiteStatusResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="getInfraRequestResponse"> + <wsdl:part name="parameters" element="tns:getInfraRequestResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:portType name="RequestsDbAdapter"> + <wsdl:operation name="getInfraRequest"> + <wsdl:input name="getInfraRequest" message="tns:getInfraRequest"> + </wsdl:input> + <wsdl:output name="getInfraRequestResponse" message="tns:getInfraRequestResponse"> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException" message="tns:MsoRequestsDbException"> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="getSiteStatus"> + <wsdl:input name="getSiteStatus" message="tns:getSiteStatus"> + </wsdl:input> + <wsdl:output name="getSiteStatusResponse" message="tns:getSiteStatusResponse"> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="updateInfraRequest"> + <wsdl:input name="updateInfraRequest" message="tns:updateInfraRequest"> + </wsdl:input> + <wsdl:output name="updateInfraRequestResponse" message="tns:updateInfraRequestResponse"> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException" message="tns:MsoRequestsDbException"> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="initResourceOperationStatus"> + <wsdl:input name="initResourceOperationStatus" message="tns:initResourceOperationStatus"> + </wsdl:input> + <wsdl:output name="initResourceOperationStatusResponse" message="tns:initResourceOperationStatusResponse"> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException" message="tns:MsoRequestsDbException"> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="updateServiceOperationStatus"> + <wsdl:input name="updateServiceOperationStatus" message="tns:updateServiceOperationStatus"> + </wsdl:input> + <wsdl:output name="updateServiceOperationStatusResponse" message="tns:updateServiceOperationStatusResponse"> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException" message="tns:MsoRequestsDbException"> + </wsdl:fault> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="RequestsDbAdapterSoapBinding" type="tns:RequestsDbAdapter"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getInfraRequest"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="getInfraRequest"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getInfraRequestResponse"> + <soap:body use="literal"/> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException"> + <soap:fault name="MsoRequestsDbException" use="literal"/> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="getSiteStatus"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="getSiteStatus"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getSiteStatusResponse"> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="updateInfraRequest"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="updateInfraRequest"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="updateInfraRequestResponse"> + <soap:body use="literal"/> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException"> + <soap:fault name="MsoRequestsDbException" use="literal"/> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="initResourceOperationStatus"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="initResourceOperationStatus"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="initResourceOperationStatusResponse"> + <soap:body use="literal"/> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException"> + <soap:fault name="MsoRequestsDbException" use="literal"/> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="updateServiceOperationStatus"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="updateServiceOperationStatus"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="updateServiceOperationStatusResponse"> + <soap:body use="literal"/> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException"> + <soap:fault name="MsoRequestsDbException" use="literal"/> + </wsdl:fault> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="RequestsDbAdapter"> + <wsdl:port name="MsoRequestsDbAdapterImplPort" binding="tns:RequestsDbAdapterSoapBinding"> + <soap:address location="http://localhost:9090/MsoRequestsDbAdapterImplPort"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> |