Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit 7b2ecc8

Browse files
author
Taras
committed
Implemented AccountDao method save()
- updated data generator
1 parent f560f05 commit 7b2ecc8

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

Diff for: account-model/src/main/java/com/bobocode/model/Account.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.math.BigDecimal;
66
import java.time.LocalDate;
7+
import java.time.LocalDateTime;
78

89
@NoArgsConstructor
910
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@@ -16,6 +17,6 @@ public class Account {
1617
private String lastName;
1718
private String email;
1819
private LocalDate birthday;
19-
private LocalDate creationDate;
20+
private LocalDateTime creationDate;
2021
private BigDecimal balance = BigDecimal.ZERO;
2122
}

Diff for: lambda-basics/src/main/java/com/bobocode/LambdaExample_01.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void main(String[] args) {
3434
private static void giveBonusForLoyalClients(List<Account> accounts, int yearsWithBank, BigDecimal bonus) {
3535
for (Account account : accounts) {
3636
// todo: HARD CODED condition should be passed as method argument
37-
if (Period.between(account.getCreationDate(), LocalDate.now()).getYears() >= yearsWithBank) {
37+
if (Period.between(account.getCreationDate().toLocalDate(), LocalDate.now()).getYears() >= yearsWithBank) {
3838
// todo: HARD CODED operation should be passed as method argument
3939
account.setBalance(account.getBalance().add(bonus));
4040
}

Diff for: lambda-basics/src/main/java/com/bobocode/LambdaExample_02.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static void main(String[] args) {
3030
Condition<Account> loyalClientCondition = new Condition<Account>() {
3131
@Override
3232
public boolean isTrue(Account account) {
33-
return between(account.getCreationDate(), LocalDate.now()).getYears() > 4;
33+
return between(account.getCreationDate().toLocalDate(), LocalDate.now()).getYears() > 4;
3434
}
3535
};
3636
Operation<Account> bonusOperation = new Operation<Account>() {

Diff for: lambda-basics/src/main/java/com/bobocode/LambdaExample_03.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class LambdaExample_03 {
2727
public static void main(String[] args) {
2828
List<Account> accounts = TestDataProvider.generateAccountList();
2929
processAccounts(accounts,
30-
a -> Period.between(a.getCreationDate(), LocalDate.now()).getYears() > 4,
30+
a -> Period.between(a.getCreationDate().toLocalDate(), LocalDate.now()).getYears() > 4,
3131
a -> a.setBalance(a.getBalance().add(BigDecimal.valueOf(50))));
3232
}
3333

Diff for: stream-api/src/main/java/com/bobocode/StreamTask_Refactoring.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class StreamTask_Refactoring {
1818
public static void main(String[] args) {
1919
List<Account> accounts = TestDataProvider.generateAccountList();
2020
processAccounts(accounts,
21-
a -> Period.between(a.getCreationDate(), LocalDate.now()).getYears() > 4,
21+
a -> Period.between(a.getCreationDate().toLocalDate(), LocalDate.now()).getYears() > 4,
2222
a -> a.setBalance(a.getBalance().add(BigDecimal.valueOf(50))));
2323
}
2424

Diff for: test-data-provider/src/main/java/com.bobocode/util/TestDataProvider.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import java.math.BigDecimal;
1010
import java.time.LocalDate;
11+
import java.time.LocalDateTime;
1112
import java.util.ArrayList;
1213
import java.util.List;
1314
import java.util.Random;
@@ -17,17 +18,17 @@ public class TestDataProvider {
1718
public static List<Account> generateAccountList() {
1819
List<Account> accounts = new ArrayList<>(6);
1920
accounts.add(new Account(1L, "Will", "Smith", "[email protected]",
20-
LocalDate.of(1968, 8, 25), LocalDate.of(2012, 3, 19), BigDecimal.valueOf(104065.25)));
21+
LocalDate.of(1968, 8, 25), LocalDateTime.now(), BigDecimal.valueOf(104065.25)));
2122
accounts.add(new Account(2L, "Tom", "Hanks", "[email protected]",
22-
LocalDate.of(1956, 7, 9), LocalDate.of(2013, 2, 23), BigDecimal.valueOf(93065.25)));
23+
LocalDate.of(1956, 7, 9), LocalDateTime.now(), BigDecimal.valueOf(93065.25)));
2324
accounts.add(new Account(3L, "Russell", "Crowe", "[email protected]",
24-
LocalDate.of(1964, 4, 7), LocalDate.of(2014, 5, 17), BigDecimal.valueOf(87641.98)));
25+
LocalDate.of(1964, 4, 7), LocalDateTime.now(), BigDecimal.valueOf(87641.98)));
2526
accounts.add(new Account(4L, "Robert", "Downey", "[email protected]",
26-
LocalDate.of(1965, 4, 9), LocalDate.of(2015, 7, 24), BigDecimal.valueOf(152345)));
27+
LocalDate.of(1965, 4, 9), LocalDateTime.now(), BigDecimal.valueOf(152345)));
2728
accounts.add(new Account(5L, "Robert", "De Niro", "[email protected]",
28-
LocalDate.of(1943, 8, 17), LocalDate.of(2010, 8, 14), BigDecimal.valueOf(67065.45)));
29+
LocalDate.of(1943, 8, 17), LocalDateTime.now(), BigDecimal.valueOf(67065.45)));
2930
accounts.add(new Account(6L, "Metthew", "Perry", "[email protected]",
30-
LocalDate.of(1969, 8, 19), LocalDate.of(2011, 10, 4), BigDecimal.valueOf(45678.12)));
31+
LocalDate.of(1969, 8, 19), LocalDateTime.now(), BigDecimal.valueOf(45678.12)));
3132
return accounts;
3233
}
3334

@@ -39,14 +40,14 @@ public static Account generateFakeAccount(){
3940

4041
Account fakeAccount = new Account();
4142
fakeAccount.setFirstName(person.getFirstName());
42-
fakeAccount.setLastName(person.getFirstName());
43+
fakeAccount.setLastName(person.getLastName());
4344
fakeAccount.setEmail(person.getEmail());
4445
fakeAccount.setBirthday(LocalDate.of(
4546
person.getDateOfBirth().getYear(),
4647
person.getDateOfBirth().getMonthOfYear(),
4748
person.getDateOfBirth().getDayOfMonth()));
4849
fakeAccount.setBalance(BigDecimal.valueOf(random.nextInt(200_000)));
49-
fakeAccount.setCreationDate(LocalDate.now());
50+
fakeAccount.setCreationDate(LocalDateTime.now());
5051

5152
return fakeAccount;
5253
}

0 commit comments

Comments
 (0)