|
|
@@ -20,6 +20,7 @@ import java.time.LocalDate;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import com.malk.minglei.dto.EmployeeRosterInfo;
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
@@ -116,6 +117,33 @@ class EmployeeRosterRepositoryTest {
|
|
|
assertTrue(sqlCaptor.getValue().contains("bank_branch_code"));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ @SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
+ void mapsBankCardNumberAndBankNameForRosterQuery() throws Exception {
|
|
|
+ JdbcTemplate jdbcTemplate = mock(JdbcTemplate.class);
|
|
|
+ ObjectProvider<JdbcTemplate> jdbcTemplateProvider = mock(ObjectProvider.class);
|
|
|
+ given(jdbcTemplateProvider.getIfAvailable()).willReturn(jdbcTemplate);
|
|
|
+ given(jdbcTemplate.query(any(String.class), any(PreparedStatementSetter.class), any(RowMapper.class)))
|
|
|
+ .willReturn(Collections.emptyList());
|
|
|
+ EmployeeRosterRepository repository = new EmployeeRosterRepository(
|
|
|
+ jdbcTemplateProvider,
|
|
|
+ new EmployeeRosterProperties());
|
|
|
+
|
|
|
+ repository.findByEmployeeNo("1001");
|
|
|
+
|
|
|
+ ArgumentCaptor<RowMapper> rowMapperCaptor = ArgumentCaptor.forClass(RowMapper.class);
|
|
|
+ verify(jdbcTemplate).query(any(String.class), any(PreparedStatementSetter.class), rowMapperCaptor.capture());
|
|
|
+ ResultSet resultSet = mock(ResultSet.class);
|
|
|
+ given(resultSet.getInt("id")).willReturn(1);
|
|
|
+ given(resultSet.getString("bank_card_no")).willReturn("6222000000000000");
|
|
|
+ given(resultSet.getString("bank_name")).willReturn("示例银行");
|
|
|
+
|
|
|
+ EmployeeRosterInfo result = (EmployeeRosterInfo) rowMapperCaptor.getValue().mapRow(resultSet, 0);
|
|
|
+
|
|
|
+ assertEquals("6222000000000000", result.getBankCardNo());
|
|
|
+ assertEquals("示例银行", result.getBankName());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
void findByUsernameFiltersResignedEmployees() {
|