すべてが単純なプロパティ マッピングを行うわけではないため、JDBI マッパー クラスを単体テストしたいと考えています。
私のテストクラスは次のようになります。
public class IdentRuleMapperTest {
@Mock
ResultSet resultSet;
@Mock
ResultSetMetaData resultSetMetaData;
@Mock
StatementContext ctx;
IdentRuleMapper mapper;
@Before
public void setup() {
mapper = new IdentRuleMapper();
}
@Test
public void mapTest() throws SQLException {
Mockito.when(resultSet.getString("ID")).thenReturn("The ID");
Mockito.when(resultSet.getString("NAME")).thenReturn("The name");
Mockito.when(resultSet.getString("REGULATION")).thenReturn("CRS");
Mockito.when(resultSet.getString("JSON_ACTIONS_STRING")).thenReturn("the json string");
IdentRule identRule = mapper.map(0, resultSet, ctx);
}
}
テストは回線に NPE をスローします
Mockito.when(resultSet.getString("ID")).thenReturn("The ID");
なぜこれがうまくいかないのか、誰でも私に指摘できますか?