Fixing issues with ARP integration of VpnService
[vpnservice.git] / itm / itm-impl / src / test / java / org / opendaylight / yang / gen / v1 / urn / opendaylight / itm / impl / rev141210 / ItmModuleTest.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.impl.rev141210;
9
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;
17
18 import javax.management.ObjectName;
19
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;
25
26 public class ItmModuleTest {
27     @Test
28     public void testCustomValidation() {
29         ItmModule module = new ItmModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
30
31         // ensure no exceptions on validation
32         // currently this method is empty
33         module.customValidation();
34     }
35
36     @Test
37     public void testCreateInstance() throws Exception {
38         // configure mocks
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);
42
43         // create instance of module with injected mocks
44         ItmModule module = new ItmModule(mock(ModuleIdentifier.class), dependencyResolver);
45
46         // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
47         AutoCloseable closeable = module.getInstance();
48
49         // verify that the module registered the returned provider with the broker
50         verify(broker).registerProvider((ItmProvider)closeable);
51
52         // ensure no exceptions on close
53         closeable.close();
54     }
55 }