Package dbfit.environment

Source Code of dbfit.environment.OracleDateNormaliserTest

package dbfit.environment;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.sql.SQLException;
import java.sql.Timestamp;

import oracle.sql.DATE;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class OracleDateNormaliserTest {

    @Rule
    public ExpectedException expectedEx = ExpectedException.none();

    @Test
    public void shouldReturnNullIfGivenNull() throws SQLException {
        assertNull(new OracleDateNormaliser().normalise(null));
    }

    @Test
    public void shouldThrowCorrectExceptionIfNotGivenAnOracleDATE() throws SQLException {
        expectedEx.expect(UnsupportedOperationException.class);
        expectedEx.expectMessage("OracleDateNormaliser cannot work with class java.lang.String");
        new OracleDateNormaliser().normalise("Any Old Object");
    }

    @Test
    public void shouldReturnContentsOfDateIfAllOkay() throws SQLException {
        DATE dt = mock(DATE.class);
        when(dt.timestampValue()).thenReturn(new Timestamp(0l));
        assertEquals(new Timestamp(0l), new OracleDateNormaliser().normalise(dt));
    }

}
TOP

Related Classes of dbfit.environment.OracleDateNormaliserTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.