@Test public void testFindAllByName() { Page<ValueSet> valueSetsMock = mock(Page.class); when( valueSetRepository.findAllByNameLike(anyString(), anyString(), any(Pageable.class))).thenReturn(valueSetsMock); List<ValueSetDto> valueSetDtosMock = new ArrayList<ValueSetDto>(); ValueSetDto valueSetDtoMock = mock(ValueSetDto.class); valueSetDtosMock.add(valueSetDtoMock); when( valueSetMgmtHelper.convertValueSetEntitiesToDtos(valueSetsMock .getContent())).thenReturn(valueSetDtosMock); when(valueSetDtoMock.getId()).thenReturn((long) 1); when(conceptCodeValueSetRepository.findAllByPkValueSetId(anyLong())) .thenReturn(null); assertEquals(vst.findAllByName("a", null, 0).get("valueSets"), valueSetDtosMock); }
@Override public Map<String, Object> findAllByName(String searchTerm, String valueSetCategory, int pageNumber) { Sort sort = new Sort(new Order(Direction.ASC, "code")); PageRequest pageRequest = new PageRequest(pageNumber, VALUE_SET_PAGE_SIZE, sort); Page<ValueSet> pagedValueSets = valueSetRepository.findAllByNameLike( "%" + searchTerm + "%", "%" + valueSetCategory + "%", pageRequest); Map<String, Object> pageResultsMap = new HashMap<String, Object>(); pageResultsMap.put("valueSets", setDeletableToValueSetDto(pagedValueSets.getContent())); pageResultsMap.put("totalNumberOfValueSets", pagedValueSets.getTotalElements()); pageResultsMap.put("totalPages", pagedValueSets.getTotalPages()); pageResultsMap.put("itemsPerPage", pagedValueSets.getSize()); pageResultsMap.put("currentPage", pagedValueSets.getNumber()); pageResultsMap.put("numberOfElements", pagedValueSets.getNumberOfElements()); return pageResultsMap; }
ValueSetServiceImpl implements ValueSetService { @Override public Map<String, Object> findAllByName(String searchTerm, String valueSetCategory, int pageNumber) { Sort sort = new Sort(new Order(Direction.ASC, "code")); PageRequest pageRequest = new PageRequest(pageNumber, VALUE_SET_PAGE_SIZE, sort); Page<ValueSet> pagedValueSets = valueSetRepository.findAllByNameLike( "%" + searchTerm + "%", "%" + valueSetCategory + "%", pageRequest); Map<String, Object> pageResultsMap = new HashMap<String, Object>(); pageResultsMap.put("valueSets", setDeletableToValueSetDto(pagedValueSets.getContent())); pageResultsMap.put("totalNumberOfValueSets", pagedValueSets.getTotalElements()); pageResultsMap.put("totalPages", pagedValueSets.getTotalPages()); pageResultsMap.put("itemsPerPage", pagedValueSets.getSize()); pageResultsMap.put("currentPage", pagedValueSets.getNumber()); pageResultsMap.put("numberOfElements", pagedValueSets.getNumberOfElements()); return pageResultsMap; } }
ValueSetServiceImpl implements ValueSetService { @Override public Map<String, Object> findAllByName(String searchTerm, String valueSetCategory, int pageNumber) { Sort sort = new Sort(new Order(Direction.ASC, "code")); PageRequest pageRequest = new PageRequest(pageNumber, VALUE_SET_PAGE_SIZE, sort); Page<ValueSet> pagedValueSets = valueSetRepository.findAllByNameLike( "%" + searchTerm + "%", "%" + valueSetCategory + "%", pageRequest); Map<String, Object> pageResultsMap = new HashMap<String, Object>(); pageResultsMap.put("valueSets", setDeletableToValueSetDto(pagedValueSets.getContent())); pageResultsMap.put("totalNumberOfValueSets", pagedValueSets.getTotalElements()); pageResultsMap.put("totalPages", pagedValueSets.getTotalPages()); pageResultsMap.put("itemsPerPage", pagedValueSets.getSize()); pageResultsMap.put("currentPage", pagedValueSets.getNumber()); pageResultsMap.put("numberOfElements", pagedValueSets.getNumberOfElements()); return pageResultsMap; } ValueSetServiceImpl(int valueSetPageSize,
			ValueSetRepository valueSetRepository,
			ValueSetCategoryRepository valueSetCategoryRepository,
			ConceptCodeValueSetRepository conceptCodeValueSetRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); }
ValueSetServiceImpl implements ValueSetService { @Override public Map<String, Object> findAllByName(String searchTerm, String valueSetCategory, int pageNumber) { Sort sort = new Sort(new Order(Direction.ASC, "code")); PageRequest pageRequest = new PageRequest(pageNumber, VALUE_SET_PAGE_SIZE, sort); Page<ValueSet> pagedValueSets = valueSetRepository.findAllByNameLike( "%" + searchTerm + "%", "%" + valueSetCategory + "%", pageRequest); Map<String, Object> pageResultsMap = new HashMap<String, Object>(); pageResultsMap.put("valueSets", setDeletableToValueSetDto(pagedValueSets.getContent())); pageResultsMap.put("totalNumberOfValueSets", pagedValueSets.getTotalElements()); pageResultsMap.put("totalPages", pagedValueSets.getTotalPages()); pageResultsMap.put("itemsPerPage", pagedValueSets.getSize()); pageResultsMap.put("currentPage", pagedValueSets.getNumber()); pageResultsMap.put("numberOfElements", pagedValueSets.getNumberOfElements()); return pageResultsMap; } ValueSetServiceImpl(int valueSetPageSize,
			ValueSetRepository valueSetRepository,
			ValueSetCategoryRepository valueSetCategoryRepository,
			ConceptCodeValueSetRepository conceptCodeValueSetRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); @Override @Transactional ValueSetDto create(ValueSetDto created); @Override @Transactional(rollbackFor = ValueSetNotFoundException.class) ValueSetDto delete(Long valueSetId); @Override ValueSetDto findById(Long id); @Override @Transactional(rollbackFor = ValueSetNotFoundException.class) ValueSetDto update(ValueSetDto updated); @Override ValueSetVSCDto create(); @Override List<ValueSetDto> findAll(); @Override List<ValueSetDto> findAllWithoutDeletable(); @Override Map<String, Object> findAll(int pageNumber); @Override Map<String, Object> findAllByName(String searchTerm,
			String valueSetCategory, int pageNumber); @Override Map<String, Object> findAllByCode(String searchTerm,
			String valueSetCategory, int pageNumber); @Override @Transactional(rollbackFor = DataIntegrityViolationException.class) ValueSetDto valueSetBatchUpload(ValueSetDto valueSetDto,
			MultipartFile file); }
ValueSetServiceImpl implements ValueSetService { @Override public Map<String, Object> findAllByName(String searchTerm, String valueSetCategory, int pageNumber) { Sort sort = new Sort(new Order(Direction.ASC, "code")); PageRequest pageRequest = new PageRequest(pageNumber, VALUE_SET_PAGE_SIZE, sort); Page<ValueSet> pagedValueSets = valueSetRepository.findAllByNameLike( "%" + searchTerm + "%", "%" + valueSetCategory + "%", pageRequest); Map<String, Object> pageResultsMap = new HashMap<String, Object>(); pageResultsMap.put("valueSets", setDeletableToValueSetDto(pagedValueSets.getContent())); pageResultsMap.put("totalNumberOfValueSets", pagedValueSets.getTotalElements()); pageResultsMap.put("totalPages", pagedValueSets.getTotalPages()); pageResultsMap.put("itemsPerPage", pagedValueSets.getSize()); pageResultsMap.put("currentPage", pagedValueSets.getNumber()); pageResultsMap.put("numberOfElements", pagedValueSets.getNumberOfElements()); return pageResultsMap; } ValueSetServiceImpl(int valueSetPageSize,
			ValueSetRepository valueSetRepository,
			ValueSetCategoryRepository valueSetCategoryRepository,
			ConceptCodeValueSetRepository conceptCodeValueSetRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); @Override @Transactional ValueSetDto create(ValueSetDto created); @Override @Transactional(rollbackFor = ValueSetNotFoundException.class) ValueSetDto delete(Long valueSetId); @Override ValueSetDto findById(Long id); @Override @Transactional(rollbackFor = ValueSetNotFoundException.class) ValueSetDto update(ValueSetDto updated); @Override ValueSetVSCDto create(); @Override List<ValueSetDto> findAll(); @Override List<ValueSetDto> findAllWithoutDeletable(); @Override Map<String, Object> findAll(int pageNumber); @Override Map<String, Object> findAllByName(String searchTerm,
			String valueSetCategory, int pageNumber); @Override Map<String, Object> findAllByCode(String searchTerm,
			String valueSetCategory, int pageNumber); @Override @Transactional(rollbackFor = DataIntegrityViolationException.class) ValueSetDto valueSetBatchUpload(ValueSetDto valueSetDto,
			MultipartFile file);  }