Clean up use of MockitoAnnotations.initMocks
[controller.git] / opendaylight / md-sal / cds-access-client / src / test / java / org / opendaylight / controller / cluster / access / client / AbstractClientActorTest.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.mockito.Mockito.doReturn;
11
12 import akka.actor.ActorRef;
13 import com.google.common.testing.FakeTicker;
14 import org.junit.Before;
15 import org.mockito.Mock;
16 import org.mockito.MockitoAnnotations;
17 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
18 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
19 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
20 import org.opendaylight.controller.cluster.access.concepts.MemberName;
21
22 /**
23  * Abstract base class for client actors and their components.
24  */
25 public abstract class AbstractClientActorTest {
26     private static final MemberName MEMBER_NAME = MemberName.forName("member-1");
27
28     @Mock
29     private ClientActorContext mockActorContext;
30     @Mock
31     private ActorRef mockSelf;
32
33     protected final FakeTicker ticker = new FakeTicker();
34
35     @Before
36     public void setup() {
37         MockitoAnnotations.initMocks(this);
38
39         final FrontendType frontendType = FrontendType.forName(getClass().getSimpleName());
40         final FrontendIdentifier frontendId = FrontendIdentifier.create(MEMBER_NAME, frontendType);
41         final ClientIdentifier clientId = ClientIdentifier.create(frontendId, 0);
42
43         doReturn(ticker).when(mockActorContext).ticker();
44         doReturn(clientId).when(mockActorContext).getIdentifier();
45         doReturn(getClass().getSimpleName()).when(mockActorContext).persistenceId();
46         doReturn(mockSelf).when(mockActorContext).self();
47     }
48
49     protected final ClientActorContext actorContext() {
50         return mockActorContext;
51     }
52
53     protected final ActorRef self() {
54         return mockSelf;
55     }
56 }