blob: a61c496b22ea860ce4f682f88434304e68683801 [file] [log] [blame]
Dhruv Dhodyb5850122016-02-17 17:51:19 +05301/*
2 * Copyright 2016 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.ospf.controller.impl;
17
18import org.junit.After;
19import org.junit.Before;
20import org.junit.Test;
21import org.onlab.packet.Ip4Address;
22
23import static org.hamcrest.CoreMatchers.is;
24import static org.junit.Assert.assertThat;
25
26/**
27 * Unit test class for DeviceInformationImpl.
28 */
29public class DeviceInformationImplTest {
30
31 private DeviceInformationImpl deviceInformation;
32
33 @Before
34 public void setUp() throws Exception {
35 deviceInformation = new DeviceInformationImpl();
36 }
37
38 @After
39 public void tearDown() throws Exception {
40 deviceInformation = null;
41 }
42
43 /**
44 * Tests routerId() getter method.
45 */
46 @Test
47 public void testRouterId() throws Exception {
48 deviceInformation.setRouterId(Ip4Address.valueOf("1.1.1.1"));
49 assertThat(deviceInformation.routerId(), is(Ip4Address.valueOf("1.1.1.1")));
50 }
51
52 /**
53 * Tests routerId() setter method.
54 */
55 @Test
56 public void testSetRouterId() throws Exception {
57 deviceInformation.setRouterId(Ip4Address.valueOf("1.1.1.1"));
58 assertThat(deviceInformation.routerId(), is(Ip4Address.valueOf("1.1.1.1")));
59 }
60
61 /**
62 * Tests deviceId() getter method.
63 */
64 @Test
65 public void testDeviceId() throws Exception {
66 deviceInformation.setDeviceId(Ip4Address.valueOf("1.1.1.1"));
67 assertThat(deviceInformation.deviceId(), is(Ip4Address.valueOf("1.1.1.1")));
68 }
69
70 /**
71 * Tests deviceId() getter method.
72 */
73 @Test
74 public void testSetDeviceId() throws Exception {
75 deviceInformation.setDeviceId(Ip4Address.valueOf("1.1.1.1"));
76 assertThat(deviceInformation.deviceId(), is(Ip4Address.valueOf("1.1.1.1")));
77 }
78
79 /**
80 * Tests interfaceId() method.
81 */
82 @Test
83 public void testInterfaceId() throws Exception {
84 deviceInformation.addInterfaceId(Ip4Address.valueOf("1.1.1.1"));
85 assertThat(deviceInformation.interfaceId().size(), is(1));
86 }
87
88 /**
89 * Tests addInterfaceId() method.
90 */
91 @Test
92 public void testAddInterfaceId() throws Exception {
93 deviceInformation.addInterfaceId(Ip4Address.valueOf("1.1.1.1"));
94 assertThat(deviceInformation.interfaceId().size(), is(1));
95 }
96
97 /**
98 * Tests areaId() getter method.
99 */
100 @Test
101 public void testAreaId() throws Exception {
102 deviceInformation.setAreaId(Ip4Address.valueOf("1.1.1.1"));
103 assertThat(deviceInformation.areaId(), is(Ip4Address.valueOf("1.1.1.1")));
104 }
105
106 /**
107 * Tests areaId() setter method.
108 */
109 @Test
110 public void testSetAreaId() throws Exception {
111 deviceInformation.setAreaId(Ip4Address.valueOf("1.1.1.1"));
112 assertThat(deviceInformation.areaId(), is(Ip4Address.valueOf("1.1.1.1")));
113 }
114
115 /**
116 * Tests isAlreadyCreated() getter method.
117 */
118 @Test
119 public void testIsAlreadyCreated() throws Exception {
120 deviceInformation.setAlreadyCreated(true);
121 assertThat(deviceInformation.isAlreadyCreated(), is(true));
122 }
123
124 /**
125 * Tests isAlreadyCreated() setter method.
126 */
127 @Test
128 public void testSetAlreadyCreated() throws Exception {
129 deviceInformation.setAlreadyCreated(true);
130 assertThat(deviceInformation.isAlreadyCreated(), is(true));
131 }
132
133 /**
134 * Tests isDr() getter method.
135 */
136 @Test
137 public void testIsDr() throws Exception {
138 deviceInformation.setDr(true);
139 assertThat(deviceInformation.isDr(), is(true));
140 }
141
142 /**
143 * Tests isDr() setter method.
144 */
145 @Test
146 public void testSetDr() throws Exception {
147 deviceInformation.setDr(true);
148 assertThat(deviceInformation.isDr(), is(true));
149 }
150
151 /**
152 * Tests neighborId() getter method.
153 */
154 @Test
155 public void testNeighborId() throws Exception {
156 deviceInformation.setNeighborId(Ip4Address.valueOf("1.1.1.1"));
157 assertThat(deviceInformation.neighborId(), is(Ip4Address.valueOf("1.1.1.1")));
158 }
159
160 /**
161 * Tests neighborId() setter method.
162 */
163 @Test
164 public void testSetNeighborId() throws Exception {
165 deviceInformation.setNeighborId(Ip4Address.valueOf("1.1.1.1"));
166 assertThat(deviceInformation.neighborId(), is(Ip4Address.valueOf("1.1.1.1")));
167 }
168}