@Test public void test_should_map_result_set_to_entity() throws Exception { Mockito.when(rs.next()).thenReturn(true).thenReturn(false); when(rs.getLong("wmc_id")).thenReturn(1L); when(rs.getString("wmc_code")).thenReturn("WMC"); when(rs.getString("wmc_metermake")).thenReturn("meterMake"); when((Boolean) rs.getObject("wmc_active")).thenReturn(true); when((Double) rs.getObject("wmc_amount")).thenReturn(4000.0); when((Long) rs.getObject("wmc_createdby")).thenReturn(1L); when((Long) rs.getObject("wmc_lastmodifiedby")).thenReturn(1L); when(rs.getString("wmc_tenantid")).thenReturn("default"); when((Long) rs.getObject("wmc_createddate")).thenReturn(1543678989L); when((Long) rs.getObject("wmc_lastmodifieddate")).thenReturn(1543678989L); final MeterCost actualMeterCost = meterCostRowMapper.mapRow(rs, 1); final MeterCost expectedMeterCost = getMeterCost(); assertThat(expectedMeterCost.equals(actualMeterCost)); }
@Override public MeterCost mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterCost meterCost = new MeterCost(); meterCost.setId(rs.getLong("wmc_id")); meterCost.setCode(rs.getString("wmc_code")); meterCost.setMeterMake(rs.getString("wmc_metermake")); meterCost.setActive((Boolean) rs.getObject("wmc_active")); meterCost.setAmount((Double) rs.getObject("wmc_amount")); meterCost.setCreatedBy((Long) rs.getObject("wmc_createdby")); meterCost.setLastModifiedBy((Long) rs.getObject("wmc_lastmodifiedby")); meterCost.setTenantId(rs.getString("wmc_tenantid")); meterCost.setCreatedDate((Long) rs.getObject("wmc_createddate")); meterCost.setLastModifiedDate((Long) rs.getObject("wmc_lastmodifieddate")); return meterCost; }
MeterCostRowMapper implements RowMapper<MeterCost> { @Override public MeterCost mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterCost meterCost = new MeterCost(); meterCost.setId(rs.getLong("wmc_id")); meterCost.setCode(rs.getString("wmc_code")); meterCost.setMeterMake(rs.getString("wmc_metermake")); meterCost.setActive((Boolean) rs.getObject("wmc_active")); meterCost.setAmount((Double) rs.getObject("wmc_amount")); meterCost.setCreatedBy((Long) rs.getObject("wmc_createdby")); meterCost.setLastModifiedBy((Long) rs.getObject("wmc_lastmodifiedby")); meterCost.setTenantId(rs.getString("wmc_tenantid")); meterCost.setCreatedDate((Long) rs.getObject("wmc_createddate")); meterCost.setLastModifiedDate((Long) rs.getObject("wmc_lastmodifieddate")); return meterCost; } }
MeterCostRowMapper implements RowMapper<MeterCost> { @Override public MeterCost mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterCost meterCost = new MeterCost(); meterCost.setId(rs.getLong("wmc_id")); meterCost.setCode(rs.getString("wmc_code")); meterCost.setMeterMake(rs.getString("wmc_metermake")); meterCost.setActive((Boolean) rs.getObject("wmc_active")); meterCost.setAmount((Double) rs.getObject("wmc_amount")); meterCost.setCreatedBy((Long) rs.getObject("wmc_createdby")); meterCost.setLastModifiedBy((Long) rs.getObject("wmc_lastmodifiedby")); meterCost.setTenantId(rs.getString("wmc_tenantid")); meterCost.setCreatedDate((Long) rs.getObject("wmc_createddate")); meterCost.setLastModifiedDate((Long) rs.getObject("wmc_lastmodifieddate")); return meterCost; }  }
MeterCostRowMapper implements RowMapper<MeterCost> { @Override public MeterCost mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterCost meterCost = new MeterCost(); meterCost.setId(rs.getLong("wmc_id")); meterCost.setCode(rs.getString("wmc_code")); meterCost.setMeterMake(rs.getString("wmc_metermake")); meterCost.setActive((Boolean) rs.getObject("wmc_active")); meterCost.setAmount((Double) rs.getObject("wmc_amount")); meterCost.setCreatedBy((Long) rs.getObject("wmc_createdby")); meterCost.setLastModifiedBy((Long) rs.getObject("wmc_lastmodifiedby")); meterCost.setTenantId(rs.getString("wmc_tenantid")); meterCost.setCreatedDate((Long) rs.getObject("wmc_createddate")); meterCost.setLastModifiedDate((Long) rs.getObject("wmc_lastmodifieddate")); return meterCost; }  @Override MeterCost mapRow(final ResultSet rs, final int rowNum); }
MeterCostRowMapper implements RowMapper<MeterCost> { @Override public MeterCost mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterCost meterCost = new MeterCost(); meterCost.setId(rs.getLong("wmc_id")); meterCost.setCode(rs.getString("wmc_code")); meterCost.setMeterMake(rs.getString("wmc_metermake")); meterCost.setActive((Boolean) rs.getObject("wmc_active")); meterCost.setAmount((Double) rs.getObject("wmc_amount")); meterCost.setCreatedBy((Long) rs.getObject("wmc_createdby")); meterCost.setLastModifiedBy((Long) rs.getObject("wmc_lastmodifiedby")); meterCost.setTenantId(rs.getString("wmc_tenantid")); meterCost.setCreatedDate((Long) rs.getObject("wmc_createddate")); meterCost.setLastModifiedDate((Long) rs.getObject("wmc_lastmodifieddate")); return meterCost; }  @Override MeterCost mapRow(final ResultSet rs, final int rowNum);  }