@Test public void test_should_map_result_set_to_entity() throws Exception { Mockito.when(rs.next()).thenReturn(true).thenReturn(false); when(rs.getLong("ut_id")).thenReturn(1L); when(rs.getString("ut_code")).thenReturn("1"); when((Boolean) rs.getObject("ut_active")).thenReturn(true); when(rs.getString("ut_description")).thenReturn("Water required for school"); when(rs.getString("ut_name")).thenReturn("School"); when(rs.getString("ut_parent")).thenReturn(null); when(rs.getString("ut_tenantid")).thenReturn("default"); when((Long) rs.getObject("ut_createdby")).thenReturn(1L); when((Long) rs.getObject("ut_createddate")).thenReturn(142356778L); when((Long) rs.getObject("ut_lastmodifiedby")).thenReturn(1L); when((Long) rs.getObject("ut_lastmodifieddate")).thenReturn(142356778L); final UsageType expectedUsgType = getUsageType(); final UsageType actualUsgType = usageTypeRowMapper.mapRow(rs, 1); assertTrue(expectedUsgType.equals(actualUsgType)); }
@Override public UsageType mapRow(final ResultSet rs, final int rowNum) throws SQLException { final UsageType usageType = new UsageType(); usageType.setId(rs.getLong("ut_id")); usageType.setCode(rs.getString("ut_code")); usageType.setActive((Boolean) rs.getObject("ut_active")); usageType.setDescription(rs.getString("ut_description")); usageType.setName(rs.getString("ut_name")); usageType.setParent(rs.getString("ut_parent")); usageType.setTenantId(rs.getString("ut_tenantid")); usageType.setCreatedBy((Long) rs.getObject("ut_createdby")); usageType.setCreatedDate((Long) rs.getObject("ut_createddate")); usageType.setLastModifiedBy((Long) rs.getObject("ut_lastmodifiedby")); usageType.setLastModifiedDate((Long) rs.getObject("ut_lastmodifieddate")); return usageType; }
UsageTypeRowMapper implements RowMapper<UsageType> { @Override public UsageType mapRow(final ResultSet rs, final int rowNum) throws SQLException { final UsageType usageType = new UsageType(); usageType.setId(rs.getLong("ut_id")); usageType.setCode(rs.getString("ut_code")); usageType.setActive((Boolean) rs.getObject("ut_active")); usageType.setDescription(rs.getString("ut_description")); usageType.setName(rs.getString("ut_name")); usageType.setParent(rs.getString("ut_parent")); usageType.setTenantId(rs.getString("ut_tenantid")); usageType.setCreatedBy((Long) rs.getObject("ut_createdby")); usageType.setCreatedDate((Long) rs.getObject("ut_createddate")); usageType.setLastModifiedBy((Long) rs.getObject("ut_lastmodifiedby")); usageType.setLastModifiedDate((Long) rs.getObject("ut_lastmodifieddate")); return usageType; } }
UsageTypeRowMapper implements RowMapper<UsageType> { @Override public UsageType mapRow(final ResultSet rs, final int rowNum) throws SQLException { final UsageType usageType = new UsageType(); usageType.setId(rs.getLong("ut_id")); usageType.setCode(rs.getString("ut_code")); usageType.setActive((Boolean) rs.getObject("ut_active")); usageType.setDescription(rs.getString("ut_description")); usageType.setName(rs.getString("ut_name")); usageType.setParent(rs.getString("ut_parent")); usageType.setTenantId(rs.getString("ut_tenantid")); usageType.setCreatedBy((Long) rs.getObject("ut_createdby")); usageType.setCreatedDate((Long) rs.getObject("ut_createddate")); usageType.setLastModifiedBy((Long) rs.getObject("ut_lastmodifiedby")); usageType.setLastModifiedDate((Long) rs.getObject("ut_lastmodifieddate")); return usageType; }  }
UsageTypeRowMapper implements RowMapper<UsageType> { @Override public UsageType mapRow(final ResultSet rs, final int rowNum) throws SQLException { final UsageType usageType = new UsageType(); usageType.setId(rs.getLong("ut_id")); usageType.setCode(rs.getString("ut_code")); usageType.setActive((Boolean) rs.getObject("ut_active")); usageType.setDescription(rs.getString("ut_description")); usageType.setName(rs.getString("ut_name")); usageType.setParent(rs.getString("ut_parent")); usageType.setTenantId(rs.getString("ut_tenantid")); usageType.setCreatedBy((Long) rs.getObject("ut_createdby")); usageType.setCreatedDate((Long) rs.getObject("ut_createddate")); usageType.setLastModifiedBy((Long) rs.getObject("ut_lastmodifiedby")); usageType.setLastModifiedDate((Long) rs.getObject("ut_lastmodifieddate")); return usageType; }  @Override UsageType mapRow(final ResultSet rs, final int rowNum); }
UsageTypeRowMapper implements RowMapper<UsageType> { @Override public UsageType mapRow(final ResultSet rs, final int rowNum) throws SQLException { final UsageType usageType = new UsageType(); usageType.setId(rs.getLong("ut_id")); usageType.setCode(rs.getString("ut_code")); usageType.setActive((Boolean) rs.getObject("ut_active")); usageType.setDescription(rs.getString("ut_description")); usageType.setName(rs.getString("ut_name")); usageType.setParent(rs.getString("ut_parent")); usageType.setTenantId(rs.getString("ut_tenantid")); usageType.setCreatedBy((Long) rs.getObject("ut_createdby")); usageType.setCreatedDate((Long) rs.getObject("ut_createddate")); usageType.setLastModifiedBy((Long) rs.getObject("ut_lastmodifiedby")); usageType.setLastModifiedDate((Long) rs.getObject("ut_lastmodifieddate")); return usageType; }  @Override UsageType mapRow(final ResultSet rs, final int rowNum);  }