@SuppressWarnings("unchecked") @Test public void testUpdateFee() { FeeRequest feeRequest = FeeRequest.builder().fees(getFeeList()).build(); int[] value = new int[] { 2 }; when(jdbcTemplate.batchUpdate(any(String.class), any(List.class))).thenReturn(value); feeRepository.updateFee(feeRequest); }
public void updateFee(FeeRequest feeRequest) { List<Fee> fees = feeRequest.getFees(); for (int j = 0; j < fees.size(); j += batchSize) { final List<Fee> batchList = fees.subList(j, j + batchSize > fees.size() ? fees.size() : j + batchSize); jdbcTemplate.batchUpdate(feeQueryBuilder.UPDATE_QUERY, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Fee fee = fees.get(i); ps.setString(1, fee.getFeeCriteria()); ps.setBigDecimal(2, fee.getFee()); ps.setLong(3, fee.getFromDate()); ps.setLong(4, fee.getToDate()); ps.setLong(5, new Date().getTime()); ps.setString(6, feeRequest.getRequestInfo().getDid()); ps.setString(7, fee.getId()); ps.setString(8, fee.getTenantId()); } @Override public int getBatchSize() { return fees.size(); } }); } }
FeeRepository { public void updateFee(FeeRequest feeRequest) { List<Fee> fees = feeRequest.getFees(); for (int j = 0; j < fees.size(); j += batchSize) { final List<Fee> batchList = fees.subList(j, j + batchSize > fees.size() ? fees.size() : j + batchSize); jdbcTemplate.batchUpdate(feeQueryBuilder.UPDATE_QUERY, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Fee fee = fees.get(i); ps.setString(1, fee.getFeeCriteria()); ps.setBigDecimal(2, fee.getFee()); ps.setLong(3, fee.getFromDate()); ps.setLong(4, fee.getToDate()); ps.setLong(5, new Date().getTime()); ps.setString(6, feeRequest.getRequestInfo().getDid()); ps.setString(7, fee.getId()); ps.setString(8, fee.getTenantId()); } @Override public int getBatchSize() { return fees.size(); } }); } } }
FeeRepository { public void updateFee(FeeRequest feeRequest) { List<Fee> fees = feeRequest.getFees(); for (int j = 0; j < fees.size(); j += batchSize) { final List<Fee> batchList = fees.subList(j, j + batchSize > fees.size() ? fees.size() : j + batchSize); jdbcTemplate.batchUpdate(feeQueryBuilder.UPDATE_QUERY, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Fee fee = fees.get(i); ps.setString(1, fee.getFeeCriteria()); ps.setBigDecimal(2, fee.getFee()); ps.setLong(3, fee.getFromDate()); ps.setLong(4, fee.getToDate()); ps.setLong(5, new Date().getTime()); ps.setString(6, feeRequest.getRequestInfo().getDid()); ps.setString(7, fee.getId()); ps.setString(8, fee.getTenantId()); } @Override public int getBatchSize() { return fees.size(); } }); } }  }
FeeRepository { public void updateFee(FeeRequest feeRequest) { List<Fee> fees = feeRequest.getFees(); for (int j = 0; j < fees.size(); j += batchSize) { final List<Fee> batchList = fees.subList(j, j + batchSize > fees.size() ? fees.size() : j + batchSize); jdbcTemplate.batchUpdate(feeQueryBuilder.UPDATE_QUERY, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Fee fee = fees.get(i); ps.setString(1, fee.getFeeCriteria()); ps.setBigDecimal(2, fee.getFee()); ps.setLong(3, fee.getFromDate()); ps.setLong(4, fee.getToDate()); ps.setLong(5, new Date().getTime()); ps.setString(6, feeRequest.getRequestInfo().getDid()); ps.setString(7, fee.getId()); ps.setString(8, fee.getTenantId()); } @Override public int getBatchSize() { return fees.size(); } }); } }  List<Fee> findForCriteria(FeeCriteria feeCriteria); void createFee(FeeRequest feeRequest); void updateFee(FeeRequest feeRequest); }
FeeRepository { public void updateFee(FeeRequest feeRequest) { List<Fee> fees = feeRequest.getFees(); for (int j = 0; j < fees.size(); j += batchSize) { final List<Fee> batchList = fees.subList(j, j + batchSize > fees.size() ? fees.size() : j + batchSize); jdbcTemplate.batchUpdate(feeQueryBuilder.UPDATE_QUERY, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Fee fee = fees.get(i); ps.setString(1, fee.getFeeCriteria()); ps.setBigDecimal(2, fee.getFee()); ps.setLong(3, fee.getFromDate()); ps.setLong(4, fee.getToDate()); ps.setLong(5, new Date().getTime()); ps.setString(6, feeRequest.getRequestInfo().getDid()); ps.setString(7, fee.getId()); ps.setString(8, fee.getTenantId()); } @Override public int getBatchSize() { return fees.size(); } }); } }  List<Fee> findForCriteria(FeeCriteria feeCriteria); void createFee(FeeRequest feeRequest); void updateFee(FeeRequest feeRequest);  }