blob: 13059d60f90d26e71b9b8efc0c16e65b4c5588e4 [file] [log] [blame]
Jian Li15468822016-04-15 16:28:11 -07001/*
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.ui.chart;
17
18import com.fasterxml.jackson.databind.node.ArrayNode;
19import org.junit.Assert;
20import org.junit.Test;
21
22/**
23 * Unit tests for {@link ChartUtils}.
24 */
25public class ChartUtilsTest {
26
27 private static final String FOO = "foo";
28 private static final String BAR = "bar";
29
30 private static final String ARRAY_AS_STRING =
31 "[{\"foo\":1.0,\"bar\":2.0},{\"foo\":3.0,\"bar\":4.0}]";
32
33 @Test
34 public void basic() {
35 ChartModel cm = new ChartModel(FOO, BAR);
36 cm.addDataPoint(1L).data(FOO, 1D).data(BAR, 2D);
37 cm.addDataPoint(2L).data(FOO, 3D).data(BAR, 4D);
38
39 ArrayNode array = ChartUtils.generateDataPointArrayNode(cm);
40 Assert.assertEquals("wrong results", ARRAY_AS_STRING, array.toString());
41 }
42}