I know it is not a good thing write a unit test for mapper or get set but, it is what it is, so I am stucked how to do unit test for mappers;
StudentGroupList below;
@Getter
@Setter
public class StudentGroupList {
private String studentId;
}
StudentGroupListRowMapper below;
public class StudentGroupListRowMapper implements RowMapper<StudentGroupList> {
@Override
public StudentGroupList mapRow(Resultset rs, int rowNum) throws SQLException {
StudentGroupList studentGroupList = new StudentGroupList();
studentGroupList.setStudentId(rs.getString("student_id"));
return studentGroupList;
}
}
I have tried below, but jococo coverage test did not coverage anything
public class TaskGroupListRowMapperTest {
private ResultSet resultSet;
private StudentGroupList studentGroupList;
@Before
public void setUp() {
resultSet = mock(ResultSet.class);
studentGroupList = mock(StudentGroupList.class);
}
@Test
public void testStudentGroupListMapper() throws SQLException {
when(resultSet.getString("student_id"))
.thenReturn(studentGroupList.getStudentID());
assertTrue(studentGroupList.getStudentId(), true);
}
}
İt says exception; thenReturn() may be missing.