aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-requests-db-adapter
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-requests-db-adapter')
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java227
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java26
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java138
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java607
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/RequestStatusType.java20
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ResponseStatus.java6
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java31
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java71
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java48
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/RequestDBConfig.java53
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java2
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java26
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java24
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java93
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java6
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java82
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java113
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java73
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java829
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/EmbeddedMariaDbConfig.java66
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/TestAppender.java12
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java1
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java98
23 files changed, 1284 insertions, 1368 deletions
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
index 09e8cf1d32..02b44efe1c 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
@@ -27,7 +27,6 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
-
import org.onap.so.db.request.beans.ArchivedInfraRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository;
@@ -41,122 +40,120 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
-
import net.javacrumbs.shedlock.core.SchedulerLock;
@Component
public class ArchiveInfraRequestsScheduler {
-
- private static Logger logger = LoggerFactory.getLogger(ArchiveInfraRequestsScheduler.class);
-
- @Autowired
- private InfraActiveRequestsRepository infraActiveRepo;
- @Autowired
- private ArchivedInfraRequestsRepository archivedInfraRepo;
-
- @Value("${mso.infra-requests.archived.period}")
- private int archivedPeriod;
-
- /**
- * Runs the scheduler nightly
- * [Seconds] [Minutes] [Hours] [Day of month] [Month] [Day of week] [Year]
- */
- @Scheduled(cron="0 0 1 * * ?")
- @SchedulerLock(name = "archiveInfraRequestsScheduler")
- public void infraRequestsScheduledTask() {
- logger.debug("Start of archiveInfraRequestsScheduler");
-
- Date currentDate= new Date();
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(currentDate);
- calendar.add(Calendar.DATE, -archivedPeriod);
- Date archivingDate = calendar.getTime();
-
- logger.debug("Date before 6 months: "+ (calendar.get(Calendar.MONTH) + 1) + "-"
- + calendar.get(Calendar.DATE) + "-" + calendar.get(Calendar.YEAR));
-
- List<InfraActiveRequests> requestsByEndTime = new ArrayList<>();
- PageRequest pageRequest = new PageRequest(0, 100);
- do {
- requestsByEndTime = infraActiveRepo.findByEndTimeLessThan(archivingDate, pageRequest);
- logger.debug("{} requests to be archived based on End Time", requestsByEndTime.size());
- archiveInfraRequests(requestsByEndTime);
- } while(!requestsByEndTime.isEmpty());
-
- List<InfraActiveRequests> requestsByStartTime = new ArrayList<>();
- do {
- requestsByStartTime = infraActiveRepo.findByStartTimeLessThanAndEndTime(archivingDate, null, pageRequest);
- logger.debug("{} requests to be archived based on Start Time", requestsByEndTime.size());
- archiveInfraRequests(requestsByStartTime);
- } while(!requestsByStartTime.isEmpty());
-
- logger.debug("End of archiveInfraRequestsScheduler");
- }
-
- protected void archiveInfraRequests(List<InfraActiveRequests> requests) {
- List<ArchivedInfraRequests> newArchivedReqs = new ArrayList<>();
- List<InfraActiveRequests> oldInfraReqs = new ArrayList<>();
-
- for(InfraActiveRequests iar: requests) {
- ArchivedInfraRequests archivedInfra = new ArchivedInfraRequests();
- try {
- archivedInfra.setAaiServiceId(iar.getAaiServiceId());
- archivedInfra.setAction(iar.getAction());
- archivedInfra.setAicCloudRegion(iar.getAicCloudRegion());
- archivedInfra.setAicNodeClli(iar.getAicNodeClli());
- archivedInfra.setCallBackUrl(iar.getCallBackUrl());
- archivedInfra.setClientRequestId(iar.getClientRequestId());
- archivedInfra.setConfigurationId(iar.getConfigurationId());
- archivedInfra.setConfigurationName(iar.getConfigurationName());
- archivedInfra.setCorrelator(iar.getCorrelator());
- archivedInfra.setEndTime(iar.getEndTime());
- archivedInfra.setLastModifiedBy(iar.getLastModifiedBy());
- archivedInfra.setNetworkId(iar.getNetworkId());
- archivedInfra.setNetworkName(iar.getNetworkName());
- archivedInfra.setNetworkType(iar.getNetworkType());
- archivedInfra.setOperationalEnvId(iar.getOperationalEnvId());
- archivedInfra.setOperationalEnvName(iar.getOperationalEnvName());
- archivedInfra.setRequestUrl(iar.getRequestUrl());
- archivedInfra.setProgress(iar.getProgress());
- archivedInfra.setProvStatus(iar.getProvStatus());
- archivedInfra.setRequestAction(iar.getRequestAction());
- archivedInfra.setRequestBody(iar.getRequestBody());
- archivedInfra.setRequestId(iar.getRequestId());
- archivedInfra.setRequestorId(iar.getRequestorId());
- archivedInfra.setRequestScope(iar.getRequestScope());
- archivedInfra.setRequestStatus(iar.getRequestStatus());
- archivedInfra.setRequestType(iar.getRequestType());
- archivedInfra.setResponseBody(iar.getResponseBody());
- archivedInfra.setServiceInstanceId(iar.getServiceInstanceId());
- archivedInfra.setServiceInstanceName(iar.getServiceInstanceName());
- archivedInfra.setServiceType(iar.getServiceType());
- archivedInfra.setSource(iar.getSource());
- archivedInfra.setStartTime(iar.getStartTime());
- archivedInfra.setStatusMessage(iar.getStatusMessage());
- archivedInfra.setTenantId(iar.getTenantId());
- archivedInfra.setVfModuleId(iar.getVfModuleId());
- archivedInfra.setVfModuleModelName(iar.getVfModuleModelName());
- archivedInfra.setVfModuleName(iar.getVfModuleName());
- archivedInfra.setVnfId(iar.getVnfId());
- archivedInfra.setVnfName(iar.getVnfName());
- archivedInfra.setVnfOutputs(iar.getVnfOutputs());
- archivedInfra.setVnfParams(iar.getVnfParams());
- archivedInfra.setVnfType(iar.getVnfType());
- archivedInfra.setVolumeGroupId(iar.getVolumeGroupId());
- archivedInfra.setVolumeGroupName(iar.getVolumeGroupName());
-
- newArchivedReqs.add(archivedInfra);
- oldInfraReqs.add(iar);
- } catch(Exception e) {
- logger.error("{} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), ErrorCode
- .UnknownError.getValue(), e);
- }
- }
-
- logger.info("Creating archivedInfraRequest records: {}", newArchivedReqs.size());
- archivedInfraRepo.saveAll(newArchivedReqs);
-
- logger.info("Deleting InfraActiveRequest records: {}", oldInfraReqs.size());
- infraActiveRepo.deleteAll(oldInfraReqs);
- }
+
+ private static Logger logger = LoggerFactory.getLogger(ArchiveInfraRequestsScheduler.class);
+
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRepo;
+ @Autowired
+ private ArchivedInfraRequestsRepository archivedInfraRepo;
+
+ @Value("${mso.infra-requests.archived.period}")
+ private int archivedPeriod;
+
+ /**
+ * Runs the scheduler nightly [Seconds] [Minutes] [Hours] [Day of month] [Month] [Day of week] [Year]
+ */
+ @Scheduled(cron = "0 0 1 * * ?")
+ @SchedulerLock(name = "archiveInfraRequestsScheduler")
+ public void infraRequestsScheduledTask() {
+ logger.debug("Start of archiveInfraRequestsScheduler");
+
+ Date currentDate = new Date();
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(currentDate);
+ calendar.add(Calendar.DATE, -archivedPeriod);
+ Date archivingDate = calendar.getTime();
+
+ logger.debug("Date before 6 months: " + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.DATE)
+ + "-" + calendar.get(Calendar.YEAR));
+
+ List<InfraActiveRequests> requestsByEndTime = new ArrayList<>();
+ PageRequest pageRequest = new PageRequest(0, 100);
+ do {
+ requestsByEndTime = infraActiveRepo.findByEndTimeLessThan(archivingDate, pageRequest);
+ logger.debug("{} requests to be archived based on End Time", requestsByEndTime.size());
+ archiveInfraRequests(requestsByEndTime);
+ } while (!requestsByEndTime.isEmpty());
+
+ List<InfraActiveRequests> requestsByStartTime = new ArrayList<>();
+ do {
+ requestsByStartTime = infraActiveRepo.findByStartTimeLessThanAndEndTime(archivingDate, null, pageRequest);
+ logger.debug("{} requests to be archived based on Start Time", requestsByEndTime.size());
+ archiveInfraRequests(requestsByStartTime);
+ } while (!requestsByStartTime.isEmpty());
+
+ logger.debug("End of archiveInfraRequestsScheduler");
+ }
+
+ protected void archiveInfraRequests(List<InfraActiveRequests> requests) {
+ List<ArchivedInfraRequests> newArchivedReqs = new ArrayList<>();
+ List<InfraActiveRequests> oldInfraReqs = new ArrayList<>();
+
+ for (InfraActiveRequests iar : requests) {
+ ArchivedInfraRequests archivedInfra = new ArchivedInfraRequests();
+ try {
+ archivedInfra.setAaiServiceId(iar.getAaiServiceId());
+ archivedInfra.setAction(iar.getAction());
+ archivedInfra.setAicCloudRegion(iar.getAicCloudRegion());
+ archivedInfra.setAicNodeClli(iar.getAicNodeClli());
+ archivedInfra.setCallBackUrl(iar.getCallBackUrl());
+ archivedInfra.setClientRequestId(iar.getClientRequestId());
+ archivedInfra.setConfigurationId(iar.getConfigurationId());
+ archivedInfra.setConfigurationName(iar.getConfigurationName());
+ archivedInfra.setCorrelator(iar.getCorrelator());
+ archivedInfra.setEndTime(iar.getEndTime());
+ archivedInfra.setLastModifiedBy(iar.getLastModifiedBy());
+ archivedInfra.setNetworkId(iar.getNetworkId());
+ archivedInfra.setNetworkName(iar.getNetworkName());
+ archivedInfra.setNetworkType(iar.getNetworkType());
+ archivedInfra.setOperationalEnvId(iar.getOperationalEnvId());
+ archivedInfra.setOperationalEnvName(iar.getOperationalEnvName());
+ archivedInfra.setRequestUrl(iar.getRequestUrl());
+ archivedInfra.setProgress(iar.getProgress());
+ archivedInfra.setProvStatus(iar.getProvStatus());
+ archivedInfra.setRequestAction(iar.getRequestAction());
+ archivedInfra.setRequestBody(iar.getRequestBody());
+ archivedInfra.setRequestId(iar.getRequestId());
+ archivedInfra.setRequestorId(iar.getRequestorId());
+ archivedInfra.setRequestScope(iar.getRequestScope());
+ archivedInfra.setRequestStatus(iar.getRequestStatus());
+ archivedInfra.setRequestType(iar.getRequestType());
+ archivedInfra.setResponseBody(iar.getResponseBody());
+ archivedInfra.setServiceInstanceId(iar.getServiceInstanceId());
+ archivedInfra.setServiceInstanceName(iar.getServiceInstanceName());
+ archivedInfra.setServiceType(iar.getServiceType());
+ archivedInfra.setSource(iar.getSource());
+ archivedInfra.setStartTime(iar.getStartTime());
+ archivedInfra.setStatusMessage(iar.getStatusMessage());
+ archivedInfra.setTenantId(iar.getTenantId());
+ archivedInfra.setVfModuleId(iar.getVfModuleId());
+ archivedInfra.setVfModuleModelName(iar.getVfModuleModelName());
+ archivedInfra.setVfModuleName(iar.getVfModuleName());
+ archivedInfra.setVnfId(iar.getVnfId());
+ archivedInfra.setVnfName(iar.getVnfName());
+ archivedInfra.setVnfOutputs(iar.getVnfOutputs());
+ archivedInfra.setVnfParams(iar.getVnfParams());
+ archivedInfra.setVnfType(iar.getVnfType());
+ archivedInfra.setVolumeGroupId(iar.getVolumeGroupId());
+ archivedInfra.setVolumeGroupName(iar.getVolumeGroupName());
+
+ newArchivedReqs.add(archivedInfra);
+ oldInfraReqs.add(iar);
+ } catch (Exception e) {
+ logger.error("{} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), ErrorCode.UnknownError.getValue(),
+ e);
+ }
+ }
+
+ logger.info("Creating archivedInfraRequest records: {}", newArchivedReqs.size());
+ archivedInfraRepo.saveAll(newArchivedReqs);
+
+ logger.info("Deleting InfraActiveRequest records: {}", oldInfraReqs.size());
+ infraActiveRepo.deleteAll(oldInfraReqs);
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java
index a476f890cc..f6a0aec86f 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java
@@ -22,7 +22,6 @@ package org.onap.so.adapters.requestsdb;
import java.util.List;
import java.util.Map;
-
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
@@ -40,26 +39,35 @@ public class InfraActiveRequestsRepositoryCustomController {
@Autowired
InfraActiveRequestsRepository infraActiveRequestsRepository;
- @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive")
- public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(@RequestBody Map<String, String> orchestrationMap) {
+ @RequestMapping(method = RequestMethod.POST,
+ value = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive")
+ public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(
+ @RequestBody Map<String, String> orchestrationMap) {
return infraActiveRequestsRepository.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap);
}
@RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive")
- public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(@RequestBody Map<String, List<String>> orchestrationMap) {
+ public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(
+ @RequestBody Map<String, List<String>> orchestrationMap) {
return infraActiveRequestsRepository.getOrchestrationFiltersFromInfraActive(orchestrationMap);
}
- @RequestMapping(method = RequestMethod.GET, value = "/infraActiveRequests/checkVnfIdStatus/{operationalEnvironmentId}")
- public InfraActiveRequests checkVnfIdStatus(@PathVariable("operationalEnvironmentId") String operationalEnvironmentId) {
+ @RequestMapping(method = RequestMethod.GET,
+ value = "/infraActiveRequests/checkVnfIdStatus/{operationalEnvironmentId}")
+ public InfraActiveRequests checkVnfIdStatus(
+ @PathVariable("operationalEnvironmentId") String operationalEnvironmentId) {
return infraActiveRequestsRepository.checkVnfIdStatus(operationalEnvironmentId);
}
@RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/checkInstanceNameDuplicate")
- public InfraActiveRequests checkInstanceNameDuplicate(@RequestBody InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest) {
- return infraActiveRequestsRepository.checkInstanceNameDuplicate(instanceNameDuplicateCheckRequest.getInstanceIdMap(), instanceNameDuplicateCheckRequest.getInstanceName(), instanceNameDuplicateCheckRequest.getRequestScope());
+ public InfraActiveRequests checkInstanceNameDuplicate(
+ @RequestBody InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest) {
+ return infraActiveRequestsRepository.checkInstanceNameDuplicate(
+ instanceNameDuplicateCheckRequest.getInstanceIdMap(),
+ instanceNameDuplicateCheckRequest.getInstanceName(),
+ instanceNameDuplicateCheckRequest.getRequestScope());
}
-
+
@RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/v1/getInfraActiveRequests")
public List<InfraActiveRequests> getInfraActiveRequests(@RequestBody Map<String, String[]> filters,
@RequestParam("from") long startTime, @RequestParam("to") long endTime,
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java
index 0c2a49ae53..f4a9f711fd 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java
@@ -24,7 +24,6 @@ import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlElement;
-
import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.ResourceOperationStatus;
@@ -35,79 +34,78 @@ import org.onap.so.db.request.beans.ResourceOperationStatus;
@WebService(name = "RequestsDbAdapter", targetNamespace = "http://org.onap.so/requestsdb")
public interface MsoRequestsDbAdapter {
- @WebMethod
- public void updateInfraRequest(@WebParam(name = "requestId") @XmlElement(required = true) String requestId,
- @WebParam(name = "lastModifiedBy") @XmlElement(required = true) String lastModifiedBy,
- @WebParam(name = "statusMessage") @XmlElement(required = false) String statusMessage,
- @WebParam(name = "responseBody") @XmlElement(required = false) String responseBody,
- @WebParam(name = "requestStatus") @XmlElement(required = false) RequestStatusType requestStatus,
- @WebParam(name = "progress") @XmlElement(required = false) String progress,
- @WebParam(name = "vnfOutputs") @XmlElement(required = false) String vnfOutputs,
- @WebParam(name = "serviceInstanceId") @XmlElement(required = false) String serviceInstanceId,
- @WebParam(name = "networkId") @XmlElement(required = false) String networkId,
- @WebParam(name = "vnfId") @XmlElement(required = false) String vnfId,
- @WebParam(name = "vfModuleId") @XmlElement(required = false) String vfModuleId,
- @WebParam(name = "volumeGroupId") @XmlElement(required = false) String volumeGroupId,
- @WebParam(name = "serviceInstanceName") @XmlElement(required = false) String serviceInstanceName,
- @WebParam(name = "configurationId") @XmlElement(required = false) String configurationId,
- @WebParam(name = "configurationName") @XmlElement(required = false) String configurationName,
- @WebParam(name = "vfModuleName") @XmlElement(required = false) String vfModuleName)
- throws MsoRequestsDbException;
+ @WebMethod
+ public void updateInfraRequest(@WebParam(name = "requestId") @XmlElement(required = true) String requestId,
+ @WebParam(name = "lastModifiedBy") @XmlElement(required = true) String lastModifiedBy,
+ @WebParam(name = "statusMessage") @XmlElement(required = false) String statusMessage,
+ @WebParam(name = "responseBody") @XmlElement(required = false) String responseBody,
+ @WebParam(name = "requestStatus") @XmlElement(required = false) RequestStatusType requestStatus,
+ @WebParam(name = "progress") @XmlElement(required = false) String progress,
+ @WebParam(name = "vnfOutputs") @XmlElement(required = false) String vnfOutputs,
+ @WebParam(name = "serviceInstanceId") @XmlElement(required = false) String serviceInstanceId,
+ @WebParam(name = "networkId") @XmlElement(required = false) String networkId,
+ @WebParam(name = "vnfId") @XmlElement(required = false) String vnfId,
+ @WebParam(name = "vfModuleId") @XmlElement(required = false) String vfModuleId,
+ @WebParam(name = "volumeGroupId") @XmlElement(required = false) String volumeGroupId,
+ @WebParam(name = "serviceInstanceName") @XmlElement(required = false) String serviceInstanceName,
+ @WebParam(name = "configurationId") @XmlElement(required = false) String configurationId,
+ @WebParam(name = "configurationName") @XmlElement(required = false) String configurationName,
+ @WebParam(name = "vfModuleName") @XmlElement(required = false) String vfModuleName)
+ throws MsoRequestsDbException;
- @WebMethod
- public InfraActiveRequests getInfraRequest(
- @WebParam(name = "requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException;
+ @WebMethod
+ public InfraActiveRequests getInfraRequest(
+ @WebParam(name = "requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException;
- @WebMethod
- public boolean getSiteStatus(@WebParam(name = "siteName") @XmlElement(required = true) String siteName);
+ @WebMethod
+ public boolean getSiteStatus(@WebParam(name = "siteName") @XmlElement(required = true) String siteName);
- @WebMethod
- public void updateServiceOperationStatus(
- @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
- @WebParam(name = "operationId") @XmlElement(required = false) String operationId,
- @WebParam(name = "operationType") @XmlElement(required = false) String operationType,
- @WebParam(name = "userId") @XmlElement(required = false) String userId,
- @WebParam(name = "result") @XmlElement(required = false) String result,
- @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent,
- @WebParam(name = "progress") @XmlElement(required = false) String progress,
- @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException;
+ @WebMethod
+ public void updateServiceOperationStatus(
+ @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
+ @WebParam(name = "operationId") @XmlElement(required = false) String operationId,
+ @WebParam(name = "operationType") @XmlElement(required = false) String operationType,
+ @WebParam(name = "userId") @XmlElement(required = false) String userId,
+ @WebParam(name = "result") @XmlElement(required = false) String result,
+ @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent,
+ @WebParam(name = "progress") @XmlElement(required = false) String progress,
+ @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException;
- @WebMethod
- public void initServiceOperationStatus(
- @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
- @WebParam(name = "operationId") @XmlElement(required = false) String operationId,
- @WebParam(name = "operationType") @XmlElement(required = false) String operationType,
- @WebParam(name = "userId") @XmlElement(required = false) String userId,
- @WebParam(name = "result") @XmlElement(required = false) String result,
- @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent,
- @WebParam(name = "progress") @XmlElement(required = false) String progress,
- @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException;
+ @WebMethod
+ public void initServiceOperationStatus(@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
+ @WebParam(name = "operationId") @XmlElement(required = false) String operationId,
+ @WebParam(name = "operationType") @XmlElement(required = false) String operationType,
+ @WebParam(name = "userId") @XmlElement(required = false) String userId,
+ @WebParam(name = "result") @XmlElement(required = false) String result,
+ @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent,
+ @WebParam(name = "progress") @XmlElement(required = false) String progress,
+ @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException;
- @WebMethod
- public void initResourceOperationStatus(@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
- @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
- @WebParam(name = "operationType") @XmlElement(required = true) String operationType,
- @WebParam(name = "resourceTemplateUUIDs") @XmlElement(required = true) String resourceTemplateUUIDs)
- throws MsoRequestsDbException;
+ @WebMethod
+ public void initResourceOperationStatus(@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
+ @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
+ @WebParam(name = "operationType") @XmlElement(required = true) String operationType,
+ @WebParam(name = "resourceTemplateUUIDs") @XmlElement(required = true) String resourceTemplateUUIDs)
+ throws MsoRequestsDbException;
- @WebMethod
- public ResourceOperationStatus getResourceOperationStatus(
- @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
- @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
- @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID)
- throws MsoRequestsDbException;
+ @WebMethod
+ public ResourceOperationStatus getResourceOperationStatus(
+ @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
+ @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
+ @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID)
+ throws MsoRequestsDbException;
- @WebMethod
- public void updateResourceOperationStatus(
- @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
- @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
- @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID,
- @WebParam(name = "operType") @XmlElement(required = false) String operType,
- @WebParam(name = "resourceInstanceID") @XmlElement(required = false) String resourceInstanceID,
- @WebParam(name = "jobId") @XmlElement(required = false) String jobId,
- @WebParam(name = "status") @XmlElement(required = false) String status,
- @WebParam(name = "progress") @XmlElement(required = false) String progress,
- @WebParam(name = "errorCode") @XmlElement(required = false) String errorCode,
- @WebParam(name = "statusDescription") @XmlElement(required = false) String statusDescription)
- throws MsoRequestsDbException;
-} \ No newline at end of file
+ @WebMethod
+ public void updateResourceOperationStatus(
+ @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
+ @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
+ @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID,
+ @WebParam(name = "operType") @XmlElement(required = false) String operType,
+ @WebParam(name = "resourceInstanceID") @XmlElement(required = false) String resourceInstanceID,
+ @WebParam(name = "jobId") @XmlElement(required = false) String jobId,
+ @WebParam(name = "status") @XmlElement(required = false) String status,
+ @WebParam(name = "progress") @XmlElement(required = false) String progress,
+ @WebParam(name = "errorCode") @XmlElement(required = false) String errorCode,
+ @WebParam(name = "statusDescription") @XmlElement(required = false) String statusDescription)
+ throws MsoRequestsDbException;
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
index e3867d1b93..9d6a8b0529 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -25,7 +25,6 @@ package org.onap.so.adapters.requestsdb;
import java.sql.Timestamp;
import java.util.List;
-
import javax.jws.WebService;
import javax.transaction.Transactional;
import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
@@ -46,324 +45,321 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
-@WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://org.onap.so/requestsdb")
+@WebService(serviceName = "RequestsDbAdapter",
+ endpointInterface = "org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter",
+ targetNamespace = "http://org.onap.so/requestsdb")
@Component
@Primary
-public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
+public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
- private static Logger logger = LoggerFactory.getLogger(MsoRequestsDbAdapterImpl.class);
-
- @Autowired
- private InfraActiveRequestsRepository infraActive;
+ private static Logger logger = LoggerFactory.getLogger(MsoRequestsDbAdapterImpl.class);
- @Autowired
- private SiteStatusRepository siteRepo;
+ @Autowired
+ private InfraActiveRequestsRepository infraActive;
- @Autowired
- private OperationStatusRepository operationStatusRepository;
+ @Autowired
+ private SiteStatusRepository siteRepo;
- @Autowired
- private ResourceOperationStatusRepository resourceOperationStatusRepository;
+ @Autowired
+ private OperationStatusRepository operationStatusRepository;
- @Transactional
- @Override
- public void updateInfraRequest(String requestId, String lastModifiedBy, String statusMessage, String responseBody,
- RequestStatusType requestStatus, String progress, String vnfOutputs, String serviceInstanceId,
- String networkId, String vnfId, String vfModuleId, String volumeGroupId, String serviceInstanceName,
- String configurationId, String configurationName, String vfModuleName) throws MsoRequestsDbException {
- try {
- InfraActiveRequests request = infraActive.findOneByRequestIdOrClientRequestId(requestId, requestId);
- if (request == null) {
- String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId;
- throw new MsoRequestsDbException(error);
- }
- if (statusMessage != null) {
- request.setStatusMessage(statusMessage);
- }
- if (responseBody != null) {
- request.setResponseBody(responseBody);
- }
- if (requestStatus != null) {
- request.setRequestStatus(requestStatus.toString());
- }
- if (progress != null) {
- setProgress(progress, request);
- }
- if (vnfOutputs != null) {
- request.setVnfOutputs(vnfOutputs);
- }
- if (serviceInstanceId != null) {
- request.setServiceInstanceId(serviceInstanceId);
- }
- if (networkId != null) {
- request.setNetworkId(networkId);
- }
- if (vnfId != null) {
- request.setVnfId(vnfId);
- }
- if (vfModuleId != null) {
- request.setVfModuleId(vfModuleId);
- }
- if (volumeGroupId != null) {
- request.setVolumeGroupId(volumeGroupId);
- }
- if (serviceInstanceName != null) {
- request.setServiceInstanceName(serviceInstanceName);
- }
- if (vfModuleName != null) {
- request.setVfModuleName(vfModuleName);
- }
- if (configurationId != null) {
- request.setConfigurationId(configurationId);
- }
- if (configurationName != null) {
- request.setConfigurationName(configurationName);
- }
- if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) {
- Timestamp nowTimeStamp = new Timestamp(System.currentTimeMillis());
- request.setEndTime(nowTimeStamp);
- }
- request.setLastModifiedBy(lastModifiedBy);
- infraActive.save(request);
- } catch (Exception e) {
- String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId;
- logger.error(error, e);
- throw new MsoRequestsDbException(error, ErrorCode.BusinessProcesssError, e);
- }
- }
+ @Autowired
+ private ResourceOperationStatusRepository resourceOperationStatusRepository;
- private void setProgress(String progress, InfraActiveRequests request) {
- try {
- request.setProgress(Long.parseLong(progress));
- } catch (NumberFormatException e) {
- logger.warn("UpdateInfraRequest", "Invalid value sent for progress");
- }
- }
+ @Transactional
+ @Override
+ public void updateInfraRequest(String requestId, String lastModifiedBy, String statusMessage, String responseBody,
+ RequestStatusType requestStatus, String progress, String vnfOutputs, String serviceInstanceId,
+ String networkId, String vnfId, String vfModuleId, String volumeGroupId, String serviceInstanceName,
+ String configurationId, String configurationName, String vfModuleName) throws MsoRequestsDbException {
+ try {
+ InfraActiveRequests request = infraActive.findOneByRequestIdOrClientRequestId(requestId, requestId);
+ if (request == null) {
+ String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId;
+ throw new MsoRequestsDbException(error);
+ }
+ if (statusMessage != null) {
+ request.setStatusMessage(statusMessage);
+ }
+ if (responseBody != null) {
+ request.setResponseBody(responseBody);
+ }
+ if (requestStatus != null) {
+ request.setRequestStatus(requestStatus.toString());
+ }
+ if (progress != null) {
+ setProgress(progress, request);
+ }
+ if (vnfOutputs != null) {
+ request.setVnfOutputs(vnfOutputs);
+ }
+ if (serviceInstanceId != null) {
+ request.setServiceInstanceId(serviceInstanceId);
+ }
+ if (networkId != null) {
+ request.setNetworkId(networkId);
+ }
+ if (vnfId != null) {
+ request.setVnfId(vnfId);
+ }
+ if (vfModuleId != null) {
+ request.setVfModuleId(vfModuleId);
+ }
+ if (volumeGroupId != null) {
+ request.setVolumeGroupId(volumeGroupId);
+ }
+ if (serviceInstanceName != null) {
+ request.setServiceInstanceName(serviceInstanceName);
+ }
+ if (vfModuleName != null) {
+ request.setVfModuleName(vfModuleName);
+ }
+ if (configurationId != null) {
+ request.setConfigurationId(configurationId);
+ }
+ if (configurationName != null) {
+ request.setConfigurationName(configurationName);
+ }
+ if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) {
+ Timestamp nowTimeStamp = new Timestamp(System.currentTimeMillis());
+ request.setEndTime(nowTimeStamp);
+ }
+ request.setLastModifiedBy(lastModifiedBy);
+ infraActive.save(request);
+ } catch (Exception e) {
+ String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId;
+ logger.error(error, e);
+ throw new MsoRequestsDbException(error, ErrorCode.BusinessProcesssError, e);
+ }
+ }
- @Override
- @Transactional
- public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException {
- logger.debug("Call to MSO Infra RequestsDb adapter get method with request Id: {}", requestId);
- InfraActiveRequests request = null;
- try {
- request = infraActive.findOneByRequestIdOrClientRequestId(requestId, requestId);
- if (request == null) {
- String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId;
- throw new MsoRequestsDbException(error);
- }
- } catch (Exception e) {
- String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId;
- logger.error(error,e);
- throw new MsoRequestsDbException(error, ErrorCode.BusinessProcesssError , e);
- }
- return request;
- }
+ private void setProgress(String progress, InfraActiveRequests request) {
+ try {
+ request.setProgress(Long.parseLong(progress));
+ } catch (NumberFormatException e) {
+ logger.warn("UpdateInfraRequest", "Invalid value sent for progress");
+ }
+ }
- /**
- * Get SiteStatus by SiteName.
- *
- * @param siteName
- * The unique name of the site
- * @return Status of that site
- */
- @Override
- @Transactional
- public boolean getSiteStatus(String siteName) {
- SiteStatus siteStatus;
- logger.debug("Request database - get Site Status with Site name: {}", siteName);
- siteStatus = siteRepo.findOneBySiteName(siteName);
- if (siteStatus == null) {
- // if not exist in DB, it means the site is not disabled, thus
- // return true
- return true;
- } else {
- return siteStatus.getStatus();
- }
- }
+ @Override
+ @Transactional
+ public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException {
+ logger.debug("Call to MSO Infra RequestsDb adapter get method with request Id: {}", requestId);
+ InfraActiveRequests request = null;
+ try {
+ request = infraActive.findOneByRequestIdOrClientRequestId(requestId, requestId);
+ if (request == null) {
+ String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId;
+ throw new MsoRequestsDbException(error);
+ }
+ } catch (Exception e) {
+ String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId;
+ logger.error(error, e);
+ throw new MsoRequestsDbException(error, ErrorCode.BusinessProcesssError, e);
+ }
+ return request;
+ }
- /**
- * update operation status <br>
- *
- * @param serviceId
- * @param operationId
- * @param operationType
- * @param userId
- * @param result
- * @param operationContent
- * @param progress
- * @param reason
- * @throws MsoRequestsDbException
- * @since ONAP Amsterdam Release
- */
- @Override
- @Transactional
- public void updateServiceOperationStatus(String serviceId, String operationId, String operationType, String userId,
- String result, String operationContent, String progress, String reason) throws MsoRequestsDbException {
- OperationStatus operStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId);
- if (operStatus == null) {
- String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: "
- + operationId;
- logger.error(error);
- operStatus = new OperationStatus();
- operStatus.setOperationId(operationId);
- operStatus.setServiceId(serviceId);
- }
+ /**
+ * Get SiteStatus by SiteName.
+ *
+ * @param siteName The unique name of the site
+ * @return Status of that site
+ */
+ @Override
+ @Transactional
+ public boolean getSiteStatus(String siteName) {
+ SiteStatus siteStatus;
+ logger.debug("Request database - get Site Status with Site name: {}", siteName);
+ siteStatus = siteRepo.findOneBySiteName(siteName);
+ if (siteStatus == null) {
+ // if not exist in DB, it means the site is not disabled, thus
+ // return true
+ return true;
+ } else {
+ return siteStatus.getStatus();
+ }
+ }
- operStatus.setUserId(userId);
- operStatus.setOperation(operationType);
- operStatus.setReason(reason);
- operStatus.setProgress(progress);
- operStatus.setResult(result);
- operStatus.setOperationContent(operationContent);
- operStatus.setResult(result);
- operationStatusRepository.save(operStatus);
- }
+ /**
+ * update operation status <br>
+ *
+ * @param serviceId
+ * @param operationId
+ * @param operationType
+ * @param userId
+ * @param result
+ * @param operationContent
+ * @param progress
+ * @param reason
+ * @throws MsoRequestsDbException
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ @Transactional
+ public void updateServiceOperationStatus(String serviceId, String operationId, String operationType, String userId,
+ String result, String operationContent, String progress, String reason) throws MsoRequestsDbException {
+ OperationStatus operStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId);
+ if (operStatus == null) {
+ String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId
+ + " operationId: " + operationId;
+ logger.error(error);
+ operStatus = new OperationStatus();
+ operStatus.setOperationId(operationId);
+ operStatus.setServiceId(serviceId);
+ }
- /**
- * Init operation status <br>
- *
- * @param serviceId
- * @param operationId
- * @param operationType
- * @param userId
- * @param result
- * @param operationContent
- * @param progress
- * @param reason
- * @throws MsoRequestsDbException
- * @since ONAP Casablanca Release
- */
- @Override
- @Transactional
- public void initServiceOperationStatus(String serviceId, String operationId, String operationType, String userId,
- String result, String operationContent, String progress, String reason) throws MsoRequestsDbException {
- OperationStatus operStatus = new OperationStatus();
+ operStatus.setUserId(userId);
+ operStatus.setOperation(operationType);
+ operStatus.setReason(reason);
+ operStatus.setProgress(progress);
+ operStatus.setResult(result);
+ operStatus.setOperationContent(operationContent);
+ operStatus.setResult(result);
+ operationStatusRepository.save(operStatus);
+ }
+
+ /**
+ * Init operation status <br>
+ *
+ * @param serviceId
+ * @param operationId
+ * @param operationType
+ * @param userId
+ * @param result
+ * @param operationContent
+ * @param progress
+ * @param reason
+ * @throws MsoRequestsDbException
+ * @since ONAP Casablanca Release
+ */
+ @Override
+ @Transactional
+ public void initServiceOperationStatus(String serviceId, String operationId, String operationType, String userId,
+ String result, String operationContent, String progress, String reason) throws MsoRequestsDbException {
+ OperationStatus operStatus = new OperationStatus();
+
+ operStatus.setOperationId(operationId);
+ operStatus.setServiceId(serviceId);
+ operStatus.setUserId(userId);
+ operStatus.setOperation(operationType);
+ operStatus.setReason(reason);
+ operStatus.setProgress(progress);
+ operStatus.setResult(result);
+ operStatus.setOperationContent(operationContent);
+ operStatus.setResult(result);
+ operationStatusRepository.save(operStatus);
+ }
+
+ /**
+ * init the operation status of all the resources <br>
+ *
+ * @param serviceId the service Id
+ * @param operationId the operation Id
+ * @param operationType the operationType
+ * @param resourceTemplateUUIDs the resources, the UUID is split by ":"
+ * @throws MsoRequestsDbException
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ @Transactional
+ public void initResourceOperationStatus(String serviceId, String operationId, String operationType,
+ String resourceTemplateUUIDs) throws MsoRequestsDbException {
+ String[] resourceLst = resourceTemplateUUIDs.split(":");
+ for (String resource : resourceLst) {
+ if ("".equals(resource)) {
+ continue;
+ }
+ ResourceOperationStatus resourceStatus = new ResourceOperationStatus();
+ resourceStatus.setOperationId(operationId);
+ resourceStatus.setServiceId(serviceId);
+ resourceStatus.setResourceTemplateUUID(resource);
+ resourceStatus.setOperType(operationType);
+ resourceStatus.setStatus(RequestsDbConstant.Status.PROCESSING);
+ resourceStatus.setStatusDescription("Waiting for start");
+ resourceOperationStatusRepository.save(resourceStatus);
- operStatus.setOperationId(operationId);
- operStatus.setServiceId(serviceId);
- operStatus.setUserId(userId);
- operStatus.setOperation(operationType);
- operStatus.setReason(reason);
- operStatus.setProgress(progress);
- operStatus.setResult(result);
- operStatus.setOperationContent(operationContent);
- operStatus.setResult(result);
- operationStatusRepository.save(operStatus);
- }
+ }
+ }
+
+ /**
+ * get resource operation status <br>
+ *
+ * @param serviceId
+ * @param operationId
+ * @param resourceTemplateUUID
+ * @return
+ * @throws MsoRequestsDbException
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId,
+ String resourceTemplateUUID) throws MsoRequestsDbException {
- /**
- * init the operation status of all the resources <br>
- *
- * @param serviceId
- * the service Id
- * @param operationId
- * the operation Id
- * @param operationType
- * the operationType
- * @param resourceTemplateUUIDs
- * the resources, the UUID is split by ":"
- * @throws MsoRequestsDbException
- * @since ONAP Amsterdam Release
- */
- @Override
- @Transactional
- public void initResourceOperationStatus(String serviceId, String operationId, String operationType,
- String resourceTemplateUUIDs) throws MsoRequestsDbException {
- String[] resourceLst = resourceTemplateUUIDs.split(":");
- for (String resource : resourceLst) {
- if ("".equals(resource)) {
- continue;
- }
- ResourceOperationStatus resourceStatus = new ResourceOperationStatus();
- resourceStatus.setOperationId(operationId);
- resourceStatus.setServiceId(serviceId);
- resourceStatus.setResourceTemplateUUID(resource);
- resourceStatus.setOperType(operationType);
- resourceStatus.setStatus(RequestsDbConstant.Status.PROCESSING);
- resourceStatus.setStatusDescription("Waiting for start");
- resourceOperationStatusRepository.save(resourceStatus);
+ return resourceOperationStatusRepository
+ .findById(new ResourceOperationStatusId(serviceId, operationId, resourceTemplateUUID))
+ .orElseThrow(() -> new MsoRequestsDbException("Operation not found:" + operationId));
- }
- }
+ }
- /**
- * get resource operation status <br>
- *
- * @param serviceId
- * @param operationId
- * @param resourceTemplateUUID
- * @return
- * @throws MsoRequestsDbException
- * @since ONAP Amsterdam Release
- */
- @Override
- public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId,
- String resourceTemplateUUID) throws MsoRequestsDbException {
+ /**
+ * update resource operation status <br>
+ *
+ * @param serviceId
+ * @param operationId
+ * @param resourceTemplateUUID
+ * @param operationType
+ * @param resourceInstanceID
+ * @param jobId
+ * @param status
+ * @param progress
+ * @param errorCode
+ * @param statusDescription
+ * @throws MsoRequestsDbException
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ public void updateResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID,
+ String operationType, String resourceInstanceID, String jobId, String status, String progress,
+ String errorCode, String statusDescription) throws MsoRequestsDbException {
+ ResourceOperationStatus resStatus = new ResourceOperationStatus();
+ resStatus.setServiceId(serviceId);
+ resStatus.setOperationId(operationId);
+ resStatus.setResourceTemplateUUID(resourceTemplateUUID);
+ resStatus.setOperType(operationType);
+ resStatus.setResourceInstanceID(resourceInstanceID);
+ resStatus.setJobId(jobId);
+ resStatus.setStatus(status);
+ resStatus.setProgress(progress);
+ resStatus.setErrorCode(errorCode);
+ resStatus.setStatusDescription(statusDescription);
+ resourceOperationStatusRepository.save(resStatus);
- return resourceOperationStatusRepository
- .findById(new ResourceOperationStatusId(serviceId, operationId, resourceTemplateUUID)).
- orElseThrow( () -> new MsoRequestsDbException("Operation not found:" + operationId));
-
- }
+ updateOperationStatusBasedOnResourceStatus(resStatus);
+ }
- /**
- * update resource operation status <br>
- *
- * @param serviceId
- * @param operationId
- * @param resourceTemplateUUID
- * @param operationType
- * @param resourceInstanceID
- * @param jobId
- * @param status
- * @param progress
- * @param errorCode
- * @param statusDescription
- * @throws MsoRequestsDbException
- * @since ONAP Amsterdam Release
- */
- @Override
- public void updateResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID,
- String operationType, String resourceInstanceID, String jobId, String status, String progress,
- String errorCode, String statusDescription) throws MsoRequestsDbException {
- ResourceOperationStatus resStatus = new ResourceOperationStatus();
- resStatus.setServiceId(serviceId);
- resStatus.setOperationId(operationId);
- resStatus.setResourceTemplateUUID(resourceTemplateUUID);
- resStatus.setOperType(operationType);
- resStatus.setResourceInstanceID(resourceInstanceID);
- resStatus.setJobId(jobId);
- resStatus.setStatus(status);
- resStatus.setProgress(progress);
- resStatus.setErrorCode(errorCode);
- resStatus.setStatusDescription(statusDescription);
- resourceOperationStatusRepository.save(resStatus);
-
- updateOperationStatusBasedOnResourceStatus(resStatus);
- }
-
/**
- * update service operation status when a operation resource status updated
- * <br>
+ * update service operation status when a operation resource status updated <br>
*
* @param operStatus the resource operation status
* @since ONAP Amsterdam Release
*/
private void updateOperationStatusBasedOnResourceStatus(ResourceOperationStatus operStatus) {
- String serviceId = operStatus.getServiceId();
+ String serviceId = operStatus.getServiceId();
String operationId = operStatus.getOperationId();
logger.debug("Request database - update Operation Status Based On Resource Operation Status with service Id: "
- + "{}, operationId: {}", serviceId, operationId);
-
- List<ResourceOperationStatus> lstResourceStatus = resourceOperationStatusRepository.findByServiceIdAndOperationId(serviceId, operationId);
- if (lstResourceStatus == null) {
- logger.error("Unable to retrieve resourceOperStatus Object by ServiceId: {} operationId: {}", serviceId,
- operationId);
- return;
- }
-
- // count the total progress
+ + "{}, operationId: {}", serviceId, operationId);
+
+ List<ResourceOperationStatus> lstResourceStatus =
+ resourceOperationStatusRepository.findByServiceIdAndOperationId(serviceId, operationId);
+ if (lstResourceStatus == null) {
+ logger.error("Unable to retrieve resourceOperStatus Object by ServiceId: {} operationId: {}", serviceId,
+ operationId);
+ return;
+ }
+
+ // count the total progress
int resourceCount = lstResourceStatus.size();
int progress = 0;
boolean isFinished = true;
@@ -373,26 +369,27 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
isFinished = false;
}
}
-
- OperationStatus serviceOperStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId);
- if (serviceOperStatus == null) {
- String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: "
- + operationId;
- logger.error(error);
-
- serviceOperStatus = new OperationStatus();
- serviceOperStatus.setOperationId(operationId);
- serviceOperStatus.setServiceId(serviceId);
- }
-
+
+ OperationStatus serviceOperStatus =
+ operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId);
+ if (serviceOperStatus == null) {
+ String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId
+ + " operationId: " + operationId;
+ logger.error(error);
+
+ serviceOperStatus = new OperationStatus();
+ serviceOperStatus.setOperationId(operationId);
+ serviceOperStatus.setServiceId(serviceId);
+ }
+
progress = progress > 100 ? 100 : progress;
serviceOperStatus.setProgress(String.valueOf(progress));
serviceOperStatus.setOperationContent(operStatus.getStatusDescription());
// if current resource failed. service failed.
- if(RequestsDbConstant.Status.ERROR.equals(operStatus.getStatus())) {
+ if (RequestsDbConstant.Status.ERROR.equals(operStatus.getStatus())) {
serviceOperStatus.setResult(RequestsDbConstant.Status.ERROR);
serviceOperStatus.setReason(operStatus.getStatusDescription());
- } else if(isFinished) {
+ } else if (isFinished) {
// if finished
serviceOperStatus.setResult(RequestsDbConstant.Status.FINISHED);
serviceOperStatus.setProgress(RequestsDbConstant.Progress.ONE_HUNDRED);
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/RequestStatusType.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/RequestStatusType.java
index 1d5b892ade..9c6bcf20e7 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/RequestStatusType.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/RequestStatusType.java
@@ -19,10 +19,10 @@
*/
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.07.24 at 11:49:17 AM EDT
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.07.24 at 11:49:17 AM EDT
//
@@ -35,10 +35,13 @@ import javax.xml.bind.annotation.XmlType;
/**
- * <p>Java class for request-status-type.
+ * <p>
+ * Java class for request-status-type.
*
- * <p>The following schema fragment specifies the expected content contained within this class.
* <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ *
* <pre>
* &lt;simpleType name="request-status-type">
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
@@ -54,10 +57,7 @@ import javax.xml.bind.annotation.XmlType;
@XmlEnum
public enum RequestStatusType {
- COMPLETE,
- FAILED,
- IN_PROGRESS,
- PENDING_MANUAL_TASK;
+ COMPLETE, FAILED, IN_PROGRESS, PENDING_MANUAL_TASK;
public String value() {
return name();
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ResponseStatus.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ResponseStatus.java
index 5ee7119f35..5ce2a729ec 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ResponseStatus.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ResponseStatus.java
@@ -22,7 +22,7 @@ package org.onap.so.adapters.requestsdb;
/*
* Enum for Status values returned by API Handler to Tail-F
-*/
+ */
public enum ResponseStatus {
- SENDING_FINAL_NOTIFY, SUCCESS, FAILED, TIMEOUT
-} \ No newline at end of file
+ SENDING_FINAL_NOTIFY, SUCCESS, FAILED, TIMEOUT
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java
index 9f52160c8e..a2c1f135c2 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java
@@ -30,22 +30,19 @@ import org.springframework.util.StringUtils;
@EnableWebSecurity
public class WebSecurityConfigImpl extends WebSecurityConfig {
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.csrf().disable()
- .authorizeRequests()
- .antMatchers("/manage/health","/manage/info").permitAll()
- .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString())
- .and()
- .httpBasic();
- }
-
- @Override
- public void configure(WebSecurity web) throws Exception {
- super.configure(web);
- StrictHttpFirewall firewall = new MSOSpringFirewall();
- web.httpFirewall(firewall);
- }
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
+ .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",").toString())
+ .and().httpBasic();
+ }
+
+ @Override
+ public void configure(WebSecurity web) throws Exception {
+ super.configure(web);
+ StrictHttpFirewall firewall = new MSOSpringFirewall();
+ web.httpFirewall(firewall);
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java
index 23a769bc21..06d75befd9 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java
@@ -21,7 +21,6 @@
package org.onap.so.adapters.requestsdb.application;
import javax.xml.ws.Endpoint;
-
import org.apache.cxf.Bus;
import org.apache.cxf.feature.LoggingFeature;
import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
@@ -39,43 +38,43 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class CXFConfiguration {
- @Autowired
- private Bus bus;
+ @Autowired
+ private Bus bus;
+
+ @Autowired
+ private MsoRequestsDbAdapter requestDbAdapterImpl;
+
+ @Bean
+ public ServletRegistrationBean cxfServlet() {
- @Autowired
- private MsoRequestsDbAdapter requestDbAdapterImpl;
-
- @Bean
- public ServletRegistrationBean cxfServlet() {
-
- return new ServletRegistrationBean(new CXFServlet(), "/services/*");
- }
+ return new ServletRegistrationBean(new CXFServlet(), "/services/*");
+ }
- @Bean
- public Endpoint requestEndpointk() {
- EndpointImpl endpoint = new EndpointImpl(bus, requestDbAdapterImpl);
- endpoint.publish("/RequestsDbAdapter");
- LoggingFeature logFeature = new LoggingFeature();
- logFeature.setPrettyLogging(true);
- logFeature.initialize(bus);
- endpoint.getFeatures().add(logFeature);
- endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
- endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
- endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
- return endpoint;
- }
+ @Bean
+ public Endpoint requestEndpointk() {
+ EndpointImpl endpoint = new EndpointImpl(bus, requestDbAdapterImpl);
+ endpoint.publish("/RequestsDbAdapter");
+ LoggingFeature logFeature = new LoggingFeature();
+ logFeature.setPrettyLogging(true);
+ logFeature.initialize(bus);
+ endpoint.getFeatures().add(logFeature);
+ endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
+ endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
+ endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
+ return endpoint;
+ }
- @Bean
- public Swagger2Feature createSwaggerFeature() {
- Swagger2Feature swagger2Feature = new Swagger2Feature();
- swagger2Feature.setPrettyPrint(true);
- swagger2Feature.setTitle("SO Request Adapter");
- swagger2Feature.setContact("The ONAP SO team");
- swagger2Feature.setDescription("This project is the SO Orchestration Engine");
- swagger2Feature.setVersion("1.0.0");
- swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb");
- swagger2Feature.setScan(true);
- return swagger2Feature;
- }
+ @Bean
+ public Swagger2Feature createSwaggerFeature() {
+ Swagger2Feature swagger2Feature = new Swagger2Feature();
+ swagger2Feature.setPrettyPrint(true);
+ swagger2Feature.setTitle("SO Request Adapter");
+ swagger2Feature.setContact("The ONAP SO team");
+ swagger2Feature.setDescription("This project is the SO Orchestration Engine");
+ swagger2Feature.setVersion("1.0.0");
+ swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb");
+ swagger2Feature.setScan(true);
+ return swagger2Feature;
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java
index 700a371375..6dab6c188c 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java
@@ -23,13 +23,10 @@
package org.onap.so.adapters.requestsdb.application;
import java.time.Duration;
-
import javax.sql.DataSource;
-
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
-
import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider;
import net.javacrumbs.shedlock.spring.ScheduledLockConfiguration;
@@ -40,35 +37,32 @@ import net.javacrumbs.shedlock.spring.ScheduledLockConfigurationBuilder;
*
*/
-@SpringBootApplication(scanBasePackages = { "org.onap.so"})
+@SpringBootApplication(scanBasePackages = {"org.onap.so"})
public class MSORequestDBApplication {
- private static final String LOGS_DIR = "logs_dir";
+ private static final String LOGS_DIR = "logs_dir";
+
+ private static void setLogsDir() {
+ if (System.getProperty(LOGS_DIR) == null) {
+ System.getProperties().setProperty(LOGS_DIR, "./logs/reqdb/");
+ }
+ }
- private static void setLogsDir() {
- if (System.getProperty(LOGS_DIR) == null) {
- System.getProperties().setProperty(LOGS_DIR, "./logs/reqdb/");
- }
- }
+ public static void main(String... args) {
+ SpringApplication.run(MSORequestDBApplication.class, args);
+ setLogsDir();
+ }
- public static void main(String... args) {
- SpringApplication.run(MSORequestDBApplication.class, args);
- setLogsDir();
- }
+ @Bean
+ public LockProvider lockProvider(DataSource dataSource) {
+ return new JdbcTemplateLockProvider(dataSource);
+ }
- @Bean
- public LockProvider lockProvider(DataSource dataSource) {
- return new JdbcTemplateLockProvider(dataSource);
- }
-
- @Bean
- public ScheduledLockConfiguration taskScheduler(LockProvider lockProvider) {
- return ScheduledLockConfigurationBuilder
- .withLockProvider(lockProvider)
- .withPoolSize(10)
- .withDefaultLockAtMostFor(Duration.ofMinutes(10))
- .build();
- }
+ @Bean
+ public ScheduledLockConfiguration taskScheduler(LockProvider lockProvider) {
+ return ScheduledLockConfigurationBuilder.withLockProvider(lockProvider).withPoolSize(10)
+ .withDefaultLockAtMostFor(Duration.ofMinutes(10)).build();
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/RequestDBConfig.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/RequestDBConfig.java
index 99fa770974..651cce8543 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/RequestDBConfig.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/RequestDBConfig.java
@@ -23,7 +23,6 @@ package org.onap.so.adapters.requestsdb.application;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
-
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -41,40 +40,30 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Profile({"!test"})
@Configuration
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager",
- basePackages = { "org.onap.so.db.request.data.repository" }
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
public class RequestDBConfig {
- @Primary
- @Bean(name = "requestDataSource")
- @ConfigurationProperties(prefix = "spring.datasource")
- public DataSource dataSource() {
- return DataSourceBuilder.create().build();
- }
+ @Primary
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource")
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().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 = "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);
- }
+ @Primary
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java
index e932bb2cca..579afe9243 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java
@@ -36,7 +36,7 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Bean
public MappedInterceptor mappedLoggingInterceptor() {
- return new MappedInterceptor(new String[]{"/**"}, loggingInterceptor);
+ return new MappedInterceptor(new String[] {"/**"}, loggingInterceptor);
}
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
index 16a3a7d427..27580977b8 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
@@ -27,12 +27,14 @@ import org.onap.so.exceptions.MSOException;
import org.onap.so.logger.ErrorCode;
/**
- * This class simply extends Exception (without addition additional functionality)
- * to provide an identifier for RequestsDB related exceptions on create, delete, query.
+ * This class simply extends Exception (without addition additional functionality) to provide an identifier for
+ * RequestsDB related exceptions on create, delete, query.
*
*
*/
-@WebFault (name="MsoRequestsDbException", faultBean="org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://org.onap.so/requestsdb")
+@WebFault(name = "MsoRequestsDbException",
+ faultBean = "org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean",
+ targetNamespace = "http://org.onap.so/requestsdb")
public class MsoRequestsDbException extends MSOException {
private static final long serialVersionUID = 1L;
@@ -40,27 +42,27 @@ public class MsoRequestsDbException extends MSOException {
private MsoRequestsDbExceptionBean faultInfo;
- public MsoRequestsDbException (String msg) {
+ public MsoRequestsDbException(String msg) {
super(msg);
- faultInfo = new MsoRequestsDbExceptionBean (msg);
+ faultInfo = new MsoRequestsDbExceptionBean(msg);
}
- public MsoRequestsDbException (Throwable e) {
+ public MsoRequestsDbException(Throwable e) {
super(e);
- faultInfo = new MsoRequestsDbExceptionBean (e.getMessage());
+ faultInfo = new MsoRequestsDbExceptionBean(e.getMessage());
}
- public MsoRequestsDbException (String msg, Throwable e) {
- super (msg, e);
- faultInfo = new MsoRequestsDbExceptionBean (msg);
+ public MsoRequestsDbException(String msg, Throwable e) {
+ super(msg, e);
+ faultInfo = new MsoRequestsDbExceptionBean(msg);
}
public MsoRequestsDbException(String msg, ErrorCode errorCode) {
- super(msg,errorCode.getValue());
+ super(msg, errorCode.getValue());
}
public MsoRequestsDbException(String msg, ErrorCode errorCode, Throwable t) {
- super(msg,errorCode.getValue(), t);
+ super(msg, errorCode.getValue(), t);
}
public MsoRequestsDbExceptionBean getFaultInfo() {
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java
index c836a6b374..9844662b51 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java
@@ -32,19 +32,19 @@ public class MsoRequestsDbExceptionBean implements Serializable {
private String message;
- public MsoRequestsDbExceptionBean () {
- /* Empty constructor */
- }
+ public MsoRequestsDbExceptionBean() {
+ /* Empty constructor */
+ }
- public MsoRequestsDbExceptionBean (String message) {
- this.message = message;
- }
+ public MsoRequestsDbExceptionBean(String message) {
+ this.message = message;
+ }
- public String getMessage() {
- return message;
- }
+ public String getMessage() {
+ return message;
+ }
- public void setMessage(String message) {
- this.message = message;
- }
+ public void setMessage(String message) {
+ this.message = message;
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java
index 34643a428d..abc70ed6bf 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java
@@ -21,12 +21,9 @@
package org.onap.so.adapters.requestdb.rest;
import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.List;
-
import javax.transaction.Transactional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,50 +40,50 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
public class RequestProcessingDataRequestDbQueryTest {
- @Autowired
- private RequestsDbClient client;
-
- @LocalServerPort
- private int port;
-
- @Before
- public void setPort() {
- client.removePortFromEndpoint();
- client.setPortToEndpoint(Integer.toString(port));
- }
-
- @Test
- @Transactional
- public void RequestProcessingDataBySoRequestIdTest() {
- String soRequestId = "00032ab7-na18-42e5-965d-8ea592502018";
- String tag = "pincFabricConfigRequest";
- RequestProcessingData firstEntry = new RequestProcessingData();
- RequestProcessingData secondEntry = new RequestProcessingData();
- List<RequestProcessingData> expectedList = new ArrayList<>();
- firstEntry.setSoRequestId(soRequestId);
- firstEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
- firstEntry.setName("configurationId");
- firstEntry.setValue("52234bc0-d6a6-41d4-a901-79015e4877e2");
- firstEntry.setTag(tag);
- secondEntry.setSoRequestId(soRequestId);
- secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
- secondEntry.setName("requestAction");
- secondEntry.setValue("assign");
- secondEntry.setTag(tag);
- expectedList.add(firstEntry);
- expectedList.add(secondEntry);
+ @Autowired
+ private RequestsDbClient client;
+
+ @LocalServerPort
+ private int port;
+
+ @Before
+ public void setPort() {
+ client.removePortFromEndpoint();
+ client.setPortToEndpoint(Integer.toString(port));
+ }
+
+ @Test
+ @Transactional
+ public void RequestProcessingDataBySoRequestIdTest() {
+ String soRequestId = "00032ab7-na18-42e5-965d-8ea592502018";
+ String tag = "pincFabricConfigRequest";
+ RequestProcessingData firstEntry = new RequestProcessingData();
+ RequestProcessingData secondEntry = new RequestProcessingData();
+ List<RequestProcessingData> expectedList = new ArrayList<>();
+ firstEntry.setSoRequestId(soRequestId);
+ firstEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
+ firstEntry.setName("configurationId");
+ firstEntry.setValue("52234bc0-d6a6-41d4-a901-79015e4877e2");
+ firstEntry.setTag(tag);
+ secondEntry.setSoRequestId(soRequestId);
+ secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
+ secondEntry.setName("requestAction");
+ secondEntry.setValue("assign");
+ secondEntry.setTag(tag);
+ expectedList.add(firstEntry);
+ expectedList.add(secondEntry);
- List<RequestProcessingData> dataFound = client.getRequestProcessingDataBySoRequestId(soRequestId);
- //bean comparison with shazam fails serialization: Forgot to register a type adapter?
- assertEquals(dataFound.get(0).getSoRequestId(), firstEntry.getSoRequestId());
- assertEquals(dataFound.get(0).getGroupingId(), firstEntry.getGroupingId());
- assertEquals(dataFound.get(0).getName(), firstEntry.getName());
- assertEquals(dataFound.get(0).getValue(), firstEntry.getValue());
- assertEquals(dataFound.get(0).getTag(), firstEntry.getTag());
- assertEquals(dataFound.get(1).getSoRequestId(), secondEntry.getSoRequestId());
- assertEquals(dataFound.get(1).getGroupingId(), secondEntry.getGroupingId());
- assertEquals(dataFound.get(1).getName(), secondEntry.getName());
- assertEquals(dataFound.get(1).getValue(), secondEntry.getValue());
- assertEquals(dataFound.get(1).getTag(), secondEntry.getTag());
- }
+ List<RequestProcessingData> dataFound = client.getRequestProcessingDataBySoRequestId(soRequestId);
+ // bean comparison with shazam fails serialization: Forgot to register a type adapter?
+ assertEquals(dataFound.get(0).getSoRequestId(), firstEntry.getSoRequestId());
+ assertEquals(dataFound.get(0).getGroupingId(), firstEntry.getGroupingId());
+ assertEquals(dataFound.get(0).getName(), firstEntry.getName());
+ assertEquals(dataFound.get(0).getValue(), firstEntry.getValue());
+ assertEquals(dataFound.get(0).getTag(), firstEntry.getTag());
+ assertEquals(dataFound.get(1).getSoRequestId(), secondEntry.getSoRequestId());
+ assertEquals(dataFound.get(1).getGroupingId(), secondEntry.getGroupingId());
+ assertEquals(dataFound.get(1).getName(), secondEntry.getName());
+ assertEquals(dataFound.get(1).getValue(), secondEntry.getValue());
+ assertEquals(dataFound.get(1).getTag(), secondEntry.getTag());
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java
index f15a93eaeb..ac520c24e3 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java
@@ -19,14 +19,14 @@
*/
package org.onap.so.adapters.requestsdb;
-import org.junit.runner.RunWith;
+import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses("**/*Test.class")
public class AllTestsTestSuite {
- // the class remains empty,
- // used only as a holder for the above annotations
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
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
index 4b783a781c..663be24318 100644
--- 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
@@ -21,10 +21,8 @@
package org.onap.so.adapters.requestsdb;
import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository;
@@ -34,45 +32,45 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
public class ArchiveInfraRequestsSchedulerTest extends RequestsAdapterBase {
-
- @Autowired
- private ArchiveInfraRequestsScheduler scheduler;
-
- @Autowired
- private InfraActiveRequestsRepository iarRepo;
-
- @Autowired
- private ArchivedInfraRequestsRepository archivedRepo;
-
- @Value("${mso.infra-requests.archived.period}")
- private int archivedPeriod;
-
- @Test
- @Transactional
- public void testArchiveInfraRequests() throws Exception {
- 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.saveAll(requests);
-
- scheduler.archiveInfraRequests(requests);
-
- assertEquals(2, archivedRepo.count());
- assertEquals(requestId1, archivedRepo.findById(requestId1)
- .orElseThrow( () -> new Exception("Request Not Found")).getRequestId());
- assertEquals(requestId2, archivedRepo.findById(requestId2).
- orElseThrow( () -> new Exception("Request Not Found")).getRequestId());
- }
+
+ @Autowired
+ private ArchiveInfraRequestsScheduler scheduler;
+
+ @Autowired
+ private InfraActiveRequestsRepository iarRepo;
+
+ @Autowired
+ private ArchivedInfraRequestsRepository archivedRepo;
+
+ @Value("${mso.infra-requests.archived.period}")
+ private int archivedPeriod;
+
+ @Test
+ @Transactional
+ public void testArchiveInfraRequests() throws Exception {
+ 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.saveAll(requests);
+
+ scheduler.archiveInfraRequests(requests);
+
+ assertEquals(2, archivedRepo.count());
+ assertEquals(requestId1,
+ archivedRepo.findById(requestId1).orElseThrow(() -> new Exception("Request Not Found")).getRequestId());
+ assertEquals(requestId2,
+ archivedRepo.findById(requestId2).orElseThrow(() -> new Exception("Request Not Found")).getRequestId());
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java
index c7804c8e0c..4ed3285a70 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java
@@ -23,15 +23,12 @@ 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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import javax.ws.rs.core.MediaType;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -52,7 +49,7 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
@LocalServerPort
private int port;
-
+
@Value("${mso.adapters.requestDb.auth}")
private String msoAdaptersAuth;
@@ -68,7 +65,8 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
private void verifyInfraActiveRequests() {
assertEquals(infraActiveRequests.getRequestId(), infraActiveRequestsResponse.getRequestId());
assertEquals(infraActiveRequests.getServiceInstanceId(), infraActiveRequestsResponse.getServiceInstanceId());
- assertEquals(infraActiveRequests.getServiceInstanceName(), infraActiveRequestsResponse.getServiceInstanceName());
+ assertEquals(infraActiveRequests.getServiceInstanceName(),
+ infraActiveRequestsResponse.getServiceInstanceName());
assertEquals(infraActiveRequests.getVnfId(), infraActiveRequestsResponse.getVnfId());
assertEquals(infraActiveRequests.getVnfName(), infraActiveRequestsResponse.getVnfName());
assertEquals(infraActiveRequests.getVfModuleId(), infraActiveRequestsResponse.getVfModuleId());
@@ -88,7 +86,7 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
assertEquals(infraActiveRequests.getOperationalEnvName(), infraActiveRequestsResponse.getOperationalEnvName());
assertEquals(infraActiveRequests.getRequestStatus(), infraActiveRequestsResponse.getRequestStatus());
assertEquals(infraActiveRequests.getAction(), infraActiveRequestsResponse.getAction());
- assertEquals(infraActiveRequests.getRequestUrl(), infraActiveRequestsResponse.getRequestUrl());
+ assertEquals(infraActiveRequests.getRequestUrl(), infraActiveRequestsResponse.getRequestUrl());
}
@Before
@@ -125,14 +123,14 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
infraActiveRequests.setOperationalEnvName(UUID.randomUUID().toString());
infraActiveRequests.setRequestStatus("IN_PROGRESS");
infraActiveRequests.setAction("create");
- infraActiveRequests.setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
+ infraActiveRequests
+ .setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
HttpEntity<String> entity = new HttpEntity(infraActiveRequests, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests"));
- ResponseEntity<String> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entity, String.class);
+ ResponseEntity<String> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
assertEquals(201, response.getStatusCodeValue());
}
@@ -148,12 +146,11 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestMap, headers);
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getCloudOrchestrationFiltersFromInfraActive");
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
+ createURLWithPort("/infraActiveRequests") + "/getCloudOrchestrationFiltersFromInfraActive");
- ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {
- });
+ ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(builder.toUriString(),
+ HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {});
List<InfraActiveRequests> iarr = response.getBody();
assertEquals(200, response.getStatusCodeValue());
@@ -180,12 +177,11 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
requestMap.put("serviceInstanceName", values);
HttpEntity<Map<String, List<String>>> entityList = new HttpEntity(requestMap, headers);
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getOrchestrationFiltersFromInfraActive");
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getOrchestrationFiltersFromInfraActive");
- ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entityList, new ParameterizedTypeReference<List<InfraActiveRequests>>() {
- });
+ ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(builder.toUriString(),
+ HttpMethod.POST, entityList, new ParameterizedTypeReference<List<InfraActiveRequests>>() {});
List<InfraActiveRequests> iarr = response.getBody();
@@ -200,13 +196,13 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
@Test
public void checkVnfIdStatusTest() {
-
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests" + "/checkVnfIdStatus/" + infraActiveRequests.getOperationalEnvId()));
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
+ "/infraActiveRequests" + "/checkVnfIdStatus/" + infraActiveRequests.getOperationalEnvId()));
HttpEntity<String> entity = new HttpEntity(HttpEntity.EMPTY, headers);
- ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.GET,entity , InfraActiveRequests.class);
+ ResponseEntity<InfraActiveRequests> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, InfraActiveRequests.class);
infraActiveRequestsResponse = response.getBody();
@@ -218,17 +214,17 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
@Test
public void checkInstanceNameDuplicateTest() {
- InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) null,
- infraActiveRequests.getOperationalEnvName(),
- infraActiveRequests.getRequestScope());
+ InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest =
+ new InstanceNameDuplicateCheckRequest((HashMap<String, String>) null,
+ infraActiveRequests.getOperationalEnvName(), infraActiveRequests.getRequestScope());
- HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
+ HttpEntity<InstanceNameDuplicateCheckRequest> entityList =
+ new HttpEntity(instanceNameDuplicateCheckRequest, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
- ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
- });
+ ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST,
+ entityList, new ParameterizedTypeReference<InfraActiveRequests>() {});
infraActiveRequestsResponse = response.getBody();
@@ -243,17 +239,16 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
Map<String, String> requestMap = new HashMap<>();
requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId());
- InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) requestMap,
- null,
- infraActiveRequests.getRequestScope());
+ InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest(
+ (HashMap<String, String>) requestMap, null, infraActiveRequests.getRequestScope());
- HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
+ HttpEntity<InstanceNameDuplicateCheckRequest> entityList =
+ new HttpEntity(instanceNameDuplicateCheckRequest, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
- ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
- });
+ ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST,
+ entityList, new ParameterizedTypeReference<InfraActiveRequests>() {});
infraActiveRequestsResponse = response.getBody();
@@ -265,15 +260,16 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
@Test
public void checkInstanceNameDuplicateTestNotFound() {
- String instanceNameDuplicateCheckRequest = "{\r\n\t \"instanceName\":\"TestNotFoundInstanceName\",\r\n\t \"requestScope\":\"testasdfasdfasdf\"\r\n}";
+ String instanceNameDuplicateCheckRequest =
+ "{\r\n\t \"instanceName\":\"TestNotFoundInstanceName\",\r\n\t \"requestScope\":\"testasdfasdfasdf\"\r\n}";
- HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
+ HttpEntity<InstanceNameDuplicateCheckRequest> entityList =
+ new HttpEntity(instanceNameDuplicateCheckRequest, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
- ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
- });
+ ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST,
+ entityList, new ParameterizedTypeReference<InfraActiveRequests>() {});
assertEquals(200, response.getStatusCodeValue());
assertEquals(null, response.getBody());
@@ -285,17 +281,16 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA
Map<String, String> requestMap = new HashMap<>();
requestMap.put("operationalEnvironmentId", "NotFoundOperationalEnvId");
- InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) requestMap,
- null,
- infraActiveRequests.getRequestScope());
+ InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest(
+ (HashMap<String, String>) requestMap, null, infraActiveRequests.getRequestScope());
- HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
+ HttpEntity<InstanceNameDuplicateCheckRequest> entityList =
+ new HttpEntity(instanceNameDuplicateCheckRequest, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
- ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
- });
+ ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST,
+ entityList, new ParameterizedTypeReference<InfraActiveRequests>() {});
infraActiveRequestsResponse = response.getBody();
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
index b911396370..514e5ad923 100644
--- 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
@@ -22,11 +22,8 @@ package org.onap.so.adapters.requestsdb.adapters;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.util.Map;
-
import javax.ws.rs.core.Response;
-
import org.json.JSONException;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
@@ -38,55 +35,53 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-
import ch.qos.logback.classic.spi.ILoggingEvent;
public class HealthCheckHandlerTest extends RequestsAdapterBase {
-
- @LocalServerPort
- private int port;
- TestRestTemplate restTemplate = new TestRestTemplate();
+ @LocalServerPort
+ private int port;
+
+ TestRestTemplate restTemplate = new TestRestTemplate();
- HttpHeaders headers = new HttpHeaders();
+ HttpHeaders headers = new HttpHeaders();
-
- @Test
- public void testHealthcheck() throws JSONException {
- TestAppender.events.clear();
- 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());
- for(ILoggingEvent logEvent : TestAppender.events)
- if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
- logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
- ){
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ @Test
+ public void testHealthcheck() throws JSONException {
+ TestAppender.events.clear();
+ 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());
+ for (ILoggingEvent logEvent : TestAppender.events)
+ if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor")
+ && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
+ Map<String, String> mdc = logEvent.getMDCPropertyMap();
assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
- assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
- assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
- logEvent.getMarker() != null && logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ } else if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor")
+ && logEvent.getMarker() != null && logEvent.getMarker() != null
+ && logEvent.getMarker().getName().equals("EXIT")) {
+ Map<String, String> mdc = logEvent.getMDCPropertyMap();
assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
- assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
- assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
- assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ assertEquals("200", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
+ assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
}
TestAppender.events.clear();
- }
-
- private String createURLWithPort(String uri) {
- return "http://localhost:" + port + uri;
- }
+ }
+
+ 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
index f6950d9777..e53b957210 100644
--- 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
@@ -25,11 +25,9 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.junit.Before;
import org.junit.Rule;
@@ -49,469 +47,422 @@ 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.web.server.LocalServerPort;
-
import ch.qos.logback.classic.spi.ILoggingEvent;
public class MSORequestDBImplTest extends RequestsAdapterBase {
- @LocalServerPort
- private int port;
+ @LocalServerPort
+ private int port;
+
+ private MsoRequestsDbAdapter dbAdapter;
- private MsoRequestsDbAdapter dbAdapter;
-
@Autowired
private OperationStatusRepository operationStatusRepository;
-
+
@Autowired
private ResourceOperationStatusRepository resourceOperationStatusRepo;
@Rule
public ExpectedException thrown = ExpectedException.none();
-
- public InfraActiveRequests setupTestEntities() {
- return buildTestRequest();
- }
-
- @Before
- public void before() throws MsoRequestsDbException{
+
+ public InfraActiveRequests setupTestEntities() {
+ return buildTestRequest();
+ }
+
+ @Before
+ public void before() throws MsoRequestsDbException {
JaxWsProxyFactoryBean jaxWsProxyFactory = new JaxWsProxyFactoryBean();
jaxWsProxyFactory.setServiceClass(MsoRequestsDbAdapter.class);
jaxWsProxyFactory.setAddress("http://localhost:" + port + "/services/RequestsDbAdapter");
jaxWsProxyFactory.setUsername("bpel");
jaxWsProxyFactory.setPassword("mso-db-1507!");
dbAdapter = (MsoRequestsDbAdapter) jaxWsProxyFactory.create();
-
+
InfraActiveRequests testRequest = this.buildTestRequest();
- dbAdapter.updateInfraRequest ( testRequest.getRequestId(),
- testRequest.getLastModifiedBy(),
- testRequest.getStatusMessage(),
- testRequest.getResponseBody(),
- RequestStatusType.valueOf(testRequest.getRequestStatus()),
- testRequest.getProgress().toString(),
- testRequest.getVnfOutputs(),
- testRequest.getServiceInstanceId(),
- testRequest.getNetworkId(),
- testRequest.getVnfId(),
- testRequest.getVfModuleId(),
- testRequest.getVolumeGroupId(),
- testRequest.getServiceInstanceName(),
- testRequest.getConfigurationId(),
- testRequest.getConfigurationName(),
- testRequest.getVfModuleName());
-
-
- }
-
- 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");
- testRequest.setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
- testRequest.setVolumeGroupId("volumeGroupId");
- testRequest.setServiceInstanceName("serviceInstanceName");
- testRequest.setConfigurationId("configurationId");
- testRequest.setConfigurationName("configurationName");
- testRequest.setNetworkId("networkId");
- testRequest.setResponseBody("responseBody");
- testRequest.setVfModuleName("vfModuleName");
- testRequest.setVnfOutputs("vnfOutputs");
- 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 (Exception e) {
- assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId");
- }
- }
-
- @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
- assertEquals(clientRequestId, infraRequest.getClientRequestId());
- }
-
-
- @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 (Exception e) {
- assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId");
- }
- }
-
-
- @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{
- TestAppender.events.clear();
- 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);
-
- 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 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{
- TestAppender.events.clear();
- 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));
-
- for(ILoggingEvent logEvent : TestAppender.events)
- if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor") &&
- logEvent.getMarker().getName().equals("ENTRY")
- ){
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ dbAdapter.updateInfraRequest(testRequest.getRequestId(), testRequest.getLastModifiedBy(),
+ testRequest.getStatusMessage(), testRequest.getResponseBody(),
+ RequestStatusType.valueOf(testRequest.getRequestStatus()), testRequest.getProgress().toString(),
+ testRequest.getVnfOutputs(), testRequest.getServiceInstanceId(), testRequest.getNetworkId(),
+ testRequest.getVnfId(), testRequest.getVfModuleId(), testRequest.getVolumeGroupId(),
+ testRequest.getServiceInstanceName(), testRequest.getConfigurationId(),
+ testRequest.getConfigurationName(), testRequest.getVfModuleName());
+
+
+ }
+
+ 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");
+ testRequest.setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
+ testRequest.setVolumeGroupId("volumeGroupId");
+ testRequest.setServiceInstanceName("serviceInstanceName");
+ testRequest.setConfigurationId("configurationId");
+ testRequest.setConfigurationName("configurationName");
+ testRequest.setNetworkId("networkId");
+ testRequest.setResponseBody("responseBody");
+ testRequest.setVfModuleName("vfModuleName");
+ testRequest.setVnfOutputs("vnfOutputs");
+ 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 (Exception e) {
+ assertEquals(e.getMessage(), "Error retrieving MSO Infra Requests DB for Request ID invalidRequestId");
+ }
+ }
+
+ @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
+ assertEquals(clientRequestId, infraRequest.getClientRequestId());
+ }
+
+
+ @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 (Exception e) {
+ assertEquals(e.getMessage(), "Error retrieving MSO Infra Requests DB for Request ID invalidRequestId");
+ }
+ }
+
+
+ @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 {
+ TestAppender.events.clear();
+ 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);
+
+ 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 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 {
+ TestAppender.events.clear();
+ 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));
+
+ for (ILoggingEvent logEvent : TestAppender.events)
+ if (logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor")
+ && logEvent.getMarker().getName().equals("ENTRY")) {
+ Map<String, String> mdc = logEvent.getMDCPropertyMap();
assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
- assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
- assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- }else if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor") &&
- logEvent.getMarker().getName().equals("EXIT")){
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/services/RequestsDbAdapter", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ } else if (logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor")
+ && logEvent.getMarker().getName().equals("EXIT")) {
+ Map<String, String> mdc = logEvent.getMDCPropertyMap();
assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- assertEquals(null,mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
- assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
- assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
- assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ assertEquals(null, mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
+ assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/services/RequestsDbAdapter", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
}
- }
+ }
}
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
index c1848e3aad..ad405984e3 100644
--- 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
@@ -19,10 +19,10 @@
*/
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.jdbc.DataSourceBuilder;
@@ -37,17 +37,14 @@ 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"}
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
public class EmbeddedMariaDbConfig {
@Bean
@@ -56,47 +53,34 @@ public class EmbeddedMariaDbConfig {
}
@Primary
- @Bean(name = "requestDataSource")
- @ConfigurationProperties(prefix = "spring.datasource")
+ @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
+ @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();
+ 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 = "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);
- }
+ @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/application/TestAppender.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/TestAppender.java
index 0da1fd7565..5607c12b83 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/TestAppender.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/TestAppender.java
@@ -27,11 +27,11 @@ import ch.qos.logback.core.AppenderBase;
-public class TestAppender extends AppenderBase<ILoggingEvent> {
+public class TestAppender extends AppenderBase<ILoggingEvent> {
public static List<ILoggingEvent> events = new ArrayList<>();
-
- @Override
- public void append(ILoggingEvent loggingEvent) {
- events.add(loggingEvent);
- }
+
+ @Override
+ public void append(ILoggingEvent loggingEvent) {
+ events.add(loggingEvent);
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java
index bd15396c03..1ccd44d384 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java
@@ -24,6 +24,7 @@ package org.onap.so.adapters.requestsdb.client;
import org.onap.so.db.request.client.RequestsDbClient;
import org.springframework.stereotype.Component;
import java.net.URI;
+
@Component
public class RequestDbClientPortChanger extends RequestsDbClient {
private int port;
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
index 467cb1ed23..3b737c6768 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
@@ -40,7 +40,6 @@ import java.util.UUID;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
-
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -86,13 +85,14 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
infraActiveRequests.setRequestStatus("IN_PROGRESS");
infraActiveRequests.setAction("create");
infraActiveRequests.setRequestAction("someaction");
- infraActiveRequests.setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
+ infraActiveRequests
+ .setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
requestsDbClient.save(infraActiveRequests);
}
- private void verifyOperationStatus(OperationStatus request,OperationStatus response){
+ private void verifyOperationStatus(OperationStatus request, OperationStatus response) {
assertThat(request, sameBeanAs(response).ignoring("operateAt").ignoring("finishedAt"));
- }
+ }
private void verifyInfraActiveRequests(InfraActiveRequests infraActiveRequestsResponse) {
@@ -116,14 +116,16 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
@Test
public void checkVnfIdStatusTest() {
- InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.checkVnfIdStatus(infraActiveRequests.getOperationalEnvId());
+ InfraActiveRequests infraActiveRequestsResponse =
+ requestsDbClient.checkVnfIdStatus(infraActiveRequests.getOperationalEnvId());
verifyInfraActiveRequests(infraActiveRequestsResponse);
assertNull(requestsDbClient.checkVnfIdStatus(UUID.randomUUID().toString()));
}
@Test
public void checkInstanceNameDuplicateTest() {
- InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.checkInstanceNameDuplicate(null,infraActiveRequests.getOperationalEnvName(),infraActiveRequests.getRequestScope());
+ InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.checkInstanceNameDuplicate(null,
+ infraActiveRequests.getOperationalEnvName(), infraActiveRequests.getRequestScope());
verifyInfraActiveRequests(infraActiveRequestsResponse);
}
@@ -133,7 +135,8 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
Map<String, String> requestMap = new HashMap<>();
requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId());
- InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.checkInstanceNameDuplicate((HashMap<String, String>)requestMap,null,infraActiveRequests.getRequestScope());
+ InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.checkInstanceNameDuplicate(
+ (HashMap<String, String>) requestMap, null, infraActiveRequests.getRequestScope());
verifyInfraActiveRequests(infraActiveRequestsResponse);
}
@@ -165,27 +168,30 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
}
@Test
- public void getInfraActiveRequestbyRequestIdTest(){
- InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
- verifyInfraActiveRequests(infraActiveRequestsResponse);
- infraActiveRequestsResponse = requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
-
+ public void getInfraActiveRequestbyRequestIdTest() {
+ InfraActiveRequests infraActiveRequestsResponse =
+ requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
+ verifyInfraActiveRequests(infraActiveRequestsResponse);
+ infraActiveRequestsResponse =
+ requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
+
assertNull(requestsDbClient.getInfraActiveRequestbyRequestId(UUID.randomUUID().toString()));
}
-
+
@Test
- public void getInfraActiveRequestbyRequestIdWhereRequestUrlNullTest(){
+ public void getInfraActiveRequestbyRequestIdWhereRequestUrlNullTest() {
// requestUrl setup to null and save
- infraActiveRequests.setRequestUrl(null);
+ infraActiveRequests.setRequestUrl(null);
requestsDbClient.save(infraActiveRequests);
- InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
+ InfraActiveRequests infraActiveRequestsResponse =
+ requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
verifyInfraActiveRequests(infraActiveRequestsResponse);
assertNull(infraActiveRequestsResponse.getRequestUrl());
}
-
+
@Test
- public void getOneByServiceIdAndOperationIdTest(){
+ public void getOneByServiceIdAndOperationIdTest() {
OperationStatus operationStatus = new OperationStatus();
operationStatus.setProgress("IN_PROGRESS");
operationStatus.setResult("FAILED");
@@ -198,51 +204,59 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
operationStatus.setServiceName("test-service");
requestsDbClient.save(operationStatus);
- OperationStatus operationStatusResponse = requestsDbClient.getOneByServiceIdAndOperationId(operationStatus.getServiceId(),operationStatus.getOperationId());
+ OperationStatus operationStatusResponse = requestsDbClient
+ .getOneByServiceIdAndOperationId(operationStatus.getServiceId(), operationStatus.getOperationId());
- verifyOperationStatus(operationStatus,operationStatusResponse);
+ verifyOperationStatus(operationStatus, operationStatusResponse);
- assertNull(requestsDbClient.getOneByServiceIdAndOperationId(UUID.randomUUID().toString(),operationStatus.getOperationId()));
+ assertNull(requestsDbClient.getOneByServiceIdAndOperationId(UUID.randomUUID().toString(),
+ operationStatus.getOperationId()));
}
@Test
- public void getRequestProcessingDataBySoRequestIdTest(){
- List<RequestProcessingData> requestProcessingDataList = requestsDbClient
- .getRequestProcessingDataBySoRequestId("00032ab7-na18-42e5-965d-8ea592502018");
+ public void getRequestProcessingDataBySoRequestIdTest() {
+ List<RequestProcessingData> requestProcessingDataList =
+ requestsDbClient.getRequestProcessingDataBySoRequestId("00032ab7-na18-42e5-965d-8ea592502018");
assertNotNull(requestProcessingDataList);
assertFalse(requestProcessingDataList.isEmpty());
- assertEquals(2,requestProcessingDataList.size());
+ assertEquals(2, requestProcessingDataList.size());
}
@Test
- public void findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdTest(){
- OperationalEnvServiceModelStatus operationalEnvServiceModelStatus =requestsDbClient.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId("1234","TEST1234", "00032ab7-3fb3-42e5-965d-8ea592502017");
+ public void findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdTest() {
+ OperationalEnvServiceModelStatus operationalEnvServiceModelStatus =
+ requestsDbClient.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId("1234", "TEST1234",
+ "00032ab7-3fb3-42e5-965d-8ea592502017");
assertNotNull(operationalEnvServiceModelStatus);
- assertEquals("1234",operationalEnvServiceModelStatus.getOperationalEnvId());
- assertEquals("TEST1234",operationalEnvServiceModelStatus.getServiceModelVersionId());
-
- OperationalEnvServiceModelStatus operationalEnvServiceModelStatus1 =requestsDbClient.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId("1234","TEST1235", "00032ab7-3fb3-42e5-965d-8ea592502018");
+ assertEquals("1234", operationalEnvServiceModelStatus.getOperationalEnvId());
+ assertEquals("TEST1234", operationalEnvServiceModelStatus.getServiceModelVersionId());
+
+ OperationalEnvServiceModelStatus operationalEnvServiceModelStatus1 =
+ requestsDbClient.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId("1234", "TEST1235",
+ "00032ab7-3fb3-42e5-965d-8ea592502018");
assertNotNull(operationalEnvServiceModelStatus1);
- assertEquals("00032ab7-3fb3-42e5-965d-8ea592502018",operationalEnvServiceModelStatus1.getRequestId());
- assertEquals("1234",operationalEnvServiceModelStatus1.getOperationalEnvId());
- assertEquals("TEST1235",operationalEnvServiceModelStatus1.getServiceModelVersionId());
+ assertEquals("00032ab7-3fb3-42e5-965d-8ea592502018", operationalEnvServiceModelStatus1.getRequestId());
+ assertEquals("1234", operationalEnvServiceModelStatus1.getOperationalEnvId());
+ assertEquals("TEST1235", operationalEnvServiceModelStatus1.getServiceModelVersionId());
}
@Test
- public void getAllByOperationalEnvIdAndRequestId(){
- List<OperationalEnvServiceModelStatus> operationalEnvServiceModelStatuses =requestsDbClient.getAllByOperationalEnvIdAndRequestId("1234","00032ab7-3fb3-42e5-965d-8ea592502017");
+ public void getAllByOperationalEnvIdAndRequestId() {
+ List<OperationalEnvServiceModelStatus> operationalEnvServiceModelStatuses =
+ requestsDbClient.getAllByOperationalEnvIdAndRequestId("1234", "00032ab7-3fb3-42e5-965d-8ea592502017");
assertNotNull(operationalEnvServiceModelStatuses);
assertFalse(operationalEnvServiceModelStatuses.isEmpty());
- assertEquals(2,operationalEnvServiceModelStatuses.size());
+ assertEquals(2, operationalEnvServiceModelStatuses.size());
}
@Test
- public void getDistributionStatusByIdTest(){
- OperationalEnvDistributionStatus operationalEnvDistributionStatus =requestsDbClient.getDistributionStatusById("111");
+ public void getDistributionStatusByIdTest() {
+ OperationalEnvDistributionStatus operationalEnvDistributionStatus =
+ requestsDbClient.getDistributionStatusById("111");
assertNotNull(operationalEnvDistributionStatus);
- assertEquals("111",operationalEnvDistributionStatus.getDistributionId());
- assertEquals("ERROR",operationalEnvDistributionStatus.getDistributionIdErrorReason());
- assertEquals("00032ab7-3fb3-42e5-965d-8ea592502017",operationalEnvDistributionStatus.getRequestId());
+ assertEquals("111", operationalEnvDistributionStatus.getDistributionId());
+ assertEquals("ERROR", operationalEnvDistributionStatus.getDistributionIdErrorReason());
+ assertEquals("00032ab7-3fb3-42e5-965d-8ea592502017", operationalEnvDistributionStatus.getRequestId());
}
}