blob: 55586b81b4cf3454b0bbacae055d9f7b8d0ab4fe [file] [log] [blame]
Phaneendra Manda8225ddb2016-02-05 20:54:04 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Phaneendra Manda8225ddb2016-02-05 20:54:04 +05303 *
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 */
16package org.onosproject.vtnrsc;
17
18import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.is;
20import static org.hamcrest.Matchers.notNullValue;
21import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
22
23import org.junit.Test;
24
25import com.google.common.testing.EqualsTester;
26
27/**
28 * Unit tests for LoadBalanceId class.
29 */
30public class LoadBalanceIdTest {
31
32 final LoadBalanceId id1 = LoadBalanceId.of((byte) 1);
33 final LoadBalanceId sameAsId1 = LoadBalanceId.of((byte) 1);
34 final LoadBalanceId id2 = LoadBalanceId.of((byte) 2);
35
36 /**
37 * Checks that the LoadBalanceId class is immutable.
38 */
39 @Test
40 public void testImmutability() {
41 assertThatClassIsImmutable(LoadBalanceId.class);
42 }
43
44 /**
45 * Checks the operation of equals() methods.
46 */
47 @Test
48 public void testEquals() {
49 new EqualsTester().addEqualityGroup(id1, sameAsId1).addEqualityGroup(id2)
50 .testEquals();
51 }
52
53 /**
54 * Checks the construction of a LoadBalanceId object.
55 */
56 @Test
57 public void testConstruction() {
58 final LoadBalanceId id = LoadBalanceId.of((byte) 1);
59 assertThat(id, is(notNullValue()));
60 assertThat(id.loadBalanceId(), is((byte) 1));
61 }
62}