blob: 25480d9f485e2d2e9e601f9319efd0bc2ad16f91 [file] [log] [blame]
Simon Hunt9ffbd8d2015-05-06 12:02:32 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Hunt9ffbd8d2015-05-06 12:02:32 -07003 *
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.
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070015 */
16
17package org.onosproject.ui.table;
18
19import com.fasterxml.jackson.databind.node.ArrayNode;
20import org.junit.Assert;
21import org.junit.Test;
22
23/**
24 * Unit tests for {@link TableUtils}.
25 */
26public class TableUtilsTest {
27
28 private static final String FOO = "foo";
29 private static final String BAR = "bar";
30
31 private static final String ARRAY_AS_STRING =
32 "[{\"foo\":\"1\",\"bar\":\"2\"},{\"foo\":\"3\",\"bar\":\"4\"}]";
33
34 @Test
35 public void basic() {
36 TableModel tm = new TableModel(FOO, BAR);
37 tm.addRow().cell(FOO, 1).cell(BAR, 2);
38 tm.addRow().cell(FOO, 3).cell(BAR, 4);
39
Jian Li69f66632016-01-15 12:27:42 -080040 ArrayNode array = TableUtils.generateRowArrayNode(tm);
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070041 Assert.assertEquals("wrong results", ARRAY_AS_STRING, array.toString());
42 }
43
44}