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