@Test(expected = InvalidDataException.class) public final void test_fetch_null_for_budget_detail() { final List<BudgetReAppropriation> budgets = getBudgetReAppropriations(); final BudgetDetail expextedResult = BudgetDetail.builder().id("1").build(); expextedResult.setTenantId("tenantId"); budgets.get(0).setBudgetDetail(expextedResult); when(budgetDetailRepository.findById(null)).thenReturn(expextedResult); budgetReAppropriationService.fetchRelated(budgets); }
public List<BudgetReAppropriation> fetchRelated(final List<BudgetReAppropriation> budgetreappropriations) { if (budgetreappropriations != null) for (final BudgetReAppropriation budgetReAppropriation : budgetreappropriations) if (budgetReAppropriation.getBudgetDetail() != null && budgetReAppropriation.getBudgetDetail().getId() != null && budgetReAppropriation.getBudgetDetail().getTenantId() != null) { final BudgetDetail budgetDetail = budgetDetailRepository .findById(budgetReAppropriation.getBudgetDetail()); if (budgetDetail == null) throw new InvalidDataException("budgetDetail", "budgetDetail.invalid", " Invalid budgetDetail"); budgetReAppropriation.setBudgetDetail(budgetDetail); } return budgetreappropriations; }
BudgetReAppropriationService { public List<BudgetReAppropriation> fetchRelated(final List<BudgetReAppropriation> budgetreappropriations) { if (budgetreappropriations != null) for (final BudgetReAppropriation budgetReAppropriation : budgetreappropriations) if (budgetReAppropriation.getBudgetDetail() != null && budgetReAppropriation.getBudgetDetail().getId() != null && budgetReAppropriation.getBudgetDetail().getTenantId() != null) { final BudgetDetail budgetDetail = budgetDetailRepository .findById(budgetReAppropriation.getBudgetDetail()); if (budgetDetail == null) throw new InvalidDataException("budgetDetail", "budgetDetail.invalid", " Invalid budgetDetail"); budgetReAppropriation.setBudgetDetail(budgetDetail); } return budgetreappropriations; } }
BudgetReAppropriationService { public List<BudgetReAppropriation> fetchRelated(final List<BudgetReAppropriation> budgetreappropriations) { if (budgetreappropriations != null) for (final BudgetReAppropriation budgetReAppropriation : budgetreappropriations) if (budgetReAppropriation.getBudgetDetail() != null && budgetReAppropriation.getBudgetDetail().getId() != null && budgetReAppropriation.getBudgetDetail().getTenantId() != null) { final BudgetDetail budgetDetail = budgetDetailRepository .findById(budgetReAppropriation.getBudgetDetail()); if (budgetDetail == null) throw new InvalidDataException("budgetDetail", "budgetDetail.invalid", " Invalid budgetDetail"); budgetReAppropriation.setBudgetDetail(budgetDetail); } return budgetreappropriations; } @Autowired  BudgetReAppropriationService(final BudgetReAppropriationRepository budgetReAppropriationRepository,
            final SmartValidator validator, final BudgetDetailRepository budgetDetailRepository); }
BudgetReAppropriationService { public List<BudgetReAppropriation> fetchRelated(final List<BudgetReAppropriation> budgetreappropriations) { if (budgetreappropriations != null) for (final BudgetReAppropriation budgetReAppropriation : budgetreappropriations) if (budgetReAppropriation.getBudgetDetail() != null && budgetReAppropriation.getBudgetDetail().getId() != null && budgetReAppropriation.getBudgetDetail().getTenantId() != null) { final BudgetDetail budgetDetail = budgetDetailRepository .findById(budgetReAppropriation.getBudgetDetail()); if (budgetDetail == null) throw new InvalidDataException("budgetDetail", "budgetDetail.invalid", " Invalid budgetDetail"); budgetReAppropriation.setBudgetDetail(budgetDetail); } return budgetreappropriations; } @Autowired  BudgetReAppropriationService(final BudgetReAppropriationRepository budgetReAppropriationRepository,
            final SmartValidator validator, final BudgetDetailRepository budgetDetailRepository); @Transactional List<BudgetReAppropriation> create(List<BudgetReAppropriation> budgetReAppropriations, final BindingResult errors,
            final RequestInfo requestInfo); @Transactional List<BudgetReAppropriation> update(List<BudgetReAppropriation> budgetReAppropriations, final BindingResult errors,
            final RequestInfo requestInfo); @Transactional List<BudgetReAppropriation> delete(List<BudgetReAppropriation> budgetReAppropriations, final BindingResult errors,
            final RequestInfo requestInfo); List<BudgetReAppropriation> fetchRelated(final List<BudgetReAppropriation> budgetreappropriations); Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch budgetReAppropriationSearch); @Transactional BudgetReAppropriation save(final BudgetReAppropriation budgetReAppropriation); @Transactional BudgetReAppropriation update(final BudgetReAppropriation budgetReAppropriation); @Transactional BudgetReAppropriation delete(final BudgetReAppropriation budgetReAppropriation); }
BudgetReAppropriationService { public List<BudgetReAppropriation> fetchRelated(final List<BudgetReAppropriation> budgetreappropriations) { if (budgetreappropriations != null) for (final BudgetReAppropriation budgetReAppropriation : budgetreappropriations) if (budgetReAppropriation.getBudgetDetail() != null && budgetReAppropriation.getBudgetDetail().getId() != null && budgetReAppropriation.getBudgetDetail().getTenantId() != null) { final BudgetDetail budgetDetail = budgetDetailRepository .findById(budgetReAppropriation.getBudgetDetail()); if (budgetDetail == null) throw new InvalidDataException("budgetDetail", "budgetDetail.invalid", " Invalid budgetDetail"); budgetReAppropriation.setBudgetDetail(budgetDetail); } return budgetreappropriations; } @Autowired  BudgetReAppropriationService(final BudgetReAppropriationRepository budgetReAppropriationRepository,
            final SmartValidator validator, final BudgetDetailRepository budgetDetailRepository); @Transactional List<BudgetReAppropriation> create(List<BudgetReAppropriation> budgetReAppropriations, final BindingResult errors,
            final RequestInfo requestInfo); @Transactional List<BudgetReAppropriation> update(List<BudgetReAppropriation> budgetReAppropriations, final BindingResult errors,
            final RequestInfo requestInfo); @Transactional List<BudgetReAppropriation> delete(List<BudgetReAppropriation> budgetReAppropriations, final BindingResult errors,
            final RequestInfo requestInfo); List<BudgetReAppropriation> fetchRelated(final List<BudgetReAppropriation> budgetreappropriations); Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch budgetReAppropriationSearch); @Transactional BudgetReAppropriation save(final BudgetReAppropriation budgetReAppropriation); @Transactional BudgetReAppropriation update(final BudgetReAppropriation budgetReAppropriation); @Transactional BudgetReAppropriation delete(final BudgetReAppropriation budgetReAppropriation); static final String ACTION_CREATE; static final String ACTION_UPDATE; static final String ACTION_DELETE; static final String ACTION_VIEW; static final String ACTION_EDIT; static final String ACTION_SEARCH; }