Skip to content

Commit af44518

Browse files
NitishBangeramaibin
authored andcommitted
BAEL-591 : Changes in the Final review. (eugenp#1059)
* String to char and vice versa initial article code * Junit test case for String Conversion. Deleting normal class. * Changes based on review. * BAEL-591 : New Java9 Collectors code snippet * Deleting String conversion test * BAEL-591 : Changing to BDD style testcase names. * BAEL-591 : Changes based on final review
1 parent 5f89c09 commit af44518

1 file changed

Lines changed: 20 additions & 29 deletions

File tree

‎core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectorImprovementTest.java‎

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,6 @@
99
import static org.junit.Assert.assertEquals;
1010

1111
public class CollectorImprovementTest {
12-
private static class Blog {
13-
private String authorName;
14-
private List<String> comments;
15-
16-
public Blog(String authorName) {
17-
this.authorName = authorName;
18-
this.comments = new LinkedList<String>();
19-
}
20-
21-
public String getAuthorName() {
22-
return this.authorName;
23-
}
24-
25-
public List<String> getComments() {
26-
return new LinkedList<String>(this.comments);
27-
}
28-
29-
public void addComment(String comment) {
30-
this.comments.add(comment);
31-
}
32-
}
33-
3412
@Test
3513
public void givenList_whenSatifyPredicate_thenMapValueWithOccurences() {
3614
List<Integer> numbers = List.of(1, 2, 3, 5, 5);
@@ -50,13 +28,8 @@ public void givenList_whenSatifyPredicate_thenMapValueWithOccurences() {
5028

5129
@Test
5230
public void givenListOfBlogs_whenAuthorName_thenMapAuthorWithComments() {
53-
Blog blog1 = new CollectorImprovementTest.Blog("1");
54-
blog1.addComment("Nice");
55-
blog1.addComment("Very Nice");
56-
Blog blog2 = new CollectorImprovementTest.Blog("2");
57-
blog2.addComment("Disappointing");
58-
blog2.addComment("Ok");
59-
blog2.addComment("Could be better");
31+
Blog blog1 = new Blog("1", "Nice", "Very Nice");
32+
Blog blog2 = new Blog("2", "Disappointing", "Ok", "Could be better");
6033
List<Blog> blogs = List.of(blog1, blog2);
6134

6235
Map<String, List<List<String>>> authorComments1 =
@@ -79,3 +52,21 @@ public void givenListOfBlogs_whenAuthorName_thenMapAuthorWithComments() {
7952
assertEquals(3, authorComments2.get("2").size());
8053
}
8154
}
55+
56+
class Blog {
57+
private String authorName;
58+
private List<String> comments;
59+
60+
public Blog(String authorName, String... comments) {
61+
this.authorName = authorName;
62+
this.comments = List.of(comments);
63+
}
64+
65+
public String getAuthorName() {
66+
return this.authorName;
67+
}
68+
69+
public List<String> getComments() {
70+
return this.comments;
71+
}
72+
}

0 commit comments

Comments
 (0)