2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.access.client;
10 import static org.mockito.Mockito.doReturn;
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;
23 * Abstract base class for client actors and their components.
25 public abstract class AbstractClientActorTest {
26 private static final MemberName MEMBER_NAME = MemberName.forName("member-1");
29 private ClientActorContext mockActorContext;
31 private ActorRef mockSelf;
33 protected final FakeTicker ticker = new FakeTicker();
37 MockitoAnnotations.initMocks(this);
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);
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();
49 protected final ClientActorContext actorContext() {
50 return mockActorContext;
53 protected final ActorRef self() {