blob: 93741b7357cfaff24068fbbddfe0fa1e2409c406 [file] [log] [blame]
Ayaka Koshibee8e45352014-10-16 00:37:19 -07001package org.onlab.onos.store.mastership.impl;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertTrue;
5import static org.onlab.onos.net.MastershipRole.*;
6
7import org.junit.Test;
8import org.onlab.onos.cluster.NodeId;
9
10import com.google.common.collect.Sets;
11
12public class RoleValueTest {
13
14 private static final RoleValue RV = new RoleValue();
15
16 private static final NodeId NID1 = new NodeId("node1");
17 private static final NodeId NID2 = new NodeId("node2");
18 private static final NodeId NID3 = new NodeId("node3");
19
20 @Test
21 public void add() {
22 assertEquals("faulty initialization: ", 3, RV.value.size());
23 RV.add(MASTER, NID1);
24 RV.add(STANDBY, NID2);
25 RV.add(STANDBY, NID3);
26
27 assertEquals("wrong nodeID: ", NID1, RV.get(MASTER));
28 assertTrue("wrong nodeIDs: ",
29 Sets.newHashSet(NID3, NID2).containsAll(RV.nodesOfRole(STANDBY)));
30 }
31}