blob: 26c49b5bfa6cb29c39d98d7fade334198ff5e6d5 [file] [log] [blame]
Simon Hunt9ffbd8d2015-05-06 12:02:32 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Hunt9ffbd8d2015-05-06 12:02:32 -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.
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070015 */
16
17package org.onosproject.ui.table.cell;
18
19import org.joda.time.DateTime;
Simon Hunt5939e652015-05-06 16:20:23 -070020import org.joda.time.DateTimeZone;
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070021import org.junit.Test;
22import org.onosproject.ui.table.CellFormatter;
23
Simon Hunt5939e652015-05-06 16:20:23 -070024import java.util.Locale;
25
Jon Halldf6a6e42015-08-25 16:22:41 -070026import static org.junit.Assert.assertTrue;
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070027
28/**
29 * Unit tests for {@link TimeFormatter}.
30 */
31public class TimeFormatterTest {
32
Simon Hunt5939e652015-05-06 16:20:23 -070033 private static final Locale LOCALE = Locale.ENGLISH;
34 private static final DateTimeZone ZONE = DateTimeZone.UTC;
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070035
Simon Hunt5939e652015-05-06 16:20:23 -070036 private static final DateTime TIME = new DateTime(2015, 5, 4, 15, 30, ZONE);
Jon Halldf6a6e42015-08-25 16:22:41 -070037 private static final String EXP_ZONE_NAME = "3:30:00 PM UTC";
38 private static final String EXP_ZONE_OFFSET = "3:30:00 PM +00:00";
Simon Hunt5939e652015-05-06 16:20:23 -070039
40 // Have to use explicit Locale and TimeZone for the unit test, so that
41 // irrespective of which locale and time zone the test is run in, it
42 // always produces the same result...
43 private CellFormatter fmt =
44 new TimeFormatter().withLocale(LOCALE).withZone(ZONE);
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070045
46 @Test
47 public void basic() {
Jon Halldf6a6e42015-08-25 16:22:41 -070048 assertTrue("wrong format", (EXP_ZONE_NAME.equals(fmt.format(TIME)) ||
49 EXP_ZONE_OFFSET.equals(fmt.format(TIME))));
Simon Hunt9ffbd8d2015-05-06 12:02:32 -070050 }
51}