From cd7f49ca4072db9b5f1d86b72666fa9077bc31f6 Mon Sep 17 00:00:00 2001 From: shashikanth Date: Wed, 27 Sep 2017 15:43:48 +0530 Subject: Improve SDNC Sonar coverage Added initial test cases for ASDC-APIs Issue-Id: SDNC-101 Change-Id: Iad8be979e39099e4ece8210dbd5d2c9c64b60990 Signed-off-by: shashikanth.vh --- .../sdnc/northbound/asdcapi/TestAsdcApiApi.java | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 asdcApi/provider/src/test/java/org/onap/sdnc/northbound/asdcapi/TestAsdcApiApi.java (limited to 'asdcApi/provider/src/test/java') diff --git a/asdcApi/provider/src/test/java/org/onap/sdnc/northbound/asdcapi/TestAsdcApiApi.java b/asdcApi/provider/src/test/java/org/onap/sdnc/northbound/asdcapi/TestAsdcApiApi.java new file mode 100644 index 000000000..c78abc8f7 --- /dev/null +++ b/asdcApi/provider/src/test/java/org/onap/sdnc/northbound/asdcapi/TestAsdcApiApi.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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.sdnc.northbound.asdcapi; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiProvider; +import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiSliClient; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateOutput; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { + + private AsdcApiProvider asdcApiProvider; + private static final Logger LOG = LoggerFactory.getLogger(AsdcApiProvider.class); + + @Before + public void setUp() throws Exception { + if (null == asdcApiProvider) { + DataBroker dataBroker = getDataBroker(); + NotificationPublishService mockNotification = mock(NotificationPublishService.class); + RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); + AsdcApiSliClient mockSliClient = mock(AsdcApiSliClient.class); + asdcApiProvider = new AsdcApiProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient); + } + } + + //Testcase should return error 503 when No service logic active for ASDC-API. + @Test + public void testVfLicenseModelUpdate() { + + VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); + + inputBuilder.setArtifactName("abc"); + inputBuilder.setArtifactVersion("1"); + + // TODO: currently initialize SvcLogicServiceClient is failing, need to fix + java.util.concurrent.Future> future = asdcApiProvider + .vfLicenseModelUpdate(inputBuilder.build()); + RpcResult rpcResult = null; + try { + rpcResult = future.get(); + } catch (Exception e) { + fail("Error : " + e); + } + LOG.info("result: {}", rpcResult); + assertEquals("503", rpcResult.getResult().getAsdcApiResponseCode()); + } + + //Input parameter validation + @Test + public void testVfLicenseModelUpdateInputValidation() { + + VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); + + inputBuilder.setArtifactName("abc"); + inputBuilder.setArtifactVersion("1"); + + java.util.concurrent.Future> future = asdcApiProvider + .vfLicenseModelUpdate(null); + assertNull(future); + } + + @Test(expected = IllegalArgumentException.class) + public void testVfLicenseModelUpdateValidation1() { + + VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); + + java.util.concurrent.Future> future = asdcApiProvider + .vfLicenseModelUpdate(inputBuilder.build()); + RpcResult rpcResult = null; + try { + rpcResult = future.get(); + } catch (Exception e) { + fail("Error : " + e); + } + } +} -- cgit 1.2.3-korg From fa9d764ef796f450f5f031a8c2a43ee60ab8b829 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 3 Oct 2017 14:30:51 -0400 Subject: Add ueb-listener unit test Enhance ueb-listener unit test to verify TOSCA parse Change-Id: Iedc675ead3ef69e4fa7151c8c4c500990c0ee6a7 Issue-ID: CCSDK-106 Signed-off-by: Dan Timoney --- .../sli/northbound/asdcapi/TestAsdcApiApi.java | 107 +++++++++++++++++++++ .../sdnc/northbound/asdcapi/TestAsdcApiApi.java | 107 --------------------- ueb-listener/pom.xml | 9 +- .../sli/northbound/uebclient/SdncARModel.java | 14 +-- .../sli/northbound/uebclient/SdncBaseModel.java | 60 ++++++------ .../sli/northbound/uebclient/SdncServiceModel.java | 2 +- .../sli/northbound/uebclient/SdncUebCallback.java | 15 +-- .../northbound/uebclient/SdncUebConfiguration.java | 17 ++-- .../sli/northbound/uebclient/SdncVFModel.java | 16 +-- .../northbound/uebclient/TestSdncUebCallback.java | 35 ++++++- ...t_resources_csars_service-NfodService-csar.csar | Bin 0 -> 38938 bytes ueb-listener/src/test/resources/log4j.properties | 30 ++++++ .../src/test/resources/ueb-listener.properties | 38 ++++---- 13 files changed, 257 insertions(+), 193 deletions(-) create mode 100644 asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java delete mode 100644 asdcApi/provider/src/test/java/org/onap/sdnc/northbound/asdcapi/TestAsdcApiApi.java create mode 100644 ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar create mode 100644 ueb-listener/src/test/resources/log4j.properties (limited to 'asdcApi/provider/src/test/java') diff --git a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java new file mode 100644 index 000000000..f65bbc045 --- /dev/null +++ b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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.ccsdk.sli.northbound.asdcapi; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiProvider; +import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiSliClient; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateOutput; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { + + private AsdcApiProvider asdcApiProvider; + private static final Logger LOG = LoggerFactory.getLogger(AsdcApiProvider.class); + + @Before + public void setUp() throws Exception { + if (null == asdcApiProvider) { + DataBroker dataBroker = getDataBroker(); + NotificationPublishService mockNotification = mock(NotificationPublishService.class); + RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); + AsdcApiSliClient mockSliClient = mock(AsdcApiSliClient.class); + asdcApiProvider = new AsdcApiProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient); + } + } + + //Testcase should return error 503 when No service logic active for ASDC-API. + @Test + public void testVfLicenseModelUpdate() { + + VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); + + inputBuilder.setArtifactName("abc"); + inputBuilder.setArtifactVersion("1"); + + // TODO: currently initialize SvcLogicServiceClient is failing, need to fix + java.util.concurrent.Future> future = asdcApiProvider + .vfLicenseModelUpdate(inputBuilder.build()); + RpcResult rpcResult = null; + try { + rpcResult = future.get(); + } catch (Exception e) { + fail("Error : " + e); + } + LOG.info("result: {}", rpcResult); + assertEquals("503", rpcResult.getResult().getAsdcApiResponseCode()); + } + + //Input parameter validation + @Test + public void testVfLicenseModelUpdateInputValidation() { + + VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); + + inputBuilder.setArtifactName("abc"); + inputBuilder.setArtifactVersion("1"); + + java.util.concurrent.Future> future = asdcApiProvider + .vfLicenseModelUpdate(null); + assertNull(future); + } + + @Test(expected = IllegalArgumentException.class) + public void testVfLicenseModelUpdateValidation1() { + + VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); + + java.util.concurrent.Future> future = asdcApiProvider + .vfLicenseModelUpdate(inputBuilder.build()); + RpcResult rpcResult = null; + try { + rpcResult = future.get(); + } catch (Exception e) { + fail("Error : " + e); + } + } +} diff --git a/asdcApi/provider/src/test/java/org/onap/sdnc/northbound/asdcapi/TestAsdcApiApi.java b/asdcApi/provider/src/test/java/org/onap/sdnc/northbound/asdcapi/TestAsdcApiApi.java deleted file mode 100644 index c78abc8f7..000000000 --- a/asdcApi/provider/src/test/java/org/onap/sdnc/northbound/asdcapi/TestAsdcApiApi.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * 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.sdnc.northbound.asdcapi; - -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiProvider; -import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiSliClient; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateOutput; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { - - private AsdcApiProvider asdcApiProvider; - private static final Logger LOG = LoggerFactory.getLogger(AsdcApiProvider.class); - - @Before - public void setUp() throws Exception { - if (null == asdcApiProvider) { - DataBroker dataBroker = getDataBroker(); - NotificationPublishService mockNotification = mock(NotificationPublishService.class); - RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); - AsdcApiSliClient mockSliClient = mock(AsdcApiSliClient.class); - asdcApiProvider = new AsdcApiProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient); - } - } - - //Testcase should return error 503 when No service logic active for ASDC-API. - @Test - public void testVfLicenseModelUpdate() { - - VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); - - inputBuilder.setArtifactName("abc"); - inputBuilder.setArtifactVersion("1"); - - // TODO: currently initialize SvcLogicServiceClient is failing, need to fix - java.util.concurrent.Future> future = asdcApiProvider - .vfLicenseModelUpdate(inputBuilder.build()); - RpcResult rpcResult = null; - try { - rpcResult = future.get(); - } catch (Exception e) { - fail("Error : " + e); - } - LOG.info("result: {}", rpcResult); - assertEquals("503", rpcResult.getResult().getAsdcApiResponseCode()); - } - - //Input parameter validation - @Test - public void testVfLicenseModelUpdateInputValidation() { - - VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); - - inputBuilder.setArtifactName("abc"); - inputBuilder.setArtifactVersion("1"); - - java.util.concurrent.Future> future = asdcApiProvider - .vfLicenseModelUpdate(null); - assertNull(future); - } - - @Test(expected = IllegalArgumentException.class) - public void testVfLicenseModelUpdateValidation1() { - - VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); - - java.util.concurrent.Future> future = asdcApiProvider - .vfLicenseModelUpdate(inputBuilder.build()); - RpcResult rpcResult = null; - try { - rpcResult = future.get(); - } catch (Exception e) { - fail("Error : " + e); - } - } -} diff --git a/ueb-listener/pom.xml b/ueb-listener/pom.xml index c00395d6e..68d8fc080 100755 --- a/ueb-listener/pom.xml +++ b/ueb-listener/pom.xml @@ -14,7 +14,8 @@ 0.1.0-SNAPSHOT - 1.1.7-SNAPSHOT + 1.1.32-SNAPSHOT + 1.1.34-SNAPSHOT 2.9.0.pr1 true /opt/app/ueb-listener @@ -31,6 +32,12 @@ ${sdc.client.version} compile + + org.openecomp.sdc.sdc-tosca + sdc-tosca + ${sdc.tosca.version} + compile + org.slf4j slf4j-api diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java index 75b19cd2e..8d480a4d1 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java @@ -8,9 +8,9 @@ * 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. @@ -23,24 +23,24 @@ package org.onap.ccsdk.sli.northbound.uebclient; import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; -import org.openecomp.sdc.toscaparser.api.Metadata; import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SdncARModel extends SdncBaseModel { - + private static final Logger LOG = LoggerFactory .getLogger(SdncARModel.class); public SdncARModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) { super(sdcCsarHelper, nodeTemplate); - + // extract metadata - Metadata metadata = nodeTemplate.getMetadata(); + Metadata metadata = nodeTemplate.getMetaData(); addParameter("type", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_TYPE)); - + // extract properties //addParameter("role", extractValue (sdcCsarHelper, nodeTemplate, SdcPropertyNames.PROPERTY_NAME_ROLE)); //addParameter("type", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_TYPE)); - wrong location, get from metadata diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java index 32e51599e..6128f288b 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java @@ -8,9 +8,9 @@ * 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. @@ -27,33 +27,33 @@ import java.util.Map; import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; import org.openecomp.sdc.toscaparser.api.Group; -import org.openecomp.sdc.toscaparser.api.Metadata; import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SdncBaseModel { - + private static final Logger LOG = LoggerFactory .getLogger(SdncBaseModel.class); - + protected String customizationUUID = null; protected String invariantUUID = null; - protected String model_yaml = null; - protected String version = null; - + protected String model_yaml = null; + protected String version = null; + protected Map params = null; protected ISdcCsarHelper sdcCsarHelper = null; public SdncBaseModel() { - + } - + public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, Metadata metadata) { params = new HashMap<>(); this.sdcCsarHelper = sdcCsarHelper; - + // extract service metadata invariantUUID = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID); addParameter("invariant_uuid",invariantUUID); @@ -70,11 +70,11 @@ public class SdncBaseModel { this.sdcCsarHelper = sdcCsarHelper; // extract nodeTemplate metadata - Metadata metadata = nodeTemplate.getMetadata(); + Metadata metadata = nodeTemplate.getMetaData(); customizationUUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); addParameter("invariant_uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); addParameter("uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_UUID)); - addParameter("version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VERSION)); + addParameter("version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VERSION)); } public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, Group group) { @@ -86,9 +86,9 @@ public class SdncBaseModel { Metadata metadata = group.getMetadata(); //customizationUUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULECUSTOMIZATIONUUID); - returning null customizationUUID = extractValue (metadata, "vfModuleModelCustomizationUUID"); - addParameter("invariant_uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)); - addParameter("uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); - addParameter("version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)); + addParameter("invariant_uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)); + addParameter("uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); + addParameter("version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)); } protected void addParameter (String name, String value) { @@ -102,26 +102,26 @@ public class SdncBaseModel { params.put(name, value); } } - + public static void addIntParameter (String name, String value, Map params) { if (value != null && !value.isEmpty()) { params.put(name, value); } } - + public static void addParameter (String name, String value, Map params) { if (value != null && !value.isEmpty()) { params.put(name, "\"" + value + "\""); } } - + protected String extractValue (Metadata metadata, String name) { String value = sdcCsarHelper.getMetadataPropertyValue(metadata, name); if (value != null) { return value; } else { return ""; - } + } } public static String extractValue (ISdcCsarHelper sdcCsarHelper, Metadata metadata, String name) { @@ -130,7 +130,7 @@ public class SdncBaseModel { return value; } else { return ""; - } + } } protected String extractValue (NodeTemplate nodeTemplate, String name) { @@ -241,19 +241,19 @@ public class SdncBaseModel { public void setCustomizationUUID(String customizationUUID) { this.customizationUUID = customizationUUID; } - + public String getSql(String tableName, String model_yaml) { - + StringBuilder sb = new StringBuilder(); sb.append("INSERT into " + tableName + " (customization_uuid, model_yaml, "); - + int paramCount = 0; for (String paramKey : params.keySet()) { paramCount++; sb.append(paramKey); if (paramCount < params.size()) sb.append(", "); } - + sb.append(") values (" + getCustomizationUUID() + ", \"" + model_yaml + "\", "); paramCount = 0; @@ -267,19 +267,19 @@ public class SdncBaseModel { sb.append(");"); return sb.toString(); } - + public static String getSql(String tableName, String keyName, String keyValue, String model_yaml, Map params) { - + StringBuilder sb = new StringBuilder(); sb.append("INSERT into " + tableName + " (" + keyName + ", "); - + int paramCount = 0; for (String paramKey : params.keySet()) { paramCount++; sb.append(paramKey); if (paramCount < params.size()) sb.append(", "); } - + sb.append(") values (" + keyValue + ", "); paramCount = 0; @@ -293,5 +293,5 @@ public class SdncBaseModel { sb.append(");"); return sb.toString(); } - + } diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModel.java index 3df27be6e..d3fd16791 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModel.java @@ -23,7 +23,7 @@ package org.onap.ccsdk.sli.northbound.uebclient; import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; -import org.openecomp.sdc.toscaparser.api.Metadata; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java index f00d73724..b3c96d9d8 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java @@ -74,8 +74,8 @@ import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; import org.openecomp.sdc.toscaparser.api.Group; -import org.openecomp.sdc.toscaparser.api.Metadata; import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.openecomp.sdc.utils.ArtifactTypeEnum; import org.openecomp.sdc.utils.DistributionActionResultEnum; import org.openecomp.sdc.utils.DistributionStatusEnum; @@ -238,6 +238,8 @@ public class SdncUebCallback implements INotificationCallback { File incomingDir = null; File archiveDir = null; + LOG.debug("IncomingDirName is {}", incomingDirName); + // Process service level artifacts List artifactList = data.getServiceArtifacts(); @@ -298,12 +300,15 @@ public class SdncUebCallback implements INotificationCallback { public void deployDownloadedFiles(File incomingDir, File archiveDir, INotificationData data) { if (incomingDir == null) { + LOG.debug("incomingDir is null - using {}", config.getIncomingDir()); incomingDir = new File(config.getIncomingDir()); if (!incomingDir.exists()) { incomingDir.mkdirs(); } + } else { + LOG.debug("incomingDir is not null - it is {}", incomingDir.getPath()); } if (archiveDir == null) { @@ -315,6 +320,7 @@ public class SdncUebCallback implements INotificationCallback { } String curFileName = ""; + LOG.debug("Scanning {} - {} for downloaded files", incomingDir.getPath(), incomingDir.toPath()); try (DirectoryStream stream = Files.newDirectoryStream(incomingDir.toPath())) { for (Path file: stream) { curFileName = file.toString(); @@ -533,7 +539,6 @@ public class SdncUebCallback implements INotificationCallback { sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath()); } catch (SdcToscaParserException e) { LOG.error("Could not create SDC TOSCA Parser ", e); - factory.close(); return; } @@ -550,7 +555,6 @@ public class SdncUebCallback implements INotificationCallback { insertToscaData(serviceModel.getSql(model_yaml)); } catch (IOException e) { LOG.error("Could not insert Tosca YAML data into the SERVICE_MODEL table ", e); - factory.close(); return; } @@ -693,7 +697,7 @@ public class SdncUebCallback implements INotificationCallback { //String extcp_subnetpool_id = "\"" + SdncBaseModel.extractValue(sdcCsarHelper, match.getLeft(), SdcPropertyNames.PROPERTY_NAME_SUBNETPOOLID) + "\""; // need path to subnetpoolid // extract values from the right "VFC" Node - String vfcCustomizationUuid = "\"" + SdncBaseModel.extractValue(sdcCsarHelper, match.getRight().getMetadata(), "customization_uuid") + "\""; + String vfcCustomizationUuid = "\"" + SdncBaseModel.extractValue(sdcCsarHelper, match.getRight().getMetaData(), "customization_uuid") + "\""; SdncBaseModel.addParameter("vm_type", SdncBaseModel.extractValue(sdcCsarHelper, match.getRight(), SdcPropertyNames.PROPERTY_NAME_VMTYPE), mappingParams); SdncBaseModel.addIntParameter("ipv4_count", SdncBaseModel.extractValue(sdcCsarHelper, match.getRight(), SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_MINSUBNETSCOUNT), mappingParams); SdncBaseModel.addIntParameter("ipv6_count", SdncBaseModel.extractValue(sdcCsarHelper, match.getRight(), SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_MINSUBNETSCOUNT), mappingParams); @@ -712,8 +716,7 @@ public class SdncUebCallback implements INotificationCallback { } // VF loop - // Close ASDC TOSCA Parser factory - we are done processing this distribution - factory.close(); + if ((artifact != null) && (data != null)) { LOG.info("Update to SDN-C succeeded"); diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java index d97abacbd..b49a66070 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.Properties; import org.openecomp.sdc.api.consumer.IConfiguration; -import org.openecomp.sdc.utils.ArtifactTypeEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -162,16 +161,8 @@ public class SdncUebConfiguration implements IConfiguration{ relevantArtifactTypes = new LinkedList<>(); for (String artifactType : artifactTypes) { - try { - if (ArtifactTypeEnum.valueOf(artifactType) != null) { - relevantArtifactTypes.add(artifactType); - } else { - LOG.warn("Skipping unrecognized artifact type {}", artifactType); - } - } catch (Exception e) { - LOG.warn("Caught exception validating artifact type {}", artifactType, e); - } + relevantArtifactTypes.add(artifactType); } @@ -282,7 +273,11 @@ public class SdncUebConfiguration implements IConfiguration{ @Override public boolean isFilterInEmptyResources() { - // TODO Auto-generated method stub + return false; + } + + @Override + public Boolean isUseHttpsWithDmaap() { return false; } diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java index deed20cf4..fd71527de 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java @@ -8,9 +8,9 @@ * 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. @@ -23,13 +23,13 @@ package org.onap.ccsdk.sli.northbound.uebclient; import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; -import org.openecomp.sdc.toscaparser.api.Metadata; import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SdncVFModel extends SdncBaseModel { - + private static final Logger LOG = LoggerFactory .getLogger(SdncVFModel.class); @@ -38,11 +38,11 @@ public class SdncVFModel extends SdncBaseModel { super(sdcCsarHelper, nodeTemplate); // extract metadata - Metadata metadata = nodeTemplate.getMetadata(); + Metadata metadata = nodeTemplate.getMetaData(); addParameter("name", extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_NAME)); - addParameter("vendor", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDOR)); - addParameter("vendor_version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDORRELEASE)); - + addParameter("vendor", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDOR)); + addParameter("vendor_version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDORRELEASE)); + // extract properties addParameter("ecomp_generated_naming", extractBooleanValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VNFECOMPNAMING_ECOMPGENERATEDNAMING)); addParameter("naming_policy", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VNFECOMPNAMING_NAMINGPOLICY)); diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java index 93fadc989..609d12011 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java @@ -1,15 +1,25 @@ package org.onap.ccsdk.sli.northbound.uebclient; -import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +import java.io.File; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.api.IDistributionClient; import org.openecomp.sdc.api.notification.INotificationData; - -import static org.mockito.Mockito.mock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestSdncUebCallback { + + private static final Logger LOG = LoggerFactory + .getLogger(TestSdncUebCallback.class); SdncUebConfiguration config; @Before @@ -17,6 +27,25 @@ public class TestSdncUebCallback { config = new SdncUebConfiguration("src/test/resources"); } + @After + public void tearDown() throws Exception { + // Move anything in archive back to incoming + String curFileName = ""; + + Path incomingPath = new File(config.getIncomingDir()).toPath(); + File archiveDir = new File(config.getArchiveDir()); + try (DirectoryStream stream = Files.newDirectoryStream(archiveDir.toPath())) { + for (Path file: stream) { + Files.move(file, incomingPath.resolve(file.getFileName()), StandardCopyOption.REPLACE_EXISTING); + } + } catch (Exception x) { + // IOException can never be thrown by the iteration. + // In this snippet, it can only be thrown by newDirectoryStream. + LOG.warn("Cannot replace spool file {}", curFileName, x); + } + + } + @Test public void test() { diff --git a/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar b/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar new file mode 100644 index 000000000..329076a15 Binary files /dev/null and b/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar differ diff --git a/ueb-listener/src/test/resources/log4j.properties b/ueb-listener/src/test/resources/log4j.properties new file mode 100644 index 000000000..71849c3db --- /dev/null +++ b/ueb-listener/src/test/resources/log4j.properties @@ -0,0 +1,30 @@ +### +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights +# reserved. +# ================================================================================ +# 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========================================================= +### + +log4j.rootLogger=DEBUG,CONSOLE + +# CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.Threshold=DEBUG +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n + + diff --git a/ueb-listener/src/test/resources/ueb-listener.properties b/ueb-listener/src/test/resources/ueb-listener.properties index 7855b2116..548cc4c45 100755 --- a/ueb-listener/src/test/resources/ueb-listener.properties +++ b/ueb-listener/src/test/resources/ueb-listener.properties @@ -1,19 +1,19 @@ -org.openecomp.sdnc.uebclient.asdc-address=localhost:1234 -org.openecomp.sdnc.uebclient.consumer-group=ccsdk1 -org.openecomp.sdnc.uebclient.consumer-id=localhost_ccsdk1 -org.openecomp.sdnc.uebclient.environment-name=UNITTEST -org.openecomp.sdnc.uebclient.password=123456 -org.openecomp.sdnc.uebclient.user=test -org.openecomp.sdnc.uebclient.sdnc-user=test -org.openecomp.sdnc.uebclient.sdnc-passwd=test -org.openecomp.sdnc.uebclient.asdc-api-base-url=http://localhost:8282/restconf/operations/ -org.openecomp.sdnc.uebclient.asdc-api-namespace=org:onap:ccsdk -org.openecomp.sdnc.uebclient.spool.incoming=src/test/resources/incoming -org.openecomp.sdnc.uebclient.spool.archive=src/test/resources/archive -org.openecomp.sdnc.uebclient.polling-interval=30 -org.openecomp.sdnc.uebclient.polling-timeout=15 -org.openecomp.sdnc.uebclient.relevant-artifact-types=YANG_XML,VF_LICENSE,TOSCA_TEMPLATE,TOSCA_CSAR,UCPE_LAYER_2_CONFIGURATION -org.openecomp.sdnc.uebclient.activate-server-tls-auth=false -org.openecomp.sdnc.uebclient.keystore-path= -org.openecomp.sdnc.uebclient.keystore-password= -org.openecomp.sdnc.uebclient.xslt-path-list=src/main/resources/removeNs.xslt,src/main/resources/normalizeTagNames.xslt +org.onap.ccsdk.sli.northbound.uebclient.asdc-address=localhost:1234 +org.onap.ccsdk.sli.northbound.uebclient.consumer-group=ccsdk1 +org.onap.ccsdk.sli.northbound.uebclient.consumer-id=localhost_ccsdk1 +org.onap.ccsdk.sli.northbound.uebclient.environment-name=UNITTEST +org.onap.ccsdk.sli.northbound.uebclient.password=123456 +org.onap.ccsdk.sli.northbound.uebclient.user=test +org.onap.ccsdk.sli.northbound.uebclient.sdnc-user=test +org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd=test +org.onap.ccsdk.sli.northbound.uebclient.asdc-api-base-url=http://localhost:8282/restconf/operations/ +org.onap.ccsdk.sli.northbound.uebclient.asdc-api-namespace=org:onap:ccsdk +org.onap.ccsdk.sli.northbound.uebclient.spool.incoming=src/test/resources/incoming +org.onap.ccsdk.sli.northbound.uebclient.spool.archive=src/test/resources/archive +org.onap.ccsdk.sli.northbound.uebclient.polling-interval=30 +org.onap.ccsdk.sli.northbound.uebclient.polling-timeout=15 +org.onap.ccsdk.sli.northbound.uebclient.relevant-artifact-types=YANG_XML,VF_LICENSE,TOSCA_TEMPLATE,TOSCA_CSAR,UCPE_LAYER_2_CONFIGURATION +org.onap.ccsdk.sli.northbound.uebclient.activate-server-tls-auth=false +org.onap.ccsdk.sli.northbound.uebclient.keystore-path= +org.onap.ccsdk.sli.northbound.uebclient.keystore-password= +org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list= \ No newline at end of file -- cgit 1.2.3-korg From 10b6a72f544dd1331e9dba53e77c61deaafbd19f Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 22 Feb 2018 17:22:31 -0600 Subject: Nitrogen port: sli/northbound Update sli/northbound to compile for ODL Nitrogen Change-Id: Ib14fea5dd3922175bd183afb9f3c85edaa7a2f0c Issue-ID: CCSDK-177 Signed-off-by: Dan Timoney --- asdcApi/features/ccsdk-asdcApi/pom.xml | 47 ++++ asdcApi/features/features-asdcApi/pom.xml | 29 +++ asdcApi/features/pom.xml | 150 ++---------- asdcApi/features/src/main/resources/features.xml | 38 --- asdcApi/installer/pom.xml | 32 ++- .../src/main/resources/scripts/install-feature.sh | 9 +- asdcApi/model/pom.xml | 84 +------ asdcApi/pom.xml | 48 +--- asdcApi/provider/pom.xml | 46 ++-- .../sli/northbound/asdcapi/TestAsdcApiApi.java | 9 +- dataChange/features/ccsdk-dataChange/pom.xml | 47 ++++ dataChange/features/features-dataChange/pom.xml | 29 +++ dataChange/features/pom.xml | 150 ++---------- .../features/src/main/resources/features.xml | 36 --- dataChange/installer/pom.xml | 264 +++++++++++---------- .../src/main/resources/scripts/install-feature.sh | 9 +- dataChange/model/pom.xml | 84 +------ dataChange/pom.xml | 46 +--- dataChange/provider/pom.xml | 177 ++++++-------- .../src/main/yang/DataChange-provider-impl.yang | 65 ----- dmaap-listener/pom.xml | 254 ++++++++++---------- pom.xml | 22 +- ueb-listener/pom.xml | 25 +- version.properties | 2 +- 24 files changed, 656 insertions(+), 1046 deletions(-) create mode 100644 asdcApi/features/ccsdk-asdcApi/pom.xml create mode 100644 asdcApi/features/features-asdcApi/pom.xml delete mode 100644 asdcApi/features/src/main/resources/features.xml create mode 100644 dataChange/features/ccsdk-dataChange/pom.xml create mode 100644 dataChange/features/features-dataChange/pom.xml delete mode 100644 dataChange/features/src/main/resources/features.xml delete mode 100755 dataChange/provider/src/main/yang/DataChange-provider-impl.yang (limited to 'asdcApi/provider/src/test/java') diff --git a/asdcApi/features/ccsdk-asdcApi/pom.xml b/asdcApi/features/ccsdk-asdcApi/pom.xml new file mode 100644 index 000000000..061e5edc8 --- /dev/null +++ b/asdcApi/features/ccsdk-asdcApi/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + ccsdk-asdcApi + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-northbound :: asdcApi :: ${project.artifactId} + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + asdcApi-model + ${project.version} + + + ${project.groupId} + asdcApi-provider + ${project.version} + + + + diff --git a/asdcApi/features/features-asdcApi/pom.xml b/asdcApi/features/features-asdcApi/pom.xml new file mode 100644 index 000000000..2ac8f59d8 --- /dev/null +++ b/asdcApi/features/features-asdcApi/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + features-asdcApi + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-northbound :: asdcApi :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-asdcApi + ${project.version} + xml + features + + + + diff --git a/asdcApi/features/pom.xml b/asdcApi/features/pom.xml index 73cc0dd12..5b940021c 100755 --- a/asdcApi/features/pom.xml +++ b/asdcApi/features/pom.xml @@ -1,131 +1,23 @@ - - 4.0.0 - - asdcApi - org.onap.ccsdk.sli.northbound - 0.2.0-SNAPSHOT - - asdcApi-features - - jar - - - - org.onap.ccsdk.sli.northbound - asdcApi-model - ${project.version} - - - org.onap.ccsdk.sli.northbound - asdcApi-provider - ${project.version} - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - - runtime - - - - - - - org.opendaylight.controller - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - - org.opendaylight.odlparent - features-test - test - ${odl.commons.opendaylight.version} - - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.northbound + asdcApi-features + 0.2.1-SNAPSHOT + pom + + ccsdk-sli-northbound :: asdcApi :: ${project.artifactId} + + + ccsdk-asdcApi + features-asdcApi + diff --git a/asdcApi/features/src/main/resources/features.xml b/asdcApi/features/src/main/resources/features.xml deleted file mode 100644 index 0f7fe3b8d..000000000 --- a/asdcApi/features/src/main/resources/features.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - odl-mdsal-broker - - mvn:org.onap.ccsdk.sli.northbound/asdcApi-model/${project.version} - mvn:org.onap.ccsdk.sli.northbound/asdcApi-provider/${project.version} - - sdnc-sli - - - diff --git a/asdcApi/installer/pom.xml b/asdcApi/installer/pom.xml index 1b7666935..aac236bde 100755 --- a/asdcApi/installer/pom.xml +++ b/asdcApi/installer/pom.xml @@ -1,19 +1,25 @@ 4.0.0 + - asdcApi - org.onap.ccsdk.sli.northbound - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.northbound asdcApi-installer - asdcApi - Karaf Installer + 0.2.1-SNAPSHOT pom + ccsdk-sli-northbound :: asdcApi :: ${project.artifactId} + - sdnc-asdcApi - sdnc-asdcApi - mvn:org.onap.ccsdk.sli.northbound/asdcApi-features/${project.version}/xml/features + ccsdk-asdcApi + ${application.name} + mvn:org.onap.ccsdk.sli.northbound/${features.boot}/${project.version}/xml/features false @@ -21,10 +27,10 @@ org.onap.ccsdk.sli.northbound - asdcApi-features + ${application.name} ${project.version} - features xml + features * @@ -32,7 +38,11 @@ - + + org.onap.ccsdk.sli.northbound + asdcApi-model + ${project.version} + org.onap.ccsdk.sli.northbound asdcApi-provider @@ -100,7 +110,6 @@ false false org.onap.ccsdk.sli.northbound - sli-common,sli-provider,dblib-provider provided @@ -135,5 +144,4 @@ - diff --git a/asdcApi/installer/src/main/resources/scripts/install-feature.sh b/asdcApi/installer/src/main/resources/scripts/install-feature.sh index e986764b9..cee4a4952 100644 --- a/asdcApi/installer/src/main/resources/scripts/install-feature.sh +++ b/asdcApi/installer/src/main/resources/scripts/install-feature.sh @@ -10,9 +10,9 @@ # 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. @@ -23,7 +23,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -36,5 +35,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/asdcApi/model/pom.xml b/asdcApi/model/pom.xml index a3b94f54f..27e5905b9 100755 --- a/asdcApi/model/pom.xml +++ b/asdcApi/model/pom.xml @@ -1,92 +1,32 @@ - + 4.0.0 + - asdcApi - org.onap.ccsdk.sli.northbound - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + org.onap.ccsdk.sli.northbound asdcApi-model - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT bundle - + ccsdk-sli-northbound :: asdcApi :: ${project.artifactId} - - - org.apache.felix - maven-bundle-plugin - true - - - * - - - - - org.opendaylight.yangtools - yang-maven-plugin - ${odl.yangtools.yang.maven.plugin.version} - - - org.opendaylight.mdsal - maven-sal-api-gen-plugin - ${odl.sal.api.gen.plugin.version} - jar - - - org.opendaylight.netconf - sal-rest-docgen-maven - ${odl.restconf.version} - jar - - - - - - generate-sources - - - ${yang.file.directory} - - - org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl - ${salGeneratorPath} - - - org.opendaylight.netconf.sal.rest.doc.maven.StaticDocGenerator - target/swagger - - - true - - - - - - - - org.opendaylight.mdsal - yang-binding - ${odl.mdsal.yang.binding.version} - - - org.opendaylight.yangtools - yang-common - ${odl.yangtools.version} - + org.opendaylight.mdsal.model ietf-inet-types - ${odl.ietf-inet-types.version} org.opendaylight.mdsal.model ietf-yang-types - ${odl.ietf-yang-types.version} + + diff --git a/asdcApi/pom.xml b/asdcApi/pom.xml index 932569b09..78c2fcb6b 100755 --- a/asdcApi/pom.xml +++ b/asdcApi/pom.xml @@ -1,51 +1,20 @@ - + 4.0.0 - org.onap.ccsdk.sli.northbound - ccsdk-sli-northbound - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - pom org.onap.ccsdk.sli.northbound asdcApi - 0.2.0-SNAPSHOT - - - asdcApi - - - - - - - org.onap.ccsdk.sli.northbound - asdcApi-features - features - xml - ${project.version} - - - - org.onap.ccsdk.sli.northbound - asdcApi-model - ${project.version} - - - - org.onap.ccsdk.sli.northbound - asdcApi-provider - ${project.version} - - - - - - - + 0.2.1-SNAPSHOT + pom + ccsdk-sli-northbound :: asdcApi model @@ -54,4 +23,5 @@ installer + diff --git a/asdcApi/provider/pom.xml b/asdcApi/provider/pom.xml index 9382b9d8a..3f33af028 100755 --- a/asdcApi/provider/pom.xml +++ b/asdcApi/provider/pom.xml @@ -1,23 +1,22 @@ - + 4.0.0 + - asdcApi - org.onap.ccsdk.sli.northbound - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.northbound asdcApi-provider + 0.2.1-SNAPSHOT bundle - - - - org.apache.felix - maven-bundle-plugin - true - - - + ccsdk-sli-northbound :: asdcApi :: ${project.artifactId} + @@ -25,60 +24,49 @@ asdcApi-model ${project.version} - - org.opendaylight.controller - config-api - ${odl.controller.config.api.version} - org.opendaylight.controller sal-binding-config - ${odl.mdsal.version} + org.opendaylight.controller sal-binding-api - ${odl.mdsal.version} + org.opendaylight.controller sal-common-util - ${odl.mdsal.version} + org.onap.ccsdk.sli.core sli-common - ${sdnctl.sli.version} org.onap.ccsdk.sli.core sli-provider - ${sdnctl.sli.version} org.opendaylight.controller sal-test-model - ${odl.mdsal.version} test org.opendaylight.netconf sal-rest-connector - ${odl.mdsal.version} test org.opendaylight.controller sal-binding-broker-impl - ${odl.mdsal.version} test org.opendaylight.controller sal-binding-broker-impl - ${odl.mdsal.version} test-jar tests test @@ -86,21 +74,19 @@ junit junit - ${junit.version} test org.testng testng - 6.11 test org.mockito mockito-core - ${mockito.version} test + diff --git a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java index f65bbc045..6ad9a829f 100644 --- a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java +++ b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java @@ -21,10 +21,12 @@ package org.onap.ccsdk.sli.northbound.asdcapi; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; import org.junit.Before; import org.junit.Test; -import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiProvider; -import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiSliClient; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; @@ -35,9 +37,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { private AsdcApiProvider asdcApiProvider; diff --git a/dataChange/features/ccsdk-dataChange/pom.xml b/dataChange/features/ccsdk-dataChange/pom.xml new file mode 100644 index 000000000..5d38e33c2 --- /dev/null +++ b/dataChange/features/ccsdk-dataChange/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + ccsdk-dataChange + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-northbound :: dataChange :: ${project.artifactId} + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + dataChange-model + ${project.version} + + + ${project.groupId} + dataChange-provider + ${project.version} + + + + diff --git a/dataChange/features/features-dataChange/pom.xml b/dataChange/features/features-dataChange/pom.xml new file mode 100644 index 000000000..470f95bde --- /dev/null +++ b/dataChange/features/features-dataChange/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + features-dataChange + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-northbound :: dataChange :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-dataChange + ${project.version} + xml + features + + + + diff --git a/dataChange/features/pom.xml b/dataChange/features/pom.xml index 93dbd0554..c32e72ce7 100755 --- a/dataChange/features/pom.xml +++ b/dataChange/features/pom.xml @@ -1,130 +1,24 @@ - - 4.0.0 - - dataChange - org.onap.ccsdk.sli.northbound - 0.2.0-SNAPSHOT - - org.onap.ccsdk.sli.northbound - dataChange-features - 0.2.0-SNAPSHOT - - jar - - - - org.onap.ccsdk.sli.northbound - dataChange-model - - - org.onap.ccsdk.sli.northbound - dataChange-provider - - - - org.opendaylight.mdsal - features-mdsal - features - ${odl.mdsal.features.version} - xml - - runtime - - - - - - - org.opendaylight.controller - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - - org.opendaylight.odlparent - features-test - test - ${odl.commons.opendaylight.version} - - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + dataChange-features + 0.2.1-SNAPSHOT + pom + + ccsdk-sli-northbound :: dataChange :: ${project.artifactId} + + + ccsdk-dataChange + features-dataChange + diff --git a/dataChange/features/src/main/resources/features.xml b/dataChange/features/src/main/resources/features.xml deleted file mode 100644 index bd090f1cc..000000000 --- a/dataChange/features/src/main/resources/features.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - odl-mdsal-broker - sdnc-sli - mvn:org.onap.ccsdk.sli.northbound/dataChange-model/${project.version} - mvn:org.onap.ccsdk.sli.northbound/dataChange-provider/${project.version} - - - diff --git a/dataChange/installer/pom.xml b/dataChange/installer/pom.xml index 31623ba13..f67669931 100755 --- a/dataChange/installer/pom.xml +++ b/dataChange/installer/pom.xml @@ -1,139 +1,149 @@ - - 4.0.0 - - dataChange - org.onap.ccsdk.sli.northbound - 0.2.0-SNAPSHOT - - dataChange-installer - dataChange - Karaf Installer - pom + + 4.0.0 - - sdnc-dataChange - sdnc-dataChange - mvn:org.onap.ccsdk.sli.northbound/dataChange-features/${project.version}/xml/features - false - + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + - + org.onap.ccsdk.sli.northbound + dataChange-installer + 0.2.1-SNAPSHOT + pom - - org.onap.ccsdk.sli.northbound - dataChange-features - ${project.version} - features - xml - - - * - * - - - + ccsdk-sli-northbound :: dataChange :: ${project.artifactId} - - org.onap.ccsdk.sli.northbound - dataChange-provider - ${project.version} - + + ccsdk-dataChange + ${application.name} + mvn:org.onap.ccsdk.sli.northbound/${features.boot}/${project.version}/xml/features + false + + - + + org.onap.ccsdk.sli.northbound + ${application.name} + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.northbound + dataChange-model + ${project.version} + - - - - maven-assembly-plugin - 2.6 - - - maven-repo-zip - - single - - package - - false - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - false - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli.northbound - sli-common,sli-provider,dblib-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + org.onap.ccsdk.sli.northbound + dataChange-provider + ${project.version} + - - - - + + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.northbound + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + diff --git a/dataChange/installer/src/main/resources/scripts/install-feature.sh b/dataChange/installer/src/main/resources/scripts/install-feature.sh index e986764b9..cee4a4952 100644 --- a/dataChange/installer/src/main/resources/scripts/install-feature.sh +++ b/dataChange/installer/src/main/resources/scripts/install-feature.sh @@ -10,9 +10,9 @@ # 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. @@ -23,7 +23,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -36,5 +35,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/dataChange/model/pom.xml b/dataChange/model/pom.xml index c3d6d6b5c..2b3851690 100755 --- a/dataChange/model/pom.xml +++ b/dataChange/model/pom.xml @@ -1,93 +1,31 @@ - + 4.0.0 + - dataChange - org.onap.ccsdk.sli.northbound - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + org.onap.ccsdk.sli.northbound dataChange-model - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT bundle - - - - - org.apache.felix - maven-bundle-plugin - true - - - * - - - - - org.opendaylight.yangtools - yang-maven-plugin - ${odl.yangtools.yang.maven.plugin.version} - - - org.opendaylight.mdsal - maven-sal-api-gen-plugin - ${odl.sal.api.gen.plugin.version} - jar - - - org.opendaylight.netconf - sal-rest-docgen-maven - ${odl.restconf.version} - jar - - - - - - generate-sources - - - ${yang.file.directory} - - - org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl - ${salGeneratorPath} - - - org.opendaylight.netconf.sal.rest.doc.maven.StaticDocGenerator - target/swagger - - - true - - - - - - + ccsdk-sli-northbound :: dataChange :: ${project.artifactId} - - org.opendaylight.mdsal - yang-binding - ${odl.mdsal.yang.binding.version} - - - org.opendaylight.yangtools - yang-common - ${odl.yangtools.version} - org.opendaylight.mdsal.model ietf-inet-types - ${odl.ietf-inet-types.version} org.opendaylight.mdsal.model ietf-yang-types - ${odl.ietf-yang-types.version} + + diff --git a/dataChange/pom.xml b/dataChange/pom.xml index f0bbf6eb3..cd1cd9683 100755 --- a/dataChange/pom.xml +++ b/dataChange/pom.xml @@ -1,52 +1,26 @@ - + 4.0.0 - org.onap.ccsdk.sli.northbound - ccsdk-sli-northbound - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - pom org.onap.ccsdk.sli.northbound dataChange - 0.2.0-SNAPSHOT - - - dataChange - - - - - - - org.onap.ccsdk.sli.northbound - dataChange-features - features - xml - ${project.version} - - - - org.onap.ccsdk.sli.northbound - dataChange-model - ${project.version} - - - org.onap.ccsdk.sli.northbound - dataChange-provider - ${project.version} - - - + 0.2.1-SNAPSHOT + pom - + ccsdk-sli-northbound :: dataChange - + model features provider installer + diff --git a/dataChange/provider/pom.xml b/dataChange/provider/pom.xml index 7d35817ef..1722912ce 100755 --- a/dataChange/provider/pom.xml +++ b/dataChange/provider/pom.xml @@ -1,105 +1,86 @@ - - 4.0.0 - - dataChange - org.onap.ccsdk.sli.northbound - 0.2.0-SNAPSHOT - - dataChange-provider - bundle + + 4.0.0 - - - - org.apache.felix - maven-bundle-plugin - true - - - + + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + - - - org.onap.ccsdk.sli.northbound - dataChange-model - - - org.opendaylight.controller - config-api + org.onap.ccsdk.sli.northbound + dataChange-provider + 0.2.1-SNAPSHOT + bundle - ${odl.controller.config.api.version} - - - org.opendaylight.controller - sal-binding-config - ${odl.mdsal.version} - - - org.opendaylight.controller - sal-binding-api - ${odl.mdsal.version} - - - org.opendaylight.controller - sal-common-util - ${odl.mdsal.version} - - - org.onap.ccsdk.sli.core - sli-common - ${sdnctl.sli.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${sdnctl.sli.version} - + ccsdk-sli-northbound :: dataChange :: ${project.artifactId} + + + + org.onap.ccsdk.sli.northbound + dataChange-model + ${project.version} + + + org.opendaylight.controller + sal-binding-config + + + + org.opendaylight.controller + sal-binding-api + + + org.onap.ccsdk.sli.core + sli-common + + + org.onap.ccsdk.sli.core + sli-provider + + + + org.opendaylight.controller + sal-test-model + test + + + org.opendaylight.netconf + sal-rest-connector + test + + + + org.opendaylight.controller + sal-binding-broker-impl + test + + + org.opendaylight.controller + sal-binding-broker-impl + test-jar + tests + test + + + junit + junit + test + + + org.testng + testng + 6.11 + test + + + org.mockito + mockito-core + test + + - - org.opendaylight.controller - sal-test-model - ${odl.mdsal.version} - test - - - org.opendaylight.netconf - sal-rest-connector - ${odl.mdsal.version} - test - - - org.opendaylight.controller - sal-binding-broker-impl - ${odl.mdsal.version} - test - - - org.opendaylight.controller - sal-binding-broker-impl - ${odl.mdsal.version} - test-jar - tests - test - - - junit - junit - ${junit.version} - test - - - org.testng - testng - 6.11 - test - - - org.mockito - mockito-core - ${mockito.version} - test - - diff --git a/dataChange/provider/src/main/yang/DataChange-provider-impl.yang b/dataChange/provider/src/main/yang/DataChange-provider-impl.yang deleted file mode 100755 index f7ca378b6..000000000 --- a/dataChange/provider/src/main/yang/DataChange-provider-impl.yang +++ /dev/null @@ -1,65 +0,0 @@ -module DataChange-provider-impl { - - yang-version 1; - namespace "org:onap:ccsdk:sli:northbound:datachange:provider:impl"; - prefix "DataChange-provider-impl"; - - import config { prefix config; revision-date 2013-04-05; } - import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } - import opendaylight-sal-binding-broker-impl { - prefix binding-impl; - revision-date 2013-10-28; - } - - description - "This module contains the base YANG definitions for - DataChange-provider impl implementation."; - - revision "2014-05-23" { - description - "Initial revision."; - } - - // This is the definition of the service implementation as a module identity. - identity DataChange-provider-impl { - base config:module-type; - - // Specifies the prefix for generated java classes. - config:java-name-prefix DataChangeProvider; - } - - // Augments the 'configuration' choice node under modules/module. - // We consume the three main services, RPCs, DataStore, and Notifications - augment "/config:modules/config:module/config:configuration" { - case DataChange-provider-impl { - when "/config:modules/config:module/config:type = 'DataChange-provider-impl'"; - - container rpc-registry { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-rpc-registry; - } - } - } - - container notification-publish-adapter { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity binding-impl:binding-new-notification-publish-service; - } - } - } - - container data-broker { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity mdsal:binding-async-data-broker; - } - } - } - } - } -} diff --git a/dmaap-listener/pom.xml b/dmaap-listener/pom.xml index 8705ff1aa..f6d04e247 100755 --- a/dmaap-listener/pom.xml +++ b/dmaap-listener/pom.xml @@ -1,140 +1,144 @@ - - 4.0.0 - org.onap.ccsdk.sli.northbound - jar - dmaap-listener - 0.2.0-SNAPSHOT + + 4.0.0 - DMAAP Listener - DMAAP Listener - - org.onap.ccsdk.sli.northbound - ccsdk-sli-northbound - 0.2.0-SNAPSHOT - - - 1.2.0-SNAPSHOT - 2.9.0.pr1 - true - /opt/app/dmaap-listener - 1.1.0-SNAPSHOT + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - yyMMdd-HHmmss - ${maven.build.timestamp} - ${project.version}-${build.number} - + org.onap.ccsdk.sli.northbound + dmaap-listener + 0.2.1-SNAPSHOT + jar - + ccsdk-sli-northbound :: dmaap-listener + DMAAP Listener - - org.onap.dmaap.messagerouter.dmaapclient - dmaapClient - ${dmaap.listener.version} - - - org.slf4j - slf4j-api - 1.7.21 - - - org.slf4j - slf4j-log4j12 - 1.6.1 - compile - - - log4j - log4j - 1.2.17 - - - com.fasterxml.jackson.core - jackson-core - ${fasterxml.jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - ${fasterxml.jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${fasterxml.jackson.version} - - - junit - junit - ${junit.version} - test - - + + 1.2.0-SNAPSHOT + 2.9.0.pr1 + true + /opt/app/dmaap-listener + 1.1.0-SNAPSHOT + + yyMMdd-HHmmss + ${maven.build.timestamp} + ${project.version}-${build.number} + + + + + + org.onap.dmaap.messagerouter.dmaapclient + dmaapClient + ${dmaap.listener.version} + + + org.slf4j + slf4j-api + 1.7.21 + + + org.slf4j + slf4j-log4j12 + 1.6.1 + compile + + + log4j + log4j + 1.2.17 + + + com.fasterxml.jackson.core + jackson-core + ${fasterxml.jackson.version} + + + com.fasterxml.jackson.core + jackson-databind + ${fasterxml.jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${fasterxml.jackson.version} + + + junit + junit + ${junit.version} + test + + ch.vorburger.mariaDB4j mariaDB4j 2.2.3 test - - org.onap.ccsdk.sli.core - dblib-provider - ${sdnctl.dblib.version} - - - - + + org.onap.ccsdk.sli.core + dblib-provider + ${sdnctl.dblib.version} + + - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - true - - 1.7 - 1.7 - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - - - true - org.onap.ccsdk.sli.northbound.dmaapclient.DmaapListener - - - - - - maven-assembly-plugin - 2.6 - - - create-zip - - single - - package - - true - ${project.artifactId}.${project.version} - true - - src/assembly/assemble_zip.xml - - false - - - - + + - - + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + true + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + + true + org.onap.ccsdk.sli.northbound.dmaapclient.DmaapListener + + + + + + maven-assembly-plugin + 2.6 + + + create-zip + + single + + package + + true + ${project.artifactId}.${project.version} + true + + src/assembly/assemble_zip.xml + + false + + + + + + diff --git a/pom.xml b/pom.xml index ded5f124b..63bcb6ead 100644 --- a/pom.xml +++ b/pom.xml @@ -3,8 +3,8 @@ org.onap.ccsdk.parent - odlparent-carbon-sr1 - 0.1.0 + odlparent-lite + 1.0.1-SNAPSHOT 4.0.0 @@ -13,32 +13,32 @@ ccsdk-sli-northbound ccsdk-sli-northbound - https://wiki.openecomp.org + https://wiki.onap.org The SDN-C Northbound APIs repo contains code for northbound API adaptors, typically MD-SAL applications JIRA - https://jira.openecomp.org/ + https://jira.onap.org/ - scm:git:ssh://git@${openecomp.git.host}/sdnc-northbound.git + scm:git:ssh://git@${onap.git.host}/sdnc-northbound.git - scm:git:ssh://${openecomp.git.host}:${openecomp.git.port}/${openecomp.git.project}/sdnc-northbound.git - ${openecomp.git.protocol}://${openecomp.git.host}/projects/${openecomp.git.project}/repos/sdnc-northbound/browse + scm:git:ssh://${onap.git.host}:${onap.git.port}/${onap.git.project}/sdnc-northbound.git + ${onap.git.protocol}://${onap.git.host}/projects/${onap.git.project}/repos/sdnc-northbound/browse Jenkins - https://jenkins.openecomp.org/ + https://jenkins.onap.org/ sdnc-javadoc - dav:https://${openecomp.nexus.host}:${openecomp.nexus.port}/repository/sdn-c-javadoc/${project.artifactId}/${project.version} + dav:https://${onap.nexus.host}:${onap.nexus.port}/repository/sdn-c-javadoc/${project.artifactId}/${project.version} @@ -110,9 +110,9 @@ ueb-listener - AT&T + ONAP - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT diff --git a/ueb-listener/pom.xml b/ueb-listener/pom.xml index 21173680a..b8ec986c1 100755 --- a/ueb-listener/pom.xml +++ b/ueb-listener/pom.xml @@ -1,18 +1,21 @@ 4.0.0 - org.onap.ccsdk.sli.northbound - jar - ueb-listener - 0.2.0-SNAPSHOT - UEB Listener - UEB Listener - org.onap.ccsdk.sli.northbound - ccsdk-sli-northbound - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + org.onap.ccsdk.sli.northbound + ueb-listener + 0.2.1-SNAPSHOT + jar + + ccsdk-sli-northbound :: ueb-listener + UEB Listener + 1.1.32 1.1.32 @@ -91,9 +94,10 @@ org.onap.ccsdk.sli.core dblib-provider - ${sdnctl.dblib.version} + ${sdnctl.dblib.version} + @@ -150,5 +154,4 @@ - diff --git a/version.properties b/version.properties index efb7e63bc..ebb19b8f6 100644 --- a/version.properties +++ b/version.properties @@ -5,7 +5,7 @@ release_name=0 sprint_number=2 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From c50170bc44f192a7c8e7efdfc773342d8b5c0437 Mon Sep 17 00:00:00 2001 From: Jeremy Wolf Date: Wed, 28 Mar 2018 17:22:09 +0000 Subject: coverage sli-northbound adding junit test files for AsdcApiSliClient, AsdcApiUtil, DataChangeClient, SdncFlatJsonDmaapConsumer, SdncARModel, SdncNodeModel, SdncVFCModel, SdncVFModuleModel, SdncUebCallback Change-Id: Ia7fb307b84957292f9080654c7ae31992434317f Issue-ID: CCSDK-230 Signed-off-by: Jeremy Wolf --- .../northbound/asdcapi/AsdcApiSliClientTest.java | 59 ++++++++++++++++ .../sli/northbound/asdcapi/AsdcApiUtilTest.java | 15 ++++ .../dataChange/DataChangeClientTest.java | 56 +++++++++++++++ .../dmaapclient/SdncFlatJsonDmaapConsumerTest.java | 41 +++++++++++ .../sli/northbound/uebclient/SdncARModelTest.java | 21 ++++++ .../northbound/uebclient/SdncNodeModelTest.java | 49 +++++++++++++ .../sli/northbound/uebclient/SdncVFCModelTest.java | 36 ++++++++++ .../uebclient/SdncVFModuleModelTest.java | 20 ++++++ .../northbound/uebclient/TestSdncUebCallback.java | 82 +++++++++++++++++++++- 9 files changed, 378 insertions(+), 1 deletion(-) create mode 100644 asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClientTest.java create mode 100644 asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtilTest.java create mode 100644 dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java create mode 100644 dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncFlatJsonDmaapConsumerTest.java create mode 100644 ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java create mode 100644 ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java create mode 100644 ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java create mode 100644 ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java (limited to 'asdcApi/provider/src/test/java') diff --git a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClientTest.java b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClientTest.java new file mode 100644 index 000000000..5e6a9daf7 --- /dev/null +++ b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClientTest.java @@ -0,0 +1,59 @@ +package org.onap.ccsdk.sli.northbound.asdcapi; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; + +public class AsdcApiSliClientTest { + Properties mockProp; + Properties propReturn; + AsdcApiSliClient testAsdcApiSliClient; + + @Before + public void setup() { + SvcLogicService mockSvcLogic = mock(SvcLogicService.class); + mockProp = new Properties(); + mockProp.setProperty("test-value1", "value1"); + propReturn = new Properties(); + propReturn.setProperty("SvcLogic.status", "Success"); + propReturn.setProperty("Object1", "value1"); + try { + when(mockSvcLogic.hasGraph("TestModule", "TestRPC", "TestVersion", "TestMode")).thenReturn(true); + when(mockSvcLogic.hasGraph("NotExist", "TestRPC", "TestVersion", "TestMode")).thenReturn(false); + when(mockSvcLogic.execute("TestModule", "TestRPC", "TestVersion", "TestMode", mockProp)).thenReturn(propReturn); + } catch (Exception e) { + System.out.println(e); + } + + testAsdcApiSliClient = new AsdcApiSliClient(mockSvcLogic); + } + + @Test + public void testhasGraphGraphExsists() throws SvcLogicException { + assertTrue(testAsdcApiSliClient.hasGraph("TestModule", "TestRPC", "TestVersion", "TestMode")); + } + + @Test + public void testhasGraphnoGraph() throws SvcLogicException { + assertFalse(testAsdcApiSliClient.hasGraph("NotExist", "TestRPC", "TestVersion", "TestMode")); + } + + @Test + public void testExecutewithSvcLogicSuccess() throws SvcLogicException { + Properties result = testAsdcApiSliClient.execute("TestModule", "TestRPC", "TestVersion", "TestMode", mockProp); + assertEquals(result.getProperty("error-code"), "200"); + } + + @Test + public void testExecutewithSvcLogicFailure500() throws SvcLogicException { + propReturn.setProperty("SvcLogic.status", "failure"); + Properties result = testAsdcApiSliClient.execute("TestModule", "TestRPC", "TestVersion", "TestMode", mockProp); + assertEquals(result.getProperty("error-code"), "500"); + } +} \ No newline at end of file diff --git a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtilTest.java b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtilTest.java new file mode 100644 index 000000000..463e5ea0b --- /dev/null +++ b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtilTest.java @@ -0,0 +1,15 @@ +package org.onap.ccsdk.sli.northbound.asdcapi; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class AsdcApiUtilTest { + + @Test + public void testAsdcApiUtilConstructor() { + AsdcApiUtil asdcApiUtilTest = new AsdcApiUtil(); + assertNotNull(asdcApiUtilTest); + } + +} \ No newline at end of file diff --git a/dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java b/dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java new file mode 100644 index 000000000..9ba6c8742 --- /dev/null +++ b/dataChange/provider/src/test/java/org/onap/sdnc/northbound/dataChange/DataChangeClientTest.java @@ -0,0 +1,56 @@ +package org.onap.sdnc.northbound.dataChange; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.onap.ccsdk.sli.northbound.DataChangeClient; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.rev150519.DataChangeNotificationOutputBuilder; + +public class DataChangeClientTest { + + SvcLogicService mockSvcLogicService; + String module = "test-module"; + String rpc = "test-rpc"; + String version = "test-version"; + String mode = "test-mode"; + Properties localProp = new Properties(); + + @Before + public void setUp() throws Exception { + mockSvcLogicService = mock(SvcLogicService.class); + when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true); + } + + @Test + public void testDataChangeClientConstructor() { + DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService); + assertNotNull(dataChangeClient); + } + + @Test + public void testHasGraph() throws SvcLogicException { + DataChangeClient dataChangeClient = new DataChangeClient(mockSvcLogicService); + boolean result = dataChangeClient.hasGraph(module, rpc, version, mode); + assertTrue(result); + } + + @Test + public void testExecuteSvcLogicStatusFailure() throws SvcLogicException { + DataChangeNotificationOutputBuilder serviceData = mock(DataChangeNotificationOutputBuilder.class); + Properties parms = mock(Properties.class); + SvcLogicService svcLogicService = mock(SvcLogicService.class); + Properties properties = new Properties(); + properties.setProperty("SvcLogic.status", "failure"); + when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties); + DataChangeClient sliClient = new DataChangeClient(svcLogicService); + Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties); + assertTrue(prop != null); + } +} \ No newline at end of file diff --git a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncFlatJsonDmaapConsumerTest.java b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncFlatJsonDmaapConsumerTest.java new file mode 100644 index 000000000..d1aee634d --- /dev/null +++ b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncFlatJsonDmaapConsumerTest.java @@ -0,0 +1,41 @@ +package org.onap.ccsdk.sli.northbound.dmaapclient; + +import static org.junit.Assert.*; + + +import java.io.File; + +import org.junit.Before; +import org.junit.Test; + +public class SdncFlatJsonDmaapConsumerTest { + + private static final String DMAAP_LISTENER_PROPERTIES = "dmaap-listener.properties"; + private static final String DMAAP_LISTENER_PROPERTIES_DIR = "src/test/resources"; + + SdncFlatJsonDmaapConsumer consumer; + + @Before + public void setUp() throws Exception { + consumer = new SdncFlatJsonDmaapConsumer(); + } + + @Test(expected = InvalidMessageException.class) + public void testProcessMsgString_NullInvalidMessageException() throws InvalidMessageException { + // expected = InvalidMessageException: Null message + consumer.processMsg(null); + } + + @Test(expected = InvalidMessageException.class) + public void testProcessMsgString_UnformatedMessageInvalidMessageException() throws InvalidMessageException { + // expected = InvalidMessageException: Cannot parse json object + consumer.processMsg("TESTING", null); + } + + @Test(expected = InvalidMessageException.class) + public void testing()throws InvalidMessageException { + // Expected = InvalidMessageException: Unable to process message - cannot load field mappings + String msg = "{\"test\":\"string\"}"; + consumer.processMsg(msg, null); + } +} \ No newline at end of file diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java new file mode 100644 index 000000000..0d152e5e0 --- /dev/null +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java @@ -0,0 +1,21 @@ +package org.onap.ccsdk.sli.northbound.uebclient; + + import static org.junit.Assert.*; + import static org.mockito.Mockito.*; + + import org.junit.Test; + import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; + import org.openecomp.sdc.toscaparser.api.NodeTemplate; + + public class SdncARModelTest { + + @Test + public void testSdncARModelConstructor() { + ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class); + NodeTemplate nodeTemplate = mock(NodeTemplate.class); + SdncARModel testSdncARModel = new SdncARModel(mockCsarHelper,nodeTemplate); + assertNotNull(testSdncARModel); + } + + } + diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java new file mode 100644 index 000000000..4a66c0201 --- /dev/null +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java @@ -0,0 +1,49 @@ +package org.onap.ccsdk.sli.northbound.uebclient; + +import static org.junit.Assert.*; + +import static org.mockito.Mockito.*; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.toscaparser.api.NodeTemplate; + +public class SdncNodeModelTest { + + SdncNodeModel sdncNodeModel; + + @Before + public void setUp() throws Exception { + ISdcCsarHelper isdcCsarHelper = mock(ISdcCsarHelper.class); + NodeTemplate nodeTemplate = mock(NodeTemplate.class); + sdncNodeModel = new SdncNodeModel(isdcCsarHelper, nodeTemplate); + sdncNodeModel.setServiceUUID("0e8d757f-1c80-40af-85de-31d64f1f5af8"); + sdncNodeModel.setEcompGeneratedNaming("hello-world"); + } + + @Test + public void testGetServiceUUID() { + String result = sdncNodeModel.getServiceUUID(); + assertNotNull(result != null); + } + + @Test + public void testGetEcompGeneratedNaming() { + String result = sdncNodeModel.getEcompGeneratedNaming(); + assertEquals("hello-world", result); + } + + @Test + public void testGetSqlString() { + String result = sdncNodeModel.getSql("TEST-HELLO"); + String test = "INSERT into NETWORK_MODEL (service_uuid, customization_uuid, model_yaml, ecomp_generated_naming) values (0e8d757f-1c80-40af-85de-31d64f1f5af8, \"\", \"TEST-HELLO\", \"hello-world\");"; + assertEquals(test, result); + } + + @Test + public void testGetVpnBindingsSql() { + String result = sdncNodeModel.getVpnBindingsSql(); + assertNotNull(result); + } +} \ No newline at end of file diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java new file mode 100644 index 000000000..d2bafbf42 --- /dev/null +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java @@ -0,0 +1,36 @@ +package org.onap.ccsdk.sli.northbound.uebclient; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.toscaparser.api.NodeTemplate; + +public class SdncVFCModelTest { + + SdncVFCModel testSdncVFCModel; + + @Before + public void setup() { + ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class); + NodeTemplate mockNodeTemplate = mock(NodeTemplate.class); + testSdncVFCModel = new SdncVFCModel(mockCsarHelper, mockNodeTemplate); + testSdncVFCModel.setVmType("Test-type"); + testSdncVFCModel.setVmCount("5"); + + } + + @Test + public void testSdncVFCModelGetVmType() { + assertEquals(testSdncVFCModel.getVmType(), "Test-type"); + } + + @Test + public void testSdncVFCModelGetVmCount() { + assertEquals(testSdncVFCModel.getVmCount(), "5"); + } + +} \ No newline at end of file diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java new file mode 100644 index 000000000..218554357 --- /dev/null +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java @@ -0,0 +1,20 @@ +package org.onap.ccsdk.sli.northbound.uebclient; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +import org.junit.Test; +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.toscaparser.api.Group; + +public class SdncVFModuleModelTest { + + @Test + public void testSdncVFModuleModelConstructor() { + Group mockGroup = mock(Group.class); + ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class); + SdncVFModuleModel testSdncVFModel = new SdncVFModuleModel(mockCsarHelper, mockGroup); + assertNotNull(testSdncVFModel); + } + +} \ No newline at end of file diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java index 79a598ce5..21854f990 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java @@ -1,6 +1,7 @@ package org.onap.ccsdk.sli.northbound.uebclient; -import static org.mockito.Mockito.mock; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.*; import java.io.File; import java.io.InputStream; @@ -9,6 +10,8 @@ import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; import org.junit.After; @@ -16,7 +19,9 @@ import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.notification.IArtifactInfo; import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -149,6 +154,15 @@ public class TestSdncUebCallback { SdncUebConfiguration config; DBResourceManager dblibSvc; DB db; + List processLevelArtifactList; + List serviceLevelArtifactList; + ArrayList resourceList; + IArtifactInfo mockProcessArtifact1; + IArtifactInfo mockProcessArtifact2; + IArtifactInfo mockProcessArtifact3; + IArtifactInfo mockServiceArtifact1; + IResourceInstance resource; + @Before public void setUp() throws Exception { @@ -186,6 +200,42 @@ public class TestSdncUebCallback { dblibSvc.writeData(CRTBL_VF_MODEL, null, null); dblibSvc.writeData(CRTBL_VF_MODULE_MODEL, null, null); dblibSvc.writeData(CRTBL_ALLOTTED_RESOURCE_MODEL, null, null); + + processLevelArtifactList = new ArrayList<>(); + serviceLevelArtifactList = new ArrayList<>(); + resourceList = new ArrayList<>(); + + + mockProcessArtifact1 = mock(IArtifactInfo.class); + when(mockProcessArtifact1.getArtifactName()).thenReturn("mockProcessArtifact1"); + when(mockProcessArtifact1.getArtifactType()).thenReturn("HEAT"); + when(mockProcessArtifact1.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); + when(mockProcessArtifact1.getArtifactChecksum()).thenReturn("123tfg123 1234ftg"); + when(mockProcessArtifact1.getArtifactTimeout()).thenReturn(110); + + mockProcessArtifact2 = mock(IArtifactInfo.class); + when(mockProcessArtifact1.getArtifactName()).thenReturn("mockProcessArtifact2"); + when(mockProcessArtifact1.getArtifactType()).thenReturn("DG_XML"); + when(mockProcessArtifact1.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); + when(mockProcessArtifact1.getArtifactChecksum()).thenReturn("456jhgt 1234ftg"); + when(mockProcessArtifact1.getArtifactTimeout()).thenReturn(110); + + mockProcessArtifact3 = mock(IArtifactInfo.class); + when(mockProcessArtifact1.getArtifactName()).thenReturn("mockProcessArtifact3"); + when(mockProcessArtifact1.getArtifactType()).thenReturn("HEAT"); + when(mockProcessArtifact1.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); + when(mockProcessArtifact1.getArtifactChecksum()).thenReturn("123tfg123 543gtd"); + when(mockProcessArtifact1.getArtifactTimeout()).thenReturn(110); + + + mockServiceArtifact1 = mock(IArtifactInfo.class); + when(mockServiceArtifact1.getArtifactName()).thenReturn("mockProcessArtifact4"); + when(mockServiceArtifact1.getArtifactType()).thenReturn("HEAT"); + when(mockServiceArtifact1.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); + when(mockServiceArtifact1.getArtifactChecksum()).thenReturn("123t3455 543gtd"); + when(mockServiceArtifact1.getArtifactTimeout()).thenReturn(110); + + resource = mock(IResourceInstance.class); } @After @@ -219,5 +269,35 @@ public class TestSdncUebCallback { INotificationData iData = mock(INotificationData.class); cb.activateCallback(iData); } + + + + @Test + public void testServiceAndProcessArtifactsactivateCallback() { + + try { + processLevelArtifactList.add(mockProcessArtifact1); + processLevelArtifactList.add(mockProcessArtifact2); + processLevelArtifactList.add(mockProcessArtifact3); + + resourceList.add(resource); + serviceLevelArtifactList.add(mockServiceArtifact1); + when(resource.getArtifacts()).thenReturn(serviceLevelArtifactList); + when(resource.getResourceName()).thenReturn("Resource_service_name"); + + + IDistributionClient iDistClient1 = mock(IDistributionClient.class); + INotificationData mockData = mock(INotificationData.class); + when(mockData.getResources()).thenReturn(resourceList); + when(mockData.getServiceName()).thenReturn("Test_service_name"); + when(mockData.getServiceArtifacts()).thenReturn(processLevelArtifactList); + + SdncUebCallback cb1 = new SdncUebCallback(iDistClient1, config); + cb1.activateCallback(mockData); + assertTrue(true); + } catch (Exception e) { + assertTrue(false); + } + } } -- cgit 1.2.3-korg From 3168c3f65abddac9ecf5321b93752d31a4edd9fa Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 5 Sep 2019 11:31:41 -0400 Subject: Add junit coverage Add junit test for asdcApi Change-Id: Ic564aa18795dabd32e664569be802cff7d823516 Issue-ID: CCSDK-1694 Signed-off-by: Timoney, Dan (dt5972) Add junit coverage Add junit test for asdcApi Change-Id: I21873f325177da0b03b7dd15c20bea962a641d4a Issue-ID: CCSDK-1694 Signed-off-by: Timoney, Dan (dt5972) --- .../sli/northbound/asdcapi/TestAsdcApiApi.java | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'asdcApi/provider/src/test/java') diff --git a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java index 6ad9a829f..1f266365c 100644 --- a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java +++ b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java @@ -25,18 +25,23 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.http.xmlns.onap.org.asdc.license.model._1._0.rev160427.vf.license.model.grouping.VfLicenseModelBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateOutput; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Properties; + public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { private AsdcApiProvider asdcApiProvider; @@ -49,6 +54,13 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { NotificationPublishService mockNotification = mock(NotificationPublishService.class); RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); AsdcApiSliClient mockSliClient = mock(AsdcApiSliClient.class); + Properties respProps = new Properties(); + respProps.setProperty("error-code", "200"); + respProps.setProperty("error-message", "Success"); + + when(mockSliClient.hasGraph("ASDC-API", "vf-license-model-update" , null, "sync")).thenReturn(true); + when(mockSliClient.execute("ASDC-API", "vf-license-model-update", null, "sync", respProps)).thenReturn(respProps); + asdcApiProvider = new AsdcApiProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient); } } @@ -72,7 +84,7 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { fail("Error : " + e); } LOG.info("result: {}", rpcResult); - assertEquals("503", rpcResult.getResult().getAsdcApiResponseCode()); + assertEquals("200", rpcResult.getResult().getAsdcApiResponseCode()); } //Input parameter validation @@ -89,11 +101,20 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { assertNull(future); } - @Test(expected = IllegalArgumentException.class) + @Test public void testVfLicenseModelUpdateValidation1() { VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); + inputBuilder.setArtifactName("license1"); + inputBuilder.setArtifactVersion("version1"); + + VfLicenseModelBuilder vfLicenseModelBuilder = new VfLicenseModelBuilder(); + vfLicenseModelBuilder.setVfId("123"); + vfLicenseModelBuilder.setVendorName("acme"); + inputBuilder.setVfLicenseModel(vfLicenseModelBuilder.build()); + + java.util.concurrent.Future> future = asdcApiProvider .vfLicenseModelUpdate(inputBuilder.build()); RpcResult rpcResult = null; @@ -103,4 +124,13 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { fail("Error : " + e); } } + + + + + @Test + public void testAddArtifactVersion() { + asdcApiProvider.addArtifactVersion("artifact1", + "version1"); + } } -- cgit 1.2.3-korg