ar.com.zauber.commons.date.SignificantDateProviderTest.java Source code

Java tutorial

Introduction

Here is the source code for ar.com.zauber.commons.date.SignificantDateProviderTest.java

Source

/**
 * Copyright (c) 2005-2012 Zauber S.A. <http://www.zaubersoftware.com/>
 *
 * 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 ar.com.zauber.commons.date;

import java.util.Calendar;
import java.util.Date;

import junit.framework.Assert;

import org.apache.commons.lang.time.DateUtils;
import org.junit.Test;

import ar.com.zauber.commons.date.impl.InmutableDateProvider;
import ar.com.zauber.commons.date.impl.SignificantDateProvider;

/**
 * Pruebas sobre {@link SignificantDateProvider}
 * 
 * @author Pablo Grigolatto
 * @since Mar 19, 2010
 */
public class SignificantDateProviderTest {
    private DateProvider target = new InmutableDateProvider(new Date(1269028059L * 1000));

    /** dia del mes */
    @Test
    public final void testDay() {
        final DateProvider provider = new SignificantDateProvider(target, Calendar.DAY_OF_MONTH);
        Assert.assertEquals(DateUtils.truncate(new Date(1269028059L * 1000), Calendar.DAY_OF_MONTH),
                provider.getDate());
    }

    /** hora del dia */
    @Test
    public final void testHour() {
        final DateProvider provider = new SignificantDateProvider(target, Calendar.HOUR_OF_DAY);
        Assert.assertEquals(DateUtils.truncate(new Date(1269028059L * 1000), Calendar.HOUR_OF_DAY),
                provider.getDate());
    }

}