blob: 26d8ff0b9e5cc0fa60ef816be08ab82b050178e1 [file] [log] [blame]
Jian Li18f3bce2016-08-04 17:36:41 +09001/*
2 * Copyright 2016-present 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 */
16package org.onosproject.lisp.msg.protocols;
17
18import com.google.common.testing.EqualsTester;
19import org.junit.Before;
20import org.junit.Test;
21
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24
25/**
26 * Unit tests for DefaultLispMapNotify class.
27 */
Jian Li47671902016-08-11 01:18:18 +090028public final class DefaultLispMapNotifyTest {
Jian Li18f3bce2016-08-04 17:36:41 +090029
30 private LispMapNotify notify1;
31 private LispMapNotify sameAsNotify1;
32 private LispMapNotify notify2;
33
34 @Before
35 public void setup() {
36
37 LispMapNotify.NotifyBuilder builder1 =
38 new DefaultLispMapNotify.DefaultNotifyBuilder();
39
40 notify1 = builder1
41 .withKeyId((short) 1)
42 .withNonce(1L)
43 .withRecordCount((byte) 0x01)
44 .build();
45
46 LispMapNotify.NotifyBuilder builder2 =
47 new DefaultLispMapNotify.DefaultNotifyBuilder();
48
49 sameAsNotify1 = builder2
50 .withKeyId((short) 1)
51 .withNonce(1L)
52 .withRecordCount((byte) 0x01)
53 .build();
54
55 LispMapNotify.NotifyBuilder builder3 =
56 new DefaultLispMapNotify.DefaultNotifyBuilder();
57
58 notify2 = builder3
59 .withKeyId((short) 2)
60 .withNonce(2L)
61 .withRecordCount((byte) 0x02)
62 .build();
63 }
64
65 @Test
66 public void testEquality() {
67 new EqualsTester()
68 .addEqualityGroup(notify1, sameAsNotify1)
69 .addEqualityGroup(notify2).testEquals();
70 }
71
72 @Test
73 public void testConstruction() {
74 DefaultLispMapNotify notify = (DefaultLispMapNotify) notify1;
75
76 assertThat(notify.getKeyId(), is((short) 1));
77 assertThat(notify.getNonce(), is(1L));
78 assertThat(notify.getRecordCount(), is((byte) 0x01));
79 }
80}