Remove use of {String,UUID}Identifier
[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.Matchers.anyString;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.mock;
15 import akka.dispatch.MessageDispatcher;
16 import org.junit.Test;
17
18 public class DispatchersTest {
19
20     @Test
21     public void testGetDefaultDispatcherPath(){
22         akka.dispatch.Dispatchers mockDispatchers = mock(akka.dispatch.Dispatchers.class);
23         doReturn(false).when(mockDispatchers).hasDispatcher(anyString());
24         Dispatchers dispatchers = new Dispatchers(mockDispatchers);
25
26         for(Dispatchers.DispatcherType type : Dispatchers.DispatcherType.values()) {
27             assertEquals(Dispatchers.DEFAULT_DISPATCHER_PATH,
28                     dispatchers.getDispatcherPath(type));
29         }
30
31     }
32
33     @Test
34     public void testGetDefaultDispatcher(){
35         akka.dispatch.Dispatchers mockDispatchers = mock(akka.dispatch.Dispatchers.class);
36         MessageDispatcher mockGlobalDispatcher = mock(MessageDispatcher.class);
37         doReturn(false).when(mockDispatchers).hasDispatcher(anyString());
38         doReturn(mockGlobalDispatcher).when(mockDispatchers).defaultGlobalDispatcher();
39         Dispatchers dispatchers = new Dispatchers(mockDispatchers);
40
41         for(Dispatchers.DispatcherType type : Dispatchers.DispatcherType.values()) {
42             assertEquals(mockGlobalDispatcher,
43                     dispatchers.getDispatcher(type));
44         }
45
46     }
47
48     @Test
49     public void testGetDispatcherPath(){
50         akka.dispatch.Dispatchers mockDispatchers = mock(akka.dispatch.Dispatchers.class);
51         doReturn(true).when(mockDispatchers).hasDispatcher(anyString());
52         Dispatchers dispatchers = new Dispatchers(mockDispatchers);
53
54         assertEquals(Dispatchers.CLIENT_DISPATCHER_PATH,
55                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Client));
56
57         assertEquals(Dispatchers.TXN_DISPATCHER_PATH,
58                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Transaction));
59
60         assertEquals(Dispatchers.SHARD_DISPATCHER_PATH,
61                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Shard));
62
63         assertEquals(Dispatchers.NOTIFICATION_DISPATCHER_PATH,
64                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Notification));
65
66     }
67
68     @Test
69     public void testGetDispatcher(){
70         akka.dispatch.Dispatchers mockDispatchers = mock(akka.dispatch.Dispatchers.class);
71         MessageDispatcher mockDispatcher = mock(MessageDispatcher.class);
72         doReturn(true).when(mockDispatchers).hasDispatcher(anyString());
73         doReturn(mockDispatcher).when(mockDispatchers).lookup(anyString());
74         Dispatchers dispatchers = new Dispatchers(mockDispatchers);
75
76         assertEquals(Dispatchers.CLIENT_DISPATCHER_PATH,
77                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Client));
78
79         assertEquals(Dispatchers.TXN_DISPATCHER_PATH,
80                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Transaction));
81
82         assertEquals(Dispatchers.SHARD_DISPATCHER_PATH,
83                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Shard));
84
85         assertEquals(Dispatchers.NOTIFICATION_DISPATCHER_PATH,
86                 dispatchers.getDispatcherPath(Dispatchers.DispatcherType.Notification));
87
88     }
89 }