@Test public final void test_fetch_accountcode() { List<InstrumentAccountCode> instrumentAccountCodes = getInstrumentAccountCodes(); ChartOfAccountContract expextedResult = ChartOfAccountContract.builder().glcode("glcode").id("1").build(); instrumentAccountCodes.get(0).setAccountCode(expextedResult); when(chartOfAccountContractRepository.findByGlcode(any(ChartOfAccountContract.class), Matchers.anyObject())) .thenReturn(expextedResult); List<InstrumentAccountCode> actualResult = instrumentAccountCodeService.fetchRelated(instrumentAccountCodes, new RequestInfo()); assertEquals(expextedResult, actualResult.get(0).getAccountCode()); }
public List<InstrumentAccountCode> fetchRelated(List<InstrumentAccountCode> instrumentaccountcodes, RequestInfo requestInfo) { if (instrumentaccountcodes != null) for (InstrumentAccountCode instrumentAccountCode : instrumentaccountcodes) { if (instrumentAccountCode.getInstrumentType() != null && instrumentAccountCode.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrumentAccountCode.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrumentAccountCode.getInstrumentType().getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentTypeSearchResult", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setInstrumentType(response.getPagedData().get(0)); } if (instrumentAccountCode.getAccountCode() != null && instrumentAccountCode.getAccountCode().getGlcode() != null) { instrumentAccountCode.getAccountCode().setTenantId(instrumentAccountCode.getTenantId()); ChartOfAccountContract accountCode = chartOfAccountContractRepository .findByGlcode(instrumentAccountCode.getAccountCode(), requestInfo); if (accountCode == null) throw new InvalidDataException("accountCode", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setAccountCode(accountCode); } } return instrumentaccountcodes; }
InstrumentAccountCodeService { public List<InstrumentAccountCode> fetchRelated(List<InstrumentAccountCode> instrumentaccountcodes, RequestInfo requestInfo) { if (instrumentaccountcodes != null) for (InstrumentAccountCode instrumentAccountCode : instrumentaccountcodes) { if (instrumentAccountCode.getInstrumentType() != null && instrumentAccountCode.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrumentAccountCode.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrumentAccountCode.getInstrumentType().getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentTypeSearchResult", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setInstrumentType(response.getPagedData().get(0)); } if (instrumentAccountCode.getAccountCode() != null && instrumentAccountCode.getAccountCode().getGlcode() != null) { instrumentAccountCode.getAccountCode().setTenantId(instrumentAccountCode.getTenantId()); ChartOfAccountContract accountCode = chartOfAccountContractRepository .findByGlcode(instrumentAccountCode.getAccountCode(), requestInfo); if (accountCode == null) throw new InvalidDataException("accountCode", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setAccountCode(accountCode); } } return instrumentaccountcodes; } }
InstrumentAccountCodeService { public List<InstrumentAccountCode> fetchRelated(List<InstrumentAccountCode> instrumentaccountcodes, RequestInfo requestInfo) { if (instrumentaccountcodes != null) for (InstrumentAccountCode instrumentAccountCode : instrumentaccountcodes) { if (instrumentAccountCode.getInstrumentType() != null && instrumentAccountCode.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrumentAccountCode.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrumentAccountCode.getInstrumentType().getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentTypeSearchResult", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setInstrumentType(response.getPagedData().get(0)); } if (instrumentAccountCode.getAccountCode() != null && instrumentAccountCode.getAccountCode().getGlcode() != null) { instrumentAccountCode.getAccountCode().setTenantId(instrumentAccountCode.getTenantId()); ChartOfAccountContract accountCode = chartOfAccountContractRepository .findByGlcode(instrumentAccountCode.getAccountCode(), requestInfo); if (accountCode == null) throw new InvalidDataException("accountCode", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setAccountCode(accountCode); } } return instrumentaccountcodes; } @Autowired  InstrumentAccountCodeService(SmartValidator validator,
            InstrumentAccountCodeRepository instrumentAccountCodeRepository,
            ChartOfAccountContractRepository chartOfAccountContractRepository,
            InstrumentTypeRepository instrumentTypeRepository); }
InstrumentAccountCodeService { public List<InstrumentAccountCode> fetchRelated(List<InstrumentAccountCode> instrumentaccountcodes, RequestInfo requestInfo) { if (instrumentaccountcodes != null) for (InstrumentAccountCode instrumentAccountCode : instrumentaccountcodes) { if (instrumentAccountCode.getInstrumentType() != null && instrumentAccountCode.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrumentAccountCode.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrumentAccountCode.getInstrumentType().getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentTypeSearchResult", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setInstrumentType(response.getPagedData().get(0)); } if (instrumentAccountCode.getAccountCode() != null && instrumentAccountCode.getAccountCode().getGlcode() != null) { instrumentAccountCode.getAccountCode().setTenantId(instrumentAccountCode.getTenantId()); ChartOfAccountContract accountCode = chartOfAccountContractRepository .findByGlcode(instrumentAccountCode.getAccountCode(), requestInfo); if (accountCode == null) throw new InvalidDataException("accountCode", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setAccountCode(accountCode); } } return instrumentaccountcodes; } @Autowired  InstrumentAccountCodeService(SmartValidator validator,
            InstrumentAccountCodeRepository instrumentAccountCodeRepository,
            ChartOfAccountContractRepository chartOfAccountContractRepository,
            InstrumentTypeRepository instrumentTypeRepository); @Transactional List<InstrumentAccountCode> create(List<InstrumentAccountCode> instrumentAccountCodes, BindingResult errors,
            RequestInfo requestInfo); @Transactional List<InstrumentAccountCode> update(List<InstrumentAccountCode> instrumentAccountCodes, BindingResult errors,
            RequestInfo requestInfo); @Transactional List<InstrumentAccountCode> delete(List<InstrumentAccountCode> instrumentAccountCodes, BindingResult errors,
            RequestInfo requestInfo); List<InstrumentAccountCode> fetchRelated(List<InstrumentAccountCode> instrumentaccountcodes, RequestInfo requestInfo); @Transactional InstrumentAccountCode delete(InstrumentAccountCode instrumentAccountCode); Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch instrumentAccountCodeSearch); @Transactional InstrumentAccountCode save(InstrumentAccountCode instrumentAccountCode); @Transactional InstrumentAccountCode update(InstrumentAccountCode instrumentAccountCode); }
InstrumentAccountCodeService { public List<InstrumentAccountCode> fetchRelated(List<InstrumentAccountCode> instrumentaccountcodes, RequestInfo requestInfo) { if (instrumentaccountcodes != null) for (InstrumentAccountCode instrumentAccountCode : instrumentaccountcodes) { if (instrumentAccountCode.getInstrumentType() != null && instrumentAccountCode.getInstrumentType().getName() != null) { InstrumentTypeSearch instrumentTypeSearch = new InstrumentTypeSearch(); instrumentTypeSearch.setName(instrumentAccountCode.getInstrumentType().getName()); instrumentTypeSearch.setTenantId(instrumentAccountCode.getInstrumentType().getTenantId()); Pagination<InstrumentType> response = instrumentTypeRepository.search(instrumentTypeSearch); if (response == null || response.getPagedData() == null || response.getPagedData().isEmpty()) throw new InvalidDataException("instrumentTypeSearchResult", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setInstrumentType(response.getPagedData().get(0)); } if (instrumentAccountCode.getAccountCode() != null && instrumentAccountCode.getAccountCode().getGlcode() != null) { instrumentAccountCode.getAccountCode().setTenantId(instrumentAccountCode.getTenantId()); ChartOfAccountContract accountCode = chartOfAccountContractRepository .findByGlcode(instrumentAccountCode.getAccountCode(), requestInfo); if (accountCode == null) throw new InvalidDataException("accountCode", ErrorCode.INVALID_REF_VALUE.getCode(), null); instrumentAccountCode.setAccountCode(accountCode); } } return instrumentaccountcodes; } @Autowired  InstrumentAccountCodeService(SmartValidator validator,
            InstrumentAccountCodeRepository instrumentAccountCodeRepository,
            ChartOfAccountContractRepository chartOfAccountContractRepository,
            InstrumentTypeRepository instrumentTypeRepository); @Transactional List<InstrumentAccountCode> create(List<InstrumentAccountCode> instrumentAccountCodes, BindingResult errors,
            RequestInfo requestInfo); @Transactional List<InstrumentAccountCode> update(List<InstrumentAccountCode> instrumentAccountCodes, BindingResult errors,
            RequestInfo requestInfo); @Transactional List<InstrumentAccountCode> delete(List<InstrumentAccountCode> instrumentAccountCodes, BindingResult errors,
            RequestInfo requestInfo); List<InstrumentAccountCode> fetchRelated(List<InstrumentAccountCode> instrumentaccountcodes, RequestInfo requestInfo); @Transactional InstrumentAccountCode delete(InstrumentAccountCode instrumentAccountCode); Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch instrumentAccountCodeSearch); @Transactional InstrumentAccountCode save(InstrumentAccountCode instrumentAccountCode); @Transactional InstrumentAccountCode update(InstrumentAccountCode instrumentAccountCode); 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; }