Eliminate use of deprecated mockito methods
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / utils / DispatchersTest.java
1 /*
2  * Copyright (c) 2014, 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
9 package org.opendaylight.controller.cluster.datastore.utils;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.mockito.ArgumentMatchers.anyString;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.mock;
15
16 import akka.dispatch.MessageDispatcher;
17 import org.junit.Test;
18 import org.opendaylight.controller.cluster.common.actor.Dispatchers;
19
20 public class DispatchersTest {
21
22     @Test
23     public void testGetDefaultDispatcherPath() {
24         akka.dispatch.Dispatchers mockDispatchers = mock(akka.dispatch.Dispatchers.class);
25         doReturn(false).when(mockDispatchers).hasDispatcher(anyString());
26         Dispatchers dispatchers = new Dispatchers(mockDispatchers);
27
28         for (Dispatchers.DispatcherType type : Dispatchers.DispatcherType.values()) {
29             assertEquals(Dispatchers.DEFAULT_DISPATCHER_PATH,
30                     dispatchers.getDispatcherPath(type));
31         }
32
33     }
34
35     @Test
36     public void testGetDefaultDispatcher() {
37         akka.dispatch.Dispatchers mockDispatchers = mock(akka.dispatch.Dispatchers.class);
38         MessageDispatcher mockGlobalDispatcher = mock(MessageDispatcher.class);
39         doReturn(false).when(mockDispatchers).hasDispatcher(anyString());
40         doReturn(mockGlobalDispatcher).when(mockDispatchers).defaultGlobalDispatcher();
41         Dispatchers dispatchers = new Dispatchers(mockDispatchers);
42
43         for (Dispatchers.DispatcherType type : Dispatchers.DispatcherType.values()) {
44             assertEquals(mockGlobalDispatcher,
45                     dispatchers.getDispatcher(type));
46         }
47
48     }
49
50     @Test
51     public void testGetDispatcherPath() {
52         akka.dispatch.Dispatchers mockDispatchers = mock(akka.dispatch.Dispatchers.class);
53         doReturn(true).when(mockDispatchers).hasDispatcher(anyString());
54         Dispatchers dispatchers = new Dispatchers(mockDispatchers);
55
56         assertEquals(Dispatchers.CLIENT_DISPATCHER_PATH,
57                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Client));
58
59         assertEquals(Dispatchers.TXN_DISPATCHER_PATH,
60                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Transaction));
61
62         assertEquals(Dispatchers.SHARD_DISPATCHER_PATH,
63                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Shard));
64
65         assertEquals(Dispatchers.NOTIFICATION_DISPATCHER_PATH,
66                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Notification));
67
68     }
69
70     @Test
71     public void testGetDispatcher() {
72         akka.dispatch.Dispatchers mockDispatchers = mock(akka.dispatch.Dispatchers.class);
73         MessageDispatcher mockDispatcher = mock(MessageDispatcher.class);
74         doReturn(true).when(mockDispatchers).hasDispatcher(anyString());
75         doReturn(mockDispatcher).when(mockDispatchers).lookup(anyString());
76         Dispatchers dispatchers = new Dispatchers(mockDispatchers);
77
78         assertEquals(Dispatchers.CLIENT_DISPATCHER_PATH,
79                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Client));
80
81         assertEquals(Dispatchers.TXN_DISPATCHER_PATH,
82                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Transaction));
83
84         assertEquals(Dispatchers.SHARD_DISPATCHER_PATH,
85                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Shard));
86
87         assertEquals(Dispatchers.NOTIFICATION_DISPATCHER_PATH,
88                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Notification));
89
90     }
91 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.