2 * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.impl.rev141210;
10 import org.junit.Test;
11 import org.opendaylight.controller.config.api.DependencyResolver;
12 import org.opendaylight.controller.config.api.JmxAttribute;
13 import org.opendaylight.controller.config.api.ModuleIdentifier;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
15 import org.opendaylight.vpnservice.itm.impl.ItmProvider;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.impl.rev141210.ItmModule;
18 import javax.management.ObjectName;
20 import static org.mockito.Matchers.any;
21 import static org.mockito.Matchers.eq;
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.verify;
24 import static org.mockito.Mockito.when;
26 public class ItmModuleTest {
28 public void testCustomValidation() {
29 ItmModule module = new ItmModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
31 // ensure no exceptions on validation
32 // currently this method is empty
33 module.customValidation();
37 public void testCreateInstance() throws Exception {
39 DependencyResolver dependencyResolver = mock(DependencyResolver.class);
40 BindingAwareBroker broker = mock(BindingAwareBroker.class);
41 when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
43 // create instance of module with injected mocks
44 ItmModule module = new ItmModule(mock(ModuleIdentifier.class), dependencyResolver);
46 // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
47 AutoCloseable closeable = module.getInstance();
49 // verify that the module registered the returned provider with the broker
50 verify(broker).registerProvider((ItmProvider)closeable);
52 // ensure no exceptions on close