@Test public void testCreate() { 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.getInsertQuery()).thenReturn(StringUtils.EMPTY); when(jdbcTemplate.update(any(String.class), any(Object[].class))).thenReturn(1); assertTrue(assetCategory.equals(assetCategoryRepository.create(assetCategoryRequest))); }
public AssetCategory create(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getInsertQuery(); 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.debug("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.debug("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getId(), assetCategory.getName(), assetCategory.getCode(), assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, assetCategory.getTenantId(), requestInfo.getUserInfo().getId(), new Date().getTime(), requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset()}; try { jdbcTemplate.update(queryStr, obj); } catch (final Exception ex) { log.debug("the exception in assetcategory insert :" + ex); throw new RuntimeException("exceptions occured while persisting the assetcategory insert : " + ex.getMessage()); } return assetCategory; }
AssetCategoryRepository { public AssetCategory create(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getInsertQuery(); 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.debug("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.debug("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getId(), assetCategory.getName(), assetCategory.getCode(), assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, assetCategory.getTenantId(), requestInfo.getUserInfo().getId(), new Date().getTime(), requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset()}; try { jdbcTemplate.update(queryStr, obj); } catch (final Exception ex) { log.debug("the exception in assetcategory insert :" + ex); throw new RuntimeException("exceptions occured while persisting the assetcategory insert : " + ex.getMessage()); } return assetCategory; } }
AssetCategoryRepository { public AssetCategory create(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getInsertQuery(); 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.debug("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.debug("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getId(), assetCategory.getName(), assetCategory.getCode(), assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, assetCategory.getTenantId(), requestInfo.getUserInfo().getId(), new Date().getTime(), requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset()}; try { jdbcTemplate.update(queryStr, obj); } catch (final Exception ex) { log.debug("the exception in assetcategory insert :" + ex); throw new RuntimeException("exceptions occured while persisting the assetcategory insert : " + ex.getMessage()); } return assetCategory; }  }
AssetCategoryRepository { public AssetCategory create(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getInsertQuery(); 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.debug("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.debug("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getId(), assetCategory.getName(), assetCategory.getCode(), assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, assetCategory.getTenantId(), requestInfo.getUserInfo().getId(), new Date().getTime(), requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset()}; try { jdbcTemplate.update(queryStr, obj); } catch (final Exception ex) { log.debug("the exception in assetcategory insert :" + ex); throw new RuntimeException("exceptions occured while persisting the assetcategory insert : " + ex.getMessage()); } return assetCategory; }  List<AssetCategory> search(final AssetCategoryCriteria assetCategoryCriteria); AssetCategory create(final AssetCategoryRequest assetCategoryRequest); AssetCategory update(final AssetCategoryRequest assetCategoryRequest); }
AssetCategoryRepository { public AssetCategory create(final AssetCategoryRequest assetCategoryRequest) { final RequestInfo requestInfo = assetCategoryRequest.getRequestInfo(); final AssetCategory assetCategory = assetCategoryRequest.getAssetCategory(); final String queryStr = assetCategoryQueryBuilder.getInsertQuery(); 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.debug("customFields:::" + customFields); } catch (final JsonProcessingException e) { log.debug("the exception in assetcategory customfileds mapping :" + e); throw new RuntimeException("the exception in assetcategory customfileds mapping"); } final Object[] obj = new Object[] { assetCategory.getId(), assetCategory.getName(), assetCategory.getCode(), assetCategory.getParent(), assetCategoryType, depreciationMethod, assetCommonService.getDepreciationRate(assetCategory.getDepreciationRate()), assetCategory.getAssetAccount(), assetCategory.getAccumulatedDepreciationAccount(), assetCategory.getRevaluationReserveAccount(), assetCategory.getDepreciationExpenseAccount(), assetCategory.getUnitOfMeasurement(), customFields, assetCategory.getTenantId(), requestInfo.getUserInfo().getId(), new Date().getTime(), requestInfo.getUserInfo().getId(), new Date().getTime(), assetCategory.getIsAssetAllow(), assetCategory.getVersion(), assetCategory.getUsedForLease(),assetCategory.getLifeOfTheAsset()}; try { jdbcTemplate.update(queryStr, obj); } catch (final Exception ex) { log.debug("the exception in assetcategory insert :" + ex); throw new RuntimeException("exceptions occured while persisting the assetcategory insert : " + ex.getMessage()); } return assetCategory; }  List<AssetCategory> search(final AssetCategoryCriteria assetCategoryCriteria); AssetCategory create(final AssetCategoryRequest assetCategoryRequest); AssetCategory update(final AssetCategoryRequest assetCategoryRequest);  }