blob: a5396605f564d0c8c6c33df520bdb05a3cbff861 [file] [log] [blame]
chidambar babu344dc812016-05-02 19:13:10 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
chidambar babu344dc812016-05-02 19:13:10 +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 */
16
17package org.onosproject.isis.controller.impl;
18
sunish vk4b5ce002016-05-09 20:18:35 +053019import com.fasterxml.jackson.databind.JsonNode;
20import com.fasterxml.jackson.databind.ObjectMapper;
chidambar babu344dc812016-05-02 19:13:10 +053021import org.junit.After;
22import org.junit.Before;
23import org.junit.Test;
24
25import static org.hamcrest.CoreMatchers.is;
26import static org.hamcrest.CoreMatchers.notNullValue;
27import static org.junit.Assert.assertThat;
28
29/**
30 * Unit test class for ControllerTest.
31 */
32public class ControllerTest {
33
34 private Controller controller;
sunish vk4b5ce002016-05-09 20:18:35 +053035 private ObjectMapper mapper;
36 private JsonNode jsonNode;
37 private JsonNode jsonNode1;
38 private String jsonString = "{" +
39 " \"processes\": [{" +
40 " \"processId\": \"4.4.4.4\"," +
41 " \"interface\": [{" +
42 " \"interfaceIndex\": \"2\"," +
43 " \"macAddress\": \"08:00:27:b7:ab:bf\"," +
44 " \"interfaceIp\": \"192.168.56.101\"," +
45 " \"networkMask\": \"255.255.255.224\"," +
46 " \"intermediateSystemName\": \"ROUTERONE\"," +
47 " \"systemId\": \"2929.2929.2929\"," +
48 " \"lanId\": \"0000.0000.0000.00\"," +
49 " \"idLength\": \"0\"," +
50 " \"maxAreaAddresses\": \"3\"," +
51 " \"reservedPacketCircuitType\": \"1\"," +
52 " \"circuitId\": \"10\"," +
53 " \"networkType\": \"2\"," +
54 " \"areaAddress\": \"490000\"," +
55 " \"areaLength\": \"3\"," +
56 " \"lspId\": \"1313131313130000\"," +
57 " \"holdingTime\": \"50\"," +
58 " \"helloInterval\": \"10\"," +
59 " \"priority\": \"0\"" +
60 " }]" +
61 " }]" +
62 "}";
63 private String jsonString1 = "{" +
64 " \"processes\": {" +
65 " \"interface\": [{" +
66 " \"interfaceIndex\": \"2\"," +
67 " \"interfaceIp\": \"100.100.100.100\"," +
68 " \"macAddress\": \"08:00:27:b7:ab:bf\"," +
69 " \"networkMask\": \"255.255.255.224\"," +
70 " \"intermediateSystemName\": \"ROUTERONE\"," +
71 " \"systemId\": \"2929.2929.2929\"," +
72 " \"lanId\": \"0000.0000.0000.00\"," +
73 " \"idLength\": \"0\"," +
74 " \"maxAreaAddresses\": \"3\"," +
75 " \"reservedPacketCircuitType\": \"1\"," +
76 " \"circuitId\": \"10\"," +
77 " \"networkType\": \"2\"," +
78 " \"areaAddress\": \"490000\"," +
79 " \"areaLength\": \"3\"," +
80 " \"lspId\": \"1313131313130000\"," +
81 " \"holdingTime\": \"50\"," +
82 " \"helloInterval\": \"10\"," +
83 " \"priority\": \"0\"" +
84 " }]" +
85 " }" +
86 "}";
chidambar babu344dc812016-05-02 19:13:10 +053087
88 @Before
89 public void setUp() throws Exception {
90 controller = new Controller();
sunish vk4b5ce002016-05-09 20:18:35 +053091 mapper = new ObjectMapper();
92 jsonNode = mapper.readTree(jsonString);
93 jsonNode1 = mapper.readTree(jsonString1);
chidambar babu344dc812016-05-02 19:13:10 +053094 }
95
96 @After
97 public void tearDown() throws Exception {
98 controller = null;
99 }
100
101 /**
102 * Tests isisDeactivate() method.
103 */
Ray Milkey11ce9302019-02-07 14:41:17 -0800104 @Test
chidambar babu344dc812016-05-02 19:13:10 +0530105 public void testIsisDeactivate() throws Exception {
106 controller.isisDeactivate();
107 assertThat(controller, is(notNullValue()));
108 }
109
110 /**
111 * Tests getAllConfiguredProcesses() method.
112 */
113 @Test
114 public void testGetAllConfiguredProcesses() throws Exception {
115 controller.getAllConfiguredProcesses();
116 assertThat(controller, is(notNullValue()));
117 }
sunish vk4b5ce002016-05-09 20:18:35 +0530118
119 /**
120 * Tests updateConfig() method.
121 */
122 @Test
123 public void testUpdateConfig() throws Exception {
124 jsonNode.path("interface");
125 controller.updateConfig(jsonNode);
126 assertThat(controller, is(notNullValue()));
127
128 controller.updateConfig(jsonNode1);
129 assertThat(controller, is(notNullValue()));
130 }
131
chidambar babu344dc812016-05-02 19:13:10 +0530132}