-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathFunction_02_Test.java
More file actions
41 lines (31 loc) · 1.2 KB
/
Function_02_Test.java
File metadata and controls
41 lines (31 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package java17.ex02;
import java.util.function.BiFunction;
import org.junit.Test;
import java17.data.Account;
import java17.data.Person;
/**
* Exercice 02 - java.util.function.BiFunction
*/
public class Function_02_Test {
// tag::buildAccount[]
// TODO Compléter la fonction buildAccount
// TODO la fonction possède 2 paramètres en entrée : une personne et un solde
BiFunction<Person, Integer, Account> buildAccount = (Person person,Integer solde) -> {
Account account = new Account();
account.setOwner(person);
account.setBalance(solde);
return account;
};
// end::buildAccount[]
@Test
public void test_build_account() throws Exception {
// TODO invoquer la fonction buildAccount pour que le test soit passant
Person person = new Person("John", "France", 80, "pass");
Account account = buildAccount.apply(person, 500);
assert account.getBalance().equals(500);
assert account.getOwner().getFirstname().equals("John");
assert account.getOwner().getLastname().equals("France");
assert account.getOwner().getAge().equals(80);
assert account.getOwner().getPassword().equals("pass");
}
}