Fixed ItmModuleTest & ItmModuleFactoryTest which were in wrong directory
[vpnservice.git] / itm / itm-impl / src / test / java / org / opendaylight / yang / gen / v1 / urn / opendaylight / vpnservice / 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
28     @Test
29     public void testCustomValidation() {
30         ItmModule module = new ItmModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
31
32         // ensure no exceptions on validation
33         // currently this method is empty
34         module.customValidation();
35     }
36
37     @Test
38     public void testCreateInstance() throws Exception {
39         // configure mocks
40         DependencyResolver dependencyResolver = mock(DependencyResolver.class);
41         BindingAwareBroker broker = mock(BindingAwareBroker.class);
42         when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
43
44         // create instance of module with injected mocks
45         ItmModule module = new ItmModule(mock(ModuleIdentifier.class), dependencyResolver);
46
47         // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
48         AutoCloseable closeable = module.getInstance();
49
50         // verify that the module registered the returned provider with the broker
51         verify(broker).registerProvider((ItmProvider)closeable);
52
53         // ensure no exceptions on close
54         closeable.close();
55     }
56 }