Search in sources :

Example 6 with JobState

use of com.thoughtworks.go.domain.JobState 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 7 with JobState

use of com.thoughtworks.go.domain.JobState in project gocd by gocd.

the class BuildStateTypeHandlerCallback method setParameter.

public void setParameter(ParameterSetter parameterSetter, Object parameter) throws SQLException {
    JobState state = (JobState) parameter;
    parameterSetter.setString(state.toString());
}
Also used : JobState(com.thoughtworks.go.domain.JobState)

Example 8 with JobState

use of com.thoughtworks.go.domain.JobState 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

JobState (com.thoughtworks.go.domain.JobState)8 BuildStateTypeHandlerCallback (com.thoughtworks.go.server.dao.handlers.BuildStateTypeHandlerCallback)4 Test (org.junit.jupiter.api.Test)4 ResultSet (java.sql.ResultSet)2 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 JobInstance (com.thoughtworks.go.domain.JobInstance)1 NullJobInstance (com.thoughtworks.go.domain.NullJobInstance)1 JobStatusMessage (com.thoughtworks.go.server.messaging.JobStatusMessage)1 CallableStatement (java.sql.CallableStatement)1