1 #set( $symbol_pound = '#' )
2 #set( $symbol_dollar = '$' )
3 #set( $symbol_escape = '\' )
4 #set( $module = "${classPrefix}Module" )
6 * ${copyright} and others. All rights reserved.
8 * This program and the accompanying materials are made available under the
9 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
10 * and is available at http://www.eclipse.org/legal/epl-v10.html
12 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.${artifactId}.impl.rev141210;
14 import org.junit.Test;
15 import org.opendaylight.controller.config.api.DependencyResolver;
16 import org.opendaylight.controller.config.api.JmxAttribute;
17 import org.opendaylight.controller.config.api.ModuleIdentifier;
18 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
19 import ${package}.${classPrefix}Provider;
21 import javax.management.ObjectName;
23 import static org.mockito.Matchers.any;
24 import static org.mockito.Matchers.eq;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.verify;
27 import static org.mockito.Mockito.when;
29 public class ${classPrefix}ModuleTest {
31 public void testCustomValidation() {
32 ${module} module = new ${module}(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
34 // ensure no exceptions on validation
35 // currently this method is empty
36 module.customValidation();
40 public void testCreateInstance() throws Exception {
42 DependencyResolver dependencyResolver = mock(DependencyResolver.class);
43 BindingAwareBroker broker = mock(BindingAwareBroker.class);
44 when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
46 // create instance of module with injected mocks
47 ${module} module = new ${module}(mock(ModuleIdentifier.class), dependencyResolver);
49 // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
50 AutoCloseable closeable = module.getInstance();
52 // verify that the module registered the returned provider with the broker
53 verify(broker).registerProvider((${classPrefix}Provider)closeable);
55 // ensure no exceptions on close