2 * Copyright (c) 2015 Brocade Communications 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.datastore.utils;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.Mockito.mock;
13 import akka.actor.ActorSelection;
14 import com.google.common.base.Optional;
15 import org.junit.Test;
16 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
18 import scala.concurrent.Future;
21 * Unit tests for PrimaryShardInfoFutureCache.
23 * @author Thomas Pantelis
25 public class PrimaryShardInfoFutureCacheTest {
28 public void testOperations() {
29 PrimaryShardInfoFutureCache cache = new PrimaryShardInfoFutureCache();
31 assertEquals("getIfPresent", null, cache.getIfPresent("foo"));
33 PrimaryShardInfo shardInfo = new PrimaryShardInfo(mock(ActorSelection.class), Optional.<DataTree>absent());
34 cache.putSuccessful("foo", shardInfo);
36 Future<PrimaryShardInfo> future = cache.getIfPresent("foo");
37 assertNotNull("Null future", future);
38 assertEquals("getIfPresent", shardInfo, future.value().get().get());
42 assertEquals("getIfPresent", null, cache.getIfPresent("foo"));