Fix CS warnings in cds-access-client and enable enforcement
[controller.git] / opendaylight / md-sal / cds-access-client / src / test / java / org / opendaylight / controller / cluster / access / client / ClientActorContextTest.java
1 /*
2  * Copyright (c) 2016 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.controller.cluster.access.client;
9
10 import static org.junit.Assert.assertSame;
11
12 import akka.actor.ActorRef;
13 import akka.actor.Scheduler;
14 import akka.dispatch.Dispatcher;
15 import com.google.common.base.Ticker;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.Mock;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
21 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
22 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
23 import org.opendaylight.controller.cluster.access.concepts.MemberName;
24
25 public class ClientActorContextTest {
26     private static final MemberName MEMBER_NAME = MemberName.forName("member-1");
27     private static final FrontendType FRONTEND_TYPE =
28             FrontendType.forName(ClientActorContextTest.class.getSimpleName());
29     private static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE);
30     private static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0);
31     private static final String PERSISTENCE_ID = ClientActorContextTest.class.getSimpleName();
32
33     @Mock
34     private ActorRef mockSelf;
35
36     @Mock
37     private Scheduler mockScheduler;
38
39     @Mock
40     private Dispatcher mockDispatcher;
41
42     @Before
43     public void setup() {
44         MockitoAnnotations.initMocks(this);
45     }
46
47     @Test
48     public void testMockingControl() {
49         ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher,
50                 PERSISTENCE_ID, CLIENT_ID);
51         assertSame(CLIENT_ID, ctx.getIdentifier());
52         assertSame(PERSISTENCE_ID, ctx.persistenceId());
53         assertSame(mockSelf, ctx.self());
54     }
55
56     @Test
57     public void testTicker() {
58         ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher,
59                 PERSISTENCE_ID, CLIENT_ID);
60         assertSame(Ticker.systemTicker(), ctx.ticker());
61     }
62 }