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

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.