summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-requests-db
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-11-04 14:48:07 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-04 14:48:07 +0000
commitb01d4d9077c4fdbb29702d59581115e2dcb2d90e (patch)
tree5ca7a3311013ed3a88c5cdd36a3f5b6f622045f8 /mso-api-handlers/mso-requests-db
parentc7808c6ba90b621a96061337ce6b0811b636fa1a (diff)
parentf39c458844188866d9c0cd7bbd59ce8f15b66cb7 (diff)
Merge "Add patch method"
Diffstat (limited to 'mso-api-handlers/mso-requests-db')
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java8
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java12
3 files changed, 23 insertions, 0 deletions
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..84eaf38da7 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;
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 ef946bfcc8..132ec28e31 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
@@ -354,6 +354,14 @@ 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);
+ }
+
protected URI getUri(String uri) {
return URI.create(uri);
}
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..fff6ad1013 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
@@ -10,8 +10,10 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.RequestProcessingData;
import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;
@@ -32,4 +34,14 @@ 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));
+ }
}