class SearchNewsDtoMapper extends AbstractConverter<EcoNews, SearchNewsDto> {

    @Override
    protected SearchNewsDto convert(EcoNews ecoNews) {
        User author = ecoNews.getAuthor();

        return SearchNewsDto.builder()
            .id(ecoNews.getId())
            .title(ecoNews.getTitle())
            .author(new EcoNewsAuthorDto(author.getId(),
                author.getName()))
            .creationDate(ecoNews.getCreationDate())
            .tags(ecoNews.getTags()
                .stream()
                .map(Tag::getName)
                .collect(Collectors.toList()))
            .build();
    }

}