Skip to content

Commit

Permalink
Merge pull request #40 from ReBy298/feature/randomPast-method
Browse files Browse the repository at this point in the history
feat: Add randomPast method (ref #37)
  • Loading branch information
nmarulo authored Oct 24, 2024
2 parents 3f3aef5 + b3d086a commit 76b7372
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/test/java/dev/nmarulo/depensaapp/FakeTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ public static LocalDateTime randomFuture() {
.future(), ZoneId.systemDefault());
}

public static LocalDateTime randomPast() {
return LocalDateTime.ofInstant(faker.timeAndDate()
.past(), ZoneId.systemDefault());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static Product initProduct() {
product.setImgUrl(FakeTestUtil.randomImage());
product.setCalories(BigDecimal.ZERO);
product.setDescription(FakeTestUtil.randomSentence());
product.setCreatedAt(LocalDateTime.now());
product.setCreatedAt(FakeTestUtil.randomPast());
product.setUpdatedAt(FakeTestUtil.randomFuture());
product.setProductHasShoppingList(Collections.emptySet());

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

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

Expand All @@ -50,7 +50,7 @@ private ShoppingList initShoppingList(User user) {
shoppingList.setTotalProducts(0);
shoppingList.setTotalCalories(BigDecimal.ZERO);
shoppingList.setTotalPrice(BigDecimal.ZERO);
shoppingList.setCreatedAt(LocalDateTime.now());
shoppingList.setCreatedAt(FakeTestUtil.randomPast());
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 @@ -46,7 +46,7 @@ private UnitType initUnitType() {

unitType.setId(FakeTestUtil.randomInteger());
unitType.setName(FakeTestUtil.randomWord());
unitType.setCreatedAt(LocalDateTime.now());
unitType.setCreatedAt(FakeTestUtil.randomPast());
unitType.setUpdatedAt(FakeTestUtil.randomFuture());
unitType.setProductHasShoppingList(Collections.emptySet());

Expand Down

0 comments on commit 76b7372

Please sign in to comment.