/*
 * Copyright (C) 2008 feilong
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.feilong.core.date.dateextensionutiltest;

import static org.junit.Assert.assertEquals;

import java.util.Date;

import org.junit.Test;

import static com.feilong.core.date.DateExtensionUtil.formatDuration;
import static com.feilong.core.date.DateUtil.toDate;

import static com.feilong.core.DatePattern.COMMON_DATE_AND_TIME;

/**
 * The Class DateExtensionUtilTest.
 *
 * @author <a href="http://feitianbenyue.iteye.com/">feilong</a>
 * @since 1.0.8
 */
public class FormatDurationTest{

    /**
     * Test get interval for view long.
     */
    @Test
    public void testFormatDurationLong(){
        assertEquals("25秒841毫秒", formatDuration(25841));
    }

    /**
     * Test format duration 1.
     */
    //**************com.feilong.core.date.DateExtensionUtil.formatDuration(Date)*****************
    @Test
    public void testFormatDuration1(){
        Date date = toDate("2016-07-03 00:00:00", COMMON_DATE_AND_TIME);
        formatDuration(date);
    }

    /**
     * Test format duration 2.
     */
    @Test(expected = NullPointerException.class)
    public void testFormatDuration2(){
        formatDuration(null);
    }

    //***************com.feilong.core.date.DateExtensionUtil.formatDuration(Date, Date)*****************

    /**
     * Test format duration 23.
     */
    @Test(expected = NullPointerException.class)
    public void testFormatDuration23(){
        formatDuration(null, null);
    }

    /**
     * Test format duration 233.
     */
    @Test(expected = NullPointerException.class)
    public void testFormatDuration233(){
        formatDuration(new Date(), null);
    }

    /**
     * Test format duration 2333.
     */
    @Test(expected = NullPointerException.class)
    public void testFormatDuration2333(){
        formatDuration(null, new Date());
    }

    /**
     * Test format duration 3.
     */
    //***************com.feilong.core.date.DateExtensionUtil.formatDuration(long)****************
    @Test(expected = IllegalArgumentException.class)
    public void testFormatDuration3(){
        formatDuration(-1);
    }

    /**
     * Test format duration zero.
     */
    @Test
    public void testFormatDuration_zero(){
        assertEquals("0", formatDuration(0));
    }
}
@@ -664,87 +664,114 @@
 tic 
-org.junit.Assert.assertEquals;%0A%0Aimport java.util.Date;%0A%0Aimport org.junit.Test;%0A
+com.feilong.core.DatePattern.COMMON_DATE_AND_TIME;%0Aimport static com.feilong.core.bean.ConvertUtil.toLong;
 %0Aimp
@@ -890,17 +890,16 @@
 toDate;%0A
-%0A
 import s
@@ -908,57 +908,124 @@
 tic 
-com.feilong.core.DatePattern.COMMON_DATE_AND_TIME
+org.junit.Assert.assertEquals;%0A%0Aimport java.util.Date;%0A%0Aimport org.junit.Test;%0A%0Aimport com.feilong.core.TimeInterval
 ;%0A%0A/
@@ -1349,32 +1349,184 @@
 25841));%0A    %7D%0A%0A
+    @Test%0A    public void testFormatDurationLong1()%7B%0A        assertEquals(%22365%E5%A4%A9%22, formatDuration(toLong(TimeInterval.SECONDS_PER_YEAR) * 1000));%0A    %7D%0A%0A
     /**%0A     * T

update test