@Test public void testUpdateRegistrationUnit() { RegistrationUnit registrationUnit = getRegistrationUnit(); when(registrationUnitQueryBuilder.getUpdateQuery()).thenReturn(getQueryGenerator()); when(jdbcTemplate.update(any(String.class), any(Object.class))).thenReturn(1); registrationUnitRepository.update(registrationUnit); }
public void update(RegistrationUnit registrationUnit) { LOGGER.info(registrationUnit.toString()); Location location = registrationUnit.getAddress(); AuditDetails auditDetails = registrationUnit.getAuditDetails(); try { jdbcTemplate.update(registrationUnitQueryBuilder.getUpdateQuery(), new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, registrationUnit.getName()); ps.setBoolean(2, registrationUnit.getIsActive()); ps.setLong(3, location.getLocality()); ps.setLong(4, location.getZone()); ps.setLong(5, location.getRevenueWard()); ps.setLong(6, location.getBlock()); ps.setLong(7, location.getStreet()); ps.setLong(8, location.getElectionWard()); ps.setString(9, location.getDoorNo()); ps.setLong(10, location.getPinCode()); ps.setBoolean(11, registrationUnit.getIsMainRegistrationUnit()); ps.setString(12, auditDetails.getCreatedBy()); ps.setString(13, auditDetails.getLastModifiedBy()); ps.setLong(14, auditDetails.getCreatedTime()); ps.setLong(15, auditDetails.getLastModifiedTime()); ps.setLong(16, registrationUnit.getId()); ps.setString(17, registrationUnit.getTenantId()); } }); } catch (DataAccessException e) { jdbcTemplate.execute("ROLLBACK"); e.printStackTrace(); } }
RegistrationUnitRepository { public void update(RegistrationUnit registrationUnit) { LOGGER.info(registrationUnit.toString()); Location location = registrationUnit.getAddress(); AuditDetails auditDetails = registrationUnit.getAuditDetails(); try { jdbcTemplate.update(registrationUnitQueryBuilder.getUpdateQuery(), new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, registrationUnit.getName()); ps.setBoolean(2, registrationUnit.getIsActive()); ps.setLong(3, location.getLocality()); ps.setLong(4, location.getZone()); ps.setLong(5, location.getRevenueWard()); ps.setLong(6, location.getBlock()); ps.setLong(7, location.getStreet()); ps.setLong(8, location.getElectionWard()); ps.setString(9, location.getDoorNo()); ps.setLong(10, location.getPinCode()); ps.setBoolean(11, registrationUnit.getIsMainRegistrationUnit()); ps.setString(12, auditDetails.getCreatedBy()); ps.setString(13, auditDetails.getLastModifiedBy()); ps.setLong(14, auditDetails.getCreatedTime()); ps.setLong(15, auditDetails.getLastModifiedTime()); ps.setLong(16, registrationUnit.getId()); ps.setString(17, registrationUnit.getTenantId()); } }); } catch (DataAccessException e) { jdbcTemplate.execute("ROLLBACK"); e.printStackTrace(); } } }
RegistrationUnitRepository { public void update(RegistrationUnit registrationUnit) { LOGGER.info(registrationUnit.toString()); Location location = registrationUnit.getAddress(); AuditDetails auditDetails = registrationUnit.getAuditDetails(); try { jdbcTemplate.update(registrationUnitQueryBuilder.getUpdateQuery(), new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, registrationUnit.getName()); ps.setBoolean(2, registrationUnit.getIsActive()); ps.setLong(3, location.getLocality()); ps.setLong(4, location.getZone()); ps.setLong(5, location.getRevenueWard()); ps.setLong(6, location.getBlock()); ps.setLong(7, location.getStreet()); ps.setLong(8, location.getElectionWard()); ps.setString(9, location.getDoorNo()); ps.setLong(10, location.getPinCode()); ps.setBoolean(11, registrationUnit.getIsMainRegistrationUnit()); ps.setString(12, auditDetails.getCreatedBy()); ps.setString(13, auditDetails.getLastModifiedBy()); ps.setLong(14, auditDetails.getCreatedTime()); ps.setLong(15, auditDetails.getLastModifiedTime()); ps.setLong(16, registrationUnit.getId()); ps.setString(17, registrationUnit.getTenantId()); } }); } catch (DataAccessException e) { jdbcTemplate.execute("ROLLBACK"); e.printStackTrace(); } }  }
RegistrationUnitRepository { public void update(RegistrationUnit registrationUnit) { LOGGER.info(registrationUnit.toString()); Location location = registrationUnit.getAddress(); AuditDetails auditDetails = registrationUnit.getAuditDetails(); try { jdbcTemplate.update(registrationUnitQueryBuilder.getUpdateQuery(), new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, registrationUnit.getName()); ps.setBoolean(2, registrationUnit.getIsActive()); ps.setLong(3, location.getLocality()); ps.setLong(4, location.getZone()); ps.setLong(5, location.getRevenueWard()); ps.setLong(6, location.getBlock()); ps.setLong(7, location.getStreet()); ps.setLong(8, location.getElectionWard()); ps.setString(9, location.getDoorNo()); ps.setLong(10, location.getPinCode()); ps.setBoolean(11, registrationUnit.getIsMainRegistrationUnit()); ps.setString(12, auditDetails.getCreatedBy()); ps.setString(13, auditDetails.getLastModifiedBy()); ps.setLong(14, auditDetails.getCreatedTime()); ps.setLong(15, auditDetails.getLastModifiedTime()); ps.setLong(16, registrationUnit.getId()); ps.setString(17, registrationUnit.getTenantId()); } }); } catch (DataAccessException e) { jdbcTemplate.execute("ROLLBACK"); e.printStackTrace(); } }  void create(RegistrationUnit registrationUnit); List<RegistrationUnit> search(RegistrationUnitSearchCriteria regnUnitSearchCriteria); void update(RegistrationUnit registrationUnit); Long getIdNextVal(); Boolean checkIdsAndTenantIdsFromDB(RegistrationUnit registrationUnit); }
RegistrationUnitRepository { public void update(RegistrationUnit registrationUnit) { LOGGER.info(registrationUnit.toString()); Location location = registrationUnit.getAddress(); AuditDetails auditDetails = registrationUnit.getAuditDetails(); try { jdbcTemplate.update(registrationUnitQueryBuilder.getUpdateQuery(), new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, registrationUnit.getName()); ps.setBoolean(2, registrationUnit.getIsActive()); ps.setLong(3, location.getLocality()); ps.setLong(4, location.getZone()); ps.setLong(5, location.getRevenueWard()); ps.setLong(6, location.getBlock()); ps.setLong(7, location.getStreet()); ps.setLong(8, location.getElectionWard()); ps.setString(9, location.getDoorNo()); ps.setLong(10, location.getPinCode()); ps.setBoolean(11, registrationUnit.getIsMainRegistrationUnit()); ps.setString(12, auditDetails.getCreatedBy()); ps.setString(13, auditDetails.getLastModifiedBy()); ps.setLong(14, auditDetails.getCreatedTime()); ps.setLong(15, auditDetails.getLastModifiedTime()); ps.setLong(16, registrationUnit.getId()); ps.setString(17, registrationUnit.getTenantId()); } }); } catch (DataAccessException e) { jdbcTemplate.execute("ROLLBACK"); e.printStackTrace(); } }  void create(RegistrationUnit registrationUnit); List<RegistrationUnit> search(RegistrationUnitSearchCriteria regnUnitSearchCriteria); void update(RegistrationUnit registrationUnit); Long getIdNextVal(); Boolean checkIdsAndTenantIdsFromDB(RegistrationUnit registrationUnit);  }