diff options
64 files changed, 277 insertions, 3208 deletions
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/AnsibleActivatorTest.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/AnsibleActivatorTest.java index 7fd2f4d8a..83a803156 100644 --- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/AnsibleActivatorTest.java +++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/AnsibleActivatorTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. @@ -43,7 +43,7 @@ import org.osgi.framework.ServiceRegistration; public class AnsibleActivatorTest { @Mock - private ServiceRegistration<AnsibleAdapter> serviceRegistration; + private ServiceRegistration serviceRegistration; @Mock private BundleContext bundleContext; diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/ChefActivatorTest.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/ChefActivatorTest.java index b261a77e9..ec291c15f 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/ChefActivatorTest.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/ChefActivatorTest.java @@ -41,7 +41,7 @@ import org.osgi.framework.ServiceRegistration; public class ChefActivatorTest { @Mock - private ServiceRegistration<ChefAdapter> serviceRegistration; + private ServiceRegistration serviceRegistration; @Mock private BundleContext bundleContext; diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/pom.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/pom.xml index 1d8cbdbc3..b7b12a155 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/pom.xml +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -72,12 +72,6 @@ </dependency> <dependency> - <groupId>equinoxSDK381</groupId> - <artifactId>org.eclipse.osgi</artifactId> - <version>${equinox.osgi.version}</version> - </dependency> - - <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> </dependency> @@ -105,6 +99,11 @@ <artifactId>mockito-core</artifactId> </dependency> <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito</artifactId> <scope>test</scope> diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/onap-appc-dmaap-adapter/pom.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/onap-appc-dmaap-adapter/pom.xml index 7490f31ab..0ba4d65c1 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/onap-appc-dmaap-adapter/pom.xml +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/onap-appc-dmaap-adapter/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2019 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. @@ -58,6 +58,14 @@ limitations under the License. <artifactId>appc-message-adapter-api</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-server</artifactId> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-servlet</artifactId> + </dependency> <!-- <dependency> --> <!-- <groupId>org.glassfish.jersey.core</groupId> --> <!-- <artifactId>jersey-server</artifactId> --> diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/pom.xml b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/pom.xml index 785d5ca53..6815d8270 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/pom.xml +++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -52,12 +52,6 @@ </dependency> <dependency> - <groupId>equinoxSDK381</groupId> - <artifactId>org.eclipse.osgi</artifactId> - <version>${equinox.osgi.version}</version> - </dependency> - - <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> </dependency> @@ -86,6 +80,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito</artifactId> <scope>test</scope> diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/pom.xml b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/pom.xml index 77de05589..d7ad26e30 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/pom.xml +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -97,6 +97,12 @@ <scope>compile</scope> </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <!-- <dependency> --> <!-- <groupId>javax</groupId> --> <!-- <artifactId>javaee-api</artifactId> --> diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml index 44f9006a3..c4e25610b 100644 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -142,6 +142,12 @@ </dependency> <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml index 8df77e2c8..43b9d17a1 100644 --- a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml +++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -178,13 +178,19 @@ <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> - </dependency> + </dependency> <dependency> <groupId>org.mariadb.jdbc</groupId> <artifactId>mariadb-java-client</artifactId> <version>${mariadb.client.version}</version> - </dependency> + </dependency> + + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> <dependency> <groupId>com.vmware</groupId> diff --git a/appc-config/appc-config-adaptor/provider/pom.xml b/appc-config/appc-config-adaptor/provider/pom.xml index d3c31b0a5..ce5bf0cf4 100644 --- a/appc-config/appc-config-adaptor/provider/pom.xml +++ b/appc-config/appc-config-adaptor/provider/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Copyright (C) 2017 Amdocs ============================================================================= @@ -126,6 +126,11 @@ <artifactId>appc-common-bundle</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build> diff --git a/appc-config/appc-flow-controller/provider/pom.xml b/appc-config/appc-flow-controller/provider/pom.xml index 19cbee450..a63e31b41 100644 --- a/appc-config/appc-flow-controller/provider/pom.xml +++ b/appc-config/appc-flow-controller/provider/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -132,6 +132,11 @@ <version>1.9.2</version> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> </dependencies> diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/test/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImplTest.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/test/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImplTest.java deleted file mode 100644 index e0214b1d5..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/test/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImplTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2019 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.dependencymanager.impl; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.onap.appc.cache.MetadataCache; -import org.onap.appc.cache.impl.MetadataCacheFactory; -import org.onap.appc.cache.impl.MetadataCacheImpl; -import org.onap.appc.dg.dependencymanager.DependencyManager; -import org.onap.appc.dg.objects.DependencyTypes; -import org.onap.appc.dg.objects.VnfcDependencyModel; -import org.onap.appc.metadata.objects.DependencyModelIdentifier; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(MetadataCacheFactory.class) -public class DependencyManagerImplTest { - - private MetadataCacheFactory metadataCacheFactory = Mockito.mock(MetadataCacheFactory.class); - private MetadataCache<DependencyModelIdentifier,VnfcDependencyModel> cache; - - @Before - public void setup() { - PowerMockito.mockStatic(MetadataCacheFactory.class); - PowerMockito.when(MetadataCacheFactory.getInstance()).thenReturn(metadataCacheFactory); - cache = (MetadataCacheImpl<DependencyModelIdentifier,VnfcDependencyModel>) Mockito.mock(MetadataCacheImpl.class); - PowerMockito.when(metadataCacheFactory.getMetadataCache()).thenReturn(cache); - } - - @Test - public void testDependencyManager() throws Exception { - DependencyManager dmImpl = DependencyModelFactory.createDependencyManager(); - DependencyModelIdentifier modelIdentifier = new DependencyModelIdentifier("VNF_TYPE", "CATALOG_VERSION"); - DependencyTypes dependencyType = DependencyTypes.findByString("resource"); - Mockito.when(cache.getObject(Mockito.any(DependencyModelIdentifier.class))).thenReturn(new VnfcDependencyModel(null)); - dmImpl.getVnfcDependencyModel(modelIdentifier, dependencyType); - } - -} diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/pom.xml b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/pom.xml index 09783a98a..6939fe4ce 100644 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/pom.xml +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/pom.xml @@ -84,14 +84,6 @@ </dependency> <dependency> <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-config</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-api</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> <artifactId>sal-common-util</artifactId> </dependency> <dependency> @@ -100,19 +92,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-broker-impl</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-broker-impl</artifactId> - <classifier>tests</classifier> - <version>${odl.mdsal.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>${apache.httpcomponents.version}</version> diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/main/java/org/onap/appc/mdsal/provider/MdsalStoreProvider.java b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/main/java/org/onap/appc/mdsal/provider/MdsalStoreProvider.java index 545bd32a9..e362f0a8b 100644 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/main/java/org/onap/appc/mdsal/provider/MdsalStoreProvider.java +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/main/java/org/onap/appc/mdsal/provider/MdsalStoreProvider.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -29,14 +29,13 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; import org.onap.appc.Constants; import org.onap.appc.mdsal.MDSALStore; import org.onap.appc.mdsal.impl.MDSALStoreFactory; import org.onap.appc.mdsal.objects.BundleInfo; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.appc.mdsal.store.rev170925.MdsalStoreService; import org.opendaylight.yang.gen.v1.org.onap.appc.mdsal.store.rev170925.StoreYangInput; @@ -49,19 +48,20 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; public class MdsalStoreProvider implements MdsalStoreService ,AutoCloseable{ protected DataBroker dataBroker; protected RpcProviderRegistry rpcRegistry; - protected NotificationProviderService notificationService; + protected NotificationPublishService notificationService; protected BindingAwareBroker.RpcRegistration<MdsalStoreService> rpcRegistration; private final EELFLogger log = EELFManager.getInstance().getLogger(MdsalStoreProvider.class); private final ExecutorService executor; private final static String APP_NAME = "MdsalStoreProvider"; - public MdsalStoreProvider(DataBroker dataBroker2, NotificationProviderService notificationProviderService + public MdsalStoreProvider(DataBroker dataBroker2, NotificationPublishService notificationProviderService , RpcProviderRegistry rpcRegistry2){ log.info("Creating provider for " + APP_NAME); executor = Executors.newFixedThreadPool(1); @@ -90,7 +90,7 @@ public class MdsalStoreProvider implements MdsalStoreService ,AutoCloseable{ } @Override - public Future<RpcResult<StoreYangOutput>> storeYang(StoreYangInput input) { + public ListenableFuture<RpcResult<StoreYangOutput>> storeYang(StoreYangInput input) { Status status = null; String message = null; try{ diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/main/resources/org/opendaylight/blueprint/dg-mdsal-blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/main/resources/org/opendaylight/blueprint/dg-mdsal-blueprint.xml index fa841a638..382e2d8cd 100644 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/main/resources/org/opendaylight/blueprint/dg-mdsal-blueprint.xml +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/main/resources/org/opendaylight/blueprint/dg-mdsal-blueprint.xml @@ -42,4 +42,4 @@ <odl:rpc-implementation ref="mdsal-store"/> -</blueprint> +</blueprint>
\ No newline at end of file diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/MDSALStoreTest.java b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/MDSALStoreTest.java deleted file mode 100644 index 2229eff9d..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/MDSALStoreTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ================================================================================ - * Modifications (C) 2019 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.mdsal; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.onap.appc.mdsal.exception.MDSALStoreException; -import org.onap.appc.mdsal.impl.MDSALStoreFactory; -import org.onap.appc.mdsal.impl.MDSALStoreImpl; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.onap.appc.mdsal.operation.ConfigOperationRequestFormatter; -import org.onap.appc.rest.client.RestClientInvoker; -import org.osgi.framework.*; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.net.URL; - -/** - * MDSALStore Tests - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({FrameworkUtil.class,BundleContext.class,ServiceReference.class, - BundleReference.class,Bundle.class,Filter.class,BundleListener.class,InvalidSyntaxException.class, - BundleException.class,FrameworkListener.class,ServiceRegistration.class,ServiceListener.class, - Version.class}) -public class MDSALStoreTest { - - private final EELFLogger logger = EELFManager.getInstance().getLogger(MDSALStoreTest.class); - private RestClientInvoker client = Mockito.mock(RestClientInvoker.class); - private ConfigOperationRequestFormatter requestFormatter = new ConfigOperationRequestFormatter(); - private ObjectMapper mapper = new ObjectMapper(); - MDSALStoreImpl store; - - @Before - public void init() throws Exception{ - PowerMockito.whenNew(RestClientInvoker.class).withArguments(Mockito.any(URL.class)).thenReturn(client); - store = (MDSALStoreImpl) MDSALStoreFactory.createMDSALStore(); - } - - @Ignore - public void testYangInput() throws MDSALStoreException { - store.storeYangModuleOnLeader("module test { }", "Name"); - } - -} diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/provider/MdsalStoreProviderTest.java b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/provider/MdsalStoreProviderTest.java index 2f0e4936a..c6fc25c4d 100644 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/provider/MdsalStoreProviderTest.java +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/provider/MdsalStoreProviderTest.java @@ -28,8 +28,8 @@ import org.onap.appc.mdsal.MDSALStore; import org.onap.appc.mdsal.impl.MDSALStoreFactory; import org.onap.appc.mdsal.impl.MDSALStoreImpl; import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.appc.mdsal.store.rev170925.MdsalStoreService; import org.opendaylight.yang.gen.v1.org.onap.appc.mdsal.store.rev170925.StoreYangInput; @@ -46,7 +46,7 @@ public class MdsalStoreProviderTest { private DataBroker dataBroker = Mockito.mock(DataBroker.class); private RpcProviderRegistry rpcRegistry = Mockito.mock(RpcProviderRegistry.class); - private NotificationProviderService notificationService = Mockito.mock(NotificationProviderService.class); + private NotificationPublishService notificationService = Mockito.mock(NotificationPublishService.class); @Test public void testClose() throws Exception { diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-model/pom.xml b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-model/pom.xml index f8ddd05da..bcdc3b45b 100644 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-model/pom.xml +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-model/pom.xml @@ -94,11 +94,11 @@ </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> + <artifactId>ietf-inet-types-2013-07-15</artifactId> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> + <artifactId>ietf-yang-types-20130715</artifactId> </dependency> <dependency> <groupId>org.opendaylight.controller</groupId> diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/onap/appc/dg/netconf/impl/NetconfClientPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/onap/appc/dg/netconf/impl/NetconfClientPluginImplTest.java deleted file mode 100644 index 9e2384e91..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/onap/appc/dg/netconf/impl/NetconfClientPluginImplTest.java +++ /dev/null @@ -1,650 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ================================================================================ - * Modifications (C) 2019 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.netconf.impl; - -import org.onap.appc.exceptions.APPCException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.onap.appc.adapter.netconf.util.Constants; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.appc.adapter.netconf.ConnectionDetails; -import org.onap.appc.adapter.netconf.NetconfClientFactory; -import org.onap.appc.adapter.netconf.NetconfClientType; -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.NetconfDataAccessService; -import org.onap.appc.adapter.netconf.OperationalStateValidatorFactory; -import org.onap.appc.adapter.netconf.VnfType; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.lang.reflect.Field; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static org.powermock.api.mockito.PowerMockito.when; - - - -@RunWith(PowerMockRunner.class) -@PrepareForTest({OperationalStateValidatorFactory.class, FrameworkUtil.class, ObjectMapper.class}) - -public class NetconfClientPluginImplTest { - private NetconfClientPluginImpl netconfClientPlugin; - private NetconfDataAccessService dao; - private NetconfClientFactory clientFactory; - private Map<String, String> params; - - private final BundleContext bundleContext = Mockito.mock(BundleContext.class); - private final Bundle bundleService = Mockito.mock(Bundle.class); - private final ServiceReference sref1 = Mockito.mock(ServiceReference.class); - private final ServiceReference sref2 = Mockito.mock(ServiceReference.class); - private final ServiceReference sref3 = Mockito.mock(ServiceReference.class); - private static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message"; - - - String host = "http://www.test.com"; - String host1 = "http://www.test1.com"; - String vnfType = "VNF"; - int port = 8080; - String username = "test"; - String password = "test"; - String connectionDetails = "{\"host\":\"" + host + "\",\"port\":" + port + ",\"username\":\"" + username + "\",\"password\":\"" + password + "\",\"capabilities\":null,\"additionalProperties\":null}"; - String fileContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + - "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + - "\t<get-config>\n" + - "\t\t<source>\n" + - "\t\t\t<running/>\n" + - "\t\t </source>\n" + - "\t</get-config>\n" + - "</rpc>'"; - String operationalState = "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + - " <get>\n" + - " <filter>\n" + - " <ManagedElement xmlns=\"urn:org:onap:appc:Test\">\n" + - " <VnfFunction xmlns=\"urn:org:openecomop:appc:Test\">\n" + - " <ProcessorManagement>\n" + - " <MatedPair>\n" + - " <operationalState/>\n" + - " <PayloadProcessor>\n" + - " <operationalState/>\n" + - " </PayloadProcessor>\n" + - " </MatedPair>\n" + - " <SystemController>\n" + - " <operationalState/>\n" + - " </SystemController>\n" + - " </ProcessorManagement>\n" + - " </VnfFunction>\n" + - " </ManagedElement>\n" + - " </filter>\n" + - " </get>\n" + - "</rpc>\n"; - - - @Before - public void setUp() throws NoSuchFieldException, IllegalAccessException { - clientFactory = new NetconfClientFactoryMock(); - } - - - @Test - public void testConfigure() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - - params = new HashMap<>(); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails); - params.put(Constants.FILE_CONTENT_FIELD_NAME, fileContent); - - netconfClientPlugin.configure(params, ctx); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - - try { - Assert.assertEquals("wrong configuration", fileContent, client.getConf()); - Assert.assertEquals("wrong host", host, client.getLastConnectionDetails().getHost()); - Assert.assertEquals("wrong port", port, client.getLastConnectionDetails().getPort()); - Assert.assertEquals("wrong username", username, client.getLastConnectionDetails().getUsername()); - Assert.assertEquals("wrong password", password, client.getLastConnectionDetails().getPassword()); - Assert.assertFalse(client.isConnection()); - } catch (Exception e) { - Assert.fail("failed with because of " + e.getCause()); - } - } - - - @Test - public void testConfigureNegativeIOException() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - - params = new HashMap<>(); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, "{" + connectionDetails); - params.put(Constants.FILE_CONTENT_FIELD_NAME, fileContent); - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - - try { - netconfClientPlugin.configure(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNull(client.getLastConnectionDetails()); - Assert.assertNull(client.getConf()); - } - - } - - @Test - public void testOperationStateValidation() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setAnswer(operationalState); - - params = new HashMap<>(); - params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType); - params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails); - MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl(); - validatorMock.setConfigurationFileName("VnfGetRunningConfig"); - - PowerMockito.mockStatic(OperationalStateValidatorFactory.class); - when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock); - - netconfClientPlugin.operationStateValidation(params, ctx); - - Assert.assertTrue("validation process failed", validatorMock.isValidated()); - Assert.assertEquals(fileContent, client.getLastMessage()); - } - - @Test - public void testOperationStateValidationNegativeJsonProcessingNullIllegalStateException() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setAnswer(operationalState); - - params = new HashMap<>(); - params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType); - params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails); - MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl(); - validatorMock.setConfigurationFileName("VnfGetRunningConfig"); - - PowerMockito.mockStatic(OperationalStateValidatorFactory.class); - when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock); - substituteMapper(true); - - try { - netconfClientPlugin.operationStateValidation(params, ctx); - substituteMapper(false); - } catch (APPCException e) { - substituteMapper(false); - Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE)); - Assert.assertFalse(validatorMock.isValidated()); - Assert.assertNull(client.getLastMessage()); - } - } - - @Test - public void testOperationStateValidationNegativeConnectionDetailsAreNullNullPointerException() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setAnswer(operationalState); - - params = new HashMap<>(); - params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType); - params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, null); - MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl(); - validatorMock.setConfigurationFileName("VnfGetRunningConfig"); - - PowerMockito.mockStatic(OperationalStateValidatorFactory.class); - when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock); - ObjectMapper mapper = PowerMockito.mock(ObjectMapper.class); - final NetconfConnectionDetails netconfConnectionDetails = null; - when(mapper.readValue(Matchers.anyString(), Matchers.any(Class.class))).thenReturn(netconfConnectionDetails); - - try { - netconfClientPlugin.operationStateValidation(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE)); - Assert.assertFalse("validation process failed", validatorMock.isValidated()); - } - } - - - @Test - public void testOperationStateValidationNegativeAppcException() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setAnswer("wrong"); - - params = new HashMap<>(); - params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType); - params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails); - MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl(); - validatorMock.setConfigurationFileName("VnfGetRunningConfig"); - - PowerMockito.mockStatic(OperationalStateValidatorFactory.class); - when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock); - - try { - netconfClientPlugin.operationStateValidation(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE)); - Assert.assertFalse("validation process failed", validatorMock.isValidated()); - } - } - - - @Test - public void testOperationStateValidatioConnectionDetailsInParamsAreEmpty() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setAnswer(operationalState); - ((DAOServiceMock) dao).setConnection(getConnectionDetails()); - - params = new HashMap<>(); - params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType); - params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, ""); - MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl(); - validatorMock.setConfigurationFileName("VnfGetRunningConfig"); - - PowerMockito.mockStatic(OperationalStateValidatorFactory.class); - when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock); - - netconfClientPlugin.operationStateValidation(params, ctx); - - Assert.assertTrue("validation process failed", validatorMock.isValidated()); - Assert.assertEquals(fileContent, client.getLastMessage()); - } - - @Test - public void testOperationStateValidatioConnectionDetailsInParamsAreNull() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setAnswer(operationalState); - ((DAOServiceMock) dao).setConnection(getConnectionDetails()); - - params = new HashMap<>(); - params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType); - params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, null); - MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl(); - validatorMock.setConfigurationFileName("VnfGetRunningConfig"); - - PowerMockito.mockStatic(OperationalStateValidatorFactory.class); - when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock); - - netconfClientPlugin.operationStateValidation(params, ctx); - - Assert.assertTrue("validation process failed", validatorMock.isValidated()); - Assert.assertEquals(fileContent, client.getLastMessage()); - } - - - @Test - public void testBackupConfiguration() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - params = new HashMap<>(); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails); - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setConf(fileContent); - netconfClientPlugin.backupConfiguration(params, ctx); - - DAOServiceMock mockdao = (DAOServiceMock) dao; - DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - Date date = new Date(); - String creationDateExpected = dateFormat.format(date); - String creationDateActual = mockdao.getBackupConf().get("creationDate").substring(0, 10); - - Assert.assertEquals("wrong configuration in db", fileContent, mockdao.getBackupConf().get("logText")); - Assert.assertEquals(creationDateExpected, creationDateActual); - } - - @Test - public void testBackupConfigurationNegativeDgErrorFieldName() throws Exception { - shortInit(); - SvcLogicContext ctx = new SvcLogicContext(); - params = new HashMap<>(); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, "{" + connectionDetails); - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setConf(fileContent); - try { - netconfClientPlugin.backupConfiguration(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE)); - DAOServiceMock mockdao = (DAOServiceMock) dao; - Assert.assertNull(mockdao.getBackupConf()); - } - } - - @Test - public void testGetConfig() throws Exception { - fullInit(); - String entity = "123"; - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("entity", entity); - - params = new HashMap<>(); - params.put("conf-id", "current"); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails); - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setConf(fileContent); - - netconfClientPlugin.getConfig(params, ctx); - - Assert.assertEquals("Success", ctx.getAttribute("getConfig_Result")); - Assert.assertEquals(fileContent, ctx.getAttribute("fullConfig")); - Assert.assertNotNull(ctx.getAttribute(entity + ".Configuration")); - Assert.assertEquals(fileContent, ctx.getAttribute(entity + ".Configuration")); - } - - - @Test - public void testGetConfigNegativeConfigurationNull() throws Exception { - fullInit(); - String entity = "123"; - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("entity", entity); - - params = new HashMap<>(); - params.put("conf-id", "current"); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails); - - netconfClientPlugin.getConfig(params, ctx); - - Assert.assertEquals("failure", ctx.getAttribute("getConfig_Result")); - Assert.assertNull(ctx.getAttribute("fullConfig")); - Assert.assertNull(ctx.getAttribute(entity + ".Configuration")); - Assert.assertNull(ctx.getAttribute(entity + ".Configuration")); - } - - - @Test - public void testGetConfigNegativeNotSupportedConfId() throws Exception { - fullInit(); - String entity = "123"; - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("entity", entity); - - params = new HashMap<>(); - params.put("conf-id", "current1"); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails); - - netconfClientPlugin.getConfig(params, ctx); - - Assert.assertNull(ctx.getAttribute("getConfig_Result")); - Assert.assertNull(ctx.getAttribute("fullConfig")); - Assert.assertNull(ctx.getAttribute(entity + ".Configuration")); - Assert.assertNull(ctx.getAttribute(entity + ".Configuration")); - } - - @Test - public void testGetConfigNegativeWronjJsonConnectionDetailsException() throws Exception { - fullInit(); - String entity = "123"; - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("entity", entity); - - params = new HashMap<>(); - params.put("conf-id", "current"); - params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, "{" + connectionDetails); - - try { - netconfClientPlugin.getConfig(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertEquals("failure", ctx.getAttribute("getConfig_Result")); - Assert.assertNull(ctx.getAttribute("fullConfig")); - Assert.assertNull(ctx.getAttribute(entity + ".Configuration")); - Assert.assertNull(ctx.getAttribute(entity + ".Configuration")); - Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE)); - } - } - - @Test - public void testGetRunningConfig() throws Exception { - fullInit(); - SvcLogicContext ctx = new SvcLogicContext(); - params = new HashMap<>(); - params.put("host-ip-address", host); - params.put("user-name", username); - params.put("password", password); - params.put("port-number", String.valueOf(port)); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setConf(fileContent); - - netconfClientPlugin.getRunningConfig(params, ctx); - - Assert.assertEquals("Success", ctx.getAttribute("getRunningConfig_Result")); - Assert.assertEquals(fileContent, ctx.getAttribute("running-config")); - Assert.assertEquals("success", ctx.getStatus()); - } - - @Test - public void testGetRunningConfigWithoutPortNumberDgErrorFieldNameException() throws Exception { - fullInit(); - SvcLogicContext ctx = new SvcLogicContext(); - params = new HashMap<>(); - params.put("host-ip-address", host); - params.put("user-name", username); - params.put("password", password); - - NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.getNetconfClient(NetconfClientType.SSH); - client.setConf(fileContent); - - try { - netconfClientPlugin.getRunningConfig(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertEquals("failure", ctx.getAttribute("getRunningConfig_Result")); - Assert.assertNull(ctx.getAttribute("running-config")); - Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE)); - } - } - - @Test - public void testGetRunningConfigNegativeConfigurationNull() throws Exception { - fullInit(); - SvcLogicContext ctx = new SvcLogicContext(); - params = new HashMap<>(); - params.put("host-ip-address", host); - params.put("user-name", username); - params.put("password", password); - params.put("port-number", String.valueOf(port)); - - netconfClientPlugin.getRunningConfig(params, ctx); - - Assert.assertEquals("failure", ctx.getAttribute("getRunningConfig_Result")); - Assert.assertNull(ctx.getAttribute("running-config")); - } - - @Test - public void testValidateMandatoryParamNegativeEmptyParamValue() throws Exception { - shortInit(); - String paramName = "test"; - String paramValue = ""; - - try { - netconfClientPlugin.validateMandatoryParam(paramName, paramValue); - Assert.assertTrue(false); - } catch (Exception e) { - Assert.assertTrue(true); - } - } - - @Test - public void testRetrieveConnectionDetails() throws Exception { - shortInit(); - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - ConnectionDetails connectionDetails1 = getConnectionDetails(); - daoServiceMock.setConnection(connectionDetails1); - - NetconfConnectionDetails connectionDetailsActual = netconfClientPlugin.retrieveConnectionDetails(VnfType.VNF); - - Assert.assertEquals("wrong host", connectionDetails1.getHost(), connectionDetailsActual.getHost()); - Assert.assertEquals("wrong password", connectionDetails1.getPassword(), connectionDetailsActual.getPassword()); - Assert.assertEquals("wrong port", connectionDetails1.getPort(), connectionDetailsActual.getPort()); - Assert.assertEquals("wrong usename", connectionDetails1.getUsername(), connectionDetailsActual.getUsername()); - } - - - @Test - public void testRetrieveConnectionDetailsNegativeMissingConfiguration() throws Exception { - shortInit(); - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - ConnectionDetails connectionDetails1 = getConnectionDetails(); - daoServiceMock.setConnection(connectionDetails1); - - NetconfConnectionDetails connectionDetailsActual = null; - try { - connectionDetailsActual = netconfClientPlugin.retrieveConnectionDetails(VnfType.MOCK); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNull(connectionDetailsActual); - } - } - - @Test - public void testRetrieveConfigurationFileContent() throws Exception { - shortInit(); - - DAOServiceMock daoServiceMock = (DAOServiceMock) dao; - daoServiceMock.setConfigFile(fileContent); - - Assert.assertEquals("wrong config in a database", fileContent, netconfClientPlugin.retrieveConfigurationFileContent("VnfGetRunningConfig")); - } - - private ConnectionDetails getConnectionDetails() { - ConnectionDetails connectionDetails = new ConnectionDetails(); - connectionDetails.setPassword(password); - connectionDetails.setPort(port); - connectionDetails.setUsername(username); - connectionDetails.setHost(host); - return connectionDetails; - } - - - private void initDao() throws NoSuchFieldException, IllegalAccessException { - dao = new DAOServiceMock(); - PowerMockito.mockStatic(FrameworkUtil.class); - when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService); - when(bundleService.getBundleContext()).thenReturn(bundleContext); - when(bundleContext.getServiceReference(NetconfDataAccessService.class)).thenReturn(sref1); - when(bundleContext.getService(sref1)).thenReturn(dao); - } - - private void fullInit() throws NoSuchFieldException, IllegalAccessException { - initClientFactory(); - initClientFactory2(); - initDao(); - netconfClientPlugin = new NetconfClientPluginImpl(); - netconfClientPlugin.setDao(this.dao); - } - - private void shortInit() throws NoSuchFieldException, IllegalAccessException { - initClientFactory(); - initDao(); - netconfClientPlugin = new NetconfClientPluginImpl(); - netconfClientPlugin.setDao(this.dao); - } - - private void initClientFactory() throws NoSuchFieldException, IllegalAccessException { - PowerMockito.mockStatic(FrameworkUtil.class); - when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService); - when(bundleService.getBundleContext()).thenReturn(bundleContext); - when(bundleContext.getServiceReference(NetconfClientFactory.class)).thenReturn(sref2); - when(bundleContext.getService(sref2)).thenReturn(clientFactory); - } - - private void initClientFactory2() { - PowerMockito.mockStatic(FrameworkUtil.class); - when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService); - when(bundleService.getBundleContext()).thenReturn(bundleContext); - when(bundleContext.getServiceReference(Matchers.anyString())).thenReturn(sref3); - when(bundleContext.getService(sref3)).thenReturn(clientFactory); - } - - private void substituteMapper(boolean command) throws NoSuchFieldException, IllegalAccessException { - ObjectMapper mapper = new ObjectMapperMock(); - ObjectMapper mapper2 = new ObjectMapper(); - Field field = NetconfClientPluginImpl.class.getDeclaredField("mapper"); - field.setAccessible(true); - if (command) { - field.set(netconfClientPlugin, mapper); - } else { - field.set(netconfClientPlugin, mapper2); - } - } - -} diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml b/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml index 5ae88642d..4ffa0b8d5 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Copyright (C) 2017 Amdocs ============================================================================= @@ -87,6 +87,11 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> <version>1.3</version> diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml b/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml index d473d4d11..87aad831c 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Copyright (C) 2017 Amdocs ============================================================================= @@ -133,6 +133,11 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>equinoxSDK381</groupId> <artifactId>org.eclipse.osgi</artifactId> <version>${equinox.osgi.version}</version> diff --git a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml index 57fb97734..12e99c244 100644 --- a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml +++ b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Copyright (C) 2017 Amdocs ============================================================================= @@ -60,16 +60,15 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>equinoxSDK381</groupId> - <artifactId>org.eclipse.osgi</artifactId> - <scope>test</scope> - <version>${equinox.osgi.version}</version> - </dependency> - <dependency> <groupId>org.onap.appc</groupId> <artifactId>transaction-recorder</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build> diff --git a/appc-inbound/appc-artifact-handler/features/onap-appc-artifact-handler/pom.xml b/appc-inbound/appc-artifact-handler/features/onap-appc-artifact-handler/pom.xml index 1fd78b0c7..07337e89b 100644 --- a/appc-inbound/appc-artifact-handler/features/onap-appc-artifact-handler/pom.xml +++ b/appc-inbound/appc-artifact-handler/features/onap-appc-artifact-handler/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2019 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. diff --git a/appc-inbound/appc-artifact-handler/features/src/main/resources/features.xml b/appc-inbound/appc-artifact-handler/features/src/main/resources/features.xml deleted file mode 100644 index 3909d1c4b..000000000 --- a/appc-inbound/appc-artifact-handler/features/src/main/resources/features.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ONAP : APPC - ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Copyright (C) 2017 Amdocs - ============================================================================= - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ============LICENSE_END========================================================= - --> - - -<features name="app-cntrl-artifact-handler-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> - - - <!--<repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features</repository>--> - - <feature name='appc-artifact-handler' description="Application Controller Artifact Handler" - version='${project.version}'> - <!-- Most applications will have a dependency on the ODL MD-SAL Broker --> - <feature >odl-mdsal-broker</feature> - <feature>ccsdk-sli</feature> - <!-- <bundle>wrap:mvn:org.onap.appc/appc-yang-generator/${project.version}</bundle> --> - <bundle>wrap:mvn:org.openecomp.sdc.common/openecomp-tosca-datatype/${tosca.datatype.version}</bundle> - <bundle>mvn:org.onap.appc/appc-config-params-provider/${project.version}</bundle> - <bundle>mvn:org.onap.appc/appc-artifact-handler-model/${project.version}</bundle> - <bundle>mvn:org.onap.appc/appc-artifact-handler-provider/${project.version}</bundle> - <bundle>wrap:mvn:org.onap.appc/appc-yang-generator/${project.version}</bundle> - <configfile finalname="etc/opendaylight/karaf/200-artifact-handler-provider.xml">mvn:org.onap.appc/appc-artifact-handler-provider/${project.version}/xml/config</configfile> - </feature> - -</features> diff --git a/appc-inbound/appc-artifact-handler/installer/pom.xml b/appc-inbound/appc-artifact-handler/installer/pom.xml index 8f5f0b728..e6b4babf8 100755 --- a/appc-inbound/appc-artifact-handler/installer/pom.xml +++ b/appc-inbound/appc-artifact-handler/installer/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,8 +45,8 @@ <dependency> <groupId>org.onap.appc</groupId> <artifactId>onap-appc-artifact-handler</artifactId> - <classifier>features</classifier> <version>${project.version}</version> + <classifier>features</classifier> <type>xml</type> <exclusions> <exclusion> @@ -60,7 +60,6 @@ <artifactId>appc-artifact-handler-provider</artifactId> <version>${project.version}</version> </dependency> - </dependencies> diff --git a/appc-inbound/appc-artifact-handler/model/pom.xml b/appc-inbound/appc-artifact-handler/model/pom.xml index 2fef74457..48f058096 100755 --- a/appc-inbound/appc-artifact-handler/model/pom.xml +++ b/appc-inbound/appc-artifact-handler/model/pom.xml @@ -30,8 +30,8 @@ </parent> <groupId>org.onap.appc</groupId> <artifactId>appc-artifact-handler-model</artifactId> - <name>APPC Artifact Handler - Model</name> <packaging>bundle</packaging> + <name>APPC Artifact Handler - Model</name> <build> @@ -42,7 +42,7 @@ <extensions>true</extensions> <configuration> <instructions> - <Import-Package>!com.google.common.collect,*</Import-Package> + <Import-Package>com.google.common.collect,com.google.common.base,*</Import-Package> <Embed-Dependency>guava</Embed-Dependency> </instructions> </configuration> @@ -76,6 +76,7 @@ </execution> </executions> </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> @@ -110,15 +111,11 @@ </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> + <artifactId>ietf-inet-types-2013-07-15</artifactId> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> + <artifactId>ietf-yang-types-20130715</artifactId> </dependency> </dependencies> <version>1.5.0-SNAPSHOT</version> diff --git a/appc-inbound/appc-artifact-handler/model/src/main/yang/artifact-handler.yang b/appc-inbound/appc-artifact-handler/model/src/main/yang/artifact-handler.yang index f9bf7ae10..0aa8082d4 100644 --- a/appc-inbound/appc-artifact-handler/model/src/main/yang/artifact-handler.yang +++ b/appc-inbound/appc-artifact-handler/model/src/main/yang/artifact-handler.yang @@ -28,7 +28,6 @@ module artifact-handler { namespace "org.onap.appc:artifacthandler"; prefix artifacthandler; - import ietf-inet-types { prefix "ietf"; revision-date "2010-09-24"; } organization "AT&T, Inc."; description diff --git a/appc-inbound/appc-artifact-handler/pom.xml b/appc-inbound/appc-artifact-handler/pom.xml index 2a9f7f2af..5c642df5c 100755 --- a/appc-inbound/appc-artifact-handler/pom.xml +++ b/appc-inbound/appc-artifact-handler/pom.xml @@ -1,72 +1,44 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ONAP : APPC
- ================================================================================
- Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- Copyright (C) 2017 Amdocs
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.onap.appc.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath />
- </parent>
- <groupId>org.onap.appc</groupId>
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <artifactId>appc-artifact-handler</artifactId>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.appc</groupId>
- <artifactId>appc-artifact-handler-features</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.appc</groupId>
- <artifactId>appc-artifact-handler-model</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.appc</groupId>
- <artifactId>appc-artifact-handler-provider</artifactId>
- <version>${project.version}</version>
- <classifier>config</classifier>
- <type>xml</type>
- </dependency>
- <dependency>
- <groupId>org.onap.appc</groupId>
- <artifactId>appc-artifact-handler-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <modules>
- <module>model</module>
- <module>provider</module>
- <module>features</module>
- <module>installer</module>
- </modules>
- <version>1.5.0-SNAPSHOT</version>
-</project>
+<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ONAP : APPC + ================================================================================ + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017 Amdocs + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.appc.parent</groupId> + <artifactId>odlparent-lite</artifactId> + <version>1.5.0-SNAPSHOT</version> + <relativePath /> + </parent> + + <packaging>pom</packaging> + <groupId>org.onap.appc</groupId> + <artifactId>appc-artifact-handler</artifactId> + + <modules> + <module>model</module> + <module>features</module> + <module>provider</module> + <module>installer</module> + </modules> + + <version>1.5.0-SNAPSHOT</version> +</project> diff --git a/appc-inbound/appc-artifact-handler/provider/pom.xml b/appc-inbound/appc-artifact-handler/provider/pom.xml index 4b0fe415b..8c465cc1c 100755 --- a/appc-inbound/appc-artifact-handler/provider/pom.xml +++ b/appc-inbound/appc-artifact-handler/provider/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ -Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Copyright (C) 2017 Amdocs ============================================================================= @@ -43,9 +43,8 @@ limitations under the License. <configuration> <instructions> <Bundle-SymbolicName>org.onap.appc.artifact.handler</Bundle-SymbolicName> - <Bundle-Activator>org.onap.appc.artifact.handler.SdcArtifactHandlerActivator</Bundle-Activator> <Export-Package>org.onap.appc.artifact.handler,org.opendaylight.controller.config.yang.config.artifact-handler_provider.impl</Export-Package> - <Import-Package>!com.google,!org.apache.commons.configuration,*;resolution:=optional</Import-Package> + <Import-Package>com.google.common.base,com.google.common.collect,!com.google,!org.apache.commons.configuration,*;resolution:=optional</Import-Package> <Embed-Dependency>commons-configuration,guava,jackson-databind,jackson-annotations,jackson-core,jackson-dataformat-yaml,json</Embed-Dependency> </instructions> </configuration> @@ -68,11 +67,6 @@ limitations under the License. <artifactId>appc-yang-generator</artifactId> <version>${project.version}</version> </dependency> - - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-config</artifactId> - </dependency> <dependency> <groupId>org.opendaylight.controller</groupId> <artifactId>sal-binding-api</artifactId> @@ -109,19 +103,6 @@ limitations under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-broker-impl</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-broker-impl</artifactId> - <version>${odl.mdsal.version}</version> - <classifier>tests</classifier> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> <groupId>com.att.eelf</groupId> <artifactId>eelf-core</artifactId> </dependency> diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java index 3246ef1ff..065bdd69a 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java +++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -25,20 +25,10 @@ package org.onap.appc.artifact.handler; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - +import org.onap.appc.artifact.handler.utils.ArtifactHandlerProviderUtil; +import org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants; import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -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.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.ArtifactHandlerService; import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.UploadartifactInput; @@ -46,101 +36,40 @@ import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.Uplo import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.UploadartifactOutput; import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.UploadartifactOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.uploadartifact.output.ConfigDocumentResponseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.Services; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServicesBuilder; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.onap.appc.artifact.handler.utils.ArtifactHandlerProviderUtil; -import org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; - - -public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerService, DataChangeListener { +public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerService { private static final EELFLogger log = EELFManager.getInstance().getLogger(ArtifactHandlerProvider.class); private final String appName = "ArtifactsHandler"; - private final ExecutorService executor; protected DataBroker dataBroker; protected NotificationPublishService notificationService; protected RpcProviderRegistry rpcRegistry; - private ListenerRegistration<DataChangeListener> dclServices; - - protected BindingAwareBroker.RpcRegistration<ArtifactHandlerService> rpcRegistration; - public ArtifactHandlerProvider(DataBroker dataBroker2, - NotificationPublishService notificationProviderService, + public ArtifactHandlerProvider(DataBroker dataBroker2, NotificationPublishService notificationProviderService, RpcProviderRegistry rpcProviderRegistry) { this.log.info("Creating provider for " + appName); - executor = Executors.newFixedThreadPool(10); dataBroker = dataBroker2; notificationService = notificationProviderService; rpcRegistry = rpcProviderRegistry; initialize(); - } public void initialize() { log.info("Initializing provider for " + appName); - // Create the top level containers - createContainers(); try { ArtifactHandlerProviderUtil.loadProperties(); } catch (Exception e) { log.error("Caught exception while trying to load properties file", e); } - // Listener for changes to Services tree - log.info("Initialization complete for " + appName); } - private void createContainers() { - final WriteTransaction t = dataBroker.newReadWriteTransaction(); - // Create the Services container - t.merge(LogicalDatastoreType.CONFIGURATION,InstanceIdentifier.create(Services.class),new ServicesBuilder().build()); - t.merge(LogicalDatastoreType.OPERATIONAL,InstanceIdentifier.create(Services.class),new ServicesBuilder().build()); - - try { - CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit(); - checkedFuture.get(); - log.info("Create containers succeeded!"); - - } catch (InterruptedException e) { - log.error("Create containers failed", e); - Thread.currentThread().interrupt(); - } catch (ExecutionException e) { - log.error("Create containers failed", e); - } - } - - - @Override - public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> arg0) { - // TODO Auto-generated method stub - - } - - - - @Override - public void close() throws Exception { - - log.info("Closing provider for " + appName); - if(this.executor != null){ - executor.shutdown(); - } - if(this.rpcRegistration != null){ - rpcRegistration.close(); - } - log.info("Successfully closed provider for " + appName); - - } private RpcResult<UploadartifactOutput> buildResponse1( String svcRequestId, @@ -158,9 +87,8 @@ public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerSe .withResult(responseBuilder.build()).build(); return rpcResult; } - @Override - public Future<RpcResult<UploadartifactOutput>> uploadartifact(UploadartifactInput input) { + public ListenableFuture<RpcResult<UploadartifactOutput>> uploadartifact(UploadartifactInput input) { if (input == null || input.getDocumentParameters() == null || input.getDocumentParameters().getArtifactContents() == null ) { RpcResult<UploadartifactOutput> rpcResult = @@ -201,7 +129,12 @@ public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerSe responseBuilder.setConfigDocumentResponse(configResponseBuilder.build()); RpcResult<UploadartifactOutput> rpcResult = RpcResultBuilder.<UploadartifactOutput> status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); + } + @Override + public void close() throws Exception { + log.info("Closing provider for " + appName); + log.info("Successfully closed provider for " + appName); } protected ArtifactHandlerProviderUtil getArtifactHandlerProviderUtil(UploadartifactInput input) { diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivator.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivator.java deleted file mode 100644 index 58f4a12ed..000000000 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivator.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ================================================================================ - * Modifications Copyright (C) 2019 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.artifact.handler; - -import java.util.LinkedList; -import java.util.List; - -import org.onap.appc.artifact.handler.node.ArtifactHandlerNode; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class SdcArtifactHandlerActivator implements BundleActivator { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(SdcArtifactHandlerActivator.class); - private List<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>(); - - @Override - public void start(BundleContext ctx) throws Exception { - ArtifactHandlerNode artifactHandlerNode = new ArtifactHandlerNode(); - log.info("Registering service-- " + artifactHandlerNode.getClass().getName()); - registrations.add(ctx.registerService(artifactHandlerNode.getClass().getName(), artifactHandlerNode, null)); - - } - - @Override - public void stop(BundleContext arg0) throws Exception { - for (ServiceRegistration registration : registrations) { - registration.unregister(); - registration = null; - } - } -} diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler-blueprint.xml b/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler.xml index d74724ce7..8185e6c5b 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler-blueprint.xml +++ b/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2018-2019 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. @@ -22,8 +22,6 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - - <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="default" /> @@ -44,4 +42,4 @@ <odl:rpc-implementation ref="artifact-handler"/> -</blueprint>
\ No newline at end of file +</blueprint> diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java index 56a999126..aa1c86ad2 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java +++ b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java @@ -65,13 +65,6 @@ public class ArtifactHandlerProviderTest { Mockito.doReturn(checkedFuture).when(writeTransaction).submit(); } - @Test - public void testClose() throws Exception { - artifactHandlerProvider = new ArtifactHandlerProvider(dataBroker, notificationService, rpcRegistry); - Whitebox.setInternalState(artifactHandlerProvider, "rpcRegistration", rpcRegistration); - artifactHandlerProvider.close(); - Mockito.verify(rpcRegistration).close(); - } @Test public void testUploadArtifactNullInput() throws InterruptedException, ExecutionException { diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivatorTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivatorTest.java deleted file mode 100644 index 995ffecc6..000000000 --- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivatorTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2019 Ericsson - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.artifact.handler; - -import java.util.LinkedList; -import org.junit.Test; -import org.mockito.Mockito; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.powermock.reflect.Whitebox; - - -public class SdcArtifactHandlerActivatorTest { - - @Test - public void testStart() throws Exception { - SdcArtifactHandlerActivator activator = new SdcArtifactHandlerActivator(); - BundleContext ctx = Mockito.mock(BundleContext.class); - LinkedList<ServiceRegistration> list = Mockito.spy(new LinkedList<>()); - Whitebox.setInternalState(activator, "registrations", list); - activator.start(ctx); - Mockito.verify(list).add(Mockito.any()); - } - - @Test - public void testStop() throws Exception { - SdcArtifactHandlerActivator activator = new SdcArtifactHandlerActivator(); - BundleContext ctx = Mockito.mock(BundleContext.class); - LinkedList<ServiceRegistration> list = Mockito.spy(new LinkedList<>()); - ServiceRegistration serviceRegistration = Mockito.mock(ServiceRegistration.class); - list.add(serviceRegistration); - Whitebox.setInternalState(activator, "registrations", list); - activator.stop(ctx); - Mockito.verify(serviceRegistration).unregister(); - } -} diff --git a/appc-inbound/appc-design-services/features/onap-appc-design-services/pom.xml b/appc-inbound/appc-design-services/features/onap-appc-design-services/pom.xml index 0920420b0..2bc2a71bc 100644 --- a/appc-inbound/appc-design-services/features/onap-appc-design-services/pom.xml +++ b/appc-inbound/appc-design-services/features/onap-appc-design-services/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2019 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. @@ -38,12 +38,6 @@ limitations under the License. <dependencies> <dependency> - <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>odl-mdsal-models</artifactId> - <type>xml</type> - <classifier>features</classifier> - </dependency> - <dependency> <groupId>org.onap.appc</groupId> <artifactId>appc-design-services-model</artifactId> <version>${project.version}</version> diff --git a/appc-inbound/appc-design-services/model/pom.xml b/appc-inbound/appc-design-services/model/pom.xml index f5875ca06..dae9f63c8 100755 --- a/appc-inbound/appc-design-services/model/pom.xml +++ b/appc-inbound/appc-design-services/model/pom.xml @@ -167,11 +167,11 @@ </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> + <artifactId>ietf-inet-types-2013-07-15</artifactId> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> + <artifactId>ietf-yang-types-20130715</artifactId> </dependency> </dependencies> <version>1.5.0-SNAPSHOT</version> diff --git a/appc-inbound/appc-design-services/provider/pom.xml b/appc-inbound/appc-design-services/provider/pom.xml index e53bec080..e3ecf887a 100755 --- a/appc-inbound/appc-design-services/provider/pom.xml +++ b/appc-inbound/appc-design-services/provider/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs Modification Copyright (C) 2018 IBM ================================================================================ @@ -93,14 +93,6 @@ </dependency> <dependency> <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-config</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-api</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> <artifactId>sal-common-util</artifactId> </dependency> <dependency> diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/impl/DesignServicesImpl.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/impl/DesignServicesImpl.java index 890f40d3d..5833b0157 100644 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/impl/DesignServicesImpl.java +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/impl/DesignServicesImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= @@ -26,7 +26,7 @@ package org.onap.appc.design.services.impl; import com.google.common.util.concurrent.Futures; -import java.util.concurrent.Future; +import com.google.common.util.concurrent.ListenableFuture; import org.onap.appc.design.dbervices.DbResponseProcessor; import org.onap.appc.design.dbervices.DesignDBService; import org.onap.appc.design.services.util.DesignServiceConstants; @@ -58,7 +58,7 @@ public class DesignServicesImpl implements DesignServicesService { private static final String ACTION_STR = " Action : "; @Override - public Future<RpcResult<DbserviceOutput>> dbservice(DbserviceInput input) { + public ListenableFuture<RpcResult<DbserviceOutput>> dbservice(DbserviceInput input) { log.info(RECEIVED_REQUEST_STR + input.getDesignRequest().getRequestId() + ACTION_STR + input.getDesignRequest().getAction() + WITH_PAYLOAD_STR + input.getDesignRequest().getPayload()); @@ -93,7 +93,7 @@ public class DesignServicesImpl implements DesignServicesService { } @Override - public Future<RpcResult<XinterfaceserviceOutput>> xinterfaceservice(XinterfaceserviceInput input) { + public ListenableFuture<RpcResult<XinterfaceserviceOutput>> xinterfaceservice(XinterfaceserviceInput input) { log.info(RECEIVED_REQUEST_STR + input.getDesignRequest().getRequestId() + ACTION_STR + input.getDesignRequest().getAction() + WITH_PAYLOAD_STR + input.getDesignRequest().getPayload()); XinterfaceserviceOutputBuilder outputBuilder = new XinterfaceserviceOutputBuilder(); @@ -124,7 +124,7 @@ public class DesignServicesImpl implements DesignServicesService { } @Override - public Future<RpcResult<ValidatorOutput>> validator(ValidatorInput input) { + public ListenableFuture<RpcResult<ValidatorOutput>> validator(ValidatorInput input) { log.info(RECEIVED_REQUEST_STR + input.getDesignRequest().getRequestId() + ACTION_STR + input.getDesignRequest().getAction() + WITH_PAYLOAD_STR + input.getDesignRequest().getPayload() + " and Data Type = " + input.getDesignRequest().getDataType()); diff --git a/appc-inbound/appc-interfaces-service/bundle/pom.xml b/appc-inbound/appc-interfaces-service/bundle/pom.xml index 8241325f9..b9b7a3fd0 100644 --- a/appc-inbound/appc-interfaces-service/bundle/pom.xml +++ b/appc-inbound/appc-interfaces-service/bundle/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -90,14 +90,6 @@ </dependency> <dependency> <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-config</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-api</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> <artifactId>sal-common-util</artifactId> </dependency> <dependency> diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java index caf024739..ba05de733 100644 --- a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -26,8 +26,6 @@ package org.onap.appc.interfaces.service; -import java.util.concurrent.Future; - import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceInput; import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceOutput; import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceOutputBuilder; @@ -41,13 +39,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; public class InterfacesServiceProviderImpl implements InterfacesServiceService{ private static final Logger log = LoggerFactory.getLogger(InterfacesServiceProviderImpl.class); @Override - public Future<RpcResult<ExecuteServiceOutput>> executeService(ExecuteServiceInput input) { + public ListenableFuture<RpcResult<ExecuteServiceOutput>> executeService(ExecuteServiceInput input) { log.info("Received Request: " + input.getRequest().getRequestId() + " Action : " + input.getRequest().getAction() + " with RequestData :" + input.getRequest().getRequestData() + " and data-Type : " + input.getRequest().getRequestDataType()); diff --git a/appc-inbound/appc-interfaces-service/features/onap-appc-interfaces-service/pom.xml b/appc-inbound/appc-interfaces-service/features/onap-appc-interfaces-service/pom.xml index fb3fd9569..56e5e8091 100644 --- a/appc-inbound/appc-interfaces-service/features/onap-appc-interfaces-service/pom.xml +++ b/appc-inbound/appc-interfaces-service/features/onap-appc-interfaces-service/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2019 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. @@ -38,12 +38,6 @@ limitations under the License. <dependencies> <dependency> - <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>odl-mdsal-models</artifactId> - <type>xml</type> - <classifier>features</classifier> - </dependency> - <dependency> <groupId>org.onap.appc</groupId> <artifactId>appc-interfaces-service-model</artifactId> <version>${project.version}</version> diff --git a/appc-inbound/appc-interfaces-service/model/pom.xml b/appc-inbound/appc-interfaces-service/model/pom.xml index 466cb18c8..382da303a 100644 --- a/appc-inbound/appc-interfaces-service/model/pom.xml +++ b/appc-inbound/appc-interfaces-service/model/pom.xml @@ -167,11 +167,11 @@ </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> + <artifactId>ietf-inet-types-2013-07-15</artifactId> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> + <artifactId>ietf-yang-types-20130715</artifactId> </dependency> </dependencies> <version>1.5.0-SNAPSHOT</version> diff --git a/appc-oam/appc-oam-bundle/pom.xml b/appc-oam/appc-oam-bundle/pom.xml index 6d04da8fe..fdc0c8ffd 100644 --- a/appc-oam/appc-oam-bundle/pom.xml +++ b/appc-oam/appc-oam-bundle/pom.xml @@ -136,14 +136,6 @@ </dependency> <dependency> <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-config</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-api</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> <artifactId>sal-common-util</artifactId> </dependency> <dependency> @@ -152,19 +144,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-broker-impl</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-broker-impl</artifactId> - <classifier>tests</classifier> - <version>${odl.mdsal.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/AppcOam.java b/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/AppcOam.java index cbe2a4d57..c41abb22d 100644 --- a/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/AppcOam.java +++ b/appc-oam/appc-oam-bundle/src/main/java/org/onap/appc/oam/AppcOam.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -28,14 +28,17 @@ package org.onap.appc.oam; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.AppcOamService; import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.AppcState; +import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetAppcStateInput; import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetAppcStateOutput; import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetAppcStateOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetMetricsInput; import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetMetricsOutput; import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetMetricsOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.MaintenanceModeInput; @@ -133,13 +136,13 @@ public class AppcOam implements AutoCloseable, AppcOamService { * and also provides the ability to subscribe for changes to data under a * given branch * of the tree. Not used in this class. - * @param notificationProviderService object of ODL Notification Service that provides publish/subscribe + * @param notificationPublishService object of ODL Notification Service that provides publish/subscribe * capabilities for YANG modeled notifications. Not used in this class. * @param rpcProviderRegistry object of RpcProviderResigstry. Used to register our RPCs. */ @SuppressWarnings({"unused", "nls"}) public AppcOam(DataBroker dataBroker, - NotificationProviderService notificationProviderService, + NotificationPublishService notificationPublishService, RpcProviderRegistry rpcProviderRegistry) { configurationHelper = new ConfigurationHelper(logger); @@ -191,7 +194,7 @@ public class AppcOam implements AutoCloseable, AppcOamService { * {@inheritDoc} */ @Override - public Future<RpcResult<GetMetricsOutput>> getMetrics() { + public ListenableFuture<RpcResult<GetMetricsOutput>> getMetrics(GetMetricsInput getMetricsInput) { if (!isMetricEnabled) { logger.error("Metric Service not enabled returning failure"); @@ -256,7 +259,7 @@ public class AppcOam implements AutoCloseable, AppcOamService { * {@inheritDoc} */ @Override - public Future<RpcResult<StopOutput>> stop(StopInput stopInput) { + public ListenableFuture<RpcResult<StopOutput>> stop(StopInput stopInput) { logger.debug("Entering Stop with Input : " + stopInput); final CommonHeader commonHeader = stopInput.getCommonHeader(); @@ -274,7 +277,7 @@ public class AppcOam implements AutoCloseable, AppcOamService { * {@inheritDoc} */ @Override - public Future<RpcResult<RestartOutput>> restart(RestartInput input) { + public ListenableFuture<RpcResult<RestartOutput>> restart(RestartInput input) { logger.debug("Entering restart with Input : " + input); final CommonHeader commonHeader = input.getCommonHeader(); @@ -293,7 +296,7 @@ public class AppcOam implements AutoCloseable, AppcOamService { * {@inheritDoc} */ @Override - public Future<RpcResult<MaintenanceModeOutput>> maintenanceMode(MaintenanceModeInput maintenanceModeInput) { + public ListenableFuture<RpcResult<MaintenanceModeOutput>> maintenanceMode(MaintenanceModeInput maintenanceModeInput) { logger.debug("Entering MaintenanceMode with Input : " + maintenanceModeInput); final CommonHeader commonHeader = maintenanceModeInput.getCommonHeader(); @@ -311,7 +314,7 @@ public class AppcOam implements AutoCloseable, AppcOamService { * {@inheritDoc} */ @Override - public Future<RpcResult<GetAppcStateOutput>> getAppcState() { + public ListenableFuture<RpcResult<GetAppcStateOutput>> getAppcState(GetAppcStateInput getAppcStateInput) { AppcState appcState = stateHelper.getCurrentOamYangState(); GetAppcStateOutputBuilder builder = new GetAppcStateOutputBuilder(); @@ -323,7 +326,7 @@ public class AppcOam implements AutoCloseable, AppcOamService { * {@inheritDoc} */ @Override - public Future<RpcResult<StartOutput>> start(StartInput startInput) { + public ListenableFuture<RpcResult<StartOutput>> start(StartInput startInput) { logger.debug("Input received : " + startInput); final CommonHeader commonHeader = startInput.getCommonHeader(); diff --git a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/AppcOamTest.java b/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/AppcOamTest.java deleted file mode 100644 index 5f2ae228b..000000000 --- a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/AppcOamTest.java +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ================================================================================ - * Modifications (C) 2018 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.oam; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.powermock.api.mockito.PowerMockito.spy; -import java.util.Collection; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.appc.exceptions.APPCException; -import org.onap.appc.i18n.Msg; -import org.onap.appc.metricservice.MetricRegistry; -import org.onap.appc.metricservice.MetricService; -import org.onap.appc.metricservice.metric.Metric; -import org.onap.appc.metricservice.metric.MetricType; -import org.onap.appc.metricservice.metric.impl.DefaultPrimitiveCounter; -import org.onap.appc.metricservice.metric.impl.DispatchingFuntionMetricImpl; -import org.onap.appc.oam.processor.OamMmodeProcessor; -import org.onap.appc.oam.processor.OamRestartProcessor; -import org.onap.appc.oam.processor.OamStartProcessor; -import org.onap.appc.oam.processor.OamStopProcessor; -import org.onap.appc.oam.util.AsyncTaskHelper; -import org.onap.appc.oam.util.ConfigurationHelper; -import org.onap.appc.oam.util.OperationHelper; -import org.onap.appc.oam.util.StateHelper; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.AppcState; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetAppcStateOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetMetricsOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.MaintenanceModeInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.MaintenanceModeOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.RestartInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.RestartOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.StartInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.StartOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.StopInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.StopOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.common.header.CommonHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.status.Status; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.powermock.reflect.Whitebox; -import com.att.aft.dme2.internal.google.common.collect.Iterables; -import com.att.eelf.configuration.EELFLogger; -import com.google.common.collect.ImmutableMap; - - -public class AppcOamTest { - - private AppcOam appcOam; - private CommonHeader mockCommonHeader = mock(CommonHeader.class); - private Status mockStatus = mock(Status.class); - private OperationHelper mockOperationHelper = mock(OperationHelper.class); - private StateHelper mockStateHelper = mock(StateHelper.class); - - @Before - public void setUp() throws Exception { - appcOam = spy(new AppcOam(null, null, null)); - - Whitebox.setInternalState(appcOam, "stateHelper", mockStateHelper); - Whitebox.setInternalState(appcOam, "operationHelper", mockOperationHelper); - } - - @Test - public void testMaintenanceMode() throws Exception { - // mock processor creation - OamMmodeProcessor mockProcessor = mock(OamMmodeProcessor.class); - Mockito.doReturn(mockProcessor).when(appcOam).getOamMmodeProcessor(Mockito.any(EELFLogger.class), - Mockito.any(ConfigurationHelper.class), Mockito.any(StateHelper.class), - Mockito.any(AsyncTaskHelper.class), Mockito.any(OperationHelper.class)); - // mock input - MaintenanceModeInput mockInput = mock(MaintenanceModeInput.class); - Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader(); - // mock processor result - Mockito.doReturn(mockStatus).when(mockProcessor).processRequest(mockInput); - - Future<RpcResult<MaintenanceModeOutput>> response = appcOam.maintenanceMode(mockInput); - - Assert.assertEquals("Should have common header", mockCommonHeader, - response.get().getResult().getCommonHeader()); - Assert.assertEquals("Should have status", mockStatus, response.get().getResult().getStatus()); - } - - @Test - public void testStart() throws Exception { - // mock processor creation - OamStartProcessor mockProcessor = mock(OamStartProcessor.class); - Mockito.doReturn(mockProcessor).when(appcOam).getOamStartProcessor(Mockito.any(EELFLogger.class), - Mockito.any(ConfigurationHelper.class), Mockito.any(StateHelper.class), - Mockito.any(AsyncTaskHelper.class), Mockito.any(OperationHelper.class)); - // mock input - StartInput mockInput = mock(StartInput.class); - Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader(); - // mock processor result - Mockito.doReturn(mockStatus).when(mockProcessor).processRequest(mockInput); - - Future<RpcResult<StartOutput>> response = appcOam.start(mockInput); - - Assert.assertEquals("Should have common header", mockCommonHeader, - response.get().getResult().getCommonHeader()); - Assert.assertEquals("Should have status", mockStatus, response.get().getResult().getStatus()); - } - - @Test - public void testStop() throws Exception { - // mock processor creation - OamStopProcessor mockProcessor = mock(OamStopProcessor.class); - //Mockito.doNothing().when(mockProcessor).setInitialLogProperties(); - Mockito.doReturn(mockProcessor).when(appcOam).getOamStopProcessor(Mockito.any(EELFLogger.class), - Mockito.any(ConfigurationHelper.class), Mockito.any(StateHelper.class), - Mockito.any(AsyncTaskHelper.class), Mockito.any(OperationHelper.class)); - // mock input - StopInput mockInput = mock(StopInput.class); - Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader(); - // mock processor result - Mockito.doReturn(mockStatus).when(mockProcessor).processRequest(mockInput); - - Future<RpcResult<StopOutput>> response = appcOam.stop(mockInput); - - Assert.assertEquals("Should have common header", mockCommonHeader, - response.get().getResult().getCommonHeader()); - Assert.assertEquals("Should have status", mockStatus, response.get().getResult().getStatus()); - } - - @Test - public void testRestart() throws Exception { - // mock processor creation - OamRestartProcessor mockProcessor = mock(OamRestartProcessor.class); - Mockito.doReturn(mockProcessor).when(appcOam).getOamRestartProcessor(Mockito.any(EELFLogger.class), - Mockito.any(ConfigurationHelper.class), Mockito.any(StateHelper.class), - Mockito.any(AsyncTaskHelper.class), Mockito.any(OperationHelper.class)); - // mock input - RestartInput mockInput = mock(RestartInput.class); - Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader(); - // mock processor result - Mockito.doReturn(mockStatus).when(mockProcessor).processRequest(mockInput); - - Future<RpcResult<RestartOutput>> response = appcOam.restart(mockInput); - - Assert.assertEquals("Should have common header", mockCommonHeader, - response.get().getResult().getCommonHeader()); - Assert.assertEquals("Should have status", mockStatus, response.get().getResult().getStatus()); - } - - @Test - public void testGetAppcState() throws Exception { - AppcState appcState = AppcState.Started; - Mockito.doReturn(appcState).when(mockStateHelper).getCurrentOamYangState(); - - Future<RpcResult<GetAppcStateOutput>> state = appcOam.getAppcState(); - Assert.assertEquals("Should return the same state", - appcState, state.get().getResult().getState()); - } - - @Test - public void testGetMetricsMetricDisabled() throws InterruptedException, ExecutionException { - Whitebox.setInternalState(appcOam, "isMetricEnabled", false); - Future<RpcResult<GetMetricsOutput>> result = appcOam.getMetrics(); - assertEquals("Metric Service not enabled", Iterables.get(result.get().getErrors(), 0).getMessage()); - } - - @Test - public void testGetMetricsNoMetricsService() throws InterruptedException, ExecutionException, APPCException { - Whitebox.setInternalState(appcOam, "isMetricEnabled", true); - Mockito.doThrow(new APPCException()).when(mockOperationHelper).getService(MetricService.class); - Future<RpcResult<GetMetricsOutput>> result = appcOam.getMetrics(); - assertEquals("Metric Service not found", Iterables.get(result.get().getErrors(), 0).getMessage()); - } - - @Test - public void testGetMetricsNoMetrics() throws InterruptedException, ExecutionException, APPCException { - Whitebox.setInternalState(appcOam, "isMetricEnabled", true); - MetricService mockMetricService = mock(MetricService.class); - Mockito.doReturn(mockMetricService).when(mockOperationHelper).getService(MetricService.class); - Future<RpcResult<GetMetricsOutput>> result = appcOam.getMetrics(); - assertEquals("No metrics Registered", Iterables.get(result.get().getErrors(), 0).getMessage()); - } - - @Test - public void testGetMetricsWithMetricRegistry() throws InterruptedException, ExecutionException, APPCException { - Whitebox.setInternalState(appcOam, "isMetricEnabled", true); - MetricService mockMetricService = mock(MetricService.class); - MetricRegistry mockMetricRegistry = mock(MetricRegistry.class); - Mockito.doReturn(mockMetricService).when(mockOperationHelper).getService(MetricService.class); - Mockito.doReturn(ImmutableMap.of("TEST REGISTRY NAME", mockMetricRegistry)).when(mockMetricService).getAllRegistry(); - Metric metric = new DispatchingFuntionMetricImpl("TEST METRIC NAME", MetricType.COUNTER, 0, 0); - Mockito.doReturn(new Metric[] {metric}).when(mockMetricRegistry).metrics(); - Future<RpcResult<GetMetricsOutput>> result = appcOam.getMetrics(); - assertEquals(1, result.get().getResult().getMetrics().size()); - } - - @Test - public void testClose() throws Exception { - ConfigurationHelper mockConfigurationHelper = mock(ConfigurationHelper.class); - Mockito.doReturn("TEST APP NAME").when(mockConfigurationHelper).getAppcName(); - Whitebox.setInternalState(appcOam, "configurationHelper", mockConfigurationHelper); - EELFLogger mockLogger = Mockito.mock(EELFLogger.class); - Whitebox.setInternalState(appcOam, "logger", mockLogger); - appcOam.close(); - Mockito.verify(mockLogger).info(Msg.COMPONENT_TERMINATED, "TEST APP NAME", "oam"); - } -} diff --git a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/processor/BaseCommonTest.java b/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/processor/BaseCommonTest.java deleted file mode 100644 index 60d9e3c92..000000000 --- a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/processor/BaseCommonTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ================================================================================ - * Modifications (C) 2018 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.oam.processor; - -import com.att.eelf.configuration.EELFLogger; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.common.header.CommonHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.status.Status; -import org.onap.appc.exceptions.InvalidInputException; -import org.onap.appc.exceptions.InvalidStateException; -import org.onap.appc.oam.AppcOam; -import org.onap.appc.oam.OAMCommandStatus; -import org.onap.appc.oam.util.ConfigurationHelper; -import org.onap.appc.oam.util.OperationHelper; -import org.onap.appc.oam.util.StateHelper; -import org.onap.appc.statemachine.impl.readers.AppcOamStates; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; -import org.slf4j.MDC; -import java.util.Map; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.powermock.api.mockito.PowerMockito.mockStatic; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({BaseCommon.class, MDC.class}) -public class BaseCommonTest { - private class TestAbc extends BaseCommon { - - /** - * Constructor - * - * @param eelfLogger for logging - * @param configurationHelperIn for property reading - * @param stateHelperIn for APP-C OAM state checking - * @param operationHelperIn for operational helper - */ - TestAbc(EELFLogger eelfLogger, - ConfigurationHelper configurationHelperIn, - StateHelper stateHelperIn, - OperationHelper operationHelperIn) { - super(eelfLogger, configurationHelperIn, stateHelperIn, operationHelperIn); - } - } - - private TestAbc testBaseCommon; - private ConfigurationHelper mockConfigHelper = mock(ConfigurationHelper.class); - private StateHelper mockStateHelper = mock(StateHelper.class); - private CommonHeader mockCommonHeader = mock(CommonHeader.class); - - @Before - public void setUp() throws Exception { - testBaseCommon = spy(new TestAbc(null, mockConfigHelper, mockStateHelper, null)); - - Whitebox.setInternalState(testBaseCommon, "commonHeader", mockCommonHeader); - Whitebox.setInternalState(testBaseCommon, "rpc", AppcOam.RPC.maintenance_mode); - - // to avoid operation on logger fail, mock up the logger - EELFLogger mockLogger = mock(EELFLogger.class); - Whitebox.setInternalState(testBaseCommon, "logger", mockLogger); - } - - @Test - public void testSetStatus() throws Exception { - OAMCommandStatus oamCommandStatus = OAMCommandStatus.ACCEPTED; - testBaseCommon.setStatus(oamCommandStatus); - Status status = testBaseCommon.status; - Assert.assertEquals("Should have code", oamCommandStatus.getResponseCode(), status.getCode().intValue()); - Assert.assertEquals("Should have message", oamCommandStatus.getResponseMessage(), status.getMessage()); - } - - @Test - public void testSetStatusWithParams() throws Exception { - String message = "testing"; - OAMCommandStatus oamCommandStatus = OAMCommandStatus.REJECTED; - testBaseCommon.setStatus(oamCommandStatus, message); - Status status = testBaseCommon.status; - Assert.assertEquals("Should have code", oamCommandStatus.getResponseCode(), status.getCode().intValue()); - Assert.assertTrue("Should have message", status.getMessage().endsWith(message)); - } - - @Test - public void testSetErrorStatus() throws Exception { - Mockito.doReturn("testName").when(mockConfigHelper).getAppcName(); - Mockito.doReturn(AppcOamStates.Started).when(mockStateHelper).getCurrentOamState(); - Mockito.doReturn("testRequestId").when(mockCommonHeader).getRequestId(); - Mockito.doReturn("testOrigId").when(mockCommonHeader).getOriginatorId(); - Mockito.doReturn("SOME HOST NAME").when(testBaseCommon).getHostInfo(Mockito.anyString()); - - String exceptionMessage = "testing"; - - OAMCommandStatus oamCommandStatus = OAMCommandStatus.INVALID_PARAMETER; - Throwable t = new InvalidInputException(exceptionMessage); - testBaseCommon.setErrorStatus(t); - Status status = testBaseCommon.status; - Assert.assertEquals("Should have code", oamCommandStatus.getResponseCode(), status.getCode().intValue()); - Mockito.verify(testBaseCommon, times(1)).resetLogProperties(false); - Mockito.verify(testBaseCommon, times(1)).resetLogProperties(true); - - oamCommandStatus = OAMCommandStatus.REJECTED; - t = new InvalidStateException(exceptionMessage); - testBaseCommon.setErrorStatus(t); - status = testBaseCommon.status; - Assert.assertEquals("Should have code", oamCommandStatus.getResponseCode(), status.getCode().intValue()); - Mockito.verify(testBaseCommon, times(2)).resetLogProperties(false); - Mockito.verify(testBaseCommon, times(2)).resetLogProperties(true); - - oamCommandStatus = OAMCommandStatus.UNEXPECTED_ERROR; - t = new NullPointerException(exceptionMessage); - testBaseCommon.setErrorStatus(t); - status = testBaseCommon.status; - Assert.assertEquals("Should have code", oamCommandStatus.getResponseCode(), status.getCode().intValue()); - Mockito.verify(testBaseCommon, times(3)).resetLogProperties(false); - Mockito.verify(testBaseCommon, times(3)).resetLogProperties(true); - } - - @Test - public void testSetInitialLogProperties() throws Exception { - mockStatic(MDC.class); - Mockito.doReturn("SOME HOST NAME").when(testBaseCommon).getHostInfo(Mockito.anyString()); - testBaseCommon.setInitialLogProperties(); - PowerMockito.verifyStatic(times(5)); - } - - @Test - public void testClearRequestLogProperties() throws Exception { - mockStatic(MDC.class); - testBaseCommon.clearRequestLogProperties(); - PowerMockito.verifyStatic(times(5)); - } - - @Test - public void testResetLogProperties() throws Exception { - Mockito.doReturn("SOME HOST NAME").when(testBaseCommon).getHostInfo(Mockito.anyString()); - testBaseCommon.setInitialLogProperties(); - - testBaseCommon.resetLogProperties(false); - Mockito.verify(mockCommonHeader, times(2)).getRequestId(); - Mockito.verify(mockCommonHeader, times(2)).getOriginatorId(); - Map<String, String> oldMdcMap = Whitebox.getInternalState(testBaseCommon, "oldMdcContent"); - Assert.assertTrue("Should have 5 entries in persisted map", oldMdcMap.size() == 5); - - testBaseCommon.resetLogProperties(false); - Mockito.verify(mockCommonHeader, times(3)).getRequestId(); - Mockito.verify(mockCommonHeader, times(3)).getOriginatorId(); - - // test oldMdcMap is cleared - testBaseCommon.resetLogProperties(false); - Mockito.verify(mockCommonHeader, times(4)).getRequestId(); - Mockito.verify(mockCommonHeader, times(4)).getOriginatorId(); - oldMdcMap = Whitebox.getInternalState(testBaseCommon, "oldMdcContent"); - Assert.assertTrue("Should have 5 entries in persisted map", oldMdcMap.size() == 5); - } -} diff --git a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/processor/BaseProcessorTest.java b/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/processor/BaseProcessorTest.java deleted file mode 100644 index 55ae11b8d..000000000 --- a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/processor/BaseProcessorTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ================================================================================ - * Modifications (C) 2018 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.oam.processor; - -import com.att.eelf.configuration.EELFLogger; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.StartInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.common.header.CommonHeader; -import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.status.Status; -import org.onap.appc.exceptions.APPCException; -import org.onap.appc.exceptions.InvalidInputException; -import org.onap.appc.exceptions.InvalidStateException; -import org.onap.appc.i18n.Msg; -import org.onap.appc.oam.AppcOam; -import org.onap.appc.oam.OAMCommandStatus; -import org.onap.appc.oam.util.AsyncTaskHelper; -import org.onap.appc.oam.util.ConfigurationHelper; -import org.onap.appc.oam.util.OperationHelper; -import org.onap.appc.oam.util.StateHelper; -import org.onap.appc.statemachine.impl.readers.AppcOamStates; -import org.powermock.reflect.Whitebox; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; - -@SuppressWarnings("ResultOfMethodCallIgnored") -public class BaseProcessorTest { - private AppcOam.RPC testRpc = AppcOam.RPC.start; - private AppcOamStates currentState = AppcOamStates.Stopped; - - private class TestAbc extends BaseProcessor { - - /** - * Constructor - * - * @param eelfLogger for logging - * @param configurationHelperIn for property reading - * @param stateHelperIn for APP-C OAM state checking - * @param asyncTaskHelperIn for scheduling async task - * @param operationHelperIn for operational helper - */ - TestAbc(EELFLogger eelfLogger, - ConfigurationHelper configurationHelperIn, - StateHelper stateHelperIn, - AsyncTaskHelper asyncTaskHelperIn, - OperationHelper operationHelperIn) { - super(eelfLogger, configurationHelperIn, stateHelperIn, asyncTaskHelperIn, operationHelperIn); - - // must set rpc and auditMsg - rpc = testRpc; - auditMsg = Msg.OAM_OPERATION_STARTING; - } - } - - private TestAbc testBaseProcessor; - private ConfigurationHelper mockConfigHelper = mock(ConfigurationHelper.class); - private StateHelper mockStateHelper = mock(StateHelper.class); - private AsyncTaskHelper mockTaskHelper = mock(AsyncTaskHelper.class); - private OperationHelper mockOperHelper = mock(OperationHelper.class); - - private StartInput mockInput = mock(StartInput.class); - private CommonHeader mockCommonHeader = mock(CommonHeader.class); - - @Before - public void setUp() throws Exception { - Mockito.doReturn(mockCommonHeader).when(mockOperHelper).getCommonHeader(mockInput); - Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader(); - - testBaseProcessor = spy( - new TestAbc(null, mockConfigHelper, mockStateHelper, mockTaskHelper, mockOperHelper)); - Mockito.doReturn("SOME HOST NAME").when(testBaseProcessor).getHostInfo(Mockito.anyString()); - Whitebox.setInternalState(testBaseProcessor, "commonHeader", mockCommonHeader); - - // to avoid operation on logger fail, mock up the logger - EELFLogger mockLogger = mock(EELFLogger.class); - Whitebox.setInternalState(testBaseProcessor, "logger", mockLogger); - } - - @Test - public void testProcessRequestError() throws Exception { - Mockito.doReturn(currentState).when(mockStateHelper).getCurrentOamState(); - Mockito.doThrow(new InvalidInputException("test")).when(mockOperHelper).isInputValid(mockInput); - Status status = testBaseProcessor.processRequest(mockInput); - Assert.assertEquals("Should return reject", - OAMCommandStatus.INVALID_PARAMETER.getResponseCode(), status.getCode().intValue()); - } - - @Test - public void testProcessRequest() throws Exception { - Mockito.doReturn(currentState).when(mockStateHelper).getCurrentOamState(); - Mockito.doReturn(AppcOamStates.Starting).when(mockOperHelper).getNextState(any(), any()); - Mockito.doReturn(mockCommonHeader).when(mockInput).getCommonHeader(); - Status status = testBaseProcessor.processRequest(mockInput); - Assert.assertEquals("Should return success", - OAMCommandStatus.ACCEPTED.getResponseCode(), status.getCode().intValue()); - } - - @Test(expected = InvalidInputException.class) - public void testPreProcessWithInvalidInput() throws Exception { - Mockito.doThrow(new InvalidInputException("test")).when(mockOperHelper).isInputValid(mockInput); - testBaseProcessor.preProcess(mockInput); - } - - @Test(expected = InvalidStateException.class) - public void testPreProcessWithInvalidState() throws Exception { - Mockito.doReturn(currentState).when(mockStateHelper).getCurrentOamState(); - Mockito.doThrow(new InvalidStateException("test")) - .when(mockOperHelper).getNextState(testRpc.getAppcOperation(), currentState); - testBaseProcessor.preProcess(mockInput); - } - - @Test(expected = APPCException.class) - public void testPreProcessWithAppcException() throws Exception { - Mockito.doReturn(currentState).when(mockStateHelper).getCurrentOamState(); - Mockito.doThrow(new APPCException("test")) - .when(mockOperHelper).getNextState(testRpc.getAppcOperation(), currentState); - testBaseProcessor.preProcess(mockInput); - } - - @Test - public void testPreProcess() throws Exception { - Mockito.doReturn(currentState).when(mockStateHelper).getCurrentOamState(); - AppcOamStates nextState = AppcOamStates.Starting; - Mockito.doReturn(nextState) - .when(mockOperHelper).getNextState(testRpc.getAppcOperation(), currentState); - testBaseProcessor.preProcess(mockInput); - Mockito.verify(mockOperHelper, times(1)).isInputValid(mockInput); - Mockito.verify(mockOperHelper, times(1)).getNextState(testRpc.getAppcOperation(), currentState); - Mockito.verify(mockStateHelper, times(1)).setState(nextState); - } - - @Test - public void testScheduleAsyncTask() throws Exception { - // test no runnable - testBaseProcessor.scheduleAsyncTask(); - Assert.assertTrue(Whitebox.getInternalState(testBaseProcessor, "runnable") == null); - Assert.assertTrue(Whitebox.getInternalState(testBaseProcessor, "scheduledRunnable") == null); - - BaseActionRunnable mockRunnable = mock(BaseActionRunnable.class); - Whitebox.setInternalState(testBaseProcessor, "runnable", mockRunnable); - testBaseProcessor.scheduleAsyncTask(); - // scheduledRunnable should still be null, there's no mock done - // as I have trouble to make mockTaskHelper.scheduleBaseRunnable to return a proper Future - Assert.assertTrue(Whitebox.getInternalState(testBaseProcessor, "scheduledRunnable") == null); - } - -} diff --git a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/util/AsyncTaskHelperTest.java b/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/util/AsyncTaskHelperTest.java deleted file mode 100644 index 319b0c796..000000000 --- a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/util/AsyncTaskHelperTest.java +++ /dev/null @@ -1,663 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.oam.util; - -import com.att.eelf.configuration.EELFLogger; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.onap.appc.oam.AppcOam; -import org.onap.appc.statemachine.impl.readers.AppcOamStates; -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.LinkedList; -import java.util.concurrent.Future; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Supplier; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.powermock.api.mockito.PowerMockito.mockStatic; - - -@RunWith(PowerMockRunner.class) -@PrepareForTest({FrameworkUtil.class}) -public class AsyncTaskHelperTest { - private AsyncTaskHelper asyncTaskHelper; - - private long initialDelayMillis = 0; - private long delayMillis = 10; - - - @Before - public void setUp() throws Exception { - - // to avoid operation on logger fail, mock up the logger - EELFLogger mockLogger = mock(EELFLogger.class); - - - mockStatic(FrameworkUtil.class); - Bundle myBundle = mock(Bundle.class); - Mockito.doReturn("TestBundle").when(myBundle).getSymbolicName(); - PowerMockito.when(FrameworkUtil.getBundle(any())).thenReturn(myBundle); - - asyncTaskHelper = new AsyncTaskHelper(mockLogger); - - - } - - - @After - public void shutdown(){ - asyncTaskHelper.close(); - } - - - /** - * Test that Base Runnable - * - * Runs at a fix rate; - * Only one Base Runnable can be scheduled at time; - * Future.cancle stops the Base Runnable; - * That another Base Runnable can be scheduled once the previous isDone. - */ - @Test - public void test_scheduleBaseRunnable_Base_isDone() throws Exception{ - - - - //loop is to test we can run consecutive Base Runnable - for(int testIteration = 0; testIteration < 3;testIteration++){ - final ExecuteTest et = new ExecuteTest(); - - Future<?> future = asyncTaskHelper.scheduleBaseRunnable( - et::test - , s -> { } - ,initialDelayMillis - ,delayMillis - ); - - //make sure it is running at a fix rate - Assert.assertTrue("It should be iterating", et.waitForTestExec(5000)); - Assert.assertFalse("It Should not be Done", future.isDone()); - Assert.assertTrue("It should be iterating", et.waitForTestExec(5000)); - Assert.assertFalse("It Should not be Done", future.isDone()); - - - //make sure a seconds Runnable cannot be scheduled when one is already running - try { - asyncTaskHelper.scheduleBaseRunnable(et::test - , s -> {} - ,initialDelayMillis - ,delayMillis - ); - Assert.fail("scheduling should have been prevented. "); - } catch (IllegalStateException e) { - //IllegalStateException means the second scheduling was not allowed. - } - - - //let it cancel itself - et.cancelSelfOnNextExecution(future); - - //it should be done after it executes itself one more time. - Assert.assertTrue("it should be done", waitFor(future::isDone, 5000)); - Assert.assertTrue("The test failed to execute", et.isExecuted); - } - - - } - - - /** - * Makes sure the Future.isDone one only returns true if its runnable is not currently executing and will not - * execute in the future. Default implementation of isDone() returns true immediately after the future is - * canceled -- Even if is there is still a thread actively executing the runnable - */ - @Test - public void test_scheduleBaseRunnable_Base_isDone_Ignore_Interrupt() throws Exception{ - - - final ExecuteTest et = new ExecuteTest(); - - //configure test to run long and ignore interrupt - et.isContinuous = true; - et.isIgnoreInterrupt = true; - - - - Future<?> future = asyncTaskHelper.scheduleBaseRunnable( - et::test - , s->{} - ,initialDelayMillis - ,delayMillis - ); - - //make sure it is running - Assert.assertTrue("It should be running",waitFor(et::isExecuting,1000)); - Assert.assertTrue("It should be running",et.waitForTestExec(1000)); - Assert.assertFalse("It Should not be Done", future.isDone()); - - //cancel it and make sure it is still running - future.cancel(true); - Assert.assertTrue("It should be running",waitFor(et::isExecuting,1000)); - Assert.assertTrue("It should be running",et.waitForTestExec(1000)); - Assert.assertFalse("It Should not be Done", future.isDone()); - - //let the thread die and then make sure its done - et.isContinuous = false; - Assert.assertTrue("It should not be running",waitForNot(et::isExecuting,1000)); - Assert.assertTrue("It Should be Done", future.isDone()); - - } - - - - - /** - * Make sure the base Future.isDone returns false until the sub callable has completed execution. - */ - @Test - public void test_scheduleBaseRunnable_SubTask_isDone_Ignore_Interrupt() throws Exception{ - - - final ExecuteTest baseET = new ExecuteTest(); - final ExecuteTest subET = new ExecuteTest(); - - //configure sub test to run long and ignore interrupt - subET.isContinuous = true; - subET.isIgnoreInterrupt = true; - - - //schedule the Base test to run and make sure it is running. - Future<?> baseFuture = asyncTaskHelper.scheduleBaseRunnable( - baseET::test - ,s->{} - ,initialDelayMillis - ,delayMillis - ); - Assert.assertTrue("baseET should be running",waitFor(baseET::isExecuted,1000)); - Assert.assertFalse("baseET Should not be Done because it runs at a fix rate", baseFuture.isDone()); - - - //schedule the sub task and make sure it is running - Future<?> subFuture = asyncTaskHelper.submitBaseSubCallable(subET::test); - Assert.assertTrue("subET should be running",waitFor(subET::isExecuting,1000)); - Assert.assertTrue("subET should be running",subET.waitForTestExec(1000)); - Assert.assertFalse("subET Should not be Done", subFuture.isDone()); - Assert.assertFalse("baseET Should not be Done", baseFuture.isDone()); - - //cancel the base task and make sure isDone is still false - baseFuture.cancel(true); - Assert.assertTrue("subET should be running",waitFor(subET::isExecuting,1000)); - Assert.assertTrue("subET should be running",subET.waitForTestExec(1000)); - Assert.assertFalse("subET Should not be Done",subFuture.isDone()); - Assert.assertFalse("baseET Should not be Done", baseFuture.isDone()); - - - //let the sub task die and and make sure the base is now finally done - subET.isContinuous = false; - Assert.assertTrue("subET should not be running",waitForNot(subET::isExecuting,1000)); - Assert.assertTrue("subET Should be Done", subFuture.isDone()); - Assert.assertTrue("baseET Should be Done", baseFuture.isDone()); - - } - - - /** - * Make sure the base Future.isDone returns false until the 3 sub callable has completed execution. - * Each sub callable will be shutdown one at a time. - */ - public void test_scheduleBaseRunnable_SubTasks_isDone() throws Exception { - - - //loop is to test we can run consecutive Base Runnable - for (int testIteration = 0; testIteration < 3; testIteration++) { - final ExecuteTest baseET = new ExecuteTest(); - final LinkedList<Sub> subList = new LinkedList<>(); - for (int i = 0; i < 3; i++) { - Sub sub = new Sub(); - sub.et.isContinuous = true; - subList.add(sub); - } - - - //schedule the base runnable and make sure it is running - Future<?> baseFuture = asyncTaskHelper.scheduleBaseRunnable( - baseET::test - , s -> { - } - , initialDelayMillis - , delayMillis - ); - Assert.assertTrue("baseET should be running", waitFor(baseET::isExecuted, 1000)); - Assert.assertFalse("baseET Should not be Done because it runs at a fix rate", baseFuture.isDone()); - - - //schedule the sub Callables and make sure these are running - subList.forEach(sub -> sub.future = asyncTaskHelper.submitBaseSubCallable(sub.et::test)); - for (Sub sub : subList) { - Assert.assertTrue("subET should be running", waitFor(sub.et::isExecuting, 100)); - Assert.assertTrue("subET should be running", sub.et.waitForTestExec(1000)); - Assert.assertFalse("subET Should not be Done", sub.future.isDone()); - } - Assert.assertFalse("baseET Should not be Done", baseFuture.isDone()); - - - //On each iteration shut down a sub callable. Make sure it stops, the others are still running and the - // //base is still running. - while (!subList.isEmpty()) { - - //stop one sub and make sure it stopped - { - Sub sub = subList.removeFirst(); - Assert.assertTrue("subET should be running", waitFor(sub.et::isExecuting, 1000)); - sub.et.isContinuous = false; - Assert.assertTrue("subET should not be running", waitForNot(sub.et::isExecuting,1000)); - Assert.assertTrue("subET Should not be Done", sub.future.isDone()); - } - - //make sure the other are still running - for (Sub sub : subList) { - Assert.assertTrue("subET should be running", waitFor(sub.et::isExecuting, 1000)); - Assert.assertTrue("subET should be running", sub.et.waitForTestExec(1000)); - Assert.assertFalse("subET Should not be Done", sub.future.isDone()); - } - - //Make sure the Base is still running - Assert.assertFalse("baseET Should not be Done", baseFuture.isDone()); - } - - //let the base cancel itself and make sure it stops - baseET.cancelSelfOnNextExecution(baseFuture); - Assert.assertTrue("baseET should be done", waitFor(baseFuture::isDone, 1000)); - } - } - - - /** - * Make sure SubCallable cannot be scheduled when there is not BaseRunnable - */ - @Test(expected=IllegalStateException.class) - public void test_SubTasksScheduleFailWhenNoBase() throws Exception { - asyncTaskHelper.submitBaseSubCallable(()->null); - } - - - - /** - * Make sure SubCallable cannot be scheduled when BaseRunnable is cancelled but is still actively running. - */ - @Test(expected=IllegalStateException.class) - public void test_SubTasksScheduleFailWhenBaseCanceledBeforeisDone() throws Exception { - - final ExecuteTest et = new ExecuteTest(); - et.isContinuous = true; - - Future<?> future = asyncTaskHelper.scheduleBaseRunnable( - et::test - , s -> { } - ,initialDelayMillis - ,delayMillis - ); - - Assert.assertTrue("It should be running",waitFor(et::isExecuting,1000)); - future.cancel(false); - Assert.assertTrue("It should be running",waitFor(et::isExecuting,1000)); - - try { - asyncTaskHelper.submitBaseSubCallable(() -> null); - } finally { - et.isContinuous = false; - } - - - - } - - - /** - * Make sure SubCallable cannot be scheduled after a BaseRunnable has completed - */ - @Test(expected=IllegalStateException.class) - public void test_SubTasksScheduleFailAfterBaseDone() throws Exception { - - final ExecuteTest et = new ExecuteTest(); - - Future<?> future = asyncTaskHelper.scheduleBaseRunnable( - et::test - , s -> { } - ,initialDelayMillis - ,delayMillis - ); - - - future.cancel(false); - Assert.assertTrue("It should not be running",waitFor(future::isDone,1000)); - - try { - asyncTaskHelper.submitBaseSubCallable(() -> null); - } finally { - et.isContinuous = false; - } - - } - - - /** - * Test {@link AsyncTaskHelper#cancelBaseActionRunnable(AppcOam.RPC, AppcOamStates, long, TimeUnit)}} - * Test cancel does not block when BaseRunnable is not scheduled - */ - @Test - public void test_cancel_noBlockingWhenBaseRunnableNotScheduled() throws Exception{ - //nothing is running so this should return immediately without TimeoutException - asyncTaskHelper.cancelBaseActionRunnable(AppcOam.RPC.stop , AppcOamStates.Started , 1, TimeUnit.MILLISECONDS); - } - - - - /** - * Test {@link AsyncTaskHelper#cancelBaseActionRunnable(AppcOam.RPC, AppcOamStates, long, TimeUnit)}} - * Test cancel does blocks until BaseRunnable is done scheduled - */ - @Test() - public void test_cancel_BlockingWhenBaseRunnableNotDone() throws Exception { - - - final ExecuteTest et = new ExecuteTest(); - et.isContinuous = true; - et.isIgnoreInterrupt = true; - asyncTaskHelper.scheduleBaseRunnable( - et::test - , s -> { - } - , initialDelayMillis - , delayMillis - ); - - Assert.assertTrue("It should be running", waitFor(et::isExecuting, 1000)); - - - //we should get a timeout - try { - asyncTaskHelper.cancelBaseActionRunnable( - AppcOam.RPC.stop, - AppcOamStates.Started, - 1, - TimeUnit.MILLISECONDS); - Assert.fail("Should have gotten TimeoutException"); - } catch (TimeoutException e) { - //just ignore as it is expected - } - - - //release the test thread - et.isContinuous = false; - - - //we should not get a timeout - asyncTaskHelper.cancelBaseActionRunnable( - AppcOam.RPC.stop, - AppcOamStates.Started, - 1000, - TimeUnit.MILLISECONDS); - - } - - - - /** - * Test {@link AsyncTaskHelper#cancelBaseActionRunnable(AppcOam.RPC, AppcOamStates, long, TimeUnit)}} - * Test cancel does not block when BaseRunnable is not scheduled - */ - @Test - public void test_BaseRunnableCancelCallback() throws Exception{ - - AtomicReference<AppcOam.RPC> cancelCallback = new AtomicReference<>(null); - - final ExecuteTest et = new ExecuteTest(); - et.isContinuous = true; - Future<?> future = asyncTaskHelper.scheduleBaseRunnable( - et::test - , cancelCallback::set - , initialDelayMillis - , delayMillis - ); - - Assert.assertTrue("It should be running", waitFor(et::isExecuting, 1000)); - Assert.assertTrue("It should be running", waitForNot(future::isDone, 1000)); - - - try { - asyncTaskHelper.cancelBaseActionRunnable( - AppcOam.RPC.stop, - AppcOamStates.Started, - 1, - TimeUnit.MILLISECONDS); - Assert.fail("Should have gotten TimeoutException"); - } catch (TimeoutException e) { - //just ignore as it is expected - } - - - Assert.assertEquals("Unexpected rpc in call back",AppcOam.RPC.stop,cancelCallback.get()); - } - - - - - - - - - /** - * @return true if the negation of the expected value is returned from the supplier within the specified - * amount of time - */ - private static boolean waitForNot(Supplier<Boolean> s,long timeoutMillis)throws Exception{ - return waitFor(()->!s.get(),timeoutMillis); - } - - - /** - * @return true if the expected value is returned from the supplier within the specified - * amount of time - */ - private static boolean waitFor(Supplier<Boolean> s,long timeoutMillis) throws Exception { - long timeout = TimeUnit.MILLISECONDS.toMillis(timeoutMillis); - long expiryTime = System.currentTimeMillis() + timeout; - long elapsedTime; - while(!s.get()){ - elapsedTime = expiryTime - System.currentTimeMillis(); - if(elapsedTime < 1) { - break; - } - Thread.sleep(10); - } - return s.get(); - } - - - /** - * This class is used control a thread executed in th {@link #test()} - */ - @SuppressWarnings("unused") - private static class ExecuteTest { - - - /** A fail safe to insure this TEst does not run indefinitely */ - private final long EXPIRY_TIME = System.currentTimeMillis() + 10000; - - - - /** A thread sets this value to true when it has completed the execution the of executes {@link #test()} */ - private volatile boolean isExecuted = false; - - /** - * A thread sets this value to true when it is actively executing {@link #test()} and back to false when - * it is not - */ - private volatile boolean isExecuting = false; - - /** - * While this value is true, a thread will not be allowed to return from {@link #test()} It will simulate a - * long execution. - */ - private volatile boolean isContinuous = false; - - /** - * When this value is set to true, an ongoing simulation of a long execution of {@link #test()} cannot be force - * to abort via a {@link Thread#interrupt()} - */ - private volatile boolean isIgnoreInterrupt = false; - - - - /** Use to send a signal to the thread executing {@link #notifyTestExcuted(long)} */ - private Semaphore inner = new Semaphore(0); - - /** Use to send a signal to the thread executing {@link #waitForTestExec(long)} */ - private Semaphore outer = new Semaphore(0); - - /** The {@link Future} of the Thread executing {@link #test()}*/ - private volatile Future<?> future; - - /** - * When set the Thread executing {@link #test()} will cancel itself - * @param future - The {@link Future} of the Thread executing {@link #test()} - */ - private void cancelSelfOnNextExecution(Future<?> future) { - this.future = future; - } - - - private boolean isExecuted() { - return isExecuted; - } - - private boolean isExecuting() { - return isExecuting; - } - - - private boolean isContinuous() { - return isContinuous; - } - - - private boolean isIgnoreInterrupt() { - return isIgnoreInterrupt; - } - - - - /** - * The thread executing this method if blocked from returning until the thread executing - * {@link #test()} invokes {@link #notifyTestExcuted(long)} or the specified time elapses - * @param timeoutMillis - the amount of time to wait for a execution iteration. - * @return true if the Thread is released because of an invocation of {@link #notifyTestExcuted(long)} - * @throws InterruptedException - If the Caller thread is interrupted. - */ - private boolean waitForTestExec(long timeoutMillis) throws InterruptedException { - inner.release(); - return outer.tryAcquire(timeoutMillis,TimeUnit.MILLISECONDS); - } - - - /** - * Test simulator - * @return Always returns true. - */ - private Boolean test() { - isTestExpired(); - System.out.println("started"); - isExecuting = true; - try { - if (future != null) { - future.cancel(false); - } - if(!isContinuous){ - notifyTestExcuted(1); - } - - while(isContinuous){ - notifyTestExcuted(100); - isTestExpired(); - } - - } finally { - isExecuting = false; - isExecuted = true; - } - return true; - } - - - /** @throws RuntimeException if the test has bee running too long */ - private void isTestExpired(){ - if(System.currentTimeMillis() > EXPIRY_TIME){ - throw new RuntimeException("Something went wrong the test expired."); - } - } - - - /** - * The thread executing {@link #test()} if blocked from returning until another thread invokes - * {@link #waitForTestExec(long)} or the specified time elapses - * @param timeoutMillis - the amount of time to wait for a execution iteration. - * @return true if the Thread is released because of an invocation of {@link #waitForTestExec(long)} - */ - private boolean notifyTestExcuted(long timeoutMillis){ - try { - boolean acquire = inner.tryAcquire(timeoutMillis,TimeUnit.MILLISECONDS); - if(acquire){ - outer.release(); - System.out.println("release"); - } - } catch (InterruptedException e) { - if(!isIgnoreInterrupt){ - return false; - } - } - return true; - } - } - - - static class Sub { - ExecuteTest et = new ExecuteTest(); - Future<?> future = null; - } - -} diff --git a/appc-oam/appc-oam-model/pom.xml b/appc-oam/appc-oam-model/pom.xml index 7db1a47b4..fc7629c78 100644 --- a/appc-oam/appc-oam-model/pom.xml +++ b/appc-oam/appc-oam-model/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Copyright (C) 2017 Amdocs ============================================================================= @@ -52,7 +52,6 @@ <plugin> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-maven-plugin</artifactId> - <version>${odl.yangtools.version}</version> <dependencies> <dependency> <groupId>org.opendaylight.mdsal</groupId> @@ -114,11 +113,11 @@ </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> + <artifactId>ietf-inet-types-2013-07-15</artifactId> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> + <artifactId>ietf-yang-types-20130715</artifactId> </dependency> </dependencies> <version>1.5.0-SNAPSHOT</version> diff --git a/appc-outbound/appc-aai-client/provider/pom.xml b/appc-outbound/appc-aai-client/provider/pom.xml index 4d6e047c9..2588a720e 100755 --- a/appc-outbound/appc-aai-client/provider/pom.xml +++ b/appc-outbound/appc-aai-client/provider/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs Modifications Copyright (C) 2019 Ericsson ================================================================================ @@ -60,11 +60,11 @@ <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>${logback.version}</version> - </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + </dependency> <dependency> <groupId>com.att.eelf</groupId> <artifactId>eelf-core</artifactId> @@ -81,7 +81,11 @@ <artifactId>junit</artifactId> <scope>test</scope> </dependency> - + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> </dependencies> diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java deleted file mode 100644 index 7e2a41820..000000000 --- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Modifications Copyright (C) 2019 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.instar.node; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.when; -import java.io.InputStream; -import java.net.URI; -import java.security.NoSuchAlgorithmException; -import java.util.HashMap; -import java.util.Properties; -import javax.net.ssl.SSLContext; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.onap.appc.instar.dme2client.Dme2Client; -import org.onap.appc.instar.utils.InstarClientConstant; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.WebResource.Builder; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({InstarClientConstant.class, SSLContext.class, Client.class}) -public class TestDme2Client { - - private Dme2Client dme2; - private InputStream inputStream; - private SSLContext sslContext; - private Properties properties; - private Client client; - private WebResource webResource; - private Builder builder; - private ClientResponse clientResponse; - - @Before - public void setUp() throws Exception { - inputStream = Mockito.mock(InputStream.class); - sslContext = PowerMockito.mock(SSLContext.class); - client = Mockito.mock(Client.class); - builder = Mockito.mock(Builder.class); - clientResponse = Mockito.mock(ClientResponse.class); - webResource = Mockito.mock(WebResource.class); - HashMap<String, String> data = new HashMap<String, String>(); - data.put("subtext", "value"); - PowerMockito.mockStatic(InstarClientConstant.class); - PowerMockito.mockStatic(SSLContext.class); - PowerMockito.mockStatic(Client.class); - PowerMockito.when(InstarClientConstant.getEnvironmentVariable("SDNC_CONFIG_DIR")) - .thenReturn("test"); - PowerMockito.when(InstarClientConstant.getInputStream("test/outbound.properties")) - .thenReturn(inputStream); - PowerMockito.when(SSLContext.getInstance("SSL")).thenReturn(sslContext); - PowerMockito.when(Client.create(anyObject())).thenReturn(client); - PowerMockito.when(client.resource(new URI("nullnullnullvalue"))).thenReturn(webResource); - - PowerMockito.when(builder.get(ClientResponse.class)).thenReturn(clientResponse); - properties = Mockito.mock(Properties.class); - dme2 = new Dme2Client("opt", "subtext", data); - Whitebox.setInternalState(dme2, "properties", properties); - when(properties.getProperty("MechID")).thenReturn("123"); - when(properties.getProperty("MechPass")).thenReturn("password"); - } - - @Test - public void testSendtoInstarGet() throws Exception { - PowerMockito.when(webResource.accept("application/json")).thenReturn(builder); - PowerMockito.when(clientResponse.getEntity(String.class)).thenReturn("Get Success"); - when(properties.getProperty("getIpAddressByVnf_method")).thenReturn("GET"); - assertEquals("Get Success", dme2.send()); - } - - @Test - public void testSendtoInstarPut() throws Exception { - PowerMockito.when(webResource.type("application/json")).thenReturn(builder); - PowerMockito.when(builder.put(ClientResponse.class, "")).thenReturn(clientResponse); - PowerMockito.when(clientResponse.getEntity(String.class)).thenReturn("Put Success"); - when(properties.getProperty("getIpAddressByVnf_method")).thenReturn("PUT"); - assertEquals("Put Success", dme2.send()); - } - - @Test - public void testSendtoInstarPost() throws Exception { - PowerMockito.when(webResource.type("application/json")).thenReturn(builder); - PowerMockito.when(builder.post(ClientResponse.class, "")).thenReturn(clientResponse); - PowerMockito.when(clientResponse.getEntity(String.class)).thenReturn("Post Success"); - when(properties.getProperty("getIpAddressByVnf_method")).thenReturn("POST"); - assertEquals("Post Success", dme2.send()); - } - - @Test - public void testSendtoInstarDelete() throws Exception { - PowerMockito.when(webResource.delete(ClientResponse.class)).thenReturn(clientResponse); - PowerMockito.when(clientResponse.getEntity(String.class)).thenReturn("Delete Success"); - when(properties.getProperty("getIpAddressByVnf_method")).thenReturn("DELETE"); - assertEquals("Delete Success", dme2.send()); - } - - @Test - public void testSendtoInstarException() throws Exception { - PowerMockito.when(SSLContext.getInstance("SSL")).thenThrow(new NoSuchAlgorithmException()); - when(properties.getProperty("getIpAddressByVnf_method")).thenReturn("DELETE"); - assertNull(dme2.send()); - } - - @Test - public void testSendtoInstarMaskNotNull() throws Exception { - Whitebox.setInternalState(dme2, "mask", "0.0.0.0/1"); - PowerMockito.when(webResource.accept("application/json")).thenReturn(builder); - PowerMockito.when(clientResponse.getEntity(String.class)).thenReturn("Get Success"); - when(properties.getProperty("getIpAddressByVnf_method")).thenReturn("GET"); - assertNull(dme2.send()); - } - - @Test - public void testSendtoInstarIpNotNull() throws Exception { - Whitebox.setInternalState(dme2, "ipAddress", "0.0.0.0"); - PowerMockito.when(webResource.accept("application/json")).thenReturn(builder); - PowerMockito.when(clientResponse.getEntity(String.class)).thenReturn("Get Success"); - when(properties.getProperty("getIpAddressByVnf_method")).thenReturn("GET"); - assertNull(dme2.send()); - } -} diff --git a/appc-provider/appc-provider-bundle/pom.xml b/appc-provider/appc-provider-bundle/pom.xml index 4d8558cb6..9a4b0d8d1 100644 --- a/appc-provider/appc-provider-bundle/pom.xml +++ b/appc-provider/appc-provider-bundle/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Copyright (C) 2017 Amdocs ============================================================================= @@ -114,30 +114,6 @@ <artifactId>appc-provider-model</artifactId> <version>${project.version}</version> </dependency> - - <!-- ADDED THIS ARTIFACT TO BE ABLE TO FIND org.onap.appc.domainmodel.lcm --> - <!-- <dependency> --> - <!-- <groupId>org.onap.appc</groupId> --> - <!-- <artifactId>domain-model-lib</artifactId> --> - <!-- <version>${project.version}</version> --> - <!-- </dependency> --> - - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>config-api</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-config</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-api</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-common-util</artifactId> - </dependency> <dependency> <groupId>org.onap.ccsdk.sli.core</groupId> <artifactId>sli-common</artifactId> @@ -147,6 +123,11 @@ <artifactId>sli-provider</artifactId> </dependency> <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <artifactId>sal-test-model</artifactId> <groupId>org.opendaylight.controller</groupId> <scope>test</scope> diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProvider.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProvider.java index 91d3a1953..8dd35286a 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProvider.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProvider.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= @@ -26,6 +26,7 @@ package org.onap.appc.provider; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; @@ -57,7 +58,6 @@ import org.onap.appc.provider.topology.TopologyService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; /* ADDED FOR FUSION SERVICE CODE */ @@ -165,7 +165,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { logger.info(Msg.COMPONENT_TERMINATED, appName, "provider"); } - public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput input) { + public ListenableFuture<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput input) { CommonRequestHeader hdr = input.getCommonRequestHeader(); ConfigPayload data = input.getConfigPayload(); RpcResult<ModifyConfigOutput> result = getTopologyService().modifyConfig(hdr, data); @@ -178,7 +178,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#rebuild(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RebuildInput) */ @Override - public Future<RpcResult<RebuildOutput>> rebuild(RebuildInput input) { + public ListenableFuture<RpcResult<RebuildOutput>> rebuild(RebuildInput input) { CommonRequestHeader hdr = input.getCommonRequestHeader(); VnfResource vnf = input.getVnfResource(); @@ -193,7 +193,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#restart(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.RestartInput) */ @Override - public Future<RpcResult<RestartOutput>> restart(RestartInput input) { + public ListenableFuture<RpcResult<RestartOutput>> restart(RestartInput input) { CommonRequestHeader hdr = input.getCommonRequestHeader(); VnfResource vnf = input.getVnfResource(); @@ -207,7 +207,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#migrate(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.MigrateInput) */ @Override - public Future<RpcResult<MigrateOutput>> migrate(MigrateInput input) { + public ListenableFuture<RpcResult<MigrateOutput>> migrate(MigrateInput input) { CommonRequestHeader hdr = input.getCommonRequestHeader(); VnfResource vnf = input.getVnfResource(); @@ -221,7 +221,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#evacuate(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.EvacuateInput) */ @Override - public Future<RpcResult<EvacuateOutput>> evacuate(EvacuateInput input) { + public ListenableFuture<RpcResult<EvacuateOutput>> evacuate(EvacuateInput input) { return null; } @@ -232,7 +232,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { * @see org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.AppcProviderService#evacuate(org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.EvacuateInput) */ @Override - public Future<RpcResult<SnapshotOutput>> snapshot(SnapshotInput input) { + public ListenableFuture<RpcResult<SnapshotOutput>> snapshot(SnapshotInput input) { CommonRequestHeader hdr = input.getCommonRequestHeader(); VnfResource vnf = input.getVnfResource(); @@ -244,7 +244,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService { * Checks status of a VM */ @Override - public Future<RpcResult<VmstatuscheckOutput>> vmstatuscheck(VmstatuscheckInput input) { + public ListenableFuture<RpcResult<VmstatuscheckOutput>> vmstatuscheck(VmstatuscheckInput input) { CommonRequestHeader hdr = input.getCommonRequestHeader(); VnfResource vnf = input.getVnfResource(); diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java index ff1195127..cd5576b0f 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -28,7 +28,6 @@ package org.onap.appc.provider; import java.text.ParseException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; import org.onap.appc.Constants; import org.onap.appc.configuration.Configuration; import org.onap.appc.configuration.ConfigurationFactory; @@ -61,6 +60,7 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, AppcProviderLcmService { @@ -140,7 +140,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, * @see org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AppcProviderLcmService#rebuild(RebuildInput) */ @Override - public Future<RpcResult<RebuildOutput>> rebuild(RebuildInput input) { + public ListenableFuture<RpcResult<RebuildOutput>> rebuild(RebuildInput input) { logger.debug("Input received : " + input.toString()); RebuildOutputBuilder outputBuilder = new RebuildOutputBuilder(); @@ -180,7 +180,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, * @see org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AppcProviderLcmService#restart(RestartInput) */ @Override - public Future<RpcResult<RestartOutput>> restart(RestartInput input) { + public ListenableFuture<RpcResult<RestartOutput>> restart(RestartInput input) { logger.debug("Input received : " + input.toString()); RestartOutputBuilder outputBuilder = new RestartOutputBuilder(); @@ -219,7 +219,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, * @see org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AppcProviderLcmService#startApplication(StartApplicationInput) */ @Override - public Future<RpcResult<StartApplicationOutput>> startApplication(StartApplicationInput input) { + public ListenableFuture<RpcResult<StartApplicationOutput>> startApplication(StartApplicationInput input) { logger.debug("Input received : " + input.toString()); StartApplicationOutputBuilder outputBuilder = new StartApplicationOutputBuilder(); @@ -258,7 +258,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, * @see org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AppcProviderLcmService#migrate(MigrateInput) */ @Override - public Future<RpcResult<MigrateOutput>> migrate(MigrateInput input) { + public ListenableFuture<RpcResult<MigrateOutput>> migrate(MigrateInput input) { logger.debug("Input received : " + input.toString()); MigrateOutputBuilder outputBuilder = new MigrateOutputBuilder(); @@ -297,7 +297,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, * @see org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AppcProviderLcmService#evacuate(EvacuateInput) */ @Override - public Future<RpcResult<EvacuateOutput>> evacuate(EvacuateInput input) { + public ListenableFuture<RpcResult<EvacuateOutput>> evacuate(EvacuateInput input) { logger.debug("Input received : " + input.toString()); EvacuateOutputBuilder outputBuilder = new EvacuateOutputBuilder(); @@ -336,7 +336,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, * @see org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AppcProviderLcmService#snapshot(SnapshotInput) */ @Override - public Future<RpcResult<SnapshotOutput>> snapshot(SnapshotInput input) { + public ListenableFuture<RpcResult<SnapshotOutput>> snapshot(SnapshotInput input) { logger.debug("Input received : " + input.toString()); SnapshotOutputBuilder outputBuilder = new SnapshotOutputBuilder(); @@ -370,7 +370,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<RollbackOutput>> rollback(RollbackInput input) { + public ListenableFuture<RpcResult<RollbackOutput>> rollback(RollbackInput input) { logger.debug("Input received : " + input.toString()); RollbackOutputBuilder outputBuilder = new RollbackOutputBuilder(); @@ -405,7 +405,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<SyncOutput>> sync(SyncInput input) { + public ListenableFuture<RpcResult<SyncOutput>> sync(SyncInput input) { logger.debug("Input received : " + input.toString()); SyncOutputBuilder outputBuilder = new SyncOutputBuilder(); String action = Action.Sync.toString(); @@ -437,7 +437,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<QueryOutput>> query(QueryInput input) { + public ListenableFuture<RpcResult<QueryOutput>> query(QueryInput input) { logger.debug(String.format("LCM query received input: %s", input.toString())); QueryOutputBuilder outputBuilder = new QueryService().process(input); RpcResult<QueryOutput> result = @@ -446,7 +446,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<RebootOutput>> reboot(RebootInput input) { + public ListenableFuture<RpcResult<RebootOutput>> reboot(RebootInput input) { logger.debug(String.format("LCM reboot received input: %s", input.toString())); RebootOutputBuilder outputBuilder = new RebootService().reboot(input); RpcResult<RebootOutput> result = @@ -455,7 +455,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<AttachVolumeOutput>> attachVolume(AttachVolumeInput input) { + public ListenableFuture<RpcResult<AttachVolumeOutput>> attachVolume(AttachVolumeInput input) { logger.debug(String.format("LCM attachVolume received input: %s", input.toString())); AttachVolumeOutputBuilder outputBuilder = new VolumeService(true).attachVolume(input); RpcResult<AttachVolumeOutput> result = @@ -464,7 +464,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<DetachVolumeOutput>> detachVolume(DetachVolumeInput input) { + public ListenableFuture<RpcResult<DetachVolumeOutput>> detachVolume(DetachVolumeInput input) { logger.debug(String.format("LCM detachVolume received input: %s", input.toString())); DetachVolumeOutputBuilder outputBuilder = new VolumeService(false).detachVolume(input); RpcResult<DetachVolumeOutput> result = @@ -473,7 +473,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<QuiesceTrafficOutput>> quiesceTraffic(QuiesceTrafficInput input) { + public ListenableFuture<RpcResult<QuiesceTrafficOutput>> quiesceTraffic(QuiesceTrafficInput input) { logger.debug(String.format("LCM quiesce received input: %s", input.toString())); QuiesceTrafficOutputBuilder outputBuilder = new QuiesceTrafficService().process(input); RpcResult<QuiesceTrafficOutput> result = @@ -482,7 +482,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<ResumeTrafficOutput>> resumeTraffic(ResumeTrafficInput input) { + public ListenableFuture<RpcResult<ResumeTrafficOutput>> resumeTraffic(ResumeTrafficInput input) { logger.debug(String.format("LCM resume received input: %s", input.toString())); ResumeTrafficOutputBuilder outputBuilder = new ResumeTrafficService().process(input); RpcResult<ResumeTrafficOutput> result = @@ -491,7 +491,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<DistributeTrafficOutput>> distributeTraffic(DistributeTrafficInput input) { + public ListenableFuture<RpcResult<DistributeTrafficOutput>> distributeTraffic(DistributeTrafficInput input) { logger.debug(String.format("LCM DistributeTraffic, received input: %s", input.toString())); DistributeTrafficOutputBuilder outputBuilder = new DistributeTrafficService().process(input); RpcResult<DistributeTrafficOutput> result = @@ -500,7 +500,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<UpgradePreCheckOutput>> upgradePreCheck(UpgradePreCheckInput input) { + public ListenableFuture<RpcResult<UpgradePreCheckOutput>> upgradePreCheck(UpgradePreCheckInput input) { logger.debug(String.format("LCM upgradeprecheck received input: %s", input.toString())); UpgradePreCheckOutputBuilder outputBuilder = new UpgradeService("upgradePre").upgradePreCheck(input); RpcResult<UpgradePreCheckOutput> result = @@ -509,7 +509,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<UpgradeSoftwareOutput>> upgradeSoftware(UpgradeSoftwareInput input) { + public ListenableFuture<RpcResult<UpgradeSoftwareOutput>> upgradeSoftware(UpgradeSoftwareInput input) { logger.debug(String.format("LCM upgradesoftware received input: %s", input.toString())); UpgradeSoftwareOutputBuilder outputBuilder = new UpgradeService("upgradeSoft").upgradeSoftware(input); RpcResult<UpgradeSoftwareOutput> result = @@ -518,7 +518,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<UpgradePostCheckOutput>> upgradePostCheck(UpgradePostCheckInput input) { + public ListenableFuture<RpcResult<UpgradePostCheckOutput>> upgradePostCheck(UpgradePostCheckInput input) { logger.debug(String.format("LCM upgradepostcheck received input: %s", input.toString())); UpgradePostCheckOutputBuilder outputBuilder = new UpgradeService("upgradePost").upgradePostCheck(input); RpcResult<UpgradePostCheckOutput> result = @@ -527,7 +527,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<UpgradeBackupOutput>> upgradeBackup(UpgradeBackupInput input) { + public ListenableFuture<RpcResult<UpgradeBackupOutput>> upgradeBackup(UpgradeBackupInput input) { logger.debug(String.format("LCM backup received input: %s", input.toString())); UpgradeBackupOutputBuilder outputBuilder = new UpgradeService("upgradeBackup").upgradeBackup(input); RpcResult<UpgradeBackupOutput> result = @@ -536,7 +536,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<UpgradeBackoutOutput>> upgradeBackout(UpgradeBackoutInput input) { + public ListenableFuture<RpcResult<UpgradeBackoutOutput>> upgradeBackout(UpgradeBackoutInput input) { logger.debug(String.format("LCM backout received input: %s", input.toString())); UpgradeBackoutOutputBuilder outputBuilder = new UpgradeService("upgradeBackout").upgradeBackout(input); RpcResult<UpgradeBackoutOutput> result = @@ -545,7 +545,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<TerminateOutput>> terminate(TerminateInput input) { + public ListenableFuture<RpcResult<TerminateOutput>> terminate(TerminateInput input) { logger.debug("Input received : " + input.toString()); TerminateOutputBuilder outputBuilder = new TerminateOutputBuilder(); Action myAction = Action.Terminate; @@ -580,7 +580,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<ConfigureOutput>> configure(ConfigureInput input) { + public ListenableFuture<RpcResult<ConfigureOutput>> configure(ConfigureInput input) { logger.debug("Input received : " + input.toString()); ConfigureOutputBuilder outputBuilder = new ConfigureOutputBuilder(); Action myAction = Action.Configure; @@ -613,7 +613,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<ActionStatusOutput>> actionStatus(ActionStatusInput input) { + public ListenableFuture<RpcResult<ActionStatusOutput>> actionStatus(ActionStatusInput input) { logger.debug(String.format("Input received : %s", input.toString())); ActionStatusOutputBuilder outputBuilder = (new ActionStatusService()).queryStatus(input); RpcResult<ActionStatusOutput> result = @@ -622,7 +622,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<ConfigModifyOutput>> configModify(ConfigModifyInput input) { + public ListenableFuture<RpcResult<ConfigModifyOutput>> configModify(ConfigModifyInput input) { logger.debug("Input received : " + input.toString()); ConfigModifyOutputBuilder outputBuilder = new ConfigModifyOutputBuilder(); Action myAction = Action.ConfigModify; @@ -655,7 +655,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<ConfigScaleOutOutput>> configScaleOut(ConfigScaleOutInput input) { + public ListenableFuture<RpcResult<ConfigScaleOutOutput>> configScaleOut(ConfigScaleOutInput input) { logger.debug("Input received : " + input.toString()); ConfigScaleOutOutputBuilder outputBuilder = new ConfigScaleOutService().process(input); RpcResult<ConfigScaleOutOutput> result = RpcResultBuilder.<ConfigScaleOutOutput> status(true).withResult(outputBuilder.build()).build(); @@ -663,7 +663,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<ConfigRestoreOutput>> configRestore(ConfigRestoreInput input) { + public ListenableFuture<RpcResult<ConfigRestoreOutput>> configRestore(ConfigRestoreInput input) { logger.debug("Input received : " + input.toString()); ConfigRestoreOutputBuilder outputBuilder = new ConfigRestoreOutputBuilder(); Action myAction = Action.ConfigRestore; @@ -696,7 +696,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<TestOutput>> test(TestInput input) { + public ListenableFuture<RpcResult<TestOutput>> test(TestInput input) { logger.debug("Input received : " + input.toString()); TestOutputBuilder outputBuilder = new TestOutputBuilder(); Action myAction = Action.Test; @@ -730,7 +730,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, @Override - public Future<RpcResult<StopOutput>> stop(StopInput input) { + public ListenableFuture<RpcResult<StopOutput>> stop(StopInput input) { logger.debug("Input received : " + input.toString()); StopOutputBuilder outputBuilder = new StopOutputBuilder(); Action myAction = Action.Stop; @@ -768,7 +768,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, * @see org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.AppcProviderLcmService#start(StartInput) */ @Override - public Future<RpcResult<StartOutput>> start(StartInput input) { + public ListenableFuture<RpcResult<StartOutput>> start(StartInput input) { logger.debug("Input received : " + input.toString()); StartOutputBuilder outputBuilder = new StartOutputBuilder(); @@ -803,7 +803,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, @Override - public Future<RpcResult<AuditOutput>> audit(AuditInput input) { + public ListenableFuture<RpcResult<AuditOutput>> audit(AuditInput input) { logger.debug("Input received : " + input.toString()); AuditOutputBuilder outputBuilder = new AuditOutputBuilder(); Action myAction = Action.Audit; @@ -836,7 +836,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<SoftwareUploadOutput>> softwareUpload(SoftwareUploadInput input) { + public ListenableFuture<RpcResult<SoftwareUploadOutput>> softwareUpload(SoftwareUploadInput input) { logger.debug("Input received : " + input.toString()); SoftwareUploadOutputBuilder outputBuilder = new SoftwareUploadOutputBuilder(); Action myAction = Action.SoftwareUpload; @@ -869,7 +869,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<HealthCheckOutput>> healthCheck(HealthCheckInput input) { + public ListenableFuture<RpcResult<HealthCheckOutput>> healthCheck(HealthCheckInput input) { logger.debug("Input received : " + input.toString()); HealthCheckOutputBuilder outputBuilder = new HealthCheckOutputBuilder(); Action myAction = Action.HealthCheck; @@ -902,7 +902,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<LiveUpgradeOutput>> liveUpgrade(LiveUpgradeInput input) { + public ListenableFuture<RpcResult<LiveUpgradeOutput>> liveUpgrade(LiveUpgradeInput input) { logger.debug("Input received : " + input.toString()); LiveUpgradeOutputBuilder outputBuilder = new LiveUpgradeOutputBuilder(); Action myAction = Action.LiveUpgrade; @@ -936,7 +936,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, @Override - public Future<RpcResult<LockOutput>> lock(LockInput input) { + public ListenableFuture<RpcResult<LockOutput>> lock(LockInput input) { logger.debug("Input received : " + input.toString()); LockOutputBuilder outputBuilder = new LockOutputBuilder(); Action myAction = Action.Lock; @@ -970,7 +970,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, @Override - public Future<RpcResult<UnlockOutput>> unlock(UnlockInput input) { + public ListenableFuture<RpcResult<UnlockOutput>> unlock(UnlockInput input) { logger.debug("Input received : " + input.toString()); UnlockOutputBuilder outputBuilder = new UnlockOutputBuilder(); Action myAction = Action.Unlock; @@ -1003,7 +1003,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<CheckLockOutput>> checkLock(CheckLockInput input) { + public ListenableFuture<RpcResult<CheckLockOutput>> checkLock(CheckLockInput input) { logger.debug("Input received : " + input.toString()); CheckLockOutputBuilder outputBuilder = new CheckLockOutputBuilder(); Action myAction = Action.CheckLock; @@ -1044,7 +1044,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } @Override - public Future<RpcResult<ConfigBackupOutput>> configBackup(ConfigBackupInput input) { + public ListenableFuture<RpcResult<ConfigBackupOutput>> configBackup(ConfigBackupInput input) { logger.debug("Input received : " + input.toString()); ConfigBackupOutputBuilder outputBuilder = new ConfigBackupOutputBuilder(); Action myAction = Action.ConfigBackup; @@ -1078,7 +1078,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, @Override - public Future<RpcResult<ConfigBackupDeleteOutput>> configBackupDelete(ConfigBackupDeleteInput input) { + public ListenableFuture<RpcResult<ConfigBackupDeleteOutput>> configBackupDelete(ConfigBackupDeleteInput input) { logger.debug("Input received : " + input.toString()); ConfigBackupDeleteOutputBuilder outputBuilder = new ConfigBackupDeleteOutputBuilder(); Action myAction = Action.ConfigBackupDelete; @@ -1112,7 +1112,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, @Override - public Future<RpcResult<ConfigExportOutput>> configExport(ConfigExportInput input) { + public ListenableFuture<RpcResult<ConfigExportOutput>> configExport(ConfigExportInput input) { logger.debug("Input received : " + input.toString()); ConfigExportOutputBuilder outputBuilder = new ConfigExportOutputBuilder(); Action myAction = Action.ConfigExport; @@ -1145,7 +1145,7 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable, } - public Future<RpcResult<StopApplicationOutput>> stopApplication(StopApplicationInput input) { + public ListenableFuture<RpcResult<StopApplicationOutput>> stopApplication(StopApplicationInput input) { logger.debug("Input received : " + input.toString()); StopApplicationOutputBuilder outputBuilder = new StopApplicationOutputBuilder(); Action myAction = Action.StopApplication; diff --git a/appc-provider/appc-provider-model/pom.xml b/appc-provider/appc-provider-model/pom.xml index a74ff8ca8..357012a62 100644 --- a/appc-provider/appc-provider-model/pom.xml +++ b/appc-provider/appc-provider-model/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -110,11 +110,11 @@ </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> + <artifactId>ietf-inet-types-2013-07-15</artifactId> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> + <artifactId>ietf-yang-types-20130715</artifactId> </dependency> <dependency> <groupId>com.google.guava</groupId> diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/pom.xml b/appc-sdc-listener/appc-sdc-listener-bundle/pom.xml index 8d7ba164c..2c9685a43 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/pom.xml +++ b/appc-sdc-listener/appc-sdc-listener-bundle/pom.xml @@ -180,11 +180,11 @@ limitations under the License. <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> + <artifactId>ietf-inet-types-2013-07-15</artifactId> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> + <artifactId>ietf-yang-types-20130715</artifactId> </dependency> <dependency> diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcCallbackTest.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcCallbackTest.java deleted file mode 100644 index 2dcdb4d1c..000000000 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcCallbackTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.sdc.listener; - - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.onap.appc.adapter.message.EventSender; -import org.onap.appc.sdc.artifacts.helper.ArtifactStorageService; -import org.onap.appc.sdc.artifacts.helper.DependencyModelGenerator; -import org.onap.appc.sdc.artifacts.impl.ArtifactProcessorFactory; -import org.onap.appc.sdc.artifacts.impl.ToscaCsarArtifactProcessor; -import org.onap.appc.sdc.artifacts.object.SDCArtifact; -import org.onap.appc.sdc.artifacts.object.SDCReference; -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.consumer.INotificationCallback; -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.INotificationData; -import org.onap.sdc.api.notification.IResourceInstance; -import org.onap.sdc.api.results.IDistributionClientDownloadResult; -import org.onap.sdc.impl.DistributionClientDownloadResultImpl; -import org.onap.sdc.utils.DistributionActionResultEnum; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static org.mockito.Matchers.anyObject; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({IDistributionClient.class, - EventSender.class, - ArtifactStorageService.class, - ToscaCsarArtifactProcessor.class, - ArtifactProcessorFactory.class, - DependencyModelGenerator.class}) -public class SdcCallbackTest { - - private INotificationCallback sdcCallback; - private ArtifactStorageService storageService; - private ToscaCsarArtifactProcessor artifactProcessor; - private String resourceContent; - - - @Before - public void setup() throws Exception { - IDistributionClient client = PowerMockito.mock(IDistributionClient.class); - EventSender eventSender = PowerMockito.mock(EventSender.class); - sdcCallback = new SdcCallback(null, client); - resourceContent=readInput("/output/resource-ResourceAppc-template.yml").replaceAll(System.lineSeparator(),""); - artifactProcessor = Mockito.spy(new ToscaCsarArtifactProcessor(client, eventSender, getNotificationData(), getResources().get(0) - , getServiceArtifacts().get(0), null)); - storageService = PowerMockito.mock(ArtifactStorageService.class); - Whitebox.setInternalState(artifactProcessor,"artifactStorageService", storageService); - DependencyModelGenerator dependencyModelGeneratorMock=PowerMockito.mock(DependencyModelGenerator.class); - PowerMockito.when(dependencyModelGeneratorMock.getDependencyModel(Matchers.anyString(),Matchers.anyString())) - .thenReturn("Dependency_model"); - Whitebox.setInternalState(artifactProcessor,"dependencyModelGenerator",dependencyModelGeneratorMock); - - PowerMockito.doCallRealMethod().when(artifactProcessor).processArtifact(anyObject()); - PowerMockito.doCallRealMethod().when(artifactProcessor).run(); - - //PowerMockito.mockStatic(ArtifactProcessorFactory.class); - ArtifactProcessorFactory artifactProcessorFactory=PowerMockito.mock(ArtifactProcessorFactory.class); - PowerMockito.when(artifactProcessorFactory.getArtifactProcessor(anyObject(), anyObject(), - anyObject(), anyObject(), - anyObject(), anyObject())).thenReturn(artifactProcessor); - - Whitebox.setInternalState(sdcCallback,"eventSender", eventSender); - PowerMockito.doReturn(readDownloadResult()).when(client).download(anyObject()); - PowerMockito.doReturn(null).when(client).sendDownloadStatus(anyObject()); - - PowerMockito.doReturn(null).when(storageService).retrieveSDCArtifact(Matchers.anyString(), - Matchers.anyString(),Matchers.anyString()); - - PowerMockito.doAnswer(invocationOnMock -> { - System.out.print(invocationOnMock.getArguments()[0].toString()); - return null; - }).when(storageService).storeSDCArtifact(anyObject()); - } - - private IDistributionClientDownloadResult readDownloadResult() throws IOException, URISyntaxException { - DistributionClientDownloadResultImpl downloadResult = new DistributionClientDownloadResultImpl - (DistributionActionResultEnum.SUCCESS,"Download success"); - File file = new File(this.getClass().getResource("/csar/service-ServiceAppc-csar.csar").toURI()); - - byte[] bFile = new byte[(int) file.length()]; - FileInputStream fileInputStream = new FileInputStream(file); - fileInputStream.read(bFile); - fileInputStream.close(); - - downloadResult.setArtifactPayload(bFile); - return downloadResult; - } - - - @Test - public void testSDCListener() throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException { - INotificationData notificationData = getNotificationData(); - sdcCallback.activateCallback(notificationData); - pause(); - } - - @Test - public void testArtifacts() throws Exception { - PowerMockito.doAnswer(invocationOnMock -> { - SDCArtifact artifact =(SDCArtifact)invocationOnMock.getArguments()[0]; - SDCReference reference=(SDCReference)invocationOnMock.getArguments()[1]; - Assert.assertEquals("abcd-efgh-ijkl",artifact.getArtifactUUID()); - Assert.assertEquals("Resource-APPC",reference.getVnfType()); - Assert.assertEquals(resourceContent.trim(),artifact.getArtifactContent().replaceAll(System.lineSeparator(),"")); - return null; - }).doAnswer(invocation -> { - SDCArtifact artifact =(SDCArtifact)invocation.getArguments()[0]; - SDCReference reference=(SDCReference)invocation.getArguments()[1]; - Assert.assertEquals("Resource-APPC",reference.getVnfType()); - Assert.assertEquals("tosca_dependency_model",reference.getFileCategory()); - Assert.assertEquals("Dependency_model",artifact.getArtifactContent()); - Assert.assertEquals("Resource-APPC",artifact.getResourceName()); - return null; - }).when(storageService).storeSDCArtifactWithReference(anyObject(),anyObject()); - - artifactProcessor.processArtifact(readDownloadResult()); - } - - private void pause(){ - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - } - } - - private String readInput(String inputFile) throws URISyntaxException { - File file = new File(this.getClass().getResource(inputFile).toURI()); - byte[] bFile = new byte[(int) file.length()]; - try(FileInputStream fileInputStream = new FileInputStream(file)){ - fileInputStream.read(bFile); - } catch (Exception e){ - e.printStackTrace(); - } - return new String(bFile); - } - - private INotificationData getNotificationData() throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException { - - INotificationData notificationData = (INotificationData)getObject("org.onap.sdc.impl.NotificationDataImpl"); - - List<IArtifactInfo> serviceArtifacts = getServiceArtifacts(); - - invokeMethod(notificationData, "setServiceArtifacts", serviceArtifacts); - return notificationData; - } - - private List<IResourceInstance> getResources() throws ClassNotFoundException, InvocationTargetException, InstantiationException, IllegalAccessException { - List<IResourceInstance> resources = new ArrayList<>(); - IResourceInstance resource = (IResourceInstance)getObject("org.onap.sdc.impl.JsonContainerResourceInstance"); - - List<IArtifactInfo> serviceArtifacts = getServiceArtifacts(); - invokeMethod(resource,"setArtifacts",serviceArtifacts); - invokeMethod(resource,"setResourceName","Vnf"); - invokeMethod(resource,"setResourceVersion","1.0"); - - resources.add(resource); - return resources; - } - - private void invokeMethod(Object object, String methodName,Object... arguments) throws IllegalAccessException, InvocationTargetException { - Method[] methods = object.getClass().getDeclaredMethods(); - for(Method method:methods){ - if(methodName.equalsIgnoreCase(method.getName())){ - method.setAccessible(true); - method.invoke(object,arguments); - } - } - } - - private Object getObject(String fqcn) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException { - Constructor constructor = Arrays.asList(Class.forName(fqcn).getDeclaredConstructors()) - .stream() - .filter(constructor1 -> constructor1.getParameterCount()==0) - .collect(Collectors.toList()) - .get(0); - constructor.setAccessible(true); - return constructor.newInstance(); - } - - private List<IArtifactInfo> getServiceArtifacts() throws ClassNotFoundException, InvocationTargetException, InstantiationException, IllegalAccessException { - List<IArtifactInfo> serviceArtifacts = new ArrayList<>(); - IArtifactInfo artifactInfo = (IArtifactInfo)getObject("org.onap.sdc.impl.ArtifactInfoImpl"); - invokeMethod(artifactInfo,"setArtifactType","TOSCA_CSAR"); - invokeMethod(artifactInfo,"setArtifactUUID","abcd-efgh-ijkl"); - serviceArtifacts.add(artifactInfo); - return serviceArtifacts; - } -} diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcListenerTest.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcListenerTest.java deleted file mode 100644 index 2e10065e5..000000000 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcListenerTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.appc.sdc.listener; - -import com.att.eelf.configuration.EELFLogger; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.onap.sdc.api.IDistributionClient; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(Thread.class) -public class SdcListenerTest { - private SdcListener sdcListener; - private EELFLogger mockLogger = mock(EELFLogger.class); - - @Before - public void setUp() throws Exception { - sdcListener = new SdcListener(); - - // to avoid operation on logger fail, mock up the logger - Whitebox.setInternalState(sdcListener, "logger", mockLogger); - } - - @Test - public void testStart() throws Exception { - sdcListener.start(); - Assert.assertTrue("Should created startThread", - Whitebox.getInternalState(sdcListener, "startThread") != null); - } - - @Test - public void testStop() throws Exception { - // test interrupt thread and other null case - MockThread mockThread = spy(new MockThread()); - mockThread.setNewState(Thread.State.TIMED_WAITING); - Whitebox.setInternalState(sdcListener, "startThread", mockThread); - - sdcListener.stop(); - Mockito.verify(mockThread, times(1)).interrupt(); - Assert.assertTrue("Should reset startThread", - Whitebox.getInternalState(sdcListener, "startThread") == null); - - // test other non-null case and thread null case - IDistributionClient mockClient = mock(IDistributionClient.class); - Whitebox.setInternalState(sdcListener, "client", mockClient); - SdcCallback mockCallback = mock(SdcCallback.class); - Whitebox.setInternalState(sdcListener, "callback", mockCallback); - CountDownLatch mockLatch = mock(CountDownLatch.class); - Whitebox.setInternalState(sdcListener, "latch", mockLatch); - - sdcListener.stop(); - - Mockito.verify(mockLatch, times(1)).await(10, TimeUnit.SECONDS); - Mockito.verify(mockCallback, times(1)).stop(); - Mockito.verify(mockClient, times(1)).stop(); - Assert.assertTrue("Should reset latch", - Whitebox.getInternalState(sdcListener, "latch") == null); - Assert.assertTrue("Should reset callback", - Whitebox.getInternalState(sdcListener, "callback") == null); - Assert.assertTrue("Should reset client", - Whitebox.getInternalState(sdcListener, "client") == null); - } - - @Test - public void testStopStartThread() throws Exception { - // null case - sdcListener.stopStartThread(123); - //Mockito.verify(mockLogger, times(0)).debug(String.valueOf(any())); - - MockThread mockThread = spy(new MockThread()); - - // thread terminated case - Whitebox.setInternalState(sdcListener, "startThread", mockThread); - mockThread.setNewState(Thread.State.TERMINATED); - sdcListener.stopStartThread(123); - Mockito.verify(mockThread, times(0)).interrupt(); - //Mockito.verify(mockLogger, times(1)).debug(String.valueOf(any())); - Assert.assertTrue("Should reset startThread", - Whitebox.getInternalState(sdcListener, "startThread") == null); - - // thread not termianted case - int timesCallThread = 0; - int timesCallLogger = 1; - for(Thread.State state : Thread.State.values()) { - if (state == Thread.State.TERMINATED) { - continue; - } - Whitebox.setInternalState(sdcListener, "startThread", mockThread); - mockThread.setNewState(state); - sdcListener.stopStartThread(123); - Mockito.verify(mockThread, times(++ timesCallThread)).interrupt(); - //Mockito.verify(mockLogger, times(timesCallLogger += 2)).debug(String.valueOf(any())); - Assert.assertTrue("Should reset startThread", - Whitebox.getInternalState(sdcListener, "startThread") == null); - } - } - - /* - * I have used the following PowerMockito (due to Thread.getName() is a final method) - * try to mock up the thread behavior. But the mock Thread.getName() always returns null - * which works in intelliJ Junit test, but not Jenkins build: - * Thread mockThread = PowerMockito.mock(Thread.class); - * PowerMockito.doReturn(Thread.State.TERMINATED).when(mockThread).getState(); - * PowerMockito.doReturn("testing").when(mockThread).getName(); - * Hence, here goes the MockThread class to override Thread to my expected behavior. - */ - class MockThread extends Thread { - private State state; - - private MockThread() { - super.setName("testing"); - } - - void setNewState(State newState) { - state = newState; - } - - @Override - public State getState() { - return state; - } - } -} diff --git a/appc-sdc-listener/appc-yang-generator/dependency-reduced-pom.xml b/appc-sdc-listener/appc-yang-generator/dependency-reduced-pom.xml index fd09e088a..3f07d1447 100644 --- a/appc-sdc-listener/appc-yang-generator/dependency-reduced-pom.xml +++ b/appc-sdc-listener/appc-yang-generator/dependency-reduced-pom.xml @@ -72,6 +72,7 @@ <groupId>net.jcip</groupId>
</exclusion>
</exclusions>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/pom.xml b/appc-sequence-generator/appc-sequence-generator-bundle/pom.xml index c460a36a2..5922b6648 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/pom.xml +++ b/appc-sequence-generator/appc-sequence-generator-bundle/pom.xml @@ -70,14 +70,6 @@ </dependency> <dependency> <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-config</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-api</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> <artifactId>sal-common-util</artifactId> </dependency> <dependency> @@ -86,19 +78,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-broker-impl</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>sal-binding-broker-impl</artifactId> - <classifier>tests</classifier> - <version>${odl.mdsal.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.onap.appc</groupId> <artifactId>appc-dg-dependency-model</artifactId> <version>${project.version}</version> diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/provider/SequenceGeneratorProvider.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/provider/SequenceGeneratorProvider.java index 86d51e393..1dd5fefdd 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/provider/SequenceGeneratorProvider.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/provider/SequenceGeneratorProvider.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -57,7 +57,7 @@ import org.onap.appc.seqgen.objects.SequenceGeneratorInputBuilder; import org.onap.appc.seqgen.objects.Transaction; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceInput; import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceOutput; @@ -80,18 +80,19 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; public class SequenceGeneratorProvider implements AutoCloseable,SequenceGeneratorService { protected DataBroker dataBroker; protected RpcProviderRegistry rpcRegistry; - protected NotificationProviderService notificationService; + protected NotificationPublishService notificationService; protected BindingAwareBroker.RpcRegistration<SequenceGeneratorService> rpcRegistration; private final EELFLogger log = EELFManager.getInstance().getLogger(SequenceGeneratorProvider.class); private final ExecutorService executor; private final static String APP_NAME = "SequenceGeneratorProvider"; - public SequenceGeneratorProvider(DataBroker dataBroker2, NotificationProviderService notificationProviderService, + public SequenceGeneratorProvider(DataBroker dataBroker2, NotificationPublishService notificationProviderService, RpcProviderRegistry rpcRegistry2) { log.info("Creating provider for " + APP_NAME); executor = Executors.newFixedThreadPool(1); @@ -119,7 +120,7 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato } @Override - public Future<RpcResult<GenerateSequenceOutput>> generateSequence(GenerateSequenceInput input) { + public ListenableFuture<RpcResult<GenerateSequenceOutput>> generateSequence(GenerateSequenceInput input) { RpcResult<GenerateSequenceOutput> rpcResult=null; log.debug("Received input = " + input ); try { diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org/opendaylight/blueprint/sequence-generator-blueprint.xml b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org/opendaylight/blueprint/sequence-generator-blueprint.xml index 9d04a0608..2a7c55636 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org/opendaylight/blueprint/sequence-generator-blueprint.xml +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org/opendaylight/blueprint/sequence-generator-blueprint.xml @@ -42,4 +42,4 @@ <odl:rpc-implementation ref="sequence-generator"/> -</blueprint> +</blueprint>
\ No newline at end of file diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/provider/SequenceGeneratorProviderTest.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/provider/SequenceGeneratorProviderTest.java index 7f54718f0..bd4445ba4 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/provider/SequenceGeneratorProviderTest.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/provider/SequenceGeneratorProviderTest.java @@ -28,7 +28,7 @@ import org.junit.Test; import org.mockito.Mockito; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceInput; import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceInputBuilder; @@ -56,7 +56,7 @@ public class SequenceGeneratorProviderTest { private DataBroker dataBroker = Mockito.mock(DataBroker.class); private RpcProviderRegistry rpcRegistry = Mockito.mock(RpcProviderRegistry.class); - private NotificationProviderService notificationService = Mockito.mock(NotificationProviderService.class); + private NotificationPublishService notificationService = Mockito.mock(NotificationPublishService.class); @Test public void testClose() throws Exception { diff --git a/appc-sequence-generator/appc-sequence-generator-model/pom.xml b/appc-sequence-generator/appc-sequence-generator-model/pom.xml index f0d051474..62e34b16d 100644 --- a/appc-sequence-generator/appc-sequence-generator-model/pom.xml +++ b/appc-sequence-generator/appc-sequence-generator-model/pom.xml @@ -51,7 +51,6 @@ <plugin> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-maven-plugin</artifactId> - <version>${odl.yangtools.version}</version> <dependencies> <dependency> <groupId>org.opendaylight.mdsal</groupId> @@ -97,13 +96,11 @@ </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> - <version>${odl.ietf-inet-types.version}</version> + <artifactId>ietf-inet-types-2013-07-15</artifactId> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> - <version>${odl.ietf-yang-types.version}</version> + <artifactId>ietf-yang-types-20130715</artifactId> </dependency> </dependencies> </project> @@ -95,8 +95,8 @@ limitations under the License. <odl.mdsal.version>1.6.1</odl.mdsal.version> <odl.mdsal.features.version>2.3.1</odl.mdsal.features.version> <odl.yang.jmx.generator.version>0.7.1</odl.yang.jmx.generator.version> - <odl.ietf-yang-types.version>2010.09.24.11.1</odl.ietf-yang-types.version> - <odl.ietf-inet-types.version>2010.09.24.11.1</odl.ietf-inet-types.version> + <odl.ietf-yang-types.version>2013.07.15.13.1</odl.ietf-yang-types.version> + <odl.ietf-inet-types.version>1.5.1</odl.ietf-inet-types.version> <odl.controller.config.api.version>0.7.1</odl.controller.config.api.version> <odl.commons.opendaylight.version>2.0.5</odl.commons.opendaylight.version> <odl.karaf.empty.distro.version>1.8.3-Carbon</odl.karaf.empty.distro.version> @@ -271,12 +271,12 @@ limitations under the License. </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-inet-types</artifactId> + <artifactId>ietf-inet-types-2013-07-15</artifactId> <version>${odl.ietf-inet-types.version}</version> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> - <artifactId>ietf-yang-types</artifactId> + <artifactId>ietf-yang-types-20130715</artifactId> <version>${odl.ietf-yang-types.version}</version> </dependency> <!-- CURRENTLY DOES NOT EXIST IN 3.0. Replacement? --> |