2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.aai.util;
23 import java.time.zone.ZoneRulesException;
25 import org.junit.Assert;
26 import org.junit.Ignore;
27 import org.junit.Test;
30 public class FormatDateTest {
32 @Test(expected = IllegalArgumentException.class)
33 public void testExceptionThrownWhenInvalidPatternIsPassed() {
34 FormatDate formatDate = new FormatDate("XX/TT/GGGG");
35 formatDate.getDateTime();
39 public void correctPattern() {
40 FormatDate formatDate = new FormatDate("dd/mm/yyyy");
41 Assert.assertNotNull(formatDate.getDateTime());
44 @Test(expected = IllegalArgumentException.class)
45 public void invalidPattern() {
46 FormatDate formatDate = new FormatDate("XX/TT/GGGG", "GMT");
47 formatDate.getDateTime();
50 @Test(expected = ZoneRulesException.class)
51 public void invalidZone() {
52 FormatDate formatDate = new FormatDate("dd/mm/yyyy", "IST");
53 formatDate.getDateTime();
56 @Test(expected = IllegalArgumentException.class)
57 public void testExceptionThrownWhenInvalidPatternAndZoneIsPassed() {
58 FormatDate formatDate = new FormatDate("XX/TT/GGGG", "IST");
59 formatDate.getDateTime();
63 public void correctPatternAndZone() {
64 FormatDate formatDate = new FormatDate("dd/mm/yyyy", "GMT");
65 Assert.assertNotNull(formatDate.getDateTime());