@Test public void testUpdate() { final AssetCategoryRequest assetCategoryRequest = new AssetCategoryRequest(); final RequestInfo requestInfo = new RequestInfo(); final User user = new User(); user.setId(1l); requestInfo.setUserInfo(user); assetCategoryRequest.setRequestInfo(requestInfo); final AssetCategory assetCategory = getAssetCategory(); assetCategoryRequest.setAssetCategory(assetCategory); when(assetCategoryQueryBuilder.getUpdateQuery()).thenReturn(StringUtils.EMPTY); when(jdbcTemplate.update(any(String.class), any(Object[].class))).thenReturn(1); assertTrue(assetCategory.equals(assetCategoryRepository.update(assetCategoryRequest))); }
public AssetCategory update(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getUpdateQuery(); mapper.setSerializationInclusion(Include.NON_NULL); final AssetCategory assetCategory2 = new AssetCategory(); assetCategory2.setAssetFieldsDefination(assetCategory.getAssetFieldsDefination()); String customFields = null; String assetCategoryType = null; String depreciationMethod = null; if (assetCategory.getAssetCategoryType() != null) assetCategoryType = assetCategory.getAssetCategoryType().toString(); if (assetCategory.getDepreciationMethod() != null) depreciationMethod = assetCategory.getDepreciationMethod().toString(); try { customFields = mapper.writeValueAsString(assetCategory2); log.info("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.info("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset(), assetCategory.getCode(), assetCategory.getTenantId() }; try { log.info("asset category update query::" + queryStr + "," + Arrays.toString(obj)); final int i = jdbcTemplate.update(queryStr, obj); log.info("output of update asset category query : " + i); } catch (final Exception exception) { log.info("the exception in assetcategory update :" + exception); throw new RuntimeException("exceptions occured while persisting the asset category update "); } return assetCategory; }
AssetCategoryRepository { public AssetCategory update(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getUpdateQuery(); mapper.setSerializationInclusion(Include.NON_NULL); final AssetCategory assetCategory2 = new AssetCategory(); assetCategory2.setAssetFieldsDefination(assetCategory.getAssetFieldsDefination()); String customFields = null; String assetCategoryType = null; String depreciationMethod = null; if (assetCategory.getAssetCategoryType() != null) assetCategoryType = assetCategory.getAssetCategoryType().toString(); if (assetCategory.getDepreciationMethod() != null) depreciationMethod = assetCategory.getDepreciationMethod().toString(); try { customFields = mapper.writeValueAsString(assetCategory2); log.info("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.info("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset(), assetCategory.getCode(), assetCategory.getTenantId() }; try { log.info("asset category update query::" + queryStr + "," + Arrays.toString(obj)); final int i = jdbcTemplate.update(queryStr, obj); log.info("output of update asset category query : " + i); } catch (final Exception exception) { log.info("the exception in assetcategory update :" + exception); throw new RuntimeException("exceptions occured while persisting the asset category update "); } return assetCategory; } }
AssetCategoryRepository { public AssetCategory update(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getUpdateQuery(); mapper.setSerializationInclusion(Include.NON_NULL); final AssetCategory assetCategory2 = new AssetCategory(); assetCategory2.setAssetFieldsDefination(assetCategory.getAssetFieldsDefination()); String customFields = null; String assetCategoryType = null; String depreciationMethod = null; if (assetCategory.getAssetCategoryType() != null) assetCategoryType = assetCategory.getAssetCategoryType().toString(); if (assetCategory.getDepreciationMethod() != null) depreciationMethod = assetCategory.getDepreciationMethod().toString(); try { customFields = mapper.writeValueAsString(assetCategory2); log.info("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.info("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset(), assetCategory.getCode(), assetCategory.getTenantId() }; try { log.info("asset category update query::" + queryStr + "," + Arrays.toString(obj)); final int i = jdbcTemplate.update(queryStr, obj); log.info("output of update asset category query : " + i); } catch (final Exception exception) { log.info("the exception in assetcategory update :" + exception); throw new RuntimeException("exceptions occured while persisting the asset category update "); } return assetCategory; }  }
AssetCategoryRepository { public AssetCategory update(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getUpdateQuery(); mapper.setSerializationInclusion(Include.NON_NULL); final AssetCategory assetCategory2 = new AssetCategory(); assetCategory2.setAssetFieldsDefination(assetCategory.getAssetFieldsDefination()); String customFields = null; String assetCategoryType = null; String depreciationMethod = null; if (assetCategory.getAssetCategoryType() != null) assetCategoryType = assetCategory.getAssetCategoryType().toString(); if (assetCategory.getDepreciationMethod() != null) depreciationMethod = assetCategory.getDepreciationMethod().toString(); try { customFields = mapper.writeValueAsString(assetCategory2); log.info("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.info("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset(), assetCategory.getCode(), assetCategory.getTenantId() }; try { log.info("asset category update query::" + queryStr + "," + Arrays.toString(obj)); final int i = jdbcTemplate.update(queryStr, obj); log.info("output of update asset category query : " + i); } catch (final Exception exception) { log.info("the exception in assetcategory update :" + exception); throw new RuntimeException("exceptions occured while persisting the asset category update "); } return assetCategory; }  List<AssetCategory> search(final AssetCategoryCriteria assetCategoryCriteria); AssetCategory create(final AssetCategoryRequest assetCategoryRequest); AssetCategory update(final AssetCategoryRequest assetCategoryRequest); }
AssetCategoryRepository { public AssetCategory update(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getUpdateQuery(); mapper.setSerializationInclusion(Include.NON_NULL); final AssetCategory assetCategory2 = new AssetCategory(); assetCategory2.setAssetFieldsDefination(assetCategory.getAssetFieldsDefination()); String customFields = null; String assetCategoryType = null; String depreciationMethod = null; if (assetCategory.getAssetCategoryType() != null) assetCategoryType = assetCategory.getAssetCategoryType().toString(); if (assetCategory.getDepreciationMethod() != null) depreciationMethod = assetCategory.getDepreciationMethod().toString(); try { customFields = mapper.writeValueAsString(assetCategory2); log.info("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.info("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset(), assetCategory.getCode(), assetCategory.getTenantId() }; try { log.info("asset category update query::" + queryStr + "," + Arrays.toString(obj)); final int i = jdbcTemplate.update(queryStr, obj); log.info("output of update asset category query : " + i); } catch (final Exception exception) { log.info("the exception in assetcategory update :" + exception); throw new RuntimeException("exceptions occured while persisting the asset category update "); } return assetCategory; }  List<AssetCategory> search(final AssetCategoryCriteria assetCategoryCriteria); AssetCategory create(final AssetCategoryRequest assetCategoryRequest); AssetCategory update(final AssetCategoryRequest assetCategoryRequest);  }