@Test public void test_Should_Update_WaterSource() { final SourceTypeRequest waterSourceTypeRequest = new SourceTypeRequest(); final RequestInfo requestInfo = new RequestInfo(); final User user = new User(); user.setId(1l); requestInfo.setUserInfo(user); waterSourceTypeRequest.setRequestInfo(requestInfo); final List<SourceType> waterSourceList = new ArrayList<>(); waterSourceList.add(getWaterSourceType()); waterSourceTypeRequest.setSourceTypes(waterSourceList); when(jdbcTemplate.update(any(String.class), any(Object[].class))).thenReturn(1); assertTrue(waterSourceTypeRequest .equals(waterSourceTypeRepository.update(waterSourceTypeRequest))); }
public SourceTypeRequest update(final SourceTypeRequest sourceTypeRequest) { log.info("SourceTypeRequest::" + sourceTypeRequest); final String waterSourceUpdate = SourceTypeQueryBuilder.updateWaterSourceTypeQuery(); final List<SourceType> waterSourceList = sourceTypeRequest.getSourceTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(waterSourceList.size()); for (final SourceType waterSource : waterSourceList) batchValues.add( new MapSqlParameterSource("name", waterSource.getName()) .addValue("description", waterSource.getDescription()) .addValue("active", waterSource.getActive()) .addValue("sourcecapacity", waterSource.getSourceCapacity()) .addValue("ulbreserved", waterSource.getUlbReserved()) .addValue("lastmodifiedby", Long.valueOf(sourceTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", waterSource.getCode()) .addValue("tenantid", waterSource.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(waterSourceUpdate, batchValues.toArray(new Map[waterSourceList.size()])); return sourceTypeRequest; }
SourceTypeRepository { public SourceTypeRequest update(final SourceTypeRequest sourceTypeRequest) { log.info("SourceTypeRequest::" + sourceTypeRequest); final String waterSourceUpdate = SourceTypeQueryBuilder.updateWaterSourceTypeQuery(); final List<SourceType> waterSourceList = sourceTypeRequest.getSourceTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(waterSourceList.size()); for (final SourceType waterSource : waterSourceList) batchValues.add( new MapSqlParameterSource("name", waterSource.getName()) .addValue("description", waterSource.getDescription()) .addValue("active", waterSource.getActive()) .addValue("sourcecapacity", waterSource.getSourceCapacity()) .addValue("ulbreserved", waterSource.getUlbReserved()) .addValue("lastmodifiedby", Long.valueOf(sourceTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", waterSource.getCode()) .addValue("tenantid", waterSource.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(waterSourceUpdate, batchValues.toArray(new Map[waterSourceList.size()])); return sourceTypeRequest; } }
SourceTypeRepository { public SourceTypeRequest update(final SourceTypeRequest sourceTypeRequest) { log.info("SourceTypeRequest::" + sourceTypeRequest); final String waterSourceUpdate = SourceTypeQueryBuilder.updateWaterSourceTypeQuery(); final List<SourceType> waterSourceList = sourceTypeRequest.getSourceTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(waterSourceList.size()); for (final SourceType waterSource : waterSourceList) batchValues.add( new MapSqlParameterSource("name", waterSource.getName()) .addValue("description", waterSource.getDescription()) .addValue("active", waterSource.getActive()) .addValue("sourcecapacity", waterSource.getSourceCapacity()) .addValue("ulbreserved", waterSource.getUlbReserved()) .addValue("lastmodifiedby", Long.valueOf(sourceTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", waterSource.getCode()) .addValue("tenantid", waterSource.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(waterSourceUpdate, batchValues.toArray(new Map[waterSourceList.size()])); return sourceTypeRequest; }  }
SourceTypeRepository { public SourceTypeRequest update(final SourceTypeRequest sourceTypeRequest) { log.info("SourceTypeRequest::" + sourceTypeRequest); final String waterSourceUpdate = SourceTypeQueryBuilder.updateWaterSourceTypeQuery(); final List<SourceType> waterSourceList = sourceTypeRequest.getSourceTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(waterSourceList.size()); for (final SourceType waterSource : waterSourceList) batchValues.add( new MapSqlParameterSource("name", waterSource.getName()) .addValue("description", waterSource.getDescription()) .addValue("active", waterSource.getActive()) .addValue("sourcecapacity", waterSource.getSourceCapacity()) .addValue("ulbreserved", waterSource.getUlbReserved()) .addValue("lastmodifiedby", Long.valueOf(sourceTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", waterSource.getCode()) .addValue("tenantid", waterSource.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(waterSourceUpdate, batchValues.toArray(new Map[waterSourceList.size()])); return sourceTypeRequest; }  SourceTypeRequest create(final SourceTypeRequest sourceTypeRequest); SourceTypeRequest update(final SourceTypeRequest sourceTypeRequest); boolean checkWaterSourceTypeByNameAndCode(final String code, final String name, final String tenantId); List<SourceType> findForCriteria(final SourceTypeGetRequest sourceTypeGetRequest); }
SourceTypeRepository { public SourceTypeRequest update(final SourceTypeRequest sourceTypeRequest) { log.info("SourceTypeRequest::" + sourceTypeRequest); final String waterSourceUpdate = SourceTypeQueryBuilder.updateWaterSourceTypeQuery(); final List<SourceType> waterSourceList = sourceTypeRequest.getSourceTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(waterSourceList.size()); for (final SourceType waterSource : waterSourceList) batchValues.add( new MapSqlParameterSource("name", waterSource.getName()) .addValue("description", waterSource.getDescription()) .addValue("active", waterSource.getActive()) .addValue("sourcecapacity", waterSource.getSourceCapacity()) .addValue("ulbreserved", waterSource.getUlbReserved()) .addValue("lastmodifiedby", Long.valueOf(sourceTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", waterSource.getCode()) .addValue("tenantid", waterSource.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(waterSourceUpdate, batchValues.toArray(new Map[waterSourceList.size()])); return sourceTypeRequest; }  SourceTypeRequest create(final SourceTypeRequest sourceTypeRequest); SourceTypeRequest update(final SourceTypeRequest sourceTypeRequest); boolean checkWaterSourceTypeByNameAndCode(final String code, final String name, final String tenantId); List<SourceType> findForCriteria(final SourceTypeGetRequest sourceTypeGetRequest);  }