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()))
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));
}
assertEquals("\"requestOverlap\" : false", executor.isRequestOverLap(requestData));
}
+ @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());
+++ /dev/null
-/*
-* ============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);
- }
-
-}