From ff3eecb980bfdc8d43d2ed3a4c786d634fa6f4e2 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Tue, 1 Dec 2020 11:52:01 -0800 Subject: Migrate sli-northbound repo Migrate sli-northbound repo files into new directory "northbound". Signed-off-by: Jessica Wagantall --- asdcApi/provider/pom.xml | 95 ------ .../sli/northbound/asdcapi/AsdcApiProvider.java | 379 --------------------- .../sli/northbound/asdcapi/AsdcApiSliClient.java | 97 ------ .../ccsdk/sli/northbound/asdcapi/AsdcApiUtil.java | 48 --- .../OSGI-INF/blueprint/asdc-blueprint.xml | 32 -- .../org/opendaylight/blueprint/asdc-blueprint.xml | 32 -- .../northbound/asdcapi/AsdcApiSliClientTest.java | 59 ---- .../sli/northbound/asdcapi/AsdcApiUtilTest.java | 15 - .../sli/northbound/asdcapi/TestAsdcApiApi.java | 136 -------- 9 files changed, 893 deletions(-) delete mode 100755 asdcApi/provider/pom.xml delete mode 100644 asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java delete mode 100644 asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClient.java delete mode 100644 asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtil.java delete mode 100644 asdcApi/provider/src/main/resources/OSGI-INF/blueprint/asdc-blueprint.xml delete mode 100644 asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml delete mode 100644 asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClientTest.java delete mode 100644 asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtilTest.java delete mode 100644 asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java (limited to 'asdcApi/provider') diff --git a/asdcApi/provider/pom.xml b/asdcApi/provider/pom.xml deleted file mode 100755 index 97c4ba9aa..000000000 --- a/asdcApi/provider/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 2.1.0 - - - - org.onap.ccsdk.sli.northbound - asdcApi-provider - 1.1.1-SNAPSHOT - bundle - - ccsdk-sli-northbound :: asdcApi :: ${project.artifactId} - - - ${project.version} - - - - - - org.onap.ccsdk.sli.core - sli-core-artifacts - ${ccsdk.sli.core.version} - pom - import - - - - - - org.onap.ccsdk.sli.northbound - asdcApi-model - ${project.version} - - - - org.opendaylight.controller - sal-binding-api - - - - org.opendaylight.controller - sal-common-util - - - - org.onap.ccsdk.sli.core - sli-common - - - org.onap.ccsdk.sli.core - sli-provider - - - - org.opendaylight.controller - sal-test-model - 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 - test - - - org.mockito - mockito-core - test - - - diff --git a/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java b/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java deleted file mode 100644 index 1a79f8c41..000000000 --- a/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java +++ /dev/null @@ -1,379 +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.ccsdk.sli.northbound.asdcapi; - -import java.util.Properties; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -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.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -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.VfLicenseModel; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.ASDCAPIService; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.Artifacts; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.ArtifactsBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInput; -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.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelVersions; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelVersionsBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.artifacts.Artifact; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.artifacts.ArtifactBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.artifacts.ArtifactKey; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.vf.license.model.versions.VfLicenseModelVersion; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.vf.license.model.versions.VfLicenseModelVersionBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Defines a base implementation for your provider. This class extends from a helper class - * which provides storage for the most commonly used components of the MD-SAL. Additionally the - * base class provides some basic logging and initialization / clean up methods. - * - * To use this, copy and paste (overwrite) the following method into the TestApplicationProviderModule - * class which is auto generated under src/main/java in this project - * (created only once during first compilation): - * - *
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-
-         final asdcApiProvider provider = new asdcApiProvider();
-         provider.setDataBroker( getDataBrokerDependency() );
-         provider.setNotificationService( getNotificationServiceDependency() );
-         provider.setRpcRegistry( getRpcRegistryDependency() );
-         provider.initialize();
-         return new AutoCloseable() {
-
-            @Override
-            public void close() throws Exception {
-                //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION
-                //SERVIE/RPC REGISTRY
-                provider.close();
-            }
-        };
-    }
-
-
-    
- */ -public class AsdcApiProvider implements AutoCloseable, ASDCAPIService { - - private static final Logger LOG = LoggerFactory.getLogger(AsdcApiProvider.class); - - private static final String ACTIVE_VERSION = "active"; - - private static final String APPLICATION_NAME = "asdcApi"; - - private final ExecutorService executor; - protected DataBroker dataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - private final AsdcApiSliClient asdcApiSliClient; - - protected BindingAwareBroker.RpcRegistration rpcRegistration; - - public AsdcApiProvider(final DataBroker dataBroker, - final NotificationPublishService notificationPublishService, - final RpcProviderRegistry rpcProviderRegistry, - final AsdcApiSliClient asdcApiSliClient) { - - LOG.info("Creating provider for {}", APPLICATION_NAME); - executor = Executors.newFixedThreadPool(1); - this.dataBroker = dataBroker; - notificationService = notificationPublishService; - rpcRegistry = rpcProviderRegistry; - this.asdcApiSliClient= asdcApiSliClient; - initialize(); - } - - public void initialize(){ - LOG.info("Initializing {} for {}", this.getClass().getName(), APPLICATION_NAME); - - createContainers(); - - if (rpcRegistration == null) { - if (rpcRegistry != null) { - rpcRegistration = rpcRegistry.addRpcImplementation( - ASDCAPIService.class, this); - LOG.info("Initialization complete for {}", APPLICATION_NAME); - } else { - LOG.warn("Error initializing {} : rpcRegistry unset", APPLICATION_NAME); - } - } - } - - private void createContainers() { - - if (dataBroker != null) { - final WriteTransaction t = dataBroker.newReadWriteTransaction(); - - // Create the vf-model-license-versions and artifacts containers - t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(VfLicenseModelVersions.class), - new VfLicenseModelVersionsBuilder().build()); - - t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Artifacts.class), new ArtifactsBuilder().build()); - - - try { - CheckedFuture checkedFuture = t.submit(); - checkedFuture.get(); - LOG.info("Create Containers succeeded!: "); - - } catch (InterruptedException | ExecutionException e) { - LOG.error("Create Containers Failed: ", e); - } - } else { - LOG.warn("createContainers : cannot find dataBroker to create containers"); - } - } - protected void initializeChild() { - //Override if you have custom initialization intelligence - } - - @Override - public void close() throws Exception { - LOG.info( "Closing provider for " + APPLICATION_NAME); - executor.shutdown(); - rpcRegistration.close(); - LOG.info( "Successfully closed provider for " + APPLICATION_NAME); - } - - protected boolean artifactVersionExists(String aName, String aVersion) { - InstanceIdentifier artifactInstanceId = - InstanceIdentifier.builder(Artifacts.class) - .child(Artifact.class, new ArtifactKey(aName, aVersion)).build(); - Optional data = null; - try(ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction()) { - data = (Optional) readTx.read(LogicalDatastoreType.CONFIGURATION, artifactInstanceId).get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Caught Exception reading MD-SAL for ["+aName+","+ aVersion+"] " ,e); - return false; - } - - return data.isPresent(); - } - - protected void addArtifactVersion(String aName, String aVersion) { - - - try { - ArtifactBuilder aBuilder = new ArtifactBuilder(); - - aBuilder.setArtifactName(aName); - aBuilder.setArtifactVersion(aVersion); - - Artifact artifact = aBuilder.build(); - - InstanceIdentifier.InstanceIdentifierBuilder aIdBuilder = InstanceIdentifier - . builder(Artifacts.class) - .child(Artifact.class, artifact.key()); - - InstanceIdentifier path = aIdBuilder.build(); - - WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); - - tx.merge(LogicalDatastoreType.CONFIGURATION, path, - artifact); - tx.submit().checkedGet(); - } catch (Exception e) { - LOG.error("Caught exception trying to add artifact entry", e); - } - - } - - - private void applyVfLicenseModelUpdate(VfLicenseModelUpdateInput input) { - - String aName = input.getArtifactName(); - String aVersion = input.getArtifactVersion(); - VfLicenseModel vfLicenseModel = input.getVfLicenseModel(); - - - // Add new version (version = artifact-version) - try { - - VfLicenseModelVersionBuilder vBuilder = new VfLicenseModelVersionBuilder(); - vBuilder.setArtifactName(aName); - vBuilder.setArtifactVersion(aVersion); - vBuilder.setVfLicenseModel(vfLicenseModel); - - VfLicenseModelVersion version = vBuilder.build(); - - InstanceIdentifier.InstanceIdentifierBuilder versionIdBuilder = InstanceIdentifier - . builder(VfLicenseModelVersions.class) - .child(VfLicenseModelVersion.class, version.key()); - - InstanceIdentifier path = versionIdBuilder.build(); - - WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); - tx.merge(LogicalDatastoreType.CONFIGURATION, path, - version); - tx.submit().checkedGet(); - } catch (Exception e) { - LOG.error( - "Caught exception trying to save entry to MD-SAL", - e); - } - - - // Add "active" version (version = "active") - try { - - VfLicenseModelVersionBuilder vBuilder = new VfLicenseModelVersionBuilder(); - vBuilder.setArtifactName(aName); - vBuilder.setArtifactVersion(ACTIVE_VERSION); - vBuilder.setVfLicenseModel(vfLicenseModel); - - VfLicenseModelVersion version = vBuilder.build(); - InstanceIdentifier.InstanceIdentifierBuilder versionIdBuilder = InstanceIdentifier - . builder(VfLicenseModelVersions.class) - .child(VfLicenseModelVersion.class, version.key()); - - InstanceIdentifier path = versionIdBuilder.build(); - - WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); - - tx.merge(LogicalDatastoreType.CONFIGURATION, path, - version); - tx.submit().checkedGet(); - } catch (Exception e) { - LOG.error( - "Caught exception trying to save entry to MD-SAL", - e); - } - -} - -@Override -public ListenableFuture> vfLicenseModelUpdate(VfLicenseModelUpdateInput input) { - final String svcOperation = "vf-license-model-update"; - - Properties parms = new Properties(); - - LOG.info( svcOperation +" called." ); - - if(input == null ) { - LOG.debug("exiting " +svcOperation+ " because of invalid input"); - return null; - } - - VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(input); - - VfLicenseModelUpdateInput inputVfLic = inputBuilder.build(); - - String errorMessage = "Success"; - String errorCode = "200"; - - // If this artifact already exists, reject this update - if (artifactVersionExists(inputVfLic.getArtifactName(), inputVfLic.getArtifactVersion())) { - errorCode = "409"; - errorMessage = "Artifact version already exists"; - } else { - // Translate input object into SLI-consumable properties - LOG.info("Adding INPUT data for "+svcOperation+" input: " + inputVfLic); - AsdcApiUtil.toProperties(parms, inputVfLic); - - - // Call directed graph - Properties respProps = null; - try - { - if (asdcApiSliClient.hasGraph("ASDC-API", svcOperation , null, "sync")) - { - - try - { - respProps = asdcApiSliClient.execute("ASDC-API", svcOperation, null, "sync", parms); - } - catch (Exception e) - { - LOG.error("Caught exception executing service logic for "+ svcOperation, e); - } - } else { - errorMessage = "No service logic active for ASDC-API: '" + svcOperation + "'"; - errorCode = "503"; - } - } - catch (Exception e) - { - errorCode = "500"; - errorMessage = e.getMessage(); - LOG.error("Caught exception looking for service logic", e); - } - - - if (respProps != null) - { - errorCode = respProps.getProperty("error-code"); - errorMessage = respProps.getProperty("error-message", ""); - } - } - - - if ("200".equals(errorCode)) { - LOG.info("ASDC update succeeded"); - - // Update config tree - applyVfLicenseModelUpdate(inputVfLic); - addArtifactVersion(inputVfLic.getArtifactName(), inputVfLic.getArtifactVersion()); - - } else { - LOG.info("ASDC update failed ("+errorCode+" : "+errorMessage); - } - - // Send response - VfLicenseModelUpdateOutputBuilder respBuilder = new VfLicenseModelUpdateOutputBuilder(); - respBuilder.setAsdcApiResponseCode(errorCode); - if (errorMessage != null && errorMessage.length() > 0) { - respBuilder.setAsdcApiResponseText(errorMessage); - } - - RpcResult rpcResult; - - - rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); - - - - return Futures.immediateFuture(rpcResult); -} - - -} diff --git a/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClient.java b/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClient.java deleted file mode 100644 index 880a2fb76..000000000 --- a/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClient.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * Modifications Copyright © 2018 IBM. - * ================================================================================ - * 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 java.util.Properties; - -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsdcApiSliClient { - - private static final Logger LOG = LoggerFactory.getLogger(AsdcApiSliClient.class); - - private final SvcLogicService svcLogicService; - - private String ErrorCode = "error-code"; - - public AsdcApiSliClient(final SvcLogicService svcLogicService) { - this.svcLogicService = svcLogicService; - } - - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException - { - return svcLogicService.hasGraph(module, rpc, version, mode); - } - - - public Properties execute(String module, String rpc, String version, String mode, Properties parms) - throws SvcLogicException { - - - if (LOG.isDebugEnabled()) - { - LOG.debug("Parameters passed to SLI"); - - for (Object key : parms.keySet()) { - String parmName = (String) key; - String parmValue = parms.getProperty(parmName); - - LOG.debug(parmName+" = "+parmValue); - - } - } - - Properties respProps = svcLogicService.execute(module, rpc, version, mode, parms); - - if (LOG.isDebugEnabled()) - { - LOG.debug("Parameters returned by SLI"); - - for (Object key : respProps.keySet()) { - String parmName = (String) key; - String parmValue = respProps.getProperty(parmName); - - LOG.debug(parmName+" = "+parmValue); - - } - } - - if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { - - if (!respProps.containsKey(ErrorCode)) { - respProps.setProperty(ErrorCode, "500"); - } - } else { - if (!respProps.containsKey(ErrorCode)) { - respProps.setProperty(ErrorCode, "200"); - } - } - - - return respProps; - } - -} diff --git a/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtil.java b/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtil.java deleted file mode 100644 index 602b389cb..000000000 --- a/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtil.java +++ /dev/null @@ -1,48 +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.ccsdk.sli.northbound.asdcapi; - -import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.ArtifactsBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelVersionsBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.vf.license.model.versions.VfLicenseModelVersionBuilder; - -public class AsdcApiUtil extends MdsalHelper { - - static { - - // Input objects - - VfLicenseModelUpdateInput i13 = new VfLicenseModelUpdateInputBuilder().build(); - - - // Other builders - ArtifactsBuilder b1 = new ArtifactsBuilder(); - - VfLicenseModelVersionsBuilder b14a = new VfLicenseModelVersionsBuilder(); - VfLicenseModelVersionBuilder b26a = new VfLicenseModelVersionBuilder(); - - - } -} diff --git a/asdcApi/provider/src/main/resources/OSGI-INF/blueprint/asdc-blueprint.xml b/asdcApi/provider/src/main/resources/OSGI-INF/blueprint/asdc-blueprint.xml deleted file mode 100644 index 9ad08d3db..000000000 --- a/asdcApi/provider/src/main/resources/OSGI-INF/blueprint/asdc-blueprint.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml b/asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml deleted file mode 100644 index 9ad08d3db..000000000 --- a/asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file 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 deleted file mode 100644 index 5e6a9daf7..000000000 --- a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiSliClientTest.java +++ /dev/null @@ -1,59 +0,0 @@ -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 deleted file mode 100644 index 463e5ea0b..000000000 --- a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiUtilTest.java +++ /dev/null @@ -1,15 +0,0 @@ -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/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 deleted file mode 100644 index 1f266365c..000000000 --- a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java +++ /dev/null @@ -1,136 +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.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 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; - 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); - 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); - } - } - - //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("200", 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 - 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; - try { - rpcResult = future.get(); - } catch (Exception e) { - fail("Error : " + e); - } - } - - - - - @Test - public void testAddArtifactVersion() { - asdcApiProvider.addArtifactVersion("artifact1", - "version1"); - } -} -- cgit 1.2.3-korg