@Test public void test() throws Exception { Mockito.when(rs.next()).thenReturn(true); when(rs.getString("doorno")).thenReturn("11"); when(rs.getLong("electionward")).thenReturn(Long.valueOf("168")); when(rs.getInt("pincode")).thenReturn(Integer.valueOf("186")); when(rs.getLong("revenueward")).thenReturn(Long.valueOf("816")); when(rs.getLong("street")).thenReturn(Long.valueOf("861")); when(rs.getLong("block")).thenReturn(Long.valueOf("618")); when(rs.getLong("locality")).thenReturn(Long.valueOf("681")); when(rs.getLong("zone")).thenReturn(Long.valueOf("0168")); when(rs.getString("createdBy")).thenReturn("user2"); when(rs.getString("lastModifiedBy")).thenReturn("user6"); when(rs.getLong("createdTime")).thenReturn(Long.valueOf("123654789")); when(rs.getLong("lastModifiedTime")).thenReturn(Long.valueOf("123654789")); when(rs.getLong("id")).thenReturn(Long.valueOf("6")); when(rs.getString("name")).thenReturn("Bangalore"); when(rs.getBoolean("isactive")).thenReturn(true); when(rs.getString("tenantid")).thenReturn("ap.kurnool"); RegistrationUnit registrationUnit = registrationUnitRowMapper.mapRow(rs, 1); assertEquals(getRegistrationUnit(), registrationUnit); }
public RegistrationUnit mapRow(ResultSet rs, int rowNum) throws SQLException { RegistrationUnit registrationUnit = new RegistrationUnit(); try { Location location = new Location(); location.setDoorNo(rs.getString("doorno")); location.setElectionWard(rs.getLong("electionward")); location.setPinCode(rs.getInt("pincode")); location.setRevenueWard(rs.getLong("revenueward")); location.setStreet(rs.getLong("street")); location.setBlock(rs.getLong("block")); location.setLocality(rs.getLong("locality")); location.setZone(rs.getLong("zone")); AuditDetails auditDetails = new AuditDetails(); auditDetails.setCreatedBy(rs.getString("createdBy")); auditDetails.setLastModifiedBy(rs.getString("lastModifiedBy")); auditDetails.setCreatedTime(rs.getLong("createdTime")); auditDetails.setLastModifiedTime(rs.getLong("lastModifiedTime")); registrationUnit.setId(rs.getLong("id")); registrationUnit.setName(rs.getString("name")); registrationUnit.setIsActive(rs.getBoolean("isactive")); registrationUnit.setAddress(location); registrationUnit.setTenantId(rs.getString("tenantid")); registrationUnit.setAuditDetails(auditDetails); registrationUnit.setIsMainRegistrationUnit((rs.getBoolean("isMainRegistrationUnit"))); } catch (Exception e) { e.printStackTrace(); } return registrationUnit; }
RegistrationUnitRowMapper implements RowMapper<RegistrationUnit> { public RegistrationUnit mapRow(ResultSet rs, int rowNum) throws SQLException { RegistrationUnit registrationUnit = new RegistrationUnit(); try { Location location = new Location(); location.setDoorNo(rs.getString("doorno")); location.setElectionWard(rs.getLong("electionward")); location.setPinCode(rs.getInt("pincode")); location.setRevenueWard(rs.getLong("revenueward")); location.setStreet(rs.getLong("street")); location.setBlock(rs.getLong("block")); location.setLocality(rs.getLong("locality")); location.setZone(rs.getLong("zone")); AuditDetails auditDetails = new AuditDetails(); auditDetails.setCreatedBy(rs.getString("createdBy")); auditDetails.setLastModifiedBy(rs.getString("lastModifiedBy")); auditDetails.setCreatedTime(rs.getLong("createdTime")); auditDetails.setLastModifiedTime(rs.getLong("lastModifiedTime")); registrationUnit.setId(rs.getLong("id")); registrationUnit.setName(rs.getString("name")); registrationUnit.setIsActive(rs.getBoolean("isactive")); registrationUnit.setAddress(location); registrationUnit.setTenantId(rs.getString("tenantid")); registrationUnit.setAuditDetails(auditDetails); registrationUnit.setIsMainRegistrationUnit((rs.getBoolean("isMainRegistrationUnit"))); } catch (Exception e) { e.printStackTrace(); } return registrationUnit; } }
RegistrationUnitRowMapper implements RowMapper<RegistrationUnit> { public RegistrationUnit mapRow(ResultSet rs, int rowNum) throws SQLException { RegistrationUnit registrationUnit = new RegistrationUnit(); try { Location location = new Location(); location.setDoorNo(rs.getString("doorno")); location.setElectionWard(rs.getLong("electionward")); location.setPinCode(rs.getInt("pincode")); location.setRevenueWard(rs.getLong("revenueward")); location.setStreet(rs.getLong("street")); location.setBlock(rs.getLong("block")); location.setLocality(rs.getLong("locality")); location.setZone(rs.getLong("zone")); AuditDetails auditDetails = new AuditDetails(); auditDetails.setCreatedBy(rs.getString("createdBy")); auditDetails.setLastModifiedBy(rs.getString("lastModifiedBy")); auditDetails.setCreatedTime(rs.getLong("createdTime")); auditDetails.setLastModifiedTime(rs.getLong("lastModifiedTime")); registrationUnit.setId(rs.getLong("id")); registrationUnit.setName(rs.getString("name")); registrationUnit.setIsActive(rs.getBoolean("isactive")); registrationUnit.setAddress(location); registrationUnit.setTenantId(rs.getString("tenantid")); registrationUnit.setAuditDetails(auditDetails); registrationUnit.setIsMainRegistrationUnit((rs.getBoolean("isMainRegistrationUnit"))); } catch (Exception e) { e.printStackTrace(); } return registrationUnit; }  }
RegistrationUnitRowMapper implements RowMapper<RegistrationUnit> { public RegistrationUnit mapRow(ResultSet rs, int rowNum) throws SQLException { RegistrationUnit registrationUnit = new RegistrationUnit(); try { Location location = new Location(); location.setDoorNo(rs.getString("doorno")); location.setElectionWard(rs.getLong("electionward")); location.setPinCode(rs.getInt("pincode")); location.setRevenueWard(rs.getLong("revenueward")); location.setStreet(rs.getLong("street")); location.setBlock(rs.getLong("block")); location.setLocality(rs.getLong("locality")); location.setZone(rs.getLong("zone")); AuditDetails auditDetails = new AuditDetails(); auditDetails.setCreatedBy(rs.getString("createdBy")); auditDetails.setLastModifiedBy(rs.getString("lastModifiedBy")); auditDetails.setCreatedTime(rs.getLong("createdTime")); auditDetails.setLastModifiedTime(rs.getLong("lastModifiedTime")); registrationUnit.setId(rs.getLong("id")); registrationUnit.setName(rs.getString("name")); registrationUnit.setIsActive(rs.getBoolean("isactive")); registrationUnit.setAddress(location); registrationUnit.setTenantId(rs.getString("tenantid")); registrationUnit.setAuditDetails(auditDetails); registrationUnit.setIsMainRegistrationUnit((rs.getBoolean("isMainRegistrationUnit"))); } catch (Exception e) { e.printStackTrace(); } return registrationUnit; }  RegistrationUnit mapRow(ResultSet rs, int rowNum); }
RegistrationUnitRowMapper implements RowMapper<RegistrationUnit> { public RegistrationUnit mapRow(ResultSet rs, int rowNum) throws SQLException { RegistrationUnit registrationUnit = new RegistrationUnit(); try { Location location = new Location(); location.setDoorNo(rs.getString("doorno")); location.setElectionWard(rs.getLong("electionward")); location.setPinCode(rs.getInt("pincode")); location.setRevenueWard(rs.getLong("revenueward")); location.setStreet(rs.getLong("street")); location.setBlock(rs.getLong("block")); location.setLocality(rs.getLong("locality")); location.setZone(rs.getLong("zone")); AuditDetails auditDetails = new AuditDetails(); auditDetails.setCreatedBy(rs.getString("createdBy")); auditDetails.setLastModifiedBy(rs.getString("lastModifiedBy")); auditDetails.setCreatedTime(rs.getLong("createdTime")); auditDetails.setLastModifiedTime(rs.getLong("lastModifiedTime")); registrationUnit.setId(rs.getLong("id")); registrationUnit.setName(rs.getString("name")); registrationUnit.setIsActive(rs.getBoolean("isactive")); registrationUnit.setAddress(location); registrationUnit.setTenantId(rs.getString("tenantid")); registrationUnit.setAuditDetails(auditDetails); registrationUnit.setIsMainRegistrationUnit((rs.getBoolean("isMainRegistrationUnit"))); } catch (Exception e) { e.printStackTrace(); } return registrationUnit; }  RegistrationUnit mapRow(ResultSet rs, int rowNum);  }