@Test public void shouldUpdateBusinessServiceDetails() { BusinessServiceDetailRequest businessServiceDetailRequest = new BusinessServiceDetailRequest(); RequestInfo requestInfo = new RequestInfo(); User user = new User(); user.setId(1l); requestInfo.setUserInfo(user); businessServiceDetailRequest.setRequestInfo(requestInfo); List<BusinessServiceDetail> businessServiceDetails = new ArrayList<>(); businessServiceDetails.add(getBusinessServiceDetail()); businessServiceDetailRequest.setBusinessServiceDetails(businessServiceDetails); when(jdbcTemplate.update(any(String.class),any(Object[].class))).thenReturn(1); assertTrue(businessServiceDetails.equals(businessServiceDetailRepository.update(businessServiceDetailRequest))); }
public List<BusinessServiceDetail> update(BusinessServiceDetailRequest businessServiceDetailRequest) { List<BusinessServiceDetail> businessServiceDetails = businessServiceDetailRequest.getBusinessServiceDetails(); if (!businessServiceDetails.isEmpty()) { String query = businessServDetailQueryBuilder.getUpdateQuery(); List<Object[]> argsList = new ArrayList<>(); RequestInfo requestInfo = businessServiceDetailRequest.getRequestInfo(); for (int i = 0; i < businessServiceDetails.size(); i++) { Object[] values = {businessServiceDetails.get(i).getBusinessService(), StringUtils.join(businessServiceDetails.get(i).getCollectionModesNotAllowed(), ','), businessServiceDetails.get(i).getPartPaymentAllowed(), businessServiceDetails.get(i).getCallBackForApportioning(), businessServiceDetails.get(i).getCallBackApportionURL(), new Date().getTime(), requestInfo.getUserInfo().getId(), businessServiceDetails.get(i).getTenantId(), businessServiceDetails.get(i).getId()}; argsList.add(values); } try { jdbcTemplate.batchUpdate(query, argsList); } catch (DataAccessException ex) { ex.printStackTrace(); throw new RuntimeException(ex.getMessage()); } } return businessServiceDetails; }
BusinessServiceDetailRepository { public List<BusinessServiceDetail> update(BusinessServiceDetailRequest businessServiceDetailRequest) { List<BusinessServiceDetail> businessServiceDetails = businessServiceDetailRequest.getBusinessServiceDetails(); if (!businessServiceDetails.isEmpty()) { String query = businessServDetailQueryBuilder.getUpdateQuery(); List<Object[]> argsList = new ArrayList<>(); RequestInfo requestInfo = businessServiceDetailRequest.getRequestInfo(); for (int i = 0; i < businessServiceDetails.size(); i++) { Object[] values = {businessServiceDetails.get(i).getBusinessService(), StringUtils.join(businessServiceDetails.get(i).getCollectionModesNotAllowed(), ','), businessServiceDetails.get(i).getPartPaymentAllowed(), businessServiceDetails.get(i).getCallBackForApportioning(), businessServiceDetails.get(i).getCallBackApportionURL(), new Date().getTime(), requestInfo.getUserInfo().getId(), businessServiceDetails.get(i).getTenantId(), businessServiceDetails.get(i).getId()}; argsList.add(values); } try { jdbcTemplate.batchUpdate(query, argsList); } catch (DataAccessException ex) { ex.printStackTrace(); throw new RuntimeException(ex.getMessage()); } } return businessServiceDetails; } }
BusinessServiceDetailRepository { public List<BusinessServiceDetail> update(BusinessServiceDetailRequest businessServiceDetailRequest) { List<BusinessServiceDetail> businessServiceDetails = businessServiceDetailRequest.getBusinessServiceDetails(); if (!businessServiceDetails.isEmpty()) { String query = businessServDetailQueryBuilder.getUpdateQuery(); List<Object[]> argsList = new ArrayList<>(); RequestInfo requestInfo = businessServiceDetailRequest.getRequestInfo(); for (int i = 0; i < businessServiceDetails.size(); i++) { Object[] values = {businessServiceDetails.get(i).getBusinessService(), StringUtils.join(businessServiceDetails.get(i).getCollectionModesNotAllowed(), ','), businessServiceDetails.get(i).getPartPaymentAllowed(), businessServiceDetails.get(i).getCallBackForApportioning(), businessServiceDetails.get(i).getCallBackApportionURL(), new Date().getTime(), requestInfo.getUserInfo().getId(), businessServiceDetails.get(i).getTenantId(), businessServiceDetails.get(i).getId()}; argsList.add(values); } try { jdbcTemplate.batchUpdate(query, argsList); } catch (DataAccessException ex) { ex.printStackTrace(); throw new RuntimeException(ex.getMessage()); } } return businessServiceDetails; }  }
BusinessServiceDetailRepository { public List<BusinessServiceDetail> update(BusinessServiceDetailRequest businessServiceDetailRequest) { List<BusinessServiceDetail> businessServiceDetails = businessServiceDetailRequest.getBusinessServiceDetails(); if (!businessServiceDetails.isEmpty()) { String query = businessServDetailQueryBuilder.getUpdateQuery(); List<Object[]> argsList = new ArrayList<>(); RequestInfo requestInfo = businessServiceDetailRequest.getRequestInfo(); for (int i = 0; i < businessServiceDetails.size(); i++) { Object[] values = {businessServiceDetails.get(i).getBusinessService(), StringUtils.join(businessServiceDetails.get(i).getCollectionModesNotAllowed(), ','), businessServiceDetails.get(i).getPartPaymentAllowed(), businessServiceDetails.get(i).getCallBackForApportioning(), businessServiceDetails.get(i).getCallBackApportionURL(), new Date().getTime(), requestInfo.getUserInfo().getId(), businessServiceDetails.get(i).getTenantId(), businessServiceDetails.get(i).getId()}; argsList.add(values); } try { jdbcTemplate.batchUpdate(query, argsList); } catch (DataAccessException ex) { ex.printStackTrace(); throw new RuntimeException(ex.getMessage()); } } return businessServiceDetails; }  List<BusinessServiceDetail> searchBusinessServiceDetails(final BusinessServiceDetailCriteria businessServiceDetailCriteria); List<BusinessServiceDetail> getBussinessServiceDetail(RequestInfo requestInfo,BusinessServiceDetailCriteria BusinessServiceDetailsCriteria); List<BusinessServiceDetail> create(BusinessServiceDetailRequest businessServiceDetailRequest); List<BusinessServiceDetail> update(BusinessServiceDetailRequest businessServiceDetailRequest); boolean checkForDuplicates(List<BusinessServiceDetail> businessServiceDetailList, String mode); }
BusinessServiceDetailRepository { public List<BusinessServiceDetail> update(BusinessServiceDetailRequest businessServiceDetailRequest) { List<BusinessServiceDetail> businessServiceDetails = businessServiceDetailRequest.getBusinessServiceDetails(); if (!businessServiceDetails.isEmpty()) { String query = businessServDetailQueryBuilder.getUpdateQuery(); List<Object[]> argsList = new ArrayList<>(); RequestInfo requestInfo = businessServiceDetailRequest.getRequestInfo(); for (int i = 0; i < businessServiceDetails.size(); i++) { Object[] values = {businessServiceDetails.get(i).getBusinessService(), StringUtils.join(businessServiceDetails.get(i).getCollectionModesNotAllowed(), ','), businessServiceDetails.get(i).getPartPaymentAllowed(), businessServiceDetails.get(i).getCallBackForApportioning(), businessServiceDetails.get(i).getCallBackApportionURL(), new Date().getTime(), requestInfo.getUserInfo().getId(), businessServiceDetails.get(i).getTenantId(), businessServiceDetails.get(i).getId()}; argsList.add(values); } try { jdbcTemplate.batchUpdate(query, argsList); } catch (DataAccessException ex) { ex.printStackTrace(); throw new RuntimeException(ex.getMessage()); } } return businessServiceDetails; }  List<BusinessServiceDetail> searchBusinessServiceDetails(final BusinessServiceDetailCriteria businessServiceDetailCriteria); List<BusinessServiceDetail> getBussinessServiceDetail(RequestInfo requestInfo,BusinessServiceDetailCriteria BusinessServiceDetailsCriteria); List<BusinessServiceDetail> create(BusinessServiceDetailRequest businessServiceDetailRequest); List<BusinessServiceDetail> update(BusinessServiceDetailRequest businessServiceDetailRequest); boolean checkForDuplicates(List<BusinessServiceDetail> businessServiceDetailList, String mode);  }