diff options
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-common/src')
7 files changed, 238 insertions, 235 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java index 3efbc02e3..c72cab750 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/IntermediateMessageSenderImpl.java @@ -11,15 +11,14 @@ * 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========================================================= */ @@ -77,7 +76,7 @@ public class IntermediateMessageSenderImpl implements IntermediateMessageSender try { validateInputs(params, context); String jsonMessage = getJsonMessage(params, context); - logger.debug("Constructed JSON Message : " + jsonMessage); + logger.debug("Constructed JSON Message: " + jsonMessage); messageService.publishMessage(PROPERTIES_PREFIX, "", jsonMessage); context.setAttribute(prefix + STATUS, SUCCESS); } catch (Exception e) { diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/JsonDgUtilImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/JsonDgUtilImplTest.java index 950cb2f1a..803058b79 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/JsonDgUtilImplTest.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/JsonDgUtilImplTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -11,15 +11,14 @@ * 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========================================================= */ @@ -38,8 +37,8 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext; public class JsonDgUtilImplTest { - private static final ThreadLocal<SimpleDateFormat> DATE_TIME_PARSER_THREAD_LOCAL = ThreadLocal - .withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + private static final ThreadLocal<SimpleDateFormat> DATE_TIME_PARSER_THREAD_LOCAL = + ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); private JsonDgUtilImpl jsonDgUtil; @Before diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDgResolverPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDgResolverPluginImpl.java index 4f0779067..5c71bc52b 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDgResolverPluginImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestDgResolverPluginImpl.java @@ -2,6 +2,8 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Ericsson. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2019 AT&T Intellectual Property + * ================================================================================ * 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 * @@ -36,65 +38,65 @@ import org.powermock.modules.junit4.PowerMockRunner; @PrepareForTest(ResolverFactory.class) public class TestDgResolverPluginImpl { - private DgResolverPluginImpl dgResolverPluginImpl; - private Map<String, String> params; - private SvcLogicContext ctx; - private AbstractResolver abstractResolver; - private FlowKey flowKey; + private DgResolverPluginImpl dgResolverPluginImpl; + private Map<String, String> params; + private SvcLogicContext ctx; + private AbstractResolver abstractResolver; + private FlowKey flowKey; - @Before - public void setUp() { - params = new HashMap<>(); - ctx = new SvcLogicContext(); - PowerMockito.mockStatic(ResolverFactory.class); - flowKey = Mockito.mock(FlowKey.class); - abstractResolver = Mockito.mock(AbstractResolver.class); - PowerMockito.when(ResolverFactory.createResolver(anyString())).thenReturn(abstractResolver); - dgResolverPluginImpl = new DgResolverPluginImpl(); - PowerMockito.when(flowKey.name()).thenReturn("flowName"); - } + @Before + public void setUp() { + params = new HashMap<>(); + ctx = new SvcLogicContext(); + PowerMockito.mockStatic(ResolverFactory.class); + flowKey = Mockito.mock(FlowKey.class); + abstractResolver = Mockito.mock(AbstractResolver.class); + PowerMockito.when(ResolverFactory.createResolver(anyString())).thenReturn(abstractResolver); + dgResolverPluginImpl = new DgResolverPluginImpl(); + PowerMockito.when(flowKey.name()).thenReturn("flowName"); + } - @Test - public void testResolveDgVNF() throws APPCException { - params.put("action", "healthcheck"); - params.put("vnfVersion", "1"); - params.put("api-ver", "1.0"); - params.put("DGResolutionType", "VNF"); - params.put("vnfType", "vnfType"); - PowerMockito.when(abstractResolver.resolve("healthcheck", "vnfType", "1", "1.0")) - .thenReturn(flowKey); - dgResolverPluginImpl.resolveDg(params, ctx); - assertEquals("flowName", ctx.getAttribute("dg_name")); - } + @Test + public void testResolveDgVNF() throws APPCException { + params.put("action", "healthcheck"); + params.put("vnfVersion", "1"); + params.put("api-ver", "1.0"); + params.put("DGResolutionType", "VNF"); + params.put("vnfType", "vnfType"); + PowerMockito.when(abstractResolver.resolve("healthcheck", "vnfType", "1", "1.0")) + .thenReturn(flowKey); + dgResolverPluginImpl.resolveDg(params, ctx); + assertEquals("flowName", ctx.getAttribute("dg_name")); + } - @Test - public void testResolveDgVNFC() throws APPCException { - params.put("action", "healthcheck"); - params.put("vnfcType", "vnfcType"); - params.put("api-ver", "1.0"); - params.put("DGResolutionType", "VNFC"); - params.put("vnfType", "vnfType"); - PowerMockito.when(abstractResolver.resolve("healthcheck", "vnfType", "vnfcType", "1.0")) - .thenReturn(flowKey); - dgResolverPluginImpl.resolveDg(params, ctx); - assertEquals("flowName", ctx.getAttribute("dg_name")); - } + @Test + public void testResolveDgVNFC() throws APPCException { + params.put("action", "healthcheck"); + params.put("vnfcType", "vnfcType"); + params.put("api-ver", "1.0"); + params.put("DGResolutionType", "VNFC"); + params.put("vnfType", "vnfType"); + PowerMockito.when(abstractResolver.resolve("healthcheck", "vnfType", "vnfcType", "1.0")) + .thenReturn(flowKey); + dgResolverPluginImpl.resolveDg(params, ctx); + assertEquals("flowName", ctx.getAttribute("dg_name")); + } - @Test(expected = DgResolverException.class) - public void testResolveDgWithException() throws APPCException { - params.put("action", "healthcheck"); - params.put("vnfcType", "vnfcType"); - params.put("api-ver", "1.0"); - params.put("DGResolutionType", "VNFC"); - params.put("vnfType", "vnfType1"); - PowerMockito.when(abstractResolver.resolve("healthcheck", "vnfType", "vnfcType", "1.0")) - .thenReturn(flowKey); - dgResolverPluginImpl.resolveDg(params, ctx); - } + @Test(expected = DgResolverException.class) + public void testResolveDgWithException() throws APPCException { + params.put("action", "healthcheck"); + params.put("vnfcType", "vnfcType"); + params.put("api-ver", "1.0"); + params.put("DGResolutionType", "VNFC"); + params.put("vnfType", "vnfType1"); + PowerMockito.when(abstractResolver.resolve("healthcheck", "vnfType", "vnfcType", "1.0")) + .thenReturn(flowKey); + dgResolverPluginImpl.resolveDg(params, ctx); + } - @Test(expected = DgResolverException.class) - public void testResolveDgResolverNull() throws APPCException { - PowerMockito.when(ResolverFactory.createResolver(anyString())).thenReturn(null); - dgResolverPluginImpl.resolveDg(params, ctx); - } + @Test(expected = DgResolverException.class) + public void testResolveDgResolverNull() throws APPCException { + PowerMockito.when(ResolverFactory.createResolver(anyString())).thenReturn(null); + dgResolverPluginImpl.resolveDg(params, ctx); + } } diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVNFConfiguratorImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVNFConfiguratorImpl.java index 8b08fc288..49bc43d28 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVNFConfiguratorImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVNFConfiguratorImpl.java @@ -2,22 +2,22 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= * 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========================================================= */ @@ -44,7 +44,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @RunWith(PowerMockRunner.class) -@PrepareForTest({MDSALStoreImpl.class,MDSALStoreFactory.class}) +@PrepareForTest({MDSALStoreImpl.class, MDSALStoreFactory.class}) public class TestVNFConfiguratorImpl { private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestVNFConfiguratorImpl.class); @@ -57,11 +57,11 @@ public class TestVNFConfiguratorImpl { @Test(expected = APPCException.class) public void testValidations() throws APPCException { VNFConfigurator configurator = new VNFConfiguratorImpl(); - Map<String,String> params = new HashMap<String, String>(); - params.put("uniqueId","uniqueId"); - params.put("yang","yang"); - params.put("configJSON","configJSON"); - configurator.storeConfig(params,new SvcLogicContext()); + Map<String, String> params = new HashMap<String, String>(); + params.put("uniqueId", "uniqueId"); + params.put("yang", "yang"); + params.put("configJSON", "configJSON"); + configurator.storeConfig(params, new SvcLogicContext()); } @Test @@ -71,14 +71,15 @@ public class TestVNFConfiguratorImpl { PowerMockito.mockStatic(MDSALStoreFactory.class); MDSALStore mdsalStore = PowerMockito.mock(MDSALStoreImpl.class); PowerMockito.when(MDSALStoreFactory.createMDSALStore()).thenReturn(mdsalStore); - PowerMockito.when(mdsalStore.isModulePresent(Matchers.anyString(),(Date) Matchers.anyObject())).thenReturn(true); - - Map<String,String> params = new HashMap<String, String>(); - params.put("uniqueId","uniqueId"); - params.put("yang","yang"); - params.put("configJSON","configJSON"); - params.put("requestId","requestId"); - configurator.storeConfig(params,new SvcLogicContext()); + PowerMockito.when(mdsalStore.isModulePresent(Matchers.anyString(), (Date) Matchers.anyObject())) + .thenReturn(true); + + Map<String, String> params = new HashMap<String, String>(); + params.put("uniqueId", "uniqueId"); + params.put("yang", "yang"); + params.put("configJSON", "configJSON"); + params.put("requestId", "requestId"); + configurator.storeConfig(params, new SvcLogicContext()); } @Test @@ -91,16 +92,18 @@ public class TestVNFConfiguratorImpl { PowerMockito.when(MDSALStoreFactory.createMDSALStore()).thenReturn(mdsalStore); - PowerMockito.when(mdsalStore.isModulePresent(Matchers.anyString(),(Date) Matchers.anyObject())).thenReturn(false); + PowerMockito.when(mdsalStore.isModulePresent(Matchers.anyString(), (Date) Matchers.anyObject())) + .thenReturn(false); - PowerMockito.doNothing().when(mdsalStore).storeYangModule(Matchers.anyString(),(BundleInfo)Matchers.anyObject()); + PowerMockito.doNothing() + .when(mdsalStore).storeYangModule(Matchers.anyString(), (BundleInfo) Matchers.anyObject()); - Map<String,String> params = new HashMap<>(); - params.put("uniqueId","uniqueId"); - params.put("yang","yang"); - params.put("configJSON","configJSON"); - params.put("requestId","requestId"); - configurator.storeConfig(params,new SvcLogicContext()); + Map<String, String> params = new HashMap<String, String>(); + params.put("uniqueId", "uniqueId"); + params.put("yang", "yang"); + params.put("configJSON", "configJSON"); + params.put("requestId", "requestId"); + configurator.storeConfig(params, new SvcLogicContext()); } } diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVNFResolverDataReader.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVNFResolverDataReader.java index 6a560ce85..84f90b0b4 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVNFResolverDataReader.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVNFResolverDataReader.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2019 IBM. * ================================================================================ + * Modifications Copyright (C) 2019 AT&T Intellectual Property + * ================================================================================ * 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 @@ -28,10 +30,11 @@ import org.junit.Before; import org.junit.Test; public class TestVNFResolverDataReader { - + VNFResolverDataReader vNFResolverDataReader; Collection<String> list = Arrays.asList("action", "api_version", "vnf_type", "vnf_version"); - String queryStatement = "select vnf_type,vnf_version,api_version,action,dg_name,dg_version,dg_module FROM VNF_DG_MAPPING"; + String queryStatement = + "select vnf_type,vnf_version,api_version,action,dg_name,dg_version,dg_module FROM VNF_DG_MAPPING"; @Before public void setUp() { diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java index 2efda6b53..3f8c1818b 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -11,15 +11,14 @@ * 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========================================================= */ @@ -51,7 +50,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @RunWith(PowerMockRunner.class) -@PrepareForTest({FrameworkUtil.class,DependencyManager.class,DependencyModelFactory.class}) +@PrepareForTest({FrameworkUtil.class, DependencyManager.class, DependencyModelFactory.class}) @SuppressWarnings("unchecked") public class VnfExecutionFlowImplTest { @@ -77,7 +76,7 @@ public class VnfExecutionFlowImplTest { VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); Whitebox.setInternalState(vnfExecutionFlow, "logger", logger); - vnfExecutionFlow.getVnfExecutionFlowData(params,context); + vnfExecutionFlow.getVnfExecutionFlowData(params, context); } @Test @@ -95,7 +94,7 @@ public class VnfExecutionFlowImplTest { VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); Whitebox.setInternalState(vnfExecutionFlow, "logger", logger); - vnfExecutionFlow.getVnfExecutionFlowData(params,context); + vnfExecutionFlow.getVnfExecutionFlowData(params, context); } @Test(expected = RuntimeException.class) @@ -112,18 +111,18 @@ public class VnfExecutionFlowImplTest { VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); Whitebox.setInternalState(vnfExecutionFlow, "logger", logger); - vnfExecutionFlow.getVnfExecutionFlowData(params,context); + vnfExecutionFlow.getVnfExecutionFlowData(params, context); } private VnfcDependencyModel readCyclicDependencyModel() { - Vnfc a = createVnfc("A","Active-Passive",null,false); - Vnfc b = createVnfc("B","Active-Active",null,false); - Vnfc c = createVnfc("C","Active-Active",null,false); - Vnfc d = createVnfc("D","Active-Active",null,false); - Vnfc e = createVnfc("E","Active-Active",null,false); - Vnfc f = createVnfc("F","Active-Active",null,false); - Vnfc g = createVnfc("G","Active-Active",null,false); + Vnfc a = createVnfc("A", "Active-Passive", null, false); + Vnfc b = createVnfc("B", "Active-Active", null, false); + Vnfc c = createVnfc("C", "Active-Active", null, false); + Vnfc d = createVnfc("D", "Active-Active", null, false); + Vnfc e = createVnfc("E", "Active-Active", null, false); + Vnfc f = createVnfc("F", "Active-Active", null, false); + Vnfc g = createVnfc("G", "Active-Active", null, false); Node aNode = new Node(a); Node bNode = new Node(b); @@ -153,7 +152,7 @@ public class VnfExecutionFlowImplTest { } - private Vnfc createVnfc(String vnfcType,String resilienceType,String vnfcName,boolean mandatory) { + private Vnfc createVnfc(String vnfcType, String resilienceType, String vnfcName, boolean mandatory) { Vnfc vnfc = new Vnfc(); vnfc.setVnfcType(vnfcType); vnfc.setResilienceType(resilienceType); @@ -164,69 +163,67 @@ public class VnfExecutionFlowImplTest { private SvcLogicContext prepareContextForComplexDependency() { SvcLogicContext context = new SvcLogicContext(); - context.setAttribute("input.action-identifiers.vnf-id","1"); - context.setAttribute("vnf.type","vSCP"); - context.setAttribute("vnf.vnfcCount","7"); - - context.setAttribute("vnf.vnfc[0].name","A"); - context.setAttribute("vnf.vnfc[0].type","A"); - context.setAttribute("vnf.vnfc[0].vm_count","2"); - context.setAttribute("vnf.vnfc[0].vm[0].url","A1"); - context.setAttribute("vnf.vnfc[0].vm[1].url","A2"); - - context.setAttribute("vnf.vnfc[1].name","B"); - context.setAttribute("vnf.vnfc[1].type","B"); - context.setAttribute("vnf.vnfc[1].vm_count","5"); - context.setAttribute("vnf.vnfc[1].vm[0].url","B1"); - context.setAttribute("vnf.vnfc[1].vm[1].url","B2"); - context.setAttribute("vnf.vnfc[1].vm[2].url","B3"); - context.setAttribute("vnf.vnfc[1].vm[3].url","B4"); - context.setAttribute("vnf.vnfc[1].vm[4].url","B5"); - - context.setAttribute("vnf.vnfc[2].name","C"); - context.setAttribute("vnf.vnfc[2].type","C"); - context.setAttribute("vnf.vnfc[2].vm_count","4"); - context.setAttribute("vnf.vnfc[2].vm[0].url","C1"); - context.setAttribute("vnf.vnfc[2].vm[1].url","C2"); - context.setAttribute("vnf.vnfc[2].vm[2].url","C3"); - context.setAttribute("vnf.vnfc[2].vm[3].url","C4"); - - context.setAttribute("vnf.vnfc[3].name","D"); - context.setAttribute("vnf.vnfc[3].type","D"); - context.setAttribute("vnf.vnfc[3].vm_count","3"); - context.setAttribute("vnf.vnfc[3].vm[0].url","D1"); - context.setAttribute("vnf.vnfc[3].vm[1].url","D2"); - context.setAttribute("vnf.vnfc[3].vm[2].url","D3"); - - context.setAttribute("vnf.vnfc[4].name","E"); - context.setAttribute("vnf.vnfc[4].type","E"); - context.setAttribute("vnf.vnfc[4].vm_count","2"); - context.setAttribute("vnf.vnfc[4].vm[0].url","E1"); - context.setAttribute("vnf.vnfc[4].vm[1].url","E2"); - - context.setAttribute("vnf.vnfc[5].name","F"); - context.setAttribute("vnf.vnfc[5].type","F"); - context.setAttribute("vnf.vnfc[5].vm_count","1"); - context.setAttribute("vnf.vnfc[5].vm[0].url","F1"); - - context.setAttribute("vnf.vnfc[6].name","G"); - context.setAttribute("vnf.vnfc[6].type","G"); - context.setAttribute("vnf.vnfc[6].vm_count","1"); - context.setAttribute("vnf.vnfc[6].vm[0].url","G1"); - + context.setAttribute("input.action-identifiers.vnf-id", "1"); + context.setAttribute("vnf.type", "vSCP"); + context.setAttribute("vnf.vnfcCount", "7"); + + context.setAttribute("vnf.vnfc[0].name", "A"); + context.setAttribute("vnf.vnfc[0].type", "A"); + context.setAttribute("vnf.vnfc[0].vm_count", "2"); + context.setAttribute("vnf.vnfc[0].vm[0].url", "A1"); + context.setAttribute("vnf.vnfc[0].vm[1].url", "A2"); + + context.setAttribute("vnf.vnfc[1].name", "B"); + context.setAttribute("vnf.vnfc[1].type", "B"); + context.setAttribute("vnf.vnfc[1].vm_count", "5"); + context.setAttribute("vnf.vnfc[1].vm[0].url", "B1"); + context.setAttribute("vnf.vnfc[1].vm[1].url", "B2"); + context.setAttribute("vnf.vnfc[1].vm[2].url", "B3"); + context.setAttribute("vnf.vnfc[1].vm[3].url", "B4"); + context.setAttribute("vnf.vnfc[1].vm[4].url", "B5"); + + context.setAttribute("vnf.vnfc[2].name", "C"); + context.setAttribute("vnf.vnfc[2].type", "C"); + context.setAttribute("vnf.vnfc[2].vm_count", "4"); + context.setAttribute("vnf.vnfc[2].vm[0].url", "C1"); + context.setAttribute("vnf.vnfc[2].vm[1].url", "C2"); + context.setAttribute("vnf.vnfc[2].vm[2].url", "C3"); + context.setAttribute("vnf.vnfc[2].vm[3].url", "C4"); + + context.setAttribute("vnf.vnfc[3].name", "D"); + context.setAttribute("vnf.vnfc[3].type", "D"); + context.setAttribute("vnf.vnfc[3].vm_count", "3"); + context.setAttribute("vnf.vnfc[3].vm[0].url", "D1"); + context.setAttribute("vnf.vnfc[3].vm[1].url", "D2"); + context.setAttribute("vnf.vnfc[3].vm[2].url", "D3"); + + context.setAttribute("vnf.vnfc[4].name", "E"); + context.setAttribute("vnf.vnfc[4].type", "E"); + context.setAttribute("vnf.vnfc[4].vm_count", "2"); + context.setAttribute("vnf.vnfc[4].vm[0].url", "E1"); + context.setAttribute("vnf.vnfc[4].vm[1].url", "E2"); + + context.setAttribute("vnf.vnfc[5].name", "F"); + context.setAttribute("vnf.vnfc[5].type", "F"); + context.setAttribute("vnf.vnfc[5].vm_count", "1"); + context.setAttribute("vnf.vnfc[5].vm[0].url", "F1"); + + context.setAttribute("vnf.vnfc[6].name", "G"); + context.setAttribute("vnf.vnfc[6].type", "G"); + context.setAttribute("vnf.vnfc[6].vm_count", "1"); + context.setAttribute("vnf.vnfc[6].vm[0].url", "G1"); return context; } private VnfcDependencyModel readComplexDependencyModel() { - Vnfc a = createVnfc("A","Active-Passive",null,false); - Vnfc b = createVnfc("B","Active-Active",null,false); - Vnfc c = createVnfc("C","Active-Active",null,false); - Vnfc d = createVnfc("D","Active-Active",null,false); - Vnfc e = createVnfc("E","Active-Active",null,false); - Vnfc f = createVnfc("F","Active-Active",null,false); - Vnfc g = createVnfc("G","Active-Active",null,false); - + Vnfc a = createVnfc("A", "Active-Passive", null, false); + Vnfc b = createVnfc("B", "Active-Active", null, false); + Vnfc c = createVnfc("C", "Active-Active", null, false); + Vnfc d = createVnfc("D", "Active-Active", null, false); + Vnfc e = createVnfc("E", "Active-Active", null, false); + Vnfc f = createVnfc("F", "Active-Active", null, false); + Vnfc g = createVnfc("G", "Active-Active", null, false); Node aNode = new Node(a); Node bNode = new Node(b); @@ -261,10 +258,9 @@ public class VnfExecutionFlowImplTest { private VnfcDependencyModel readDependencyModel() { - Vnfc smp = createVnfc("SMP","Active-Passive",null,false); - Vnfc be = createVnfc("BE","Active-Active",null,false); - Vnfc fe = createVnfc("FE","Active-Active",null,false); - + Vnfc smp = createVnfc("SMP", "Active-Passive", null, false); + Vnfc be = createVnfc("BE", "Active-Active", null, false); + Vnfc fe = createVnfc("FE", "Active-Active", null, false); Node smpNode = new Node(smp); Node beNode = new Node(be); @@ -283,41 +279,41 @@ public class VnfExecutionFlowImplTest { } private Map<String, String> prepareParams() { - Map<String,String> params = new HashMap<>(); - params.put(Constants.DEPENDENCY_TYPE,"RESOURCE"); - params.put(Constants.FLOW_STRATEGY,"FORWARD"); + Map<String, String> params = new HashMap<>(); + params.put(Constants.DEPENDENCY_TYPE, "RESOURCE"); + params.put(Constants.FLOW_STRATEGY, "FORWARD"); - params.put(Constants.VNF_TYPE,"vSCP"); - params.put(Constants.VNF_VERION,"1.00"); + params.put(Constants.VNF_TYPE, "vSCP"); + params.put(Constants.VNF_VERION, "1.00"); return params; } private SvcLogicContext prepareContext() { SvcLogicContext context = new SvcLogicContext(); - context.setAttribute("input.action-identifiers.vnf-id","1"); - context.setAttribute("vnf.type","vSCP"); - context.setAttribute("vnf.vnfcCount","3"); - - context.setAttribute("vnf.vnfc[0].name","SMPname"); - context.setAttribute("vnf.vnfc[0].type","SMP"); - context.setAttribute("vnf.vnfc[0].vm_count","2"); - context.setAttribute("vnf.vnfc[0].vm[0].url","SMP_URL1"); - context.setAttribute("vnf.vnfc[0].vm[1].url","SMP_URL2"); - - context.setAttribute("vnf.vnfc[1].name","BEname"); - context.setAttribute("vnf.vnfc[1].type","BE"); - context.setAttribute("vnf.vnfc[1].vm_count","5"); - context.setAttribute("vnf.vnfc[1].vm[0].url","BE_URL1"); - context.setAttribute("vnf.vnfc[1].vm[1].url","BE_URL2"); - context.setAttribute("vnf.vnfc[1].vm[2].url","BE_URL3"); - context.setAttribute("vnf.vnfc[1].vm[3].url","BE_URL4"); - context.setAttribute("vnf.vnfc[1].vm[4].url","BE_URL5"); - - context.setAttribute("vnf.vnfc[2].name","FEname"); - context.setAttribute("vnf.vnfc[2].type","FE"); - context.setAttribute("vnf.vnfc[2].vm_count","2"); - context.setAttribute("vnf.vnfc[2].vm[0].url","FE_URL1"); - context.setAttribute("vnf.vnfc[2].vm[1].url","FE_URL2"); + context.setAttribute("input.action-identifiers.vnf-id", "1"); + context.setAttribute("vnf.type", "vSCP"); + context.setAttribute("vnf.vnfcCount", "3"); + + context.setAttribute("vnf.vnfc[0].name", "SMPname"); + context.setAttribute("vnf.vnfc[0].type", "SMP"); + context.setAttribute("vnf.vnfc[0].vm_count", "2"); + context.setAttribute("vnf.vnfc[0].vm[0].url", "SMP_URL1"); + context.setAttribute("vnf.vnfc[0].vm[1].url", "SMP_URL2"); + + context.setAttribute("vnf.vnfc[1].name", "BEname"); + context.setAttribute("vnf.vnfc[1].type", "BE"); + context.setAttribute("vnf.vnfc[1].vm_count", "5"); + context.setAttribute("vnf.vnfc[1].vm[0].url", "BE_URL1"); + context.setAttribute("vnf.vnfc[1].vm[1].url", "BE_URL2"); + context.setAttribute("vnf.vnfc[1].vm[2].url", "BE_URL3"); + context.setAttribute("vnf.vnfc[1].vm[3].url", "BE_URL4"); + context.setAttribute("vnf.vnfc[1].vm[4].url", "BE_URL5"); + + context.setAttribute("vnf.vnfc[2].name", "FEname"); + context.setAttribute("vnf.vnfc[2].type", "FE"); + context.setAttribute("vnf.vnfc[2].vm_count", "2"); + context.setAttribute("vnf.vnfc[2].vm[0].url", "FE_URL1"); + context.setAttribute("vnf.vnfc[2].vm[1].url", "FE_URL2"); return context; } @@ -326,12 +322,12 @@ public class VnfExecutionFlowImplTest { public void testMissingVnfcTypeInDependencyModel() throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); - context.setAttribute("vnf.vnfc[3].name","XEname"); - context.setAttribute("vnf.vnfc[3].type","XE"); - context.setAttribute("vnf.vnfc[3].vm_count","2"); - context.setAttribute("vnf.vnfc[3].vm[0].url","XE_URL1"); - context.setAttribute("vnf.vnfc[3].vm[1].url","XE_URL2"); - context.setAttribute("vnf.vnfcCount","4"); + context.setAttribute("vnf.vnfc[3].name", "XEname"); + context.setAttribute("vnf.vnfc[3].type", "XE"); + context.setAttribute("vnf.vnfc[3].vm_count", "2"); + context.setAttribute("vnf.vnfc[3].vm[0].url", "XE_URL1"); + context.setAttribute("vnf.vnfc[3].vm[1].url", "XE_URL2"); + context.setAttribute("vnf.vnfcCount", "4"); VnfcDependencyModel dependencyModel = readDependencyModel(); @@ -343,16 +339,17 @@ public class VnfExecutionFlowImplTest { .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); - vnfExecutionFlow.getVnfExecutionFlowData(params,context); + vnfExecutionFlow.getVnfExecutionFlowData(params, context); } @Test(expected = RuntimeException.class) - public void testMissingMandatoryVnfcTypeInInventoryModel() throws DependencyModelNotFound, InvalidDependencyModelException { + public void testMissingMandatoryVnfcTypeInInventoryModel() + throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); VnfcDependencyModel dependencyModel = readDependencyModel(); - Vnfc xe = createVnfc("XE","Active-Active",null, true); + Vnfc xe = createVnfc("XE", "Active-Active", null, true); Node xeNode = new Node(xe); dependencyModel.getDependencies().add(xeNode); @@ -364,16 +361,17 @@ public class VnfExecutionFlowImplTest { .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); - vnfExecutionFlow.getVnfExecutionFlowData(params,context); + vnfExecutionFlow.getVnfExecutionFlowData(params, context); } @Test - public void testMissingOptionalVnfcTypeInInventoryModel() throws DependencyModelNotFound, InvalidDependencyModelException { + public void testMissingOptionalVnfcTypeInInventoryModel() + throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); VnfcDependencyModel dependencyModel = readDependencyModel(); - Vnfc xe = createVnfc("XE","Active-Active",null, false); + Vnfc xe = createVnfc("XE", "Active-Active", null, false); Node xeNode = new Node(xe); dependencyModel.getDependencies().add(xeNode); @@ -385,24 +383,25 @@ public class VnfExecutionFlowImplTest { .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); - vnfExecutionFlow.getVnfExecutionFlowData(params,context); + vnfExecutionFlow.getVnfExecutionFlowData(params, context); } @Test - public void testMissingOptionalVnfcTypeInInventoryModelWithDependentChild() throws DependencyModelNotFound, InvalidDependencyModelException { + public void testMissingOptionalVnfcTypeInInventoryModelWithDependentChild() + throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); - context.setAttribute("vnf.vnfc[3].name","YEname"); - context.setAttribute("vnf.vnfc[3].type","YE"); - context.setAttribute("vnf.vnfc[3].vm_count","2"); - context.setAttribute("vnf.vnfc[3].vm[0].url","YE_URL1"); - context.setAttribute("vnf.vnfc[3].vm[1].url","YE_URL2"); - context.setAttribute("vnf.vnfcCount","4"); + context.setAttribute("vnf.vnfc[3].name", "YEname"); + context.setAttribute("vnf.vnfc[3].type", "YE"); + context.setAttribute("vnf.vnfc[3].vm_count", "2"); + context.setAttribute("vnf.vnfc[3].vm[0].url", "YE_URL1"); + context.setAttribute("vnf.vnfc[3].vm[1].url", "YE_URL2"); + context.setAttribute("vnf.vnfcCount", "4"); VnfcDependencyModel dependencyModel = readDependencyModel(); - Vnfc xe = createVnfc("XE","Active-Active",null, false); - Vnfc ye = createVnfc("YE","Active-Active",null, true); + Vnfc xe = createVnfc("XE", "Active-Active", null, false); + Vnfc ye = createVnfc("YE", "Active-Active", null, true); Node xeNode = new Node(xe); Node yeNode = new Node(ye); yeNode.addParent(xe); @@ -418,8 +417,6 @@ public class VnfExecutionFlowImplTest { .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); - vnfExecutionFlow.getVnfExecutionFlowData(params,context); + vnfExecutionFlow.getVnfExecutionFlowData(params, context); } - - } diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/utils/JSONUtilTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/utils/JSONUtilTest.java index 50429f680..a80e8ccba 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/utils/JSONUtilTest.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/utils/JSONUtilTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ -* Copyright 2018 AT&T +* Copyright 2018-2019 AT&T *================================================================================= * Modifications Copyright 2018 IBM. *================================================================================= @@ -43,7 +43,8 @@ public class JSONUtilTest { public void testFromJsonReader() { try { - JSONUtilVnfTest jOut = JSONUtil.fromJson(new FileReader("src/test/resources/data/input.json"), JSONUtilVnfTest.class); + JSONUtilVnfTest jOut = + JSONUtil.fromJson(new FileReader("src/test/resources/data/input.json"), JSONUtilVnfTest.class); assertEquals("I1", jOut.getVnfId()); assertEquals("T1", jOut.getVnfType()); } catch (UncheckedIOException uioe) { @@ -97,9 +98,9 @@ public class JSONUtilTest { Map<String, String> map = JSONUtil.extractPlainValues(refJson, "vnfId", "vnfType"); HashMap<String, String> hashMap = - (map instanceof HashMap) - ? (HashMap) map - : new HashMap<String, String>(map); + (map instanceof HashMap) + ? (HashMap) map + : new HashMap<String, String>(map); assertEquals(hashMap.get("vnfId"), "I2"); assertEquals(hashMap.get("vnfType"), "T2"); @@ -108,10 +109,9 @@ public class JSONUtilTest { fail(uioe.getMessage() + " Unchecked IO exception encountered"); } } - + @Test(expected=UncheckedIOException.class) - public void testCatchSectionOfToJson() throws IOException - { - JSONUtil.toJson(new Object()); + public void testCatchSectionOfToJson() throws IOException { + JSONUtil.toJson(new Object()); } } |