@SuppressWarnings("unchecked") @Test public void test_should_search_serviceCharge_based_on_certain_Criteria() { final Map<String, Object> preparedStatementValues = new HashMap<>(); when(serviceChargeQueryBuilder.getQuery(getServiceChargeGetCriteria(), preparedStatementValues)) .thenReturn("Select sc.id as sc_id,sc.code" + " as sc_code,sc.servicetype as sc_servicetype,sc.servicechargeapplicable" + " as sc_servicechargeapplicable," + "sc.servicechargetype as sc_servicechargetype,sc.description as sc_description," + "sc.active as sc_active,sc.effectivefrom as sc_effectivefrom,sc.effectiveto" + " as sc_effectiveto,sc.outsideulb as sc_outsideulb,sc.tenantid as sc_tenantid," + "sc.createdby as sc_createdby,sc.createddate as sc_createddate,sc.lastmodifiedby" + " as sc_lastmodifiedby,sc.lastmodifieddate as sc_lastmodifieddate from" + " egwtr_servicecharge sc WHERE sc.id IN (:ids) AND sc.tenantid = :tenantId AND sc.servicetype = :serviceType" + " AND sc.outsideulb = :outsideUlb ORDER BY sc.serviceChargeType desc"); when(serviceChargeQueryBuilder.insertServiceChargeDetailsData()) .thenReturn("Select scd.id as scd_id,scd.code as scd_code," + "scd.uomfrom as scd_uomfrom,scd.uomto as scd_uomto," + "scd.amountorpercentage as scd_amountorpercentage,scd.servicecharge as scd_servicecharge," + "scd.tenantid as scd_tenantid from egwtr_servicecharge_details scd" + " where scd.servicecharge = :servicecharge and scd.tenantid = :tenantid"); when(namedParameterJdbcTemplate.query(any(String.class), anyMap(), any(org.springframework.jdbc.core.RowMapper.class))) .thenReturn(getListOfServiceChargesForSearch(), getListOfServiceChargeDetails1ForSearch(), getListOfServiceChargeDetails2ForSearch()); assertThat(serviceChargeRepository.searchServiceChargesByCriteria(getServiceChargeGetCriteria()) .equals(getListOfServiceChargesAssociatedForSearch())); }
public List<ServiceCharge> searchServiceChargesByCriteria(final ServiceChargeGetRequest serviceChargeGetRequest) { final Map<String, Object> preparedStatementValues = new HashMap<>(); final List<ServiceChargeDetails> serviceChargeDetails = new ArrayList<>(); final String getServiceChargeQuery = serviceChargeQueryBuilder.getQuery(serviceChargeGetRequest, preparedStatementValues); final List<ServiceCharge> listOfServiceChargesFromDB = namedParameterJdbcTemplate.query(getServiceChargeQuery, preparedStatementValues, serviceChargeRowMapper); final String serviceChargeDetailsQuery = serviceChargeQueryBuilder.getServiceChargeDetailsQuery(); for (final ServiceCharge serviceCharge : listOfServiceChargesFromDB) { final Map<String, Object> preparedVals = new HashMap<>(); preparedVals.put("servicecharge", Long.valueOf(serviceCharge.getCode())); preparedVals.put("tenantid", serviceCharge.getTenantId()); final List<ServiceChargeDetails> listOfServiceChargeDetailsFromDB = namedParameterJdbcTemplate.query( serviceChargeDetailsQuery, preparedVals, serviceChargeDetailsRowmapper); serviceChargeDetails.addAll(listOfServiceChargeDetailsFromDB); } return convertToModel(listOfServiceChargesFromDB, serviceChargeDetails); }
ServiceChargeRepository { public List<ServiceCharge> searchServiceChargesByCriteria(final ServiceChargeGetRequest serviceChargeGetRequest) { final Map<String, Object> preparedStatementValues = new HashMap<>(); final List<ServiceChargeDetails> serviceChargeDetails = new ArrayList<>(); final String getServiceChargeQuery = serviceChargeQueryBuilder.getQuery(serviceChargeGetRequest, preparedStatementValues); final List<ServiceCharge> listOfServiceChargesFromDB = namedParameterJdbcTemplate.query(getServiceChargeQuery, preparedStatementValues, serviceChargeRowMapper); final String serviceChargeDetailsQuery = serviceChargeQueryBuilder.getServiceChargeDetailsQuery(); for (final ServiceCharge serviceCharge : listOfServiceChargesFromDB) { final Map<String, Object> preparedVals = new HashMap<>(); preparedVals.put("servicecharge", Long.valueOf(serviceCharge.getCode())); preparedVals.put("tenantid", serviceCharge.getTenantId()); final List<ServiceChargeDetails> listOfServiceChargeDetailsFromDB = namedParameterJdbcTemplate.query( serviceChargeDetailsQuery, preparedVals, serviceChargeDetailsRowmapper); serviceChargeDetails.addAll(listOfServiceChargeDetailsFromDB); } return convertToModel(listOfServiceChargesFromDB, serviceChargeDetails); } }
ServiceChargeRepository { public List<ServiceCharge> searchServiceChargesByCriteria(final ServiceChargeGetRequest serviceChargeGetRequest) { final Map<String, Object> preparedStatementValues = new HashMap<>(); final List<ServiceChargeDetails> serviceChargeDetails = new ArrayList<>(); final String getServiceChargeQuery = serviceChargeQueryBuilder.getQuery(serviceChargeGetRequest, preparedStatementValues); final List<ServiceCharge> listOfServiceChargesFromDB = namedParameterJdbcTemplate.query(getServiceChargeQuery, preparedStatementValues, serviceChargeRowMapper); final String serviceChargeDetailsQuery = serviceChargeQueryBuilder.getServiceChargeDetailsQuery(); for (final ServiceCharge serviceCharge : listOfServiceChargesFromDB) { final Map<String, Object> preparedVals = new HashMap<>(); preparedVals.put("servicecharge", Long.valueOf(serviceCharge.getCode())); preparedVals.put("tenantid", serviceCharge.getTenantId()); final List<ServiceChargeDetails> listOfServiceChargeDetailsFromDB = namedParameterJdbcTemplate.query( serviceChargeDetailsQuery, preparedVals, serviceChargeDetailsRowmapper); serviceChargeDetails.addAll(listOfServiceChargeDetailsFromDB); } return convertToModel(listOfServiceChargesFromDB, serviceChargeDetails); }  }
ServiceChargeRepository { public List<ServiceCharge> searchServiceChargesByCriteria(final ServiceChargeGetRequest serviceChargeGetRequest) { final Map<String, Object> preparedStatementValues = new HashMap<>(); final List<ServiceChargeDetails> serviceChargeDetails = new ArrayList<>(); final String getServiceChargeQuery = serviceChargeQueryBuilder.getQuery(serviceChargeGetRequest, preparedStatementValues); final List<ServiceCharge> listOfServiceChargesFromDB = namedParameterJdbcTemplate.query(getServiceChargeQuery, preparedStatementValues, serviceChargeRowMapper); final String serviceChargeDetailsQuery = serviceChargeQueryBuilder.getServiceChargeDetailsQuery(); for (final ServiceCharge serviceCharge : listOfServiceChargesFromDB) { final Map<String, Object> preparedVals = new HashMap<>(); preparedVals.put("servicecharge", Long.valueOf(serviceCharge.getCode())); preparedVals.put("tenantid", serviceCharge.getTenantId()); final List<ServiceChargeDetails> listOfServiceChargeDetailsFromDB = namedParameterJdbcTemplate.query( serviceChargeDetailsQuery, preparedVals, serviceChargeDetailsRowmapper); serviceChargeDetails.addAll(listOfServiceChargeDetailsFromDB); } return convertToModel(listOfServiceChargesFromDB, serviceChargeDetails); }  @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 { public List<ServiceCharge> searchServiceChargesByCriteria(final ServiceChargeGetRequest serviceChargeGetRequest) { final Map<String, Object> preparedStatementValues = new HashMap<>(); final List<ServiceChargeDetails> serviceChargeDetails = new ArrayList<>(); final String getServiceChargeQuery = serviceChargeQueryBuilder.getQuery(serviceChargeGetRequest, preparedStatementValues); final List<ServiceCharge> listOfServiceChargesFromDB = namedParameterJdbcTemplate.query(getServiceChargeQuery, preparedStatementValues, serviceChargeRowMapper); final String serviceChargeDetailsQuery = serviceChargeQueryBuilder.getServiceChargeDetailsQuery(); for (final ServiceCharge serviceCharge : listOfServiceChargesFromDB) { final Map<String, Object> preparedVals = new HashMap<>(); preparedVals.put("servicecharge", Long.valueOf(serviceCharge.getCode())); preparedVals.put("tenantid", serviceCharge.getTenantId()); final List<ServiceChargeDetails> listOfServiceChargeDetailsFromDB = namedParameterJdbcTemplate.query( serviceChargeDetailsQuery, preparedVals, serviceChargeDetailsRowmapper); serviceChargeDetails.addAll(listOfServiceChargeDetailsFromDB); } return convertToModel(listOfServiceChargesFromDB, serviceChargeDetails); }  @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; }