@Test public void findEmployeeById() { this.company.addEmployee(new EmployeeFixed("123", "Dave", 100_000.00)); this.company.addEmployee(new EmployeeFixed("456", "Alice", 100_000.00)); this.company.addEmployee(new EmployeeFixed("789", "Bob", 100_000.00)); EmployeeFixed hopefullyDave = this.company.findEmployeeById("123"); Assert.assertEquals("123", hopefullyDave.getId()); Assert.assertEquals("Dave", hopefullyDave.getName()); Assert.assertEquals(100_000.00, hopefullyDave.getSalary(), 0.00001); EmployeeFixed hopefullyNoOne = this.company.findEmployeeById("999"); Assert.assertNull(hopefullyNoOne); }
public EmployeeFixed findEmployeeById(String id) { return this.employees.stream() .filter(e -> e.getId().equals(id)) .findFirst() .orElse(null); }
CompanyFixed { public EmployeeFixed findEmployeeById(String id) { return this.employees.stream() .filter(e -> e.getId().equals(id)) .findFirst() .orElse(null); } }
CompanyFixed { public EmployeeFixed findEmployeeById(String id) { return this.employees.stream() .filter(e -> e.getId().equals(id)) .findFirst() .orElse(null); } CompanyFixed(String newName); }
CompanyFixed { public EmployeeFixed findEmployeeById(String id) { return this.employees.stream() .filter(e -> e.getId().equals(id)) .findFirst() .orElse(null); } CompanyFixed(String newName); String getName(); void setName(String newName); void addEmployee(EmployeeFixed newEmployee); void everybodyGetsRaiseBy(double incrementAsFraction); EmployeeFixed findEmployeeById(String id); int numberOfEmployees(); }
CompanyFixed { public EmployeeFixed findEmployeeById(String id) { return this.employees.stream() .filter(e -> e.getId().equals(id)) .findFirst() .orElse(null); } CompanyFixed(String newName); String getName(); void setName(String newName); void addEmployee(EmployeeFixed newEmployee); void everybodyGetsRaiseBy(double incrementAsFraction); EmployeeFixed findEmployeeById(String id); int numberOfEmployees();  }