blob: 6351a1f4e912fd9ef86f2163c3423d7e59e8b67d [file] [log] [blame]
Simon Hunte9828152015-05-01 17:54:25 -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
Simon Hunt3ee7f742015-05-05 10:18:20 -070018package org.onosproject.ui.table.cell;
Simon Hunte9828152015-05-01 17:54:25 -070019
20import org.junit.Test;
Simon Hunt3ee7f742015-05-05 10:18:20 -070021import org.onosproject.ui.table.CellFormatter;
Simon Hunte9828152015-05-01 17:54:25 -070022
23import static org.junit.Assert.assertEquals;
24
25/**
26 * Unit tests for {@link DefaultCellFormatter}.
27 */
28public class DefaultCellFormatterTest {
29
30 private static final String UNEX = "Unexpected result";
31 private static final String SOME_STRING = "SoMeStRiNg";
32
33 private static class TestClass {
34 @Override
35 public String toString() {
36 return SOME_STRING;
37 }
38 }
39
Simon Hunt3d1b0652015-05-05 17:27:24 -070040 private CellFormatter fmt = DefaultCellFormatter.INSTANCE;
Simon Hunte9828152015-05-01 17:54:25 -070041
42 @Test
43 public void formatNull() {
44 assertEquals(UNEX, "", fmt.format(null));
45 }
46
47 @Test
48 public void formatInteger() {
49 assertEquals(UNEX, "3", fmt.format(3));
50 }
51
52 @Test
53 public void formatTrue() {
54 assertEquals(UNEX, "true", fmt.format(true));
55 }
56
57 @Test
58 public void formatFalse() {
59 assertEquals(UNEX, "false", fmt.format(false));
60 }
61
62 @Test
63 public void formatString() {
64 assertEquals(UNEX, "FOO", fmt.format("FOO"));
65 }
66
67 @Test
68 public void formatObject() {
69 assertEquals(UNEX, SOME_STRING, fmt.format(new TestClass()));
70 }
71}