Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nmarulo committed Oct 23, 2024
2 parents 76766df + 883684e commit 3f3aef5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/test/java/dev/nmarulo/depensaapp/FakeTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import net.datafaker.Faker;

import java.time.LocalDateTime;
import java.time.ZoneId;

public final class FakeTestUtil {

public static final Faker faker;
Expand Down Expand Up @@ -44,10 +47,15 @@ public static String randomUsername() {
return faker.internet()
.username();
}

public static String randomImage() {
return faker.internet()
.image();
}

public static LocalDateTime randomFuture() {
return LocalDateTime.ofInstant(faker.timeAndDate()
.future(), ZoneId.systemDefault());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static Product initProduct() {
product.setCalories(BigDecimal.ZERO);
product.setDescription(FakeTestUtil.randomSentence());
product.setCreatedAt(LocalDateTime.now());
product.setUpdatedAt(LocalDateTime.now());
product.setUpdatedAt(FakeTestUtil.randomFuture());
product.setProductHasShoppingList(Collections.emptySet());

return product;
Expand All @@ -88,7 +88,7 @@ private User initUser() {
user.setPassword(FakeTestUtil.randomPassword());
user.setEmail(FakeTestUtil.randomEmail());
user.setCreatedAt(LocalDateTime.now());
user.setUpdatedAt(LocalDateTime.now());
user.setUpdatedAt(FakeTestUtil.randomFuture());
user.setShoppingLists(Collections.emptySet());

return user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private User initUser() {
user.setPassword(FakeTestUtil.randomPassword());
user.setEmail(FakeTestUtil.randomEmail());
user.setCreatedAt(LocalDateTime.now());
user.setUpdatedAt(LocalDateTime.now());
user.setUpdatedAt(FakeTestUtil.randomFuture());
user.setShoppingLists(Collections.emptySet());

return user;
Expand All @@ -51,7 +51,7 @@ private ShoppingList initShoppingList(User user) {
shoppingList.setTotalCalories(BigDecimal.ZERO);
shoppingList.setTotalPrice(BigDecimal.ZERO);
shoppingList.setCreatedAt(LocalDateTime.now());
shoppingList.setUpdatedAt(LocalDateTime.now());
shoppingList.setUpdatedAt(FakeTestUtil.randomFuture());
shoppingList.setProductHasShoppingList(Collections.emptySet());
shoppingList.setUser(user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private UnitType initUnitType() {
unitType.setId(FakeTestUtil.randomInteger());
unitType.setName(FakeTestUtil.randomWord());
unitType.setCreatedAt(LocalDateTime.now());
unitType.setUpdatedAt(LocalDateTime.now());
unitType.setUpdatedAt(FakeTestUtil.randomFuture());
unitType.setProductHasShoppingList(Collections.emptySet());

return unitType;
Expand Down

0 comments on commit 3f3aef5

Please sign in to comment.