/*
- * Copyright © 2017 AT&T and others. All rights reserved.
+ * Copyright © 2018 Orange Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
+
+
package org.opendaylight.transportpce.olm;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.common.mapping.PortMappingImpl;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
+import org.opendaylight.transportpce.olm.power.PowerMgmt;
+import org.opendaylight.transportpce.olm.service.OlmPowerService;
+import org.opendaylight.transportpce.olm.service.OlmPowerServiceImpl;
+import org.opendaylight.transportpce.olm.stub.MountPointServiceStub;
+import org.opendaylight.transportpce.olm.stub.MountPointStub;
+import org.opendaylight.transportpce.olm.stub.RpcProviderRegistryStub;
+import org.opendaylight.transportpce.olm.stub.RpcProviderRegistryStub2;
+import org.opendaylight.transportpce.test.AbstractTest;
+
+public class OlmProviderTest extends AbstractTest {
+
+ private MountPoint mountPoint;
+ private MountPointService mountPointService;
+ private DeviceTransactionManager deviceTransactionManager;
+ private CrossConnect crossConnect;
+ private OpenRoadmInterfaces openRoadmInterfaces;
+ private PortMapping portMapping;
+ private PowerMgmt powerMgmt;
+ private OlmPowerService olmPowerService;
+ private RpcProviderRegistry rpcProviderRegistry;
+ private OlmProvider olmProvider;
+
+ @Before
+ public void setUp() {
+ this.mountPoint = new MountPointStub(this.getDataBroker());
+ this.mountPointService = new MountPointServiceStub(mountPoint);
+ this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
+ this.crossConnect = new CrossConnectImpl(this.deviceTransactionManager);
+ this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager));
+ this.portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager,
+ this.openRoadmInterfaces);
+ this.powerMgmt = new PowerMgmt(this.getDataBroker(), this.openRoadmInterfaces, this.crossConnect,
+ this.deviceTransactionManager);
+ this.olmPowerService = new OlmPowerServiceImpl(this.getDataBroker(), this.powerMgmt,
+ this.deviceTransactionManager, this.portMapping);
+ this.rpcProviderRegistry = new RpcProviderRegistryStub();
+ this.olmProvider = new OlmProvider(this.rpcProviderRegistry, this.olmPowerService);
+
+ }
+
+
+ @Test
+ public void testInitAndClose() {
+ this.olmProvider.init();
+ this.olmProvider.close();
+ }
+
-public class OlmProviderTest {
@Test
- public void init() throws Exception {
- //TODO implement test
+ public void testClose2() {
+ this.rpcProviderRegistry = new RpcProviderRegistryStub2();
+ this.olmProvider = new OlmProvider(this.rpcProviderRegistry, this.olmPowerService);
+ this.olmProvider.init();
+ this.olmProvider.close();
}
}
--- /dev/null
+/*
+ * Copyright © 2018 Orange Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+
+package org.opendaylight.transportpce.olm.stub;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class CompositeRoutedRpcRegistrationStub<T extends RpcService> implements
+ BindingAwareBroker.RoutedRpcRegistration<T> {
+ private final Class<T> type;
+ private final T instance;
+ private final BindingDOMRpcProviderServiceAdapter adapter;
+ private final Map<InstanceIdentifier<?>, ObjectRegistration<T>> registrations = new HashMap(2);
+
+ CompositeRoutedRpcRegistrationStub(final Class<T> type, final T impl,
+ final BindingDOMRpcProviderServiceAdapter providerAdapter) {
+ this.type = type;
+ this.instance = impl;
+ this.adapter = providerAdapter;
+ }
+
+ @Override public void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> myinstance) {
+
+ }
+
+ @Override public void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> myinstance) {
+
+ }
+
+ @Override public void registerPath(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path) {
+
+ }
+
+ @Override public void unregisterPath(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path) {
+
+ }
+
+ @Override public Class<T> getServiceType() {
+ return null;
+ }
+
+ @Override public void close() {
+
+ }
+
+ @Nonnull
+ @Override public T getInstance() {
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2018 Orange Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.olm.stub;
+
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class RpcProviderRegistryStub implements RpcProviderRegistry {
+ @Override public <T extends RpcService> BindingAwareBroker.RpcRegistration<T> addRpcImplementation(
+ Class<T> serviceInterface, T implementation) throws IllegalStateException {
+ return new CompositeRoutedRpcRegistrationStub(serviceInterface, implementation, null);
+ }
+
+ @Override public <T extends RpcService> BindingAwareBroker.RoutedRpcRegistration<T> addRoutedRpcImplementation(
+ Class<T> serviceInterface, T implementation) throws IllegalStateException {
+ return null;
+ }
+
+ @Override public <L extends RouteChangeListener<RpcContextIdentifier,
+ InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(L listener) {
+ return null;
+ }
+
+ @Override public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2018 Orange Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.olm.stub;
+
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class RpcProviderRegistryStub2 implements RpcProviderRegistry {
+ @Override public <T extends RpcService> BindingAwareBroker.RpcRegistration<T> addRpcImplementation(
+ Class<T> serviceInterface, T implementation) throws IllegalStateException {
+ return null;
+ }
+
+ @Override public <T extends RpcService> BindingAwareBroker.RoutedRpcRegistration<T> addRoutedRpcImplementation(
+ Class<T> serviceInterface, T implementation) throws IllegalStateException {
+ return null;
+ }
+
+ @Override public <L extends RouteChangeListener<RpcContextIdentifier,
+ InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(L listener) {
+ return null;
+ }
+
+ @Override public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2018 Orange Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.olm.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class OtsPmHolderTest {
+
+ @Test
+ public void test() {
+ OtsPmHolder otspmholder0 = new OtsPmHolder("name", Double.valueOf(12), "interface");
+
+ Assert.assertEquals("name", otspmholder0.getOtsParameterName());
+ Assert.assertEquals(Double.valueOf(12), otspmholder0.getOtsParameterVal());
+ Assert.assertEquals("interface", otspmholder0.getOtsInterfaceName());
+
+ otspmholder0.setOtsParameterName("name 2");
+ otspmholder0.setOtsParameterVal(Double.valueOf(120));
+ otspmholder0.setOtsInterfaceName("interface 2");
+
+ Assert.assertEquals("name 2", otspmholder0.getOtsParameterName());
+ Assert.assertEquals(Double.valueOf(120), otspmholder0.getOtsParameterVal());
+ Assert.assertEquals("interface 2", otspmholder0.getOtsInterfaceName());
+ }
+}