BAEL-965 - adding changes as per Grzegorz comments
This commit is contained in:
parent
0f49c26335
commit
7a77016b3c
@ -2,9 +2,9 @@ package com.baeldung.commons.collectionutil;
|
|||||||
|
|
||||||
public class Address {
|
public class Address {
|
||||||
|
|
||||||
String locality;
|
private String locality;
|
||||||
String city;
|
private String city;
|
||||||
String zip;
|
private String zip;
|
||||||
|
|
||||||
public String getLocality() {
|
public String getLocality() {
|
||||||
return locality;
|
return locality;
|
||||||
|
@ -2,12 +2,12 @@ package com.baeldung.commons.collectionutil;
|
|||||||
|
|
||||||
public class Customer implements Comparable<Customer> {
|
public class Customer implements Comparable<Customer> {
|
||||||
|
|
||||||
Integer id;
|
private Integer id;
|
||||||
String name;
|
private String name;
|
||||||
Long phone;
|
private Long phone;
|
||||||
String locality;
|
private String locality;
|
||||||
String city;
|
private String city;
|
||||||
String zip;
|
private String zip;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -12,6 +12,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@ -45,6 +46,8 @@ public class CollectionUtilsGuideTest {
|
|||||||
@Test
|
@Test
|
||||||
public void givenTwoSortedLists_whenCollated_thenSorted() {
|
public void givenTwoSortedLists_whenCollated_thenSorted() {
|
||||||
List<Customer> sortedList = CollectionUtils.collate(list1, list2);
|
List<Customer> sortedList = CollectionUtils.collate(list1, list2);
|
||||||
|
|
||||||
|
assertEquals(6, sortedList.size());
|
||||||
assertTrue(sortedList.get(0).getName().equals("Bob"));
|
assertTrue(sortedList.get(0).getName().equals("Bob"));
|
||||||
assertTrue(sortedList.get(2).getName().equals("Daniel"));
|
assertTrue(sortedList.get(2).getName().equals("Daniel"));
|
||||||
}
|
}
|
||||||
@ -61,7 +64,7 @@ public class CollectionUtilsGuideTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenCustomerList_WhenFiltered_thenCorrectSize() {
|
public void givenCustomerList_whenFiltered_thenCorrectSize() {
|
||||||
|
|
||||||
boolean isModified = CollectionUtils.filter(linkedList1, customer -> Arrays.asList("Daniel","Kyle").contains(customer.getName()));
|
boolean isModified = CollectionUtils.filter(linkedList1, customer -> Arrays.asList("Daniel","Kyle").contains(customer.getName()));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user