diff --git a/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeControllerTests.java b/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeControllerTests.java index a193f1c..d87aa63 100644 --- a/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeControllerTests.java +++ b/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeControllerTests.java @@ -172,7 +172,7 @@ public class RecipeControllerTests { public void getFullRecipeViewPrincipalIsStarer() throws Exception { final User owner = this.createTestUser("owner"); final Recipe recipe = this.createTestRecipe(owner, false); - this.recipeStarService.create(recipe.getId(), owner.getUsername()); + this.recipeStarService.create(recipe.getId(), owner.getId()); final String accessToken = this.getAccessToken(owner); this.mockMvc.perform( get("/recipes/{username}/{slug}", recipe.getOwner().getUsername(), recipe.getSlug()) @@ -338,7 +338,7 @@ public class RecipeControllerTests { final User owner = this.createTestUser("recipe-owner"); final User starer = this.createTestUser("recipe-starer"); final Recipe recipe = this.createTestRecipe(owner, true); - this.recipeStarService.create(recipe.getId(), starer.getUsername()); + this.recipeStarService.create(recipe.getId(), starer.getId()); this.mockMvc.perform( get("/recipes/{username}/{slug}/star", recipe.getOwner().getUsername(), recipe.getSlug()) .header("Authorization", "Bearer " + this.getAccessToken(starer)) @@ -355,7 +355,7 @@ public class RecipeControllerTests { final User owner = this.createTestUser("recipe-owner"); final User starer = this.createTestUser("recipe-starer"); final Recipe recipe = this.createTestRecipe(owner, true); - this.recipeStarService.create(recipe.getId(), starer.getUsername()); + this.recipeStarService.create(recipe.getId(), starer.getId()); this.mockMvc.perform( delete("/recipes/{username}/{slug}/star", recipe.getOwner().getUsername(), recipe.getSlug()) .header("Authorization", "Bearer " + this.getAccessToken(starer)) diff --git a/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeRepositoryTests.java b/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeRepositoryTests.java index 1f66155..b771eb2 100644 --- a/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeRepositoryTests.java +++ b/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeRepositoryTests.java @@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; -import java.time.LocalDateTime; +import java.time.OffsetDateTime; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -43,7 +43,7 @@ public class RecipeRepositoryTests { @DirtiesContext public void findsAllPublicRecipes() { final RecipeEntity publicRecipe = new RecipeEntity(); - publicRecipe.setCreated(LocalDateTime.now()); + publicRecipe.setCreated(OffsetDateTime.now()); publicRecipe.setSlug("public-recipe"); publicRecipe.setPublic(true); publicRecipe.setOwner(this.getOwnerUser()); @@ -59,7 +59,7 @@ public class RecipeRepositoryTests { @DirtiesContext public void doesNotFindNonPublicRecipe() { final RecipeEntity nonPublicRecipe = new RecipeEntity(); - nonPublicRecipe.setCreated(LocalDateTime.now()); + nonPublicRecipe.setCreated(OffsetDateTime.now()); nonPublicRecipe.setSlug("non-public-recipe"); nonPublicRecipe.setOwner(this.getOwnerUser()); nonPublicRecipe.setTitle("Non-Public Recipe"); @@ -74,7 +74,7 @@ public class RecipeRepositoryTests { @DirtiesContext public void findsAllForViewer() { final RecipeEntity recipe = new RecipeEntity(); - recipe.setCreated(LocalDateTime.now()); + recipe.setCreated(OffsetDateTime.now()); recipe.setSlug("test-recipe"); recipe.setOwner(this.getOwnerUser()); recipe.setTitle("Test Recipe"); @@ -96,7 +96,7 @@ public class RecipeRepositoryTests { @DirtiesContext public void doesNotIncludeNonViewable() { final RecipeEntity recipe = new RecipeEntity(); - recipe.setCreated(LocalDateTime.now()); + recipe.setCreated(OffsetDateTime.now()); recipe.setSlug("test-recipe"); recipe.setOwner(this.getOwnerUser()); recipe.setTitle("Test Recipe"); diff --git a/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeServiceTests.java b/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeServiceTests.java index 0e89140..ceb5f8b 100644 --- a/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeServiceTests.java +++ b/src/integrationTest/java/app/mealsmadeeasy/api/recipe/RecipeServiceTests.java @@ -145,7 +145,7 @@ public class RecipeServiceTests { public void getByIdOkayWithStarsPublicAndNoViewer() { final User owner = this.createTestUser("recipeOwner"); final Recipe recipe = this.createTestRecipe(owner, true); - final RecipeStar star = this.recipeStarService.create(recipe.getId(), owner.getUsername()); + final RecipeStar star = this.recipeStarService.create(recipe.getId(), owner.getId()); final Recipe byIdWithStars = assertDoesNotThrow(() -> this.recipeService.getByIdWithStars( recipe.getId(), null )); @@ -190,9 +190,9 @@ public class RecipeServiceTests { final Recipe r2 = this.createTestRecipe(owner, true, "r2"); // r0.stars = 0, r1.stars = 1, r2.stars = 2 - this.recipeStarService.create(r1.getId(), u0.getUsername()); - this.recipeStarService.create(r2.getId(), u0.getUsername()); - this.recipeStarService.create(r2.getId(), u1.getUsername()); + this.recipeStarService.create(r1.getId(), u0.getId()); + this.recipeStarService.create(r2.getId(), u0.getId()); + this.recipeStarService.create(r2.getId(), u1.getId()); final List zeroStars = this.recipeService.getByMinimumStars(0, null); final List oneStar = this.recipeService.getByMinimumStars(1, null); @@ -226,9 +226,9 @@ public class RecipeServiceTests { } // r0.stars = 0, r1.stars = 1, r2.stars = 2 - this.recipeStarService.create(r1.getId(), u0.getUsername()); - this.recipeStarService.create(r2.getId(), u0.getUsername()); - this.recipeStarService.create(r2.getId(), u1.getUsername()); + this.recipeStarService.create(r1.getId(), u0.getId()); + this.recipeStarService.create(r2.getId(), u0.getId()); + this.recipeStarService.create(r2.getId(), u1.getId()); final List zeroStarsNoneViewable = this.recipeService.getByMinimumStars(0, viewer); final List oneStarNoneViewable = this.recipeService.getByMinimumStars(1, viewer); diff --git a/src/integrationTest/java/app/mealsmadeeasy/api/recipe/star/RecipeStarServiceTests.java b/src/integrationTest/java/app/mealsmadeeasy/api/recipe/star/RecipeStarServiceTests.java index a9c9d2e..26b4d2f 100644 --- a/src/integrationTest/java/app/mealsmadeeasy/api/recipe/star/RecipeStarServiceTests.java +++ b/src/integrationTest/java/app/mealsmadeeasy/api/recipe/star/RecipeStarServiceTests.java @@ -58,7 +58,7 @@ public class RecipeStarServiceTests { recipe.getSlug(), starer )); - assertThat(star.getDate(), is(notNullValue())); + assertThat(star.getTimestamp(), is(notNullValue())); } @Test @@ -69,9 +69,9 @@ public class RecipeStarServiceTests { final Recipe recipe = this.getTestRecipe(owner, "test-recipe", true); final RecipeStar star = assertDoesNotThrow(() -> this.recipeStarService.create( recipe.getId(), - starer.getUsername() + starer.getId() )); - assertThat(star.getDate(), is(notNullValue())); + assertThat(star.getTimestamp(), is(notNullValue())); } @Test @@ -80,7 +80,7 @@ public class RecipeStarServiceTests { final User owner = this.getTestUser("recipe-owner"); final User starer = this.getTestUser("recipe-starer"); final Recipe recipe = this.getTestRecipe(owner, "test-recipe", true); - this.recipeStarService.create(recipe.getId(), starer.getUsername()); + this.recipeStarService.create(recipe.getId(), starer.getId()); final @Nullable RecipeStar star = this.recipeStarService.find( recipe.getOwner().getUsername(), recipe.getSlug(), @@ -95,7 +95,7 @@ public class RecipeStarServiceTests { final User owner = this.getTestUser("recipe-owner"); final User starer = this.getTestUser("recipe-starer"); final Recipe recipe = this.getTestRecipe(owner, "test-recipe", true); - this.recipeStarService.create(recipe.getId(), starer.getUsername()); + this.recipeStarService.create(recipe.getId(), starer.getId()); assertDoesNotThrow(() -> this.recipeStarService.delete( recipe.getOwner().getUsername(), recipe.getSlug(), diff --git a/src/main/java/app/mealsmadeeasy/api/job/JobEntity.java b/src/main/java/app/mealsmadeeasy/api/job/JobEntity.java new file mode 100644 index 0000000..0a7b469 --- /dev/null +++ b/src/main/java/app/mealsmadeeasy/api/job/JobEntity.java @@ -0,0 +1,21 @@ +package app.mealsmadeeasy.api.job; + +import jakarta.persistence.Column; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +public class JobEntity { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(nullable = false, updatable = false) + private Long id; + + @Column(nullable = false) + private String key; + + @Column(nullable = false, columnDefinition = "jsonb") + private String payload; + +} diff --git a/src/main/java/app/mealsmadeeasy/api/recipe/view/RecipeInfoView.java b/src/main/java/app/mealsmadeeasy/api/recipe/view/RecipeInfoView.java index c7f214c..e1ea529 100644 --- a/src/main/java/app/mealsmadeeasy/api/recipe/view/RecipeInfoView.java +++ b/src/main/java/app/mealsmadeeasy/api/recipe/view/RecipeInfoView.java @@ -26,7 +26,7 @@ public final class RecipeInfoView { return view; } - private long id; + private Integer id; private OffsetDateTime created; private OffsetDateTime modified; private String slug; @@ -39,11 +39,11 @@ public final class RecipeInfoView { private int starCount; private @Nullable ImageView mainImage; - public long getId() { + public Integer getId() { return this.id; } - public void setId(long id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/testFixtures/java/app/mealsmadeeasy/api/image/ContainsImagesMatcher.java b/src/testFixtures/java/app/mealsmadeeasy/api/image/ContainsImagesMatcher.java index cad6788..9564330 100644 --- a/src/testFixtures/java/app/mealsmadeeasy/api/image/ContainsImagesMatcher.java +++ b/src/testFixtures/java/app/mealsmadeeasy/api/image/ContainsImagesMatcher.java @@ -4,7 +4,7 @@ import app.mealsmadeeasy.api.matchers.ContainsItemsMatcher; import java.util.List; -public final class ContainsImagesMatcher extends ContainsItemsMatcher { +public final class ContainsImagesMatcher extends ContainsItemsMatcher { public static ContainsImagesMatcher containsImages(Image... expected) { return new ContainsImagesMatcher(expected); diff --git a/src/testFixtures/java/app/mealsmadeeasy/api/recipe/ContainsRecipeInfoViewsForRecipesMatcher.java b/src/testFixtures/java/app/mealsmadeeasy/api/recipe/ContainsRecipeInfoViewsForRecipesMatcher.java index cd3b42b..2fcb2c0 100644 --- a/src/testFixtures/java/app/mealsmadeeasy/api/recipe/ContainsRecipeInfoViewsForRecipesMatcher.java +++ b/src/testFixtures/java/app/mealsmadeeasy/api/recipe/ContainsRecipeInfoViewsForRecipesMatcher.java @@ -5,7 +5,7 @@ import app.mealsmadeeasy.api.recipe.view.RecipeInfoView; import java.util.List; -public class ContainsRecipeInfoViewsForRecipesMatcher extends ContainsItemsMatcher { +public class ContainsRecipeInfoViewsForRecipesMatcher extends ContainsItemsMatcher { public static ContainsRecipeInfoViewsForRecipesMatcher containsRecipeInfoViewsForRecipes(Recipe... expected) { return new ContainsRecipeInfoViewsForRecipesMatcher(List.of(expected)); diff --git a/src/testFixtures/java/app/mealsmadeeasy/api/recipe/ContainsRecipesMatcher.java b/src/testFixtures/java/app/mealsmadeeasy/api/recipe/ContainsRecipesMatcher.java index bb0d8f9..b9d0c94 100644 --- a/src/testFixtures/java/app/mealsmadeeasy/api/recipe/ContainsRecipesMatcher.java +++ b/src/testFixtures/java/app/mealsmadeeasy/api/recipe/ContainsRecipesMatcher.java @@ -4,7 +4,7 @@ import app.mealsmadeeasy.api.matchers.ContainsItemsMatcher; import java.util.List; -public final class ContainsRecipesMatcher extends ContainsItemsMatcher { +public final class ContainsRecipesMatcher extends ContainsItemsMatcher { public static ContainsRecipesMatcher containsRecipes(Recipe... expected) { return new ContainsRecipesMatcher(expected); diff --git a/src/testFixtures/java/app/mealsmadeeasy/api/user/ContainsUsersMatcher.java b/src/testFixtures/java/app/mealsmadeeasy/api/user/ContainsUsersMatcher.java index 700d669..71258e6 100644 --- a/src/testFixtures/java/app/mealsmadeeasy/api/user/ContainsUsersMatcher.java +++ b/src/testFixtures/java/app/mealsmadeeasy/api/user/ContainsUsersMatcher.java @@ -4,7 +4,7 @@ import app.mealsmadeeasy.api.matchers.ContainsItemsMatcher; import java.util.List; -public class ContainsUsersMatcher extends ContainsItemsMatcher { +public class ContainsUsersMatcher extends ContainsItemsMatcher { public static ContainsUsersMatcher containsUsers(User... allExpected) { return new ContainsUsersMatcher(allExpected);