diff options
Diffstat (limited to 'mso-api-handlers/mso-requests-db')
8 files changed, 164 insertions, 121 deletions
diff --git a/mso-api-handlers/mso-requests-db/pom.xml b/mso-api-handlers/mso-requests-db/pom.xml index 651f35fd5c..031f86282a 100644 --- a/mso-api-handlers/mso-requests-db/pom.xml +++ b/mso-api-handlers/mso-requests-db/pom.xml @@ -31,6 +31,11 @@ <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <scope>test</scope> + </dependency> </dependencies> <packaging>jar</packaging> <build> diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java index 2cf442406e..2d44eebacd 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java @@ -35,7 +35,6 @@ public class ArchivedInfraRequests extends InfraRequests { public ArchivedInfraRequests(String requestId, String action) { setRequestId(requestId); - setAction(action); } public ArchivedInfraRequests(String requestId) { @@ -61,22 +60,19 @@ public class ArchivedInfraRequests extends InfraRequests { @Override public String toString() { - return new ToStringBuilder(this).append("requestId", getRequestId()) - .append("clientRequestId", getClientRequestId()).append("action", getAction()) - .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage()) - .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) - .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) - .append("vnfType", getVnfType()).append("serviceType", getServiceType()) - .append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId()) - .append("provStatus", getProvStatus()).append("vnfParams", getVnfParams()) - .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) - .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) - .append("modifyTime", getModifyTime()).append("requestType", getRequestType()) + return new ToStringBuilder(this).append("requestId", getRequestId()).append("requestStatus", getRequestStatus()) + .append("statusMessage", getStatusMessage()).append("progress", getProgress()) + .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource()) + .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("vnfType", getVnfType()) + .append("serviceType", getServiceType()).append("tenantId", getTenantId()) + .append("vnfParams", getVnfParams()).append("vnfOutputs", getVnfOutputs()) + .append("requestBody", getRequestBody()).append("responseBody", getResponseBody()) + .append("lastModifiedBy", getLastModifiedBy()).append("modifyTime", getModifyTime()) .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName()) .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName()) - .append("vfModuleModelName", getVfModuleModelName()).append("aaiServiceId", getAaiServiceId()) - .append("aicCloudRegion", getAicCloudRegion()).append("callBackUrl", getCallBackUrl()) - .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId()) + .append("vfModuleModelName", getVfModuleModelName()).append("aicCloudRegion", getAicCloudRegion()) + .append("callBackUrl", getCallBackUrl()).append("correlator", getCorrelator()) + .append("serviceInstanceId", getServiceInstanceId()) .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) .append("requestAction", getRequestAction()).append("networkId", getNetworkId()) .append("networkName", getNetworkName()).append("networkType", getNetworkType()) diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java index 1f5fb8f77e..9d76e289ab 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java @@ -25,6 +25,8 @@ import javax.persistence.Entity; import javax.persistence.Table; import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; /** * InfraActiveRequests generated by hbm2java @@ -32,6 +34,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties(ignoreUnknown = true) @Entity @Table(name = "infra_active_requests") +@JsonInclude(Include.NON_NULL) public class InfraActiveRequests extends InfraRequests { private static final long serialVersionUID = -6818265918910035170L; @@ -40,7 +43,6 @@ public class InfraActiveRequests extends InfraRequests { public InfraActiveRequests(final String requestId, final String action) { setRequestId(requestId); - setAction(action); } public InfraActiveRequests(final String requestId) { @@ -66,22 +68,19 @@ public class InfraActiveRequests extends InfraRequests { @Override public String toString() { - return new ToStringBuilder(this).append("requestId", getRequestId()) - .append("clientRequestId", getClientRequestId()).append("action", getAction()) - .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage()) - .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) - .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) - .append("vnfType", getVnfType()).append("serviceType", getServiceType()) - .append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId()) - .append("provStatus", getProvStatus()).append("vnfParams", getVnfParams()) - .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) - .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) - .append("modifyTime", getModifyTime()).append("requestType", getRequestType()) + return new ToStringBuilder(this).append("requestId", getRequestId()).append("requestStatus", getRequestStatus()) + .append("statusMessage", getStatusMessage()).append("progress", getProgress()) + .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource()) + .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("vnfType", getVnfType()) + .append("serviceType", getServiceType()).append("tenantId", getTenantId()) + .append("vnfParams", getVnfParams()).append("vnfOutputs", getVnfOutputs()) + .append("requestBody", getRequestBody()).append("responseBody", getResponseBody()) + .append("lastModifiedBy", getLastModifiedBy()).append("modifyTime", getModifyTime()) .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName()) .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName()) - .append("vfModuleModelName", getVfModuleModelName()).append("aaiServiceId", getAaiServiceId()) - .append("aicCloudRegion", getAicCloudRegion()).append("callBackUrl", getCallBackUrl()) - .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId()) + .append("vfModuleModelName", getVfModuleModelName()).append("aicCloudRegion", getAicCloudRegion()) + .append("callBackUrl", getCallBackUrl()).append("correlator", getCorrelator()) + .append("serviceInstanceId", getServiceInstanceId()) .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) .append("requestAction", getRequestAction()).append("networkId", getNetworkId()) .append("networkName", getNetworkName()).append("networkType", getNetworkType()) diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java index 73e5e16324..f36bf9058c 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java @@ -53,10 +53,6 @@ public abstract class InfraRequests implements java.io.Serializable { @Id @Column(name = "REQUEST_ID", length = 45) private String requestId; - @Column(name = "CLIENT_REQUEST_ID", length = 45, unique = true) - private String clientRequestId; - @Column(name = "ACTION", length = 45) - private String action; @Column(name = "REQUEST_STATUS", length = 20) private String requestStatus; @Column(name = "STATUS_MESSAGE", length = 2000) @@ -84,12 +80,8 @@ public abstract class InfraRequests implements java.io.Serializable { private String vnfType; @Column(name = "SERVICE_TYPE", length = 45) private String serviceType; - @Column(name = "AIC_NODE_CLLI", length = 11) - private String aicNodeClli; @Column(name = "TENANT_ID", length = 45) private String tenantId; - @Column(name = "PROV_STATUS", length = 20) - private String provStatus; @Column(name = "VNF_PARAMS") private String vnfParams; @Column(name = "VNF_OUTPUTS") @@ -103,8 +95,6 @@ public abstract class InfraRequests implements java.io.Serializable { @Column(name = "MODIFY_TIME") @Temporal(TemporalType.TIMESTAMP) private Date modifyTime; - @Column(name = "REQUEST_TYPE", length = 20) - private String requestType; @Column(name = "VOLUME_GROUP_ID", length = 45) private String volumeGroupId; @Column(name = "VOLUME_GROUP_NAME", length = 45) @@ -115,8 +105,6 @@ public abstract class InfraRequests implements java.io.Serializable { private String vfModuleName; @Column(name = "VF_MODULE_MODEL_NAME", length = 200) private String vfModuleModelName; - @Column(name = "AAI_SERVICE_ID", length = 50) - private String aaiServiceId; @Column(name = "CLOUD_REGION", length = 11) private String aicCloudRegion; @Column(name = "CALLBACK_URL", length = 200) @@ -177,22 +165,6 @@ public abstract class InfraRequests implements java.io.Serializable { this.requestId = requestId; } - public String getClientRequestId() { - return clientRequestId; - } - - public void setClientRequestId(String clientRequestId) { - this.clientRequestId = clientRequestId; - } - - public String getAction() { - return this.action; - } - - public void setAction(String action) { - this.action = action; - } - public String getRequestStatus() { return this.requestStatus; } @@ -299,14 +271,6 @@ public abstract class InfraRequests implements java.io.Serializable { this.serviceType = serviceType; } - public String getAicNodeClli() { - return this.aicNodeClli; - } - - public void setAicNodeClli(String aicNodeClli) { - this.aicNodeClli = aicNodeClli; - } - public String getTenantId() { return this.tenantId; } @@ -315,14 +279,6 @@ public abstract class InfraRequests implements java.io.Serializable { this.tenantId = tenantId; } - public String getProvStatus() { - return this.provStatus; - } - - public void setProvStatus(String provStatus) { - this.provStatus = provStatus; - } - public String getVnfParams() { return this.vnfParams; } @@ -367,14 +323,6 @@ public abstract class InfraRequests implements java.io.Serializable { return this.modifyTime; } - public String getRequestType() { - return this.requestType; - } - - public void setRequestType(String requestType) { - this.requestType = requestType; - } - public String getVolumeGroupId() { return this.volumeGroupId; } @@ -415,14 +363,6 @@ public abstract class InfraRequests implements java.io.Serializable { this.vfModuleModelName = vfModuleModelName; } - public String getAaiServiceId() { - return this.aaiServiceId; - } - - public void setAaiServiceId(String aaiServiceId) { - this.aaiServiceId = aaiServiceId; - } - public String getAicCloudRegion() { return this.aicCloudRegion; } @@ -637,24 +577,20 @@ public abstract class InfraRequests implements java.io.Serializable { @Override public String toString() { - return new ToStringBuilder(this).append("requestId", getRequestId()) - .append("clientRequestId", getClientRequestId()).append("action", getAction()) - .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage()) - .append("rollbackStatusMessage", getRollbackStatusMessage()).append("flowStatus", getFlowStatus()) - .append("retryStatusMessage", getRetryStatusMessage()).append("progress", getProgress()) - .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource()) - .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("vnfType", getVnfType()) - .append("serviceType", getServiceType()).append("aicNodeClli", getAicNodeClli()) - .append("tenantId", getTenantId()).append("provStatus", getProvStatus()) - .append("vnfParams", getVnfParams()).append("vnfOutputs", getVnfOutputs()) - .append("requestBody", getRequestBody()).append("responseBody", getResponseBody()) - .append("lastModifiedBy", getLastModifiedBy()).append("modifyTime", getModifyTime()) - .append("requestType", getRequestType()).append("volumeGroupId", getVolumeGroupId()) + return new ToStringBuilder(this).append("requestId", getRequestId()).append("requestStatus", getRequestStatus()) + .append("statusMessage", getStatusMessage()).append("rollbackStatusMessage", getRollbackStatusMessage()) + .append("flowStatus", getFlowStatus()).append("retryStatusMessage", getRetryStatusMessage()) + .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) + .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) + .append("vnfType", getVnfType()).append("serviceType", getServiceType()) + .append("tenantId", getTenantId()).append("vnfParams", getVnfParams()) + .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) + .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) + .append("modifyTime", getModifyTime()).append("volumeGroupId", getVolumeGroupId()) .append("volumeGroupName", getVolumeGroupName()).append("vfModuleId", getVfModuleId()) .append("vfModuleName", getVfModuleName()).append("vfModuleModelName", getVfModuleModelName()) - .append("aaiServiceId", getAaiServiceId()).append("aicCloudRegion", getAicCloudRegion()) - .append("callBackUrl", getCallBackUrl()).append("correlator", getCorrelator()) - .append("serviceInstanceId", getServiceInstanceId()) + .append("aicCloudRegion", getAicCloudRegion()).append("callBackUrl", getCallBackUrl()) + .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId()) .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) .append("requestAction", getRequestAction()).append("networkId", getNetworkId()) .append("networkName", getNetworkName()).append("networkType", getNetworkType()) diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java index 3c81555b99..e386789c7f 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,7 +42,7 @@ import com.openpojo.business.annotation.BusinessKey; * persist the request identifiers created when MSO POSTs a request to PINC <br> * <p> * </p> - * + * * @author * @version */ @@ -54,7 +54,7 @@ import com.openpojo.business.annotation.BusinessKey; public class RequestProcessingData implements Serializable { /** - * + * */ private static final long serialVersionUID = -3497593687393936143L; @@ -87,7 +87,7 @@ public class RequestProcessingData implements Serializable { private Date created = null; @Column(name = "IS_DATA_INTERNAL") - private Boolean isDataInternal = true; + private Boolean isDataInternal = false; @Override public boolean equals(final Object other) { diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 99c1d1ea72..334eb73da4 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -22,6 +22,7 @@ package org.onap.so.db.request.client; import java.net.URI; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -70,6 +71,7 @@ public class RequestsDbClient { private static final String SERVICE_ID = "SERVICE_ID"; private static final String OPERATION_ID = "OPERATION_ID"; private static final String SO_REQUEST_ID = "SO_REQUEST_ID"; + private static final String IS_INTERNAL_DATA = "IS_INTERNAL_DATA"; private static final String NAME = "NAME"; private static final String GROUPING_ID = "GROUPING_ID"; private static final String REQUEST_ID = "REQUEST_ID"; @@ -83,7 +85,7 @@ public class RequestsDbClient { protected String endpoint; @Value("${mso.adapters.requestDb.auth:#{null}}") - private String msoAdaptersAuth; + protected String msoAdaptersAuth; private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/"; private static final String OPERATION_STATUS_SEARCH = "/operationStatus/search"; @@ -115,6 +117,8 @@ public class RequestsDbClient { private String getInfraActiveRequests = "/infraActiveRequests/v1/getInfraActiveRequests"; + private String getInProgressVolumeGroupsAndVfModules = "/infraActiveRequests/getInProgressVolumeGroupsAndVfModules"; + private static final String findBySoRequestIdAndGroupIdAndName = "/requestProcessingData/search/findOneBySoRequestIdAndGroupingIdAndName"; @@ -123,6 +127,9 @@ public class RequestsDbClient { private static final String findBySoRequestIdOrderByGroupingIdDesc = "/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc"; + private static final String findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc = + "/requestProcessingData/search/findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc"; + private static final String findByGroupingIdAndNameAndTag = "/requestProcessingData/search/findByGroupingIdAndNameAndTag"; @@ -151,8 +158,12 @@ public class RequestsDbClient { findOneByRequestId = endpoint + findOneByRequestId; } - private ClientFactory getClientFactory() { - URI baseUri = UriBuilder.fromUri(endpoint).build(); + protected String getEndpoint() { + return endpoint; + } + + protected ClientFactory getClientFactory() { + URI baseUri = UriBuilder.fromUri(getEndpoint()).build(); ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); @@ -185,6 +196,15 @@ public class RequestsDbClient { } } + public List<InfraActiveRequests> getInProgressVolumeGroupsAndVfModules() { + HttpHeaders headers = getHttpHeaders(); + URI uri = getUri(endpoint + getInProgressVolumeGroupsAndVfModules); + HttpEntity<Map<String, List<String>>> entity = new HttpEntity<>(headers); + return restTemplate + .exchange(uri, HttpMethod.GET, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}) + .getBody(); + } + public InfraActiveRequests getInfraActiveRequestbyRequestId(String requestId) { try { HttpEntity<?> entity = getHttpEntity(); @@ -343,6 +363,49 @@ public class RequestsDbClient { restTemplate.put(uri, entity); } + public void patchInfraActiveRequests(InfraActiveRequests request) { + HttpHeaders headers = getHttpHeaders(); + URI uri = getUri(infraActiveRequestURI + request.getRequestId()); + HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers); + restTemplate.exchange(uri, HttpMethod.PATCH, new HttpEntity<InfraActiveRequests>(request, headers), + String.class); + } + + public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) { + RestTemplate template = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.set(HttpHeaders.AUTHORIZATION, basicAuth); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); + URI uri = getUri(host + "/infraActiveRequests/" + requestId); + try { + InfraActiveRequests infraActiveRequests = template + .exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), InfraActiveRequests.class).getBody(); + if (infraActiveRequests != null) { + infraActiveRequests.setRequestId(requestId); + } + return infraActiveRequests; + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } + } + + public void updateInfraActiveRequests(InfraActiveRequests request, String basicAuth, String host) { + RestTemplate template = new RestTemplate(); + template.getInterceptors().add(new SOSpringClientFilter()); + template.getInterceptors().add(new SpringClientPayloadFilter()); + HttpHeaders headers = new HttpHeaders(); + headers.set(HttpHeaders.AUTHORIZATION, basicAuth); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); + URI uri = getUri(host + "/infraActiveRequests/" + request.getRequestId()); + HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers); + template.put(uri, entity); + } + protected URI getUri(String uri) { return URI.create(uri); } @@ -367,6 +430,18 @@ public class RequestsDbClient { .queryParam(SO_REQUEST_ID, soRequestId).build().toString())); } + public List<RequestProcessingData> getExternalRequestProcessingDataBySoRequestId(String soRequestId) { + URI uri = getUri(UriBuilder.fromUri(getEndpoint() + findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc) + .queryParam(SO_REQUEST_ID, soRequestId).queryParam(IS_INTERNAL_DATA, false).build().toString()); + ResponseEntity<RequestProcessingData[]> array = + restTemplate.exchange(uri, HttpMethod.GET, getHttpEntity(), RequestProcessingData[].class); + if (array != null) { + return Arrays.asList(array.getBody()); + } else { + return null; + } + } + public RequestProcessingData getRequestProcessingDataBySoRequestIdAndNameAndGrouping(String soRequestId, String name, String groupingId) { return getClientFactory().create(RequestProcessingData.class) @@ -405,6 +480,7 @@ public class RequestsDbClient { rpd.setSoRequestId(requestId); rpd.setValue(flowExecutionPath); rpd.setTag(BPMN_EXECUTION_DATA_TAG); + rpd.setIsDataInternal(true); HttpEntity<RequestProcessingData> entity = new HttpEntity<>(rpd, headers); restTemplate.postForLocation(uri, entity); diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java index e4464450ea..21dea7577e 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java @@ -65,9 +65,6 @@ public class RequestsDBHelper { request.setProgress(100L); request.setLastModifiedBy("APIH"); request.setOperationalEnvId(operationalEnvironmentId); - if (request.getAction() == null) { - request.setRequestAction(UNKNOWN); - } if (request.getRequestScope() == null) { request.setRequestScope(UNKNOWN); } @@ -100,9 +97,6 @@ public class RequestsDBHelper { request.setProgress(100L); request.setLastModifiedBy("APIH"); request.setOperationalEnvId(operationalEnvironmentId); - if (request.getAction() == null) { - request.setRequestAction(UNKNOWN); - } if (request.getRequestScope() == null) { request.setRequestScope(UNKNOWN); } diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java index fdbc04acb4..0ad8d1458e 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java @@ -4,20 +4,35 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.times; import java.net.URI; +import javax.ws.rs.core.UriBuilder; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; +import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.RequestProcessingData; +import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; +import uk.co.blackpepper.bowman.ClientFactory; +import uk.co.blackpepper.bowman.Configuration; @RunWith(MockitoJUnitRunner.class) public class RequestDbClientTest { - + @Spy @InjectMocks protected RequestsDbClient requestsDbClient; @@ -32,4 +47,26 @@ public class RequestDbClientTest { requestsDbClient.updateRequestProcessingData(requestProcessingData); Mockito.verify(restTemplate, times(1)).put(eq(uri), isA(HttpEntity.class)); } + + @Test + public void updateInfraActiveRequestsTest() { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("1"); + URI uri = URI.create("/infraActiveRequests/1"); + requestsDbClient.patchInfraActiveRequests(request); + Mockito.verify(restTemplate, times(1)).exchange(eq(uri), eq(HttpMethod.PATCH), isA(HttpEntity.class), + eq(String.class)); + } + + @Test + public void testGetRequestProcessingDataBySoRequestIdAndIsInternalData() { + Mockito.doReturn("host").when(requestsDbClient).getEndpoint(); + requestsDbClient.getExternalRequestProcessingDataBySoRequestId("12345"); + URI uri = URI.create(UriBuilder + .fromUri("host/requestProcessingData/search/findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc") + .queryParam("SO_REQUEST_ID", "12345").queryParam("IS_INTERNAL_DATA", false).build().toString()); + Mockito.verify(restTemplate, times(1)).exchange(eq(uri), eq(HttpMethod.GET), isA(HttpEntity.class), + eq(RequestProcessingData[].class)); + } + } |