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