BAEL-591 : Changes in the Final review. (#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
This commit is contained in:
Nitish Bangera 2017-01-28 00:30:28 +05:30 committed by maibin
parent 5f89c098bd
commit af44518a6a
1 changed files with 20 additions and 29 deletions

View File

@ -9,28 +9,6 @@ import java.util.function.Function;
import static org.junit.Assert.assertEquals;
public class CollectorImprovementTest {
private static class Blog {
private String authorName;
private List<String> comments;
public Blog(String authorName) {
this.authorName = authorName;
this.comments = new LinkedList<String>();
}
public String getAuthorName() {
return this.authorName;
}
public List<String> getComments() {
return new LinkedList<String>(this.comments);
}
public void addComment(String comment) {
this.comments.add(comment);
}
}
@Test
public void givenList_whenSatifyPredicate_thenMapValueWithOccurences() {
List<Integer> numbers = List.of(1, 2, 3, 5, 5);
@ -50,13 +28,8 @@ public class CollectorImprovementTest {
@Test
public void givenListOfBlogs_whenAuthorName_thenMapAuthorWithComments() {
Blog blog1 = new CollectorImprovementTest.Blog("1");
blog1.addComment("Nice");
blog1.addComment("Very Nice");
Blog blog2 = new CollectorImprovementTest.Blog("2");
blog2.addComment("Disappointing");
blog2.addComment("Ok");
blog2.addComment("Could be better");
Blog blog1 = new Blog("1", "Nice", "Very Nice");
Blog blog2 = new Blog("2", "Disappointing", "Ok", "Could be better");
List<Blog> blogs = List.of(blog1, blog2);
Map<String, List<List<String>>> authorComments1 =
@ -79,3 +52,21 @@ public class CollectorImprovementTest {
assertEquals(3, authorComments2.get("2").size());
}
}
class Blog {
private String authorName;
private List<String> comments;
public Blog(String authorName, String... comments) {
this.authorName = authorName;
this.comments = List.of(comments);
}
public String getAuthorName() {
return this.authorName;
}
public List<String> getComments() {
return this.comments;
}
}