@Test public void test_should_map_result_set_to_entity() throws Exception { Mockito.when(rs.next()).thenReturn(true).thenReturn(false); when(rs.getLong("ms_id")).thenReturn(1L); when(rs.getString("ms_code")).thenReturn("1"); when(rs.getString("ms_status")).thenReturn("faulty meter"); when(rs.getString("ms_description")).thenReturn("meter is faulty"); when((Long) rs.getObject("ms_createdby")).thenReturn(1L); when((Long) rs.getObject("ms_createddate")).thenReturn(15436789L); when((Long) rs.getObject("ms_lastmodifiedby")).thenReturn(1L); when((Long) rs.getObject("ms_lastmodifieddate")).thenReturn(15436789L); when(rs.getString("ms_tenantid")).thenReturn("default"); final MeterStatus actualMeterStatus = meterStatusRowMapper.mapRow(rs, 1); final MeterStatus expectedMeterStatus = getMeterStatus(); assertTrue(expectedMeterStatus.equals(actualMeterStatus)); }
@Override public MeterStatus mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterStatus meterStatus = new MeterStatus(); meterStatus.setId(rs.getLong("ms_id")); meterStatus.setCode(rs.getString("ms_code")); meterStatus.setMeterStatus(rs.getString("ms_status")); meterStatus.setDescription(rs.getString("ms_description")); meterStatus.setActive((Boolean) rs.getObject("ms_active")); meterStatus.setCreatedBy((Long) rs.getObject("ms_createdby")); meterStatus.setCreatedDate((Long) rs.getObject("ms_createddate")); meterStatus.setLastModifiedBy((Long) rs.getObject("ms_lastmodifiedby")); meterStatus.setLastModifiedDate((Long) rs.getObject("ms_lastmodifieddate")); meterStatus.setTenantId(rs.getString("ms_tenantid")); return meterStatus; }
MeterStatusRowMapper implements RowMapper<MeterStatus> { @Override public MeterStatus mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterStatus meterStatus = new MeterStatus(); meterStatus.setId(rs.getLong("ms_id")); meterStatus.setCode(rs.getString("ms_code")); meterStatus.setMeterStatus(rs.getString("ms_status")); meterStatus.setDescription(rs.getString("ms_description")); meterStatus.setActive((Boolean) rs.getObject("ms_active")); meterStatus.setCreatedBy((Long) rs.getObject("ms_createdby")); meterStatus.setCreatedDate((Long) rs.getObject("ms_createddate")); meterStatus.setLastModifiedBy((Long) rs.getObject("ms_lastmodifiedby")); meterStatus.setLastModifiedDate((Long) rs.getObject("ms_lastmodifieddate")); meterStatus.setTenantId(rs.getString("ms_tenantid")); return meterStatus; } }
MeterStatusRowMapper implements RowMapper<MeterStatus> { @Override public MeterStatus mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterStatus meterStatus = new MeterStatus(); meterStatus.setId(rs.getLong("ms_id")); meterStatus.setCode(rs.getString("ms_code")); meterStatus.setMeterStatus(rs.getString("ms_status")); meterStatus.setDescription(rs.getString("ms_description")); meterStatus.setActive((Boolean) rs.getObject("ms_active")); meterStatus.setCreatedBy((Long) rs.getObject("ms_createdby")); meterStatus.setCreatedDate((Long) rs.getObject("ms_createddate")); meterStatus.setLastModifiedBy((Long) rs.getObject("ms_lastmodifiedby")); meterStatus.setLastModifiedDate((Long) rs.getObject("ms_lastmodifieddate")); meterStatus.setTenantId(rs.getString("ms_tenantid")); return meterStatus; }  }
MeterStatusRowMapper implements RowMapper<MeterStatus> { @Override public MeterStatus mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterStatus meterStatus = new MeterStatus(); meterStatus.setId(rs.getLong("ms_id")); meterStatus.setCode(rs.getString("ms_code")); meterStatus.setMeterStatus(rs.getString("ms_status")); meterStatus.setDescription(rs.getString("ms_description")); meterStatus.setActive((Boolean) rs.getObject("ms_active")); meterStatus.setCreatedBy((Long) rs.getObject("ms_createdby")); meterStatus.setCreatedDate((Long) rs.getObject("ms_createddate")); meterStatus.setLastModifiedBy((Long) rs.getObject("ms_lastmodifiedby")); meterStatus.setLastModifiedDate((Long) rs.getObject("ms_lastmodifieddate")); meterStatus.setTenantId(rs.getString("ms_tenantid")); return meterStatus; }  @Override MeterStatus mapRow(final ResultSet rs, final int rowNum); }
MeterStatusRowMapper implements RowMapper<MeterStatus> { @Override public MeterStatus mapRow(final ResultSet rs, final int rowNum) throws SQLException { final MeterStatus meterStatus = new MeterStatus(); meterStatus.setId(rs.getLong("ms_id")); meterStatus.setCode(rs.getString("ms_code")); meterStatus.setMeterStatus(rs.getString("ms_status")); meterStatus.setDescription(rs.getString("ms_description")); meterStatus.setActive((Boolean) rs.getObject("ms_active")); meterStatus.setCreatedBy((Long) rs.getObject("ms_createdby")); meterStatus.setCreatedDate((Long) rs.getObject("ms_createddate")); meterStatus.setLastModifiedBy((Long) rs.getObject("ms_lastmodifiedby")); meterStatus.setLastModifiedDate((Long) rs.getObject("ms_lastmodifieddate")); meterStatus.setTenantId(rs.getString("ms_tenantid")); return meterStatus; }  @Override MeterStatus mapRow(final ResultSet rs, final int rowNum);  }