blob: be2f84a13d344178d53e139c0f63199983340dd9 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Yuta HIGUCHI80912e62014-10-12 00:15:47 -070016package org.onlab.onos.mastership;
Ayaka Koshibe3de43ca2014-09-26 16:40:23 -070017
18import static org.junit.Assert.assertEquals;
19
20import org.junit.Test;
Yuta HIGUCHI80912e62014-10-12 00:15:47 -070021import org.onlab.onos.cluster.NodeId;
Ayaka Koshibe3de43ca2014-09-26 16:40:23 -070022
23import com.google.common.testing.EqualsTester;
24
25public class MastershipTermTest {
26
27 private static final NodeId N1 = new NodeId("foo");
28 private static final NodeId N2 = new NodeId("bar");
29
30 private static final MastershipTerm TERM1 = MastershipTerm.of(N1, 0);
31 private static final MastershipTerm TERM2 = MastershipTerm.of(N2, 1);
32 private static final MastershipTerm TERM3 = MastershipTerm.of(N2, 1);
33 private static final MastershipTerm TERM4 = MastershipTerm.of(N1, 1);
34
35 @Test
36 public void basics() {
37 assertEquals("incorrect term number", 0, TERM1.termNumber());
38 assertEquals("incorrect master", new NodeId("foo"), TERM1.master());
39 }
40
41 @Test
42 public void testEquality() {
43 new EqualsTester().addEqualityGroup(MastershipTerm.of(N1, 0), TERM1)
44 .addEqualityGroup(TERM2, TERM3)
45 .addEqualityGroup(TERM4);
46 }
47
48}