Skip to content

Commit 52a3565

Browse files
moguzozcanmaibin
authored andcommitted
Seems no conflict (eugenp#1274)
* Bean Injection Project is added Different Types of Bean Injection article codes are added. * Java-based configuration added Java-based configuration and tests are added. Coding styles are fixed. * List of Lists Article Codes added. List of Lists Article Codes added. * Most popular use case of grouping elements together added Most popular use case of grouping elements together added
1 parent 442c005 commit 52a3565

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

‎core-java/src/test/java/com/baeldung/list/listoflist/ListOfListsTest.java‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,38 @@ public void givenListOfLists_thenCheckNames() {
3939
@SuppressWarnings("unchecked")
4040
@Test
4141
public void givenListOfLists_whenRemovingElements_thenCheckNames() {
42-
((ArrayList<Pencil>) listOfLists.get(1)).remove(0);
42+
43+
((ArrayList<Pencil>) listOfLists.get(1)).remove(0);
4344
listOfLists.remove(1);
4445
assertEquals("Rubber 1", ((Rubber) listOfLists.get(1)
4546
.get(0)).getName());
4647
listOfLists.remove(0);
4748
assertEquals("Rubber 1", ((Rubber) listOfLists.get(0)
4849
.get(0)).getName());
4950
}
51+
52+
@Test
53+
public void givenThreeList_whenCombineIntoOneList_thenCheckList() {
54+
ArrayList<Pen> pens = new ArrayList<>();
55+
pens.add(new Pen("Pen 1"));
56+
pens.add(new Pen("Pen 2"));
57+
ArrayList<Pencil> pencils = new ArrayList<>();
58+
pencils.add(new Pencil("Pencil 1"));
59+
pencils.add(new Pencil("Pencil 2"));
60+
ArrayList<Rubber> rubbers = new ArrayList<>();
61+
rubbers.add(new Rubber("Rubber 1"));
62+
rubbers.add(new Rubber("Rubber 2"));
63+
64+
List<ArrayList<? extends Stationery>> list = new ArrayList<ArrayList<? extends Stationery>>();
65+
list.add(pens);
66+
list.add(pencils);
67+
list.add(rubbers);
68+
69+
assertEquals("Pen 1", ((Pen) list.get(0)
70+
.get(0)).getName());
71+
assertEquals("Pencil 1", ((Pencil) list.get(1)
72+
.get(0)).getName());
73+
assertEquals("Rubber 1", ((Rubber) list.get(2)
74+
.get(0)).getName());
75+
}
5076
}

0 commit comments

Comments
 (0)