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:
parent
5f89c098bd
commit
af44518a6a
@ -9,28 +9,6 @@ import java.util.function.Function;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class CollectorImprovementTest {
|
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
|
@Test
|
||||||
public void givenList_whenSatifyPredicate_thenMapValueWithOccurences() {
|
public void givenList_whenSatifyPredicate_thenMapValueWithOccurences() {
|
||||||
List<Integer> numbers = List.of(1, 2, 3, 5, 5);
|
List<Integer> numbers = List.of(1, 2, 3, 5, 5);
|
||||||
@ -50,13 +28,8 @@ public class CollectorImprovementTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenListOfBlogs_whenAuthorName_thenMapAuthorWithComments() {
|
public void givenListOfBlogs_whenAuthorName_thenMapAuthorWithComments() {
|
||||||
Blog blog1 = new CollectorImprovementTest.Blog("1");
|
Blog blog1 = new Blog("1", "Nice", "Very Nice");
|
||||||
blog1.addComment("Nice");
|
Blog blog2 = new Blog("2", "Disappointing", "Ok", "Could be better");
|
||||||
blog1.addComment("Very Nice");
|
|
||||||
Blog blog2 = new CollectorImprovementTest.Blog("2");
|
|
||||||
blog2.addComment("Disappointing");
|
|
||||||
blog2.addComment("Ok");
|
|
||||||
blog2.addComment("Could be better");
|
|
||||||
List<Blog> blogs = List.of(blog1, blog2);
|
List<Blog> blogs = List.of(blog1, blog2);
|
||||||
|
|
||||||
Map<String, List<List<String>>> authorComments1 =
|
Map<String, List<List<String>>> authorComments1 =
|
||||||
@ -79,3 +52,21 @@ public class CollectorImprovementTest {
|
|||||||
assertEquals(3, authorComments2.get("2").size());
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user