removed unnecessary Mockito and refactored test method name

This commit is contained in:
Tom Hombergs 2018-10-15 21:40:00 +02:00
parent a513308b4d
commit eeb5e0892b

View File

@ -1,4 +1,4 @@
package findItems;
package com.baeldung.findItems;
import static org.junit.Assert.assertEquals;
@ -10,24 +10,20 @@ import java.util.stream.Collectors;
import org.junit.Test;
public class FindItemsBasedOnValues {
public class FindItemsBasedOnOtherStreamUnitTest {
List<Employee> EmplList = new ArrayList<Employee>();
List<Department> deptList = new ArrayList<Department>();
private List<Employee> employeeList = new ArrayList<Employee>();
public static void main(String[] args) throws ParseException {
FindItemsBasedOnValues findItems = new FindItemsBasedOnValues();
findItems.givenDepartmentList_thenEmployeeListIsFilteredCorrectly();
}
private List<Department> departmentList = new ArrayList<Department>();
@Test
public void givenDepartmentList_thenEmployeeListIsFilteredCorrectly() {
Integer expectedId = 1002;
populate(EmplList, deptList);
populate(employeeList, departmentList);
List<Employee> filteredList = EmplList.stream()
.filter(empl -> deptList.stream()
List<Employee> filteredList = employeeList.stream()
.filter(empl -> departmentList.stream()
.anyMatch(dept -> dept.getDepartment()
.equals("sales") && empl.getEmployeeId()
.equals(dept.getEmployeeId())))
@ -53,16 +49,16 @@ public class FindItemsBasedOnValues {
}
class Employee {
Integer employeeId;
String employeeName;
private Integer employeeId;
private String employeeName;
public Employee(Integer employeeId, String employeeName) {
Employee(Integer employeeId, String employeeName) {
super();
this.employeeId = employeeId;
this.employeeName = employeeName;
}
public Integer getEmployeeId() {
Integer getEmployeeId() {
return employeeId;
}
@ -73,20 +69,20 @@ class Employee {
}
class Department {
Integer employeeId;
String department;
private Integer employeeId;
private String department;
public Department(Integer employeeId, String department) {
Department(Integer employeeId, String department) {
super();
this.employeeId = employeeId;
this.department = department;
}
public Integer getEmployeeId() {
Integer getEmployeeId() {
return employeeId;
}
public String getDepartment() {
String getDepartment() {
return department;
}