blob: d578e24d55c0b474cf27f19f8aded38f4ee34e50 [file] [log] [blame]
sunishvkf7c56552016-07-18 16:02:39 +05301/*
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.ospf.controller.impl;
17
18import com.fasterxml.jackson.databind.JsonNode;
19import com.fasterxml.jackson.databind.ObjectMapper;
20import org.junit.After;
21import org.junit.Before;
22import org.junit.Test;
23import org.onosproject.ospf.controller.OspfProcess;
24
25import java.util.ArrayList;
26import java.util.List;
27
28import static org.hamcrest.CoreMatchers.is;
29import static org.hamcrest.CoreMatchers.notNullValue;
30import static org.hamcrest.MatcherAssert.assertThat;
31
32/**
33 * Unit test class for OspfJsonParsingUtilTest.
34 */
35public class OspfConfigUtilTest {
36 private ObjectMapper mapper;
37 private JsonNode jsonNode;
38 private List<OspfProcess> ospfProcessList = new ArrayList<>();
39 private String jsonString = "{\n" +
40 "\t\"processes\": {\n" +
41 "\t\t\"areas\": [{\n" +
42 "\t\t\t\"interface\": [{\n" +
43 "\t\t\t\t\"interfaceIndex\": \"2\",\n" +
44 "\n" +
45 "\t\t\t\t\"helloIntervalTime\": \"10\",\n" +
46 "\n" +
47 "\t\t\t\t\"routerDeadIntervalTime\": \"40\",\n" +
48 "\n" +
49 "\t\t\t\t\"interfaceType\": \"2\",\n" +
50 "\n" +
51 "\t\t\t\t\"reTransmitInterval\": \"5\"\n" +
52 "\t\t\t}],\n" +
53 "\t\t\t\"areaId\": \"5.5.5.5\",\n" +
54 "\n" +
55 "\t\t\t\"routerId\": \"7.7.7.7\",\n" +
56 "\n" +
57 "\t\t\t\"isOpaqueEnable\": \"false\",\n" +
58 "\n" +
59 "\t\t\t\"externalRoutingCapability\": \"true\"\n" +
60 "\t\t}]\n" +
61 "\t}\n" +
62 "}";
63
64 @Before
65 public void setUp() throws Exception {
66 mapper = new ObjectMapper();
67 jsonNode = mapper.readTree(jsonString);
68 mapper = new ObjectMapper();
69 }
70
71 @After
72 public void tearDown() throws Exception {
73
74 }
75
76 @Test
77 public void testProcesses() throws Exception {
78 jsonNode.path("areas");
79 ospfProcessList = OspfConfigUtil.processes(jsonNode);
80 assertThat(ospfProcessList, is(notNullValue()));
81 }
82}