2 * Copyright (c) 2016 Red Hat, 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.md.sal.common.api.clustering.testutil;
10 import static org.opendaylight.yangtools.testutils.mockito.MoreAnswers.realOrException;
12 import com.google.common.base.Optional;
13 import org.mockito.Mockito;
14 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
15 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
16 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
17 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
18 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
19 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
22 * Fake EntityOwnershipService suitable for non-clustered component tests.
24 * @author Michael Vorburger
26 public abstract class TestEntityOwnershipService implements EntityOwnershipService {
28 private static final EntityOwnershipState STATE = new EntityOwnershipState(true, true);
30 public static EntityOwnershipService newInstance() {
31 return Mockito.mock(TestEntityOwnershipService.class, realOrException());
35 public EntityOwnershipCandidateRegistration registerCandidate(Entity entity) {
36 return Mockito.mock(EntityOwnershipCandidateRegistration.class, realOrException());
40 public EntityOwnershipListenerRegistration registerListener(String entityType, EntityOwnershipListener listener) {
41 return Mockito.mock(EntityOwnershipListenerRegistration.class, realOrException());
45 public Optional<EntityOwnershipState> getOwnershipState(Entity forEntity) {
46 return Optional.of(STATE);
50 public boolean isCandidateRegistered(Entity entity) {