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