@Test public final void testFetchRelated() { when(chartOfAccountRepository.findById(any(ChartOfAccount.class))).thenReturn(getChartOfAccount()); when(accountDetailTypeRepository.findById(any(AccountDetailType.class))).thenReturn(getAccountDetailType()); chartOfAccountDetails.add(getChartOfAccountDetail()); chartOfAccountDetailService.fetchRelated(chartOfAccountDetails); }
public List<ChartOfAccountDetail> fetchRelated(List<ChartOfAccountDetail> chartofaccountdetails) { for (ChartOfAccountDetail chartOfAccountDetail : chartofaccountdetails) { chartOfAccountDetail.setTenantId(ApplicationThreadLocals.getTenantId().get()); if (chartOfAccountDetail.getChartOfAccount() != null) { ChartOfAccount chartOfAccount = chartOfAccountRepository .findById(chartOfAccountDetail.getChartOfAccount()); if (chartOfAccount == null) { throw new InvalidDataException("chartOfAccount", "chartOfAccount.invalid", " Invalid chartOfAccount"); } chartOfAccountDetail.setChartOfAccount(chartOfAccount); } if (chartOfAccountDetail.getAccountDetailType() != null) { AccountDetailType accountDetailType = accountDetailTypeRepository .findById(chartOfAccountDetail.getAccountDetailType()); if (accountDetailType == null) { throw new InvalidDataException("accountDetailType", "accountDetailType.invalid", " Invalid accountDetailType"); } chartOfAccountDetail.setAccountDetailType(accountDetailType); } } return chartofaccountdetails; }
ChartOfAccountDetailService { public List<ChartOfAccountDetail> fetchRelated(List<ChartOfAccountDetail> chartofaccountdetails) { for (ChartOfAccountDetail chartOfAccountDetail : chartofaccountdetails) { chartOfAccountDetail.setTenantId(ApplicationThreadLocals.getTenantId().get()); if (chartOfAccountDetail.getChartOfAccount() != null) { ChartOfAccount chartOfAccount = chartOfAccountRepository .findById(chartOfAccountDetail.getChartOfAccount()); if (chartOfAccount == null) { throw new InvalidDataException("chartOfAccount", "chartOfAccount.invalid", " Invalid chartOfAccount"); } chartOfAccountDetail.setChartOfAccount(chartOfAccount); } if (chartOfAccountDetail.getAccountDetailType() != null) { AccountDetailType accountDetailType = accountDetailTypeRepository .findById(chartOfAccountDetail.getAccountDetailType()); if (accountDetailType == null) { throw new InvalidDataException("accountDetailType", "accountDetailType.invalid", " Invalid accountDetailType"); } chartOfAccountDetail.setAccountDetailType(accountDetailType); } } return chartofaccountdetails; } }
ChartOfAccountDetailService { public List<ChartOfAccountDetail> fetchRelated(List<ChartOfAccountDetail> chartofaccountdetails) { for (ChartOfAccountDetail chartOfAccountDetail : chartofaccountdetails) { chartOfAccountDetail.setTenantId(ApplicationThreadLocals.getTenantId().get()); if (chartOfAccountDetail.getChartOfAccount() != null) { ChartOfAccount chartOfAccount = chartOfAccountRepository .findById(chartOfAccountDetail.getChartOfAccount()); if (chartOfAccount == null) { throw new InvalidDataException("chartOfAccount", "chartOfAccount.invalid", " Invalid chartOfAccount"); } chartOfAccountDetail.setChartOfAccount(chartOfAccount); } if (chartOfAccountDetail.getAccountDetailType() != null) { AccountDetailType accountDetailType = accountDetailTypeRepository .findById(chartOfAccountDetail.getAccountDetailType()); if (accountDetailType == null) { throw new InvalidDataException("accountDetailType", "accountDetailType.invalid", " Invalid accountDetailType"); } chartOfAccountDetail.setAccountDetailType(accountDetailType); } } return chartofaccountdetails; }  }
ChartOfAccountDetailService { public List<ChartOfAccountDetail> fetchRelated(List<ChartOfAccountDetail> chartofaccountdetails) { for (ChartOfAccountDetail chartOfAccountDetail : chartofaccountdetails) { chartOfAccountDetail.setTenantId(ApplicationThreadLocals.getTenantId().get()); if (chartOfAccountDetail.getChartOfAccount() != null) { ChartOfAccount chartOfAccount = chartOfAccountRepository .findById(chartOfAccountDetail.getChartOfAccount()); if (chartOfAccount == null) { throw new InvalidDataException("chartOfAccount", "chartOfAccount.invalid", " Invalid chartOfAccount"); } chartOfAccountDetail.setChartOfAccount(chartOfAccount); } if (chartOfAccountDetail.getAccountDetailType() != null) { AccountDetailType accountDetailType = accountDetailTypeRepository .findById(chartOfAccountDetail.getAccountDetailType()); if (accountDetailType == null) { throw new InvalidDataException("accountDetailType", "accountDetailType.invalid", " Invalid accountDetailType"); } chartOfAccountDetail.setAccountDetailType(accountDetailType); } } return chartofaccountdetails; }  List<ChartOfAccountDetail> fetchRelated(List<ChartOfAccountDetail> chartofaccountdetails); @Transactional List<ChartOfAccountDetail> add(List<ChartOfAccountDetail> chartofaccountdetails, BindingResult errors); @Transactional List<ChartOfAccountDetail> update(List<ChartOfAccountDetail> chartofaccountdetails, BindingResult errors); void addToQue(ChartOfAccountDetailRequest request); Pagination<ChartOfAccountDetail> search(ChartOfAccountDetailSearch chartOfAccountDetailSearch, BindingResult errors); @Transactional ChartOfAccountDetail save(ChartOfAccountDetail chartOfAccountDetail); @Transactional ChartOfAccountDetail update(ChartOfAccountDetail chartOfAccountDetail); }
ChartOfAccountDetailService { public List<ChartOfAccountDetail> fetchRelated(List<ChartOfAccountDetail> chartofaccountdetails) { for (ChartOfAccountDetail chartOfAccountDetail : chartofaccountdetails) { chartOfAccountDetail.setTenantId(ApplicationThreadLocals.getTenantId().get()); if (chartOfAccountDetail.getChartOfAccount() != null) { ChartOfAccount chartOfAccount = chartOfAccountRepository .findById(chartOfAccountDetail.getChartOfAccount()); if (chartOfAccount == null) { throw new InvalidDataException("chartOfAccount", "chartOfAccount.invalid", " Invalid chartOfAccount"); } chartOfAccountDetail.setChartOfAccount(chartOfAccount); } if (chartOfAccountDetail.getAccountDetailType() != null) { AccountDetailType accountDetailType = accountDetailTypeRepository .findById(chartOfAccountDetail.getAccountDetailType()); if (accountDetailType == null) { throw new InvalidDataException("accountDetailType", "accountDetailType.invalid", " Invalid accountDetailType"); } chartOfAccountDetail.setAccountDetailType(accountDetailType); } } return chartofaccountdetails; }  List<ChartOfAccountDetail> fetchRelated(List<ChartOfAccountDetail> chartofaccountdetails); @Transactional List<ChartOfAccountDetail> add(List<ChartOfAccountDetail> chartofaccountdetails, BindingResult errors); @Transactional List<ChartOfAccountDetail> update(List<ChartOfAccountDetail> chartofaccountdetails, BindingResult errors); void addToQue(ChartOfAccountDetailRequest request); Pagination<ChartOfAccountDetail> search(ChartOfAccountDetailSearch chartOfAccountDetailSearch, BindingResult errors); @Transactional ChartOfAccountDetail save(ChartOfAccountDetail chartOfAccountDetail); @Transactional ChartOfAccountDetail update(ChartOfAccountDetail chartOfAccountDetail);  }