@Test public void test_Should_Update_WaterSource() { final SupplyTypeRequest waterSourceTypeRequest = new SupplyTypeRequest(); final RequestInfo requestInfo = new RequestInfo(); final User user = new User(); user.setId(1l); requestInfo.setUserInfo(user); waterSourceTypeRequest.setRequestInfo(requestInfo); final List<SupplyType> waterSourceList = new ArrayList<>(); waterSourceList.add(getSupplyType()); waterSourceTypeRequest.setSupplyTypes(waterSourceList); when(jdbcTemplate.update(any(String.class), any(Object[].class))).thenReturn(1); assertTrue(waterSourceTypeRequest .equals(supplyTypeRepository.update(waterSourceTypeRequest))); }
public SupplyTypeRequest update(final SupplyTypeRequest supplyTypeRequest) { final String updateQuery = SupplyTypeQueryBuilder.updateSupplyTypeQuery(); final List<SupplyType> supplyTypeList = supplyTypeRequest.getSupplyTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(supplyTypeList.size()); for (final SupplyType supplyType : supplyTypeList) batchValues.add( new MapSqlParameterSource("name", supplyType.getName()) .addValue("description", supplyType.getDescription()).addValue("active", supplyType.getActive()) .addValue("lastmodifiedby", Long.valueOf(supplyTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", supplyType.getCode()) .addValue("tenantid", supplyType.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(updateQuery, batchValues.toArray(new Map[supplyTypeList.size()])); return supplyTypeRequest; }
SupplyTypeRepository { public SupplyTypeRequest update(final SupplyTypeRequest supplyTypeRequest) { final String updateQuery = SupplyTypeQueryBuilder.updateSupplyTypeQuery(); final List<SupplyType> supplyTypeList = supplyTypeRequest.getSupplyTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(supplyTypeList.size()); for (final SupplyType supplyType : supplyTypeList) batchValues.add( new MapSqlParameterSource("name", supplyType.getName()) .addValue("description", supplyType.getDescription()).addValue("active", supplyType.getActive()) .addValue("lastmodifiedby", Long.valueOf(supplyTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", supplyType.getCode()) .addValue("tenantid", supplyType.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(updateQuery, batchValues.toArray(new Map[supplyTypeList.size()])); return supplyTypeRequest; } }
SupplyTypeRepository { public SupplyTypeRequest update(final SupplyTypeRequest supplyTypeRequest) { final String updateQuery = SupplyTypeQueryBuilder.updateSupplyTypeQuery(); final List<SupplyType> supplyTypeList = supplyTypeRequest.getSupplyTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(supplyTypeList.size()); for (final SupplyType supplyType : supplyTypeList) batchValues.add( new MapSqlParameterSource("name", supplyType.getName()) .addValue("description", supplyType.getDescription()).addValue("active", supplyType.getActive()) .addValue("lastmodifiedby", Long.valueOf(supplyTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", supplyType.getCode()) .addValue("tenantid", supplyType.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(updateQuery, batchValues.toArray(new Map[supplyTypeList.size()])); return supplyTypeRequest; }  }
SupplyTypeRepository { public SupplyTypeRequest update(final SupplyTypeRequest supplyTypeRequest) { final String updateQuery = SupplyTypeQueryBuilder.updateSupplyTypeQuery(); final List<SupplyType> supplyTypeList = supplyTypeRequest.getSupplyTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(supplyTypeList.size()); for (final SupplyType supplyType : supplyTypeList) batchValues.add( new MapSqlParameterSource("name", supplyType.getName()) .addValue("description", supplyType.getDescription()).addValue("active", supplyType.getActive()) .addValue("lastmodifiedby", Long.valueOf(supplyTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", supplyType.getCode()) .addValue("tenantid", supplyType.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(updateQuery, batchValues.toArray(new Map[supplyTypeList.size()])); return supplyTypeRequest; }  SupplyTypeRequest create(final SupplyTypeRequest supplyTypeRequest); SupplyTypeRequest update(final SupplyTypeRequest supplyTypeRequest); boolean checkSupplyTypeByNameAndCode(final String code, final String name, final String tenantId); List<SupplyType> findForCriteria(final SupplyTypeGetRequest supplyTypeGetRequest); }
SupplyTypeRepository { public SupplyTypeRequest update(final SupplyTypeRequest supplyTypeRequest) { final String updateQuery = SupplyTypeQueryBuilder.updateSupplyTypeQuery(); final List<SupplyType> supplyTypeList = supplyTypeRequest.getSupplyTypes(); final List<Map<String, Object>> batchValues = new ArrayList<>(supplyTypeList.size()); for (final SupplyType supplyType : supplyTypeList) batchValues.add( new MapSqlParameterSource("name", supplyType.getName()) .addValue("description", supplyType.getDescription()).addValue("active", supplyType.getActive()) .addValue("lastmodifiedby", Long.valueOf(supplyTypeRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())) .addValue("code", supplyType.getCode()) .addValue("tenantid", supplyType.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(updateQuery, batchValues.toArray(new Map[supplyTypeList.size()])); return supplyTypeRequest; }  SupplyTypeRequest create(final SupplyTypeRequest supplyTypeRequest); SupplyTypeRequest update(final SupplyTypeRequest supplyTypeRequest); boolean checkSupplyTypeByNameAndCode(final String code, final String name, final String tenantId); List<SupplyType> findForCriteria(final SupplyTypeGetRequest supplyTypeGetRequest);  }