0

public class EventMapper implements RowMapper {

@Override
public EventData mapRow(ResultSet rs, int arg1) throws SQLException {
    EventData eventData = new EventData();
    eventData.setResourceId(rs.getLong(RESOURCEID));
    DateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
    eventData.setrecordDate(df.format(rs.getDate(RECORDDATE)));
    return eventData;

}

Below is my test class

@Test
public void mapRowTest() throws SQLException {
  ResultSet resultSet = mock(ResultSet.class);
  Mockito.when(resultSet.getLong(RESOURCEID)).thenReturn(12345L);
  DateFormat df = new SimpleDateFormat("2017-08-19 12:20:55");
  Mockito.when((df.format(resultSet.getDate(RECORDDATE)))).thenReturn("2017-08-19 
  12:20:55");

eventMapper.mapRow(resultSet, 1); }

nandini
  • 57
  • 6

0 Answers0