blob: b1f48ebf8dc4d8de365a0074dc1bae190775eb54 [file] [log] [blame]
Bri Prebilic Cole9467a232015-05-06 16:59:05 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Bri Prebilic Cole9467a232015-05-06 16:59:05 -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.
15 */
16
17package org.onosproject.ui.table.cell;
18
19import org.junit.Test;
20import org.onosproject.ui.table.CellFormatter;
21
22import static org.junit.Assert.assertEquals;
23
24/**
25 * Unit tests for {@link EnumFormatter}.
26 */
27public class EnumFormatterTest {
28
29 enum TestEnum {
30 ADDED,
31 PENDING_ADD,
32 WAITING_AUDIT_COMPLETE
33 }
34
35 private CellFormatter fmt = EnumFormatter.INSTANCE;
36
37 @Test
38 public void nullValue() {
39 assertEquals("null value", "", fmt.format(null));
40 }
41
42 @Test
43 public void noUnderscores() {
44 assertEquals("All caps", "Added", fmt.format(TestEnum.ADDED));
45 }
46
47 @Test
48 public void underscores() {
49 assertEquals("All caps with underscores",
50 "Pending Add", fmt.format(TestEnum.PENDING_ADD));
51 }
52
53 @Test
54 public void multiUnderscores() {
55 assertEquals("All caps with underscores",
56 "Waiting Audit Complete",
57 fmt.format(TestEnum.WAITING_AUDIT_COMPLETE));
58 }
59
60}