summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorKuleshov, Elena <evn@att.com>2020-05-20 11:23:22 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-05-20 11:23:23 -0400
commit570c4324718b7563911c4e180ab13908cf20d738 (patch)
tree49ca8cd04a2049aca7179f9d89131111165640a6 /mso-api-handlers
parent5dd30849655e5a218c63d6c3855e8916399e49e7 (diff)
Add Spring Component markup to rest validator
Add Spring Component markup to rest validator classes. Do not invoke serviceInstanceDeleteValidator for macro deletes. Issue-ID: SO-2945 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I0eb501bccb016d5d5fed43c3f5d1bd39c7d4fd72
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java28
6 files changed, 45 insertions, 6 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
index f75897dda1..89c5cbed9b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
@@ -8,8 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
-
+@Component
public class NetworkDeleteValidator implements RequestValidator {
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
index 1dea57ad9c..50938e6826 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
@@ -24,7 +24,9 @@ import java.util.Map;
import java.util.Optional;
import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.stereotype.Component;
+@Component
public interface RequestValidator {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
index 61f757ba64..843d94ce6c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
@@ -8,8 +8,10 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+@Component
public class ServiceInstanceDeleteValidator implements RequestValidator {
@Autowired
@@ -17,8 +19,17 @@ public class ServiceInstanceDeleteValidator implements RequestValidator {
@Override
public boolean shouldRunFor(String requestUri, ServiceInstancesRequest request, Actions action) {
+ boolean isALaCarte = false;
+ if (request.getRequestDetails() != null && request.getRequestDetails().getRequestParameters() != null) {
+ if (request.getRequestDetails().getRequestParameters().getALaCarte() == null) {
+ isALaCarte = false;
+ } else {
+ isALaCarte = request.getRequestDetails().getRequestParameters().getALaCarte();
+ }
+
+ }
return Pattern.compile("[Vv][5-8]/serviceInstances/[^/]+").matcher(requestUri).matches()
- && action.equals(Action.deleteInstance);
+ && action.equals(Action.deleteInstance) && isALaCarte;
}
@Override
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
index d54e60d153..37e3f0cb2e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
@@ -8,8 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
-
+@Component
public class VnfDeleteValidator implements RequestValidator {
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
index f010d47f70..e3598af31d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
@@ -8,7 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+@Component
public class VolumeGroupDeleteValidator implements RequestValidator {
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java
index c334d522b6..f461df3720 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java
@@ -5,6 +5,7 @@ import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -14,6 +15,8 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.apihandlerinfra.infra.rest.validators.ServiceInstanceDeleteValidator;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -30,22 +33,41 @@ public class ServiceInstanceDeleteValidatorTest {
private Map<String, String> instanceIdMap = new HashMap<>();
+ private ServiceInstancesRequest serviceInstancesRequest;
+
+ @Before
+ public void before() {
+ serviceInstancesRequest = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setaLaCarte(true);
+ requestDetails.setRequestParameters(requestParameters);
+ serviceInstancesRequest.setRequestDetails(requestDetails);
+ }
+
@Test
public void validateURIMatchTest() {
- assertEquals(true, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", new ServiceInstancesRequest(),
+ assertEquals(true, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", serviceInstancesRequest,
Action.deleteInstance));
}
@Test
public void validateURINotMatchTest() {
assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/vnfs/asdfasdf",
- new ServiceInstancesRequest(), Action.deleteInstance));
+ serviceInstancesRequest, Action.deleteInstance));
}
@Test
public void validateURINotMatch2Test() {
assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/update",
- new ServiceInstancesRequest(), Action.deleteInstance));
+ serviceInstancesRequest, Action.deleteInstance));
+ }
+
+ @Test
+ public void validateNotALaCarteTest() {
+ serviceInstancesRequest.getRequestDetails().getRequestParameters().setaLaCarte(false);
+ assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", serviceInstancesRequest,
+ Action.deleteInstance));
}
@Test