2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org.onosproject.ui.table.cell;
20 import org.junit.Test;
21 import org.onosproject.ui.table.CellFormatter;
23 import static org.junit.Assert.assertEquals;
26 * Unit tests for {@link DefaultCellFormatter}.
28 public class DefaultCellFormatterTest {
30 private static final String UNEX = "Unexpected result";
31 private static final String SOME_STRING = "SoMeStRiNg";
33 private static class TestClass {
35 public String toString() {
40 private CellFormatter fmt = DefaultCellFormatter.INSTANCE;
43 public void formatNull() {
44 assertEquals(UNEX, "", fmt.format(null));
48 public void formatInteger() {
49 assertEquals(UNEX, "3", fmt.format(3));
53 public void formatTrue() {
54 assertEquals(UNEX, "true", fmt.format(true));
58 public void formatFalse() {
59 assertEquals(UNEX, "false", fmt.format(false));
63 public void formatString() {
64 assertEquals(UNEX, "FOO", fmt.format("FOO"));
68 public void formatObject() {
69 assertEquals(UNEX, SOME_STRING, fmt.format(new TestClass()));