[JAVA-13290] Update record name
This commit is contained in:
parent
dfda4c7756
commit
8bf83f0fe6
|
@ -10,7 +10,7 @@ public class BlogPost {
|
||||||
private BlogPostType type;
|
private BlogPostType type;
|
||||||
private int likes;
|
private int likes;
|
||||||
record AuthPostTypesLikes(String author, BlogPostType type, int likes) {};
|
record AuthPostTypesLikes(String author, BlogPostType type, int likes) {};
|
||||||
record PostcountTitlesLikesStats(long postCount, String titles, IntSummaryStatistics likesStats){};
|
record PostCountTitlesLikesStats(long postCount, String titles, IntSummaryStatistics likesStats){};
|
||||||
record TitlesBoundedSumOfLikes(String titles, int boundedSumOfLikes) {};
|
record TitlesBoundedSumOfLikes(String titles, int boundedSumOfLikes) {};
|
||||||
|
|
||||||
public BlogPost(String title, String author, BlogPostType type, int likes) {
|
public BlogPost(String title, String author, BlogPostType type, int likes) {
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class JavaGroupingByCollectorUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenListOfPosts_whenGroupedByAuthor_thenGetAMapUsingCollectingAndThen() {
|
public void givenListOfPosts_whenGroupedByAuthor_thenGetAMapUsingCollectingAndThen() {
|
||||||
|
|
||||||
Map<String, BlogPost.PostcountTitlesLikesStats> postsPerAuthor = posts.stream()
|
Map<String, BlogPost.PostCountTitlesLikesStats> postsPerAuthor = posts.stream()
|
||||||
.collect(groupingBy(BlogPost::getAuthor, collectingAndThen(toList(), list -> {
|
.collect(groupingBy(BlogPost::getAuthor, collectingAndThen(toList(), list -> {
|
||||||
long count = list.stream()
|
long count = list.stream()
|
||||||
.map(BlogPost::getTitle)
|
.map(BlogPost::getTitle)
|
||||||
|
@ -267,10 +267,10 @@ public class JavaGroupingByCollectorUnitTest {
|
||||||
.collect(joining(" : "));
|
.collect(joining(" : "));
|
||||||
IntSummaryStatistics summary = list.stream()
|
IntSummaryStatistics summary = list.stream()
|
||||||
.collect(summarizingInt(BlogPost::getLikes));
|
.collect(summarizingInt(BlogPost::getLikes));
|
||||||
return new BlogPost.PostcountTitlesLikesStats(count, titles, summary);
|
return new BlogPost.PostCountTitlesLikesStats(count, titles, summary);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
BlogPost.PostcountTitlesLikesStats result = postsPerAuthor.get("Author 1");
|
BlogPost.PostCountTitlesLikesStats result = postsPerAuthor.get("Author 1");
|
||||||
assertThat(result.postCount()).isEqualTo(3L);
|
assertThat(result.postCount()).isEqualTo(3L);
|
||||||
assertThat(result.titles()).isEqualTo("News item 1 : Programming guide : Tech review 2");
|
assertThat(result.titles()).isEqualTo("News item 1 : Programming guide : Tech review 2");
|
||||||
assertThat(result.likesStats().getMax()).isEqualTo(20);
|
assertThat(result.likesStats().getMax()).isEqualTo(20);
|
||||||
|
|
Loading…
Reference in New Issue