@Test public void test_should_persist_create_service_Charge_to_db() { when(codeGeneratorService.generate("SEQ_EGWTR_SERVICECHARGE_DETAILS")).thenReturn("1", "2", "3", "4", "5", "6", "7", "8"); final ServiceChargeReq serviceChargeRequest = serviceChargeRepository .create(getServiceChargeRequest()); assertThat(serviceChargeRequest.getServiceCharge().size()).isEqualTo(4); }
@SuppressWarnings("unchecked") public ServiceChargeReq create(final ServiceChargeReq serviceChargeRequest) { final List<ServiceCharge> listOfServiceCharges = serviceChargeRequest.getServiceCharge(); final String insertServiceCharge = serviceChargeQueryBuilder.insertServiceChargeData(); final String insertServiceChargeDetails = serviceChargeQueryBuilder.insertServiceChargeDetailsData(); final List<ServiceChargeDetails> listOfServiceChargeDetail = new ArrayList<>(); for (final ServiceCharge servicecharge : listOfServiceCharges) listOfServiceChargeDetail.addAll(servicecharge.getChargeDetails()); final List<Map<String, Object>> batchValues = new ArrayList<>(listOfServiceCharges.size()); final List<Map<String, Object>> batchArgs = new ArrayList<>(listOfServiceChargeDetail.size()); for (final ServiceCharge serviceCharge : listOfServiceCharges) { batchValues.add(new MapSqlParameterSource("id", Long.valueOf(serviceCharge.getCode())) .addValue("code", serviceCharge.getCode()) .addValue("servicetype", serviceCharge.getServiceType()) .addValue("servicechargeapplicable", serviceCharge.getServiceChargeApplicable()) .addValue("servicechargetype", serviceCharge.getServiceChargeType()) .addValue("description", serviceCharge.getDescription()) .addValue("active", serviceCharge.getActive()) .addValue("effectivefrom", serviceCharge.getEffectiveFrom()) .addValue("effectiveto", serviceCharge.getEffectiveTo()).addValue("outsideulb", serviceCharge.getOutsideUlb()) .addValue(TENANT, serviceCharge.getTenantId()).addValue("createdby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).getValues()); final List<ServiceChargeDetails> listOfServiceChargeDetails = serviceCharge.getChargeDetails(); for (final ServiceChargeDetails serviceChargeDetail : listOfServiceChargeDetails) { final String sequenceDetail = codeGeneratorService.generate(ServiceChargeDetails.SEQ_SERVICECHARGEDETAILS); batchArgs.add(new MapSqlParameterSource("id", Long.valueOf(sequenceDetail)).addValue("code", sequenceDetail) .addValue("uomfrom", serviceChargeDetail.getUomFrom()).addValue("uomto", serviceChargeDetail.getUomTo()) .addValue("amountorpercentage", serviceChargeDetail.getAmountOrpercentage()).addValue(SERVICECHARGE, Long.valueOf(serviceCharge.getCode())) .addValue(TENANT, serviceChargeDetail.getTenantId()) .getValues()); } } namedParameterJdbcTemplate.batchUpdate(insertServiceCharge, batchValues.toArray(new Map[listOfServiceCharges.size()])); namedParameterJdbcTemplate.batchUpdate(insertServiceChargeDetails, batchArgs.toArray(new Map[listOfServiceChargeDetail.size()])); return serviceChargeRequest; }
ServiceChargeRepository { @SuppressWarnings("unchecked") public ServiceChargeReq create(final ServiceChargeReq serviceChargeRequest) { final List<ServiceCharge> listOfServiceCharges = serviceChargeRequest.getServiceCharge(); final String insertServiceCharge = serviceChargeQueryBuilder.insertServiceChargeData(); final String insertServiceChargeDetails = serviceChargeQueryBuilder.insertServiceChargeDetailsData(); final List<ServiceChargeDetails> listOfServiceChargeDetail = new ArrayList<>(); for (final ServiceCharge servicecharge : listOfServiceCharges) listOfServiceChargeDetail.addAll(servicecharge.getChargeDetails()); final List<Map<String, Object>> batchValues = new ArrayList<>(listOfServiceCharges.size()); final List<Map<String, Object>> batchArgs = new ArrayList<>(listOfServiceChargeDetail.size()); for (final ServiceCharge serviceCharge : listOfServiceCharges) { batchValues.add(new MapSqlParameterSource("id", Long.valueOf(serviceCharge.getCode())) .addValue("code", serviceCharge.getCode()) .addValue("servicetype", serviceCharge.getServiceType()) .addValue("servicechargeapplicable", serviceCharge.getServiceChargeApplicable()) .addValue("servicechargetype", serviceCharge.getServiceChargeType()) .addValue("description", serviceCharge.getDescription()) .addValue("active", serviceCharge.getActive()) .addValue("effectivefrom", serviceCharge.getEffectiveFrom()) .addValue("effectiveto", serviceCharge.getEffectiveTo()).addValue("outsideulb", serviceCharge.getOutsideUlb()) .addValue(TENANT, serviceCharge.getTenantId()).addValue("createdby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).getValues()); final List<ServiceChargeDetails> listOfServiceChargeDetails = serviceCharge.getChargeDetails(); for (final ServiceChargeDetails serviceChargeDetail : listOfServiceChargeDetails) { final String sequenceDetail = codeGeneratorService.generate(ServiceChargeDetails.SEQ_SERVICECHARGEDETAILS); batchArgs.add(new MapSqlParameterSource("id", Long.valueOf(sequenceDetail)).addValue("code", sequenceDetail) .addValue("uomfrom", serviceChargeDetail.getUomFrom()).addValue("uomto", serviceChargeDetail.getUomTo()) .addValue("amountorpercentage", serviceChargeDetail.getAmountOrpercentage()).addValue(SERVICECHARGE, Long.valueOf(serviceCharge.getCode())) .addValue(TENANT, serviceChargeDetail.getTenantId()) .getValues()); } } namedParameterJdbcTemplate.batchUpdate(insertServiceCharge, batchValues.toArray(new Map[listOfServiceCharges.size()])); namedParameterJdbcTemplate.batchUpdate(insertServiceChargeDetails, batchArgs.toArray(new Map[listOfServiceChargeDetail.size()])); return serviceChargeRequest; } }
ServiceChargeRepository { @SuppressWarnings("unchecked") public ServiceChargeReq create(final ServiceChargeReq serviceChargeRequest) { final List<ServiceCharge> listOfServiceCharges = serviceChargeRequest.getServiceCharge(); final String insertServiceCharge = serviceChargeQueryBuilder.insertServiceChargeData(); final String insertServiceChargeDetails = serviceChargeQueryBuilder.insertServiceChargeDetailsData(); final List<ServiceChargeDetails> listOfServiceChargeDetail = new ArrayList<>(); for (final ServiceCharge servicecharge : listOfServiceCharges) listOfServiceChargeDetail.addAll(servicecharge.getChargeDetails()); final List<Map<String, Object>> batchValues = new ArrayList<>(listOfServiceCharges.size()); final List<Map<String, Object>> batchArgs = new ArrayList<>(listOfServiceChargeDetail.size()); for (final ServiceCharge serviceCharge : listOfServiceCharges) { batchValues.add(new MapSqlParameterSource("id", Long.valueOf(serviceCharge.getCode())) .addValue("code", serviceCharge.getCode()) .addValue("servicetype", serviceCharge.getServiceType()) .addValue("servicechargeapplicable", serviceCharge.getServiceChargeApplicable()) .addValue("servicechargetype", serviceCharge.getServiceChargeType()) .addValue("description", serviceCharge.getDescription()) .addValue("active", serviceCharge.getActive()) .addValue("effectivefrom", serviceCharge.getEffectiveFrom()) .addValue("effectiveto", serviceCharge.getEffectiveTo()).addValue("outsideulb", serviceCharge.getOutsideUlb()) .addValue(TENANT, serviceCharge.getTenantId()).addValue("createdby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).getValues()); final List<ServiceChargeDetails> listOfServiceChargeDetails = serviceCharge.getChargeDetails(); for (final ServiceChargeDetails serviceChargeDetail : listOfServiceChargeDetails) { final String sequenceDetail = codeGeneratorService.generate(ServiceChargeDetails.SEQ_SERVICECHARGEDETAILS); batchArgs.add(new MapSqlParameterSource("id", Long.valueOf(sequenceDetail)).addValue("code", sequenceDetail) .addValue("uomfrom", serviceChargeDetail.getUomFrom()).addValue("uomto", serviceChargeDetail.getUomTo()) .addValue("amountorpercentage", serviceChargeDetail.getAmountOrpercentage()).addValue(SERVICECHARGE, Long.valueOf(serviceCharge.getCode())) .addValue(TENANT, serviceChargeDetail.getTenantId()) .getValues()); } } namedParameterJdbcTemplate.batchUpdate(insertServiceCharge, batchValues.toArray(new Map[listOfServiceCharges.size()])); namedParameterJdbcTemplate.batchUpdate(insertServiceChargeDetails, batchArgs.toArray(new Map[listOfServiceChargeDetail.size()])); return serviceChargeRequest; }  }
ServiceChargeRepository { @SuppressWarnings("unchecked") public ServiceChargeReq create(final ServiceChargeReq serviceChargeRequest) { final List<ServiceCharge> listOfServiceCharges = serviceChargeRequest.getServiceCharge(); final String insertServiceCharge = serviceChargeQueryBuilder.insertServiceChargeData(); final String insertServiceChargeDetails = serviceChargeQueryBuilder.insertServiceChargeDetailsData(); final List<ServiceChargeDetails> listOfServiceChargeDetail = new ArrayList<>(); for (final ServiceCharge servicecharge : listOfServiceCharges) listOfServiceChargeDetail.addAll(servicecharge.getChargeDetails()); final List<Map<String, Object>> batchValues = new ArrayList<>(listOfServiceCharges.size()); final List<Map<String, Object>> batchArgs = new ArrayList<>(listOfServiceChargeDetail.size()); for (final ServiceCharge serviceCharge : listOfServiceCharges) { batchValues.add(new MapSqlParameterSource("id", Long.valueOf(serviceCharge.getCode())) .addValue("code", serviceCharge.getCode()) .addValue("servicetype", serviceCharge.getServiceType()) .addValue("servicechargeapplicable", serviceCharge.getServiceChargeApplicable()) .addValue("servicechargetype", serviceCharge.getServiceChargeType()) .addValue("description", serviceCharge.getDescription()) .addValue("active", serviceCharge.getActive()) .addValue("effectivefrom", serviceCharge.getEffectiveFrom()) .addValue("effectiveto", serviceCharge.getEffectiveTo()).addValue("outsideulb", serviceCharge.getOutsideUlb()) .addValue(TENANT, serviceCharge.getTenantId()).addValue("createdby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).getValues()); final List<ServiceChargeDetails> listOfServiceChargeDetails = serviceCharge.getChargeDetails(); for (final ServiceChargeDetails serviceChargeDetail : listOfServiceChargeDetails) { final String sequenceDetail = codeGeneratorService.generate(ServiceChargeDetails.SEQ_SERVICECHARGEDETAILS); batchArgs.add(new MapSqlParameterSource("id", Long.valueOf(sequenceDetail)).addValue("code", sequenceDetail) .addValue("uomfrom", serviceChargeDetail.getUomFrom()).addValue("uomto", serviceChargeDetail.getUomTo()) .addValue("amountorpercentage", serviceChargeDetail.getAmountOrpercentage()).addValue(SERVICECHARGE, Long.valueOf(serviceCharge.getCode())) .addValue(TENANT, serviceChargeDetail.getTenantId()) .getValues()); } } namedParameterJdbcTemplate.batchUpdate(insertServiceCharge, batchValues.toArray(new Map[listOfServiceCharges.size()])); namedParameterJdbcTemplate.batchUpdate(insertServiceChargeDetails, batchArgs.toArray(new Map[listOfServiceChargeDetail.size()])); return serviceChargeRequest; }  @SuppressWarnings("unchecked") ServiceChargeReq create(final ServiceChargeReq serviceChargeRequest); @SuppressWarnings("unchecked") ServiceChargeReq update(final ServiceChargeReq serviceChargeRequest); List<ServiceCharge> pushCreateToQueue(final ServiceChargeReq serviceChargeRequest); List<ServiceCharge> pushUpdateToQueue(final ServiceChargeReq serviceChargeRequest); List<ServiceCharge> searchServiceChargesByCriteria(final ServiceChargeGetRequest serviceChargeGetRequest); List<ServiceCharge> convertToModel(final List<ServiceCharge> listOfServiceChargesFromDB,
            final List<ServiceChargeDetails> serviceChargeDetails); }
ServiceChargeRepository { @SuppressWarnings("unchecked") public ServiceChargeReq create(final ServiceChargeReq serviceChargeRequest) { final List<ServiceCharge> listOfServiceCharges = serviceChargeRequest.getServiceCharge(); final String insertServiceCharge = serviceChargeQueryBuilder.insertServiceChargeData(); final String insertServiceChargeDetails = serviceChargeQueryBuilder.insertServiceChargeDetailsData(); final List<ServiceChargeDetails> listOfServiceChargeDetail = new ArrayList<>(); for (final ServiceCharge servicecharge : listOfServiceCharges) listOfServiceChargeDetail.addAll(servicecharge.getChargeDetails()); final List<Map<String, Object>> batchValues = new ArrayList<>(listOfServiceCharges.size()); final List<Map<String, Object>> batchArgs = new ArrayList<>(listOfServiceChargeDetail.size()); for (final ServiceCharge serviceCharge : listOfServiceCharges) { batchValues.add(new MapSqlParameterSource("id", Long.valueOf(serviceCharge.getCode())) .addValue("code", serviceCharge.getCode()) .addValue("servicetype", serviceCharge.getServiceType()) .addValue("servicechargeapplicable", serviceCharge.getServiceChargeApplicable()) .addValue("servicechargetype", serviceCharge.getServiceChargeType()) .addValue("description", serviceCharge.getDescription()) .addValue("active", serviceCharge.getActive()) .addValue("effectivefrom", serviceCharge.getEffectiveFrom()) .addValue("effectiveto", serviceCharge.getEffectiveTo()).addValue("outsideulb", serviceCharge.getOutsideUlb()) .addValue(TENANT, serviceCharge.getTenantId()).addValue("createdby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", serviceChargeRequest.getRequestInfo() .getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).getValues()); final List<ServiceChargeDetails> listOfServiceChargeDetails = serviceCharge.getChargeDetails(); for (final ServiceChargeDetails serviceChargeDetail : listOfServiceChargeDetails) { final String sequenceDetail = codeGeneratorService.generate(ServiceChargeDetails.SEQ_SERVICECHARGEDETAILS); batchArgs.add(new MapSqlParameterSource("id", Long.valueOf(sequenceDetail)).addValue("code", sequenceDetail) .addValue("uomfrom", serviceChargeDetail.getUomFrom()).addValue("uomto", serviceChargeDetail.getUomTo()) .addValue("amountorpercentage", serviceChargeDetail.getAmountOrpercentage()).addValue(SERVICECHARGE, Long.valueOf(serviceCharge.getCode())) .addValue(TENANT, serviceChargeDetail.getTenantId()) .getValues()); } } namedParameterJdbcTemplate.batchUpdate(insertServiceCharge, batchValues.toArray(new Map[listOfServiceCharges.size()])); namedParameterJdbcTemplate.batchUpdate(insertServiceChargeDetails, batchArgs.toArray(new Map[listOfServiceChargeDetail.size()])); return serviceChargeRequest; }  @SuppressWarnings("unchecked") ServiceChargeReq create(final ServiceChargeReq serviceChargeRequest); @SuppressWarnings("unchecked") ServiceChargeReq update(final ServiceChargeReq serviceChargeRequest); List<ServiceCharge> pushCreateToQueue(final ServiceChargeReq serviceChargeRequest); List<ServiceCharge> pushUpdateToQueue(final ServiceChargeReq serviceChargeRequest); List<ServiceCharge> searchServiceChargesByCriteria(final ServiceChargeGetRequest serviceChargeGetRequest); List<ServiceCharge> convertToModel(final List<ServiceCharge> listOfServiceChargesFromDB,
            final List<ServiceChargeDetails> serviceChargeDetails); static final String TENANT; static final String SERVICECHARGE; static final Logger logger; }