Search in sources :

Example 1 with BuildStateTypeHandlerCallback

use of com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback in project gocd by gocd.

the class BuildStateTypeHandlerCallbackTest method shouldReturnScheduledWhenGivenStringScheduled.

@Test
public void shouldReturnScheduledWhenGivenStringScheduled() throws SQLException {
    context.checking(new Expectations() {

        {
            one(resultGetter).getString();
            will(returnValue(JobState.Scheduled.toString()));
        }
    });
    BuildStateTypeHandlerCallback callback = new BuildStateTypeHandlerCallback();
    JobState result = (JobState) callback.getResult(resultGetter);
    assertThat(result, is(equal(JobState.Scheduled)));
}
Also used : Expectations(org.jmock.Expectations) JobState(com.thoughtworks.go.domain.JobState) BuildStateTypeHandlerCallback(com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback) Test(org.junit.Test)

Example 2 with BuildStateTypeHandlerCallback

use of com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback in project gocd by gocd.

the class BuildStateTypeHandlerCallbackTest method shouldReturnStateWithStringColumnName.

@Test
public void shouldReturnStateWithStringColumnName() throws SQLException {
    ResultSet rs = mock(ResultSet.class);
    when(rs.getString("foo")).thenReturn(JobState.Scheduled.toString());
    BuildStateTypeHandlerCallback callback = new BuildStateTypeHandlerCallback(JobState.class);
    JobState result = callback.getResult(rs, "foo");
    assertThat(result, is(JobState.Scheduled));
}
Also used : ResultSet(java.sql.ResultSet) JobState(com.thoughtworks.go.domain.JobState) BuildStateTypeHandlerCallback(com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback) Test(org.junit.jupiter.api.Test)

Example 3 with BuildStateTypeHandlerCallback

use of com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback in project gocd by gocd.

the class BuildStateTypeHandlerCallbackTest method shouldReturnStateWithIntegerColumnNameAndCallableStatement.

@Test
public void shouldReturnStateWithIntegerColumnNameAndCallableStatement() throws SQLException {
    CallableStatement rs = mock(CallableStatement.class);
    when(rs.getString(42)).thenReturn(JobState.Scheduled.toString());
    BuildStateTypeHandlerCallback callback = new BuildStateTypeHandlerCallback(JobState.class);
    JobState result = callback.getResult(rs, 42);
    assertThat(result, is(JobState.Scheduled));
}
Also used : CallableStatement(java.sql.CallableStatement) JobState(com.thoughtworks.go.domain.JobState) BuildStateTypeHandlerCallback(com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback) Test(org.junit.jupiter.api.Test)

Example 4 with BuildStateTypeHandlerCallback

use of com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback in project gocd by gocd.

the class BuildStateTypeHandlerCallbackTest method shouldReturnScheduledStringWhenGivenScheduled.

@Test
public void shouldReturnScheduledStringWhenGivenScheduled() throws SQLException {
    final ParameterSetter parameterSetter = context.mock(ParameterSetter.class);
    context.checking(new Expectations() {

        {
            one(parameterSetter).setString(JobState.Scheduled.toString());
        }
    });
    BuildStateTypeHandlerCallback callback = new BuildStateTypeHandlerCallback();
    callback.setParameter(parameterSetter, JobState.Scheduled);
}
Also used : Expectations(org.jmock.Expectations) ParameterSetter(com.ibatis.sqlmap.client.extensions.ParameterSetter) BuildStateTypeHandlerCallback(com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback) Test(org.junit.Test)

Example 5 with BuildStateTypeHandlerCallback

use of com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback in project gocd by gocd.

the class BuildStateTypeHandlerCallbackTest method shouldReturnStateWithIntegerColumnName.

@Test
public void shouldReturnStateWithIntegerColumnName() throws SQLException {
    ResultSet rs = mock(ResultSet.class);
    when(rs.getString(42)).thenReturn(JobState.Scheduled.toString());
    BuildStateTypeHandlerCallback callback = new BuildStateTypeHandlerCallback(JobState.class);
    JobState result = callback.getResult(rs, 42);
    assertThat(result, is(JobState.Scheduled));
}
Also used : ResultSet(java.sql.ResultSet) JobState(com.thoughtworks.go.domain.JobState) BuildStateTypeHandlerCallback(com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback) Test(org.junit.jupiter.api.Test)

Aggregations

BuildStateTypeHandlerCallback (com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback)6 JobState (com.thoughtworks.go.domain.JobState)4 Test (org.junit.jupiter.api.Test)4 ResultSet (java.sql.ResultSet)2 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 ParameterSetter (com.ibatis.sqlmap.client.extensions.ParameterSetter)1 CallableStatement (java.sql.CallableStatement)1 PreparedStatement (java.sql.PreparedStatement)1