@Test public void findAllCategoryDtoTest() { List<Category> genericEntityList = Arrays.asList( Category.builder() .name("Test") .build(), Category.builder() .name("Test1") .build()); when(categoryService.findAll()).thenReturn(genericEntityList); List<CategoryDto> mappedList = genericEntityList .stream() .map(category -> modelMapper.map(category, CategoryDto.class)) .collect(Collectors.toList()); List<CategoryDto> allCategoryDto = categoryService.findAllCategoryDto(); assertEquals(mappedList, allCategoryDto); }
@Override public List<CategoryDto> findAllCategoryDto() { List<Category> categories = findAll(); return categories.stream() .map(category -> modelMapper.map(category, CategoryDto.class)) .collect(Collectors.toList()); }
CategoryServiceImpl implements CategoryService { @Override public List<CategoryDto> findAllCategoryDto() { List<Category> categories = findAll(); return categories.stream() .map(category -> modelMapper.map(category, CategoryDto.class)) .collect(Collectors.toList()); } }
CategoryServiceImpl implements CategoryService { @Override public List<CategoryDto> findAllCategoryDto() { List<Category> categories = findAll(); return categories.stream() .map(category -> modelMapper.map(category, CategoryDto.class)) .collect(Collectors.toList()); }  }
CategoryServiceImpl implements CategoryService { @Override public List<CategoryDto> findAllCategoryDto() { List<Category> categories = findAll(); return categories.stream() .map(category -> modelMapper.map(category, CategoryDto.class)) .collect(Collectors.toList()); }  @Override Category save(CategoryDto dto); @Override Category save(Category category); @Override List<Category> findAll(); @Override Category findById(Long id); @Override Category update(Long id, Category category); @Override Long deleteById(Long id); @Override Category findByName(String name); @Override List<CategoryDto> findAllCategoryDto(); }
CategoryServiceImpl implements CategoryService { @Override public List<CategoryDto> findAllCategoryDto() { List<Category> categories = findAll(); return categories.stream() .map(category -> modelMapper.map(category, CategoryDto.class)) .collect(Collectors.toList()); }  @Override Category save(CategoryDto dto); @Override Category save(Category category); @Override List<Category> findAll(); @Override Category findById(Long id); @Override Category update(Long id, Category category); @Override Long deleteById(Long id); @Override Category findByName(String name); @Override List<CategoryDto> findAllCategoryDto();  }