Bug 5596 Created lifecycle service
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / lifecycle / LifecycleServiceImplTest.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.openflowplugin.impl.lifecycle;
9
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13 import org.mockito.Mock;
14 import org.mockito.Mockito;
15 import org.mockito.runners.MockitoJUnitRunner;
16 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
17 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
18 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
19 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService;
20 import org.opendaylight.openflowplugin.api.openflow.role.RoleContext;
21 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
22 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
23
24 @RunWith(MockitoJUnitRunner.class)
25 public class LifecycleServiceImplTest {
26
27     private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = ServiceGroupIdentifier.create("test node");
28     @Mock
29     private DeviceInfo deviceInfo;
30     @Mock
31     private DeviceContext deviceContext;
32     @Mock
33     private RpcContext rpcContext;
34     @Mock
35     private RoleContext roleContext;
36     @Mock
37     private StatisticsContext statContext;
38
39     private LifecycleService lifecycleService;
40
41     @Before
42     public void setUp() {
43         lifecycleService = new LifecycleServiceImpl(deviceContext, rpcContext, roleContext, statContext);
44         Mockito.when(deviceInfo.getServiceIdentifier()).thenReturn(SERVICE_GROUP_IDENTIFIER);
45     }
46
47     @Test
48     public void instantiateServiceInstance() throws Exception {
49         lifecycleService.instantiateServiceInstance();
50         Mockito.verify(deviceContext).startupClusterServices();
51     }
52
53     @Test
54     public void closeServiceInstance() throws Exception {
55         lifecycleService.closeServiceInstance();
56         Mockito.verify(deviceContext).stopClusterServices();
57     }
58
59 }