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.DataStoreVersions;
17 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
19 import scala.concurrent.Future;
22 * Unit tests for PrimaryShardInfoFutureCache.
24 * @author Thomas Pantelis
26 public class PrimaryShardInfoFutureCacheTest {
29 public void testOperations() {
30 PrimaryShardInfoFutureCache cache = new PrimaryShardInfoFutureCache();
32 assertEquals("getIfPresent", null, cache.getIfPresent("foo"));
34 PrimaryShardInfo shardInfo = new PrimaryShardInfo(mock(ActorSelection.class), DataStoreVersions.CURRENT_VERSION,
35 Optional.<DataTree>absent());
36 cache.putSuccessful("foo", shardInfo);
38 Future<PrimaryShardInfo> future = cache.getIfPresent("foo");
39 assertNotNull("Null future", future);
40 assertEquals("getIfPresent", shardInfo, future.value().get().get());
44 assertEquals("getIfPresent", null, cache.getIfPresent("foo"));