aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-01-23 18:17:31 +0000
committerTakamune Cho <takamune.cho@att.com>2019-01-24 19:39:37 +0000
commit0360dfcc5b4de89005f2724b8fbd4dcdb23979ae (patch)
tree04197d06dd8dcb12f77513f51424bb9430838fdb /appc-inbound
parent2cf3a78839c51b9de01c70f1b561b1bd059d0f69 (diff)
Fix ServiceExecutorImpl
Code change to fix handling of vserver-id Issue-ID: APPC-1358 Change-Id: I463fceda2321b5006100b12644708d22fe25a04e Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-inbound')
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java26
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImplTest.java20
-rw-r--r--appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/utils/ServiceConstantsTest.java34
3 files changed, 35 insertions, 45 deletions
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java
index 67b9c6f2e..ee83c87bc 100644
--- a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java
+++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java
@@ -102,24 +102,28 @@ public class ServiceExecutorImpl {
int vm_count = Integer.parseInt(ctx.getAttribute("vm-count"));
for(Request inprogressRequest:inProgressRequests){
if(inprogressRequest.getActionIdentifiers().getVnfcName() != null){
- for (int i = 0; i < vm_count; i++) {
- if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name")
- .equals(inprogressRequest.getActionIdentifiers().getVnfcName()))
- inProgressVServerIds.add(ctx.getAttribute("vm[" + i + "].vserver-id"));
- log.debug("Received vserver-id from AAI: " + inProgressVServerIds);
+ for (int i = 0; i < vm_count; i++) {
+ if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name")
+ .equals(inprogressRequest.getActionIdentifiers().getVnfcName())) {
+ String newInProgressVserverId = ctx.getAttribute("vm[" + i + "].vserver-id");
+ inProgressVServerIds.add(newInProgressVserverId);
+ log.debug("Received vserver-id from AAI: " + newInProgressVserverId);
+ }
+ }
}
- }
}
for(Request inProgVserverIds:inProgressRequests)
if(inProgVserverIds.getActionIdentifiers().getvServerId() != null)
inProgressVServerIds.add(inProgVserverIds.getActionIdentifiers().getvServerId());
if(currentRequestVnfcName != null){
- for (int i = 0; i < vm_count; i++)
+ for (int i = 0; i < vm_count; i++) {
if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name")
- .equals(currentRequestVnfcName))
- currentVnfcVserverId = ctx.getAttribute("vm[" + i + "].vserver-id");
- log.debug("Received vserver-id from AAI: " + currentVnfcVserverId);
- return inProgressVServerIds.contains(currentVnfcVserverId);
+ .equals(currentRequestVnfcName)) {
+ currentVnfcVserverId = ctx.getAttribute("vm[" + i + "].vserver-id");
+ log.debug("Received vserver-id from AAI: " + currentVnfcVserverId);
+ return inProgressVServerIds.contains(currentVnfcVserverId);
+ }
+ }
}
for (Request request : inProgressRequests) {
if(!Strings.isNullOrEmpty(currentRequestVServerId) && currentRequestVServerId.equalsIgnoreCase(request.getActionIdentifiers().getvServerId()))
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImplTest.java b/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImplTest.java
index 6cdca796b..040723f3b 100644
--- a/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImplTest.java
+++ b/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImplTest.java
@@ -123,6 +123,7 @@ public class ServiceExecutorImplTest {
Mockito.doReturn(aaiServiceMock).when(executor).getAaiService(Mockito.any(AAIClient.class));
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("vm-count", "1");
+ ctx.setAttribute("vm[0].vnfc-name", "vnfc-name1");
Mockito.doReturn(ctx).when(executor).getSvcLogicContext();
assertEquals("\"requestOverlap\" : false", executor.isRequestOverLap(requestData));
}
@@ -145,6 +146,25 @@ public class ServiceExecutorImplTest {
}
@Test
+ public void testScopeOverlapWithVnfcNameAndInProgressRequestAndContextVariables() throws Exception {
+ executor = Mockito.spy(new ServiceExecutorImpl());
+ String requestData = "{\"vnf-id\":\"\",\"current-request\" :{\"action\" : \"Audit\",\"action-identifiers\" : {\"service-instance-id\" :"
+ + " \"service-instance-id\",\"vnfc-name\" : \"vnfc-name\"}},\"in-progress-requests\" :"
+ + " [{\"target-id\": \"vnf-id1\",\"action\" : \"HealthCheck\",\"action-identifiers\" : {\"service-instance-id\" :"
+ + " \"service-instance-id1\",\"vnfc-name\" : \"vnfc-name1\",\"vserver-id\": \"vserver-id1\"}},{\"action\" :"
+ + " \"CheckLock\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id2\",\"vnfc-name\" :"
+ + " \"vnfc-name2\",\"vserver-id\": \"vserver-id2\"}}]}";
+ AaiService aaiServiceMock = Mockito.mock(AaiService.class);
+ Mockito.doReturn(aaiServiceMock).when(executor).getAaiService(Mockito.any(AAIClient.class));
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vm-count", "1");
+ ctx.setAttribute("vm[0].vnfc-name", "vnfc-name");
+ ctx.setAttribute("vm[0].vserverid", "vnfc-name");
+ Mockito.doReturn(ctx).when(executor).getSvcLogicContext();
+ assertEquals("\"requestOverlap\" : false", executor.isRequestOverLap(requestData));
+ }
+
+ @Test
public void testScopeOverlapExceptionFlow() throws Exception {
executor = Mockito.spy(new ServiceExecutorImpl());
String requestData = "{\"vnf-id\":\"\",\"current-request\" :{\"action\" : \"Audit\",\"action-identifiers\" : {\"service-instance-id\" :"
diff --git a/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/utils/ServiceConstantsTest.java b/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/utils/ServiceConstantsTest.java
deleted file mode 100644
index 64d150a52..000000000
--- a/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaces/service/utils/ServiceConstantsTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : APPC
-* ================================================================================
-* Copyright 2018 TechMahindra
-* ================================================================================
-* Modifications Copyright (C) 2019 Ericsson
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.onap.appc.interfaces.service.utils;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ServiceConstantsTest {
-
- @Test
- public void testServiceConstants() {
- Assert.assertEquals("action-identifiers", ServiceConstants.ACTIONIDENTIFIER);
- }
-
-}