Fix tests to compile.

This commit is contained in:
Jesse Brault 2025-12-26 13:50:18 -06:00
parent 1fefeaa1da
commit b9e7ccedce
10 changed files with 48 additions and 27 deletions

View File

@ -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))

View File

@ -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");

View File

@ -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<Recipe> zeroStars = this.recipeService.getByMinimumStars(0, null);
final List<Recipe> 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<Recipe> zeroStarsNoneViewable = this.recipeService.getByMinimumStars(0, viewer);
final List<Recipe> oneStarNoneViewable = this.recipeService.getByMinimumStars(1, viewer);

View File

@ -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(),

View File

@ -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;
}

View File

@ -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;
}

View File

@ -4,7 +4,7 @@ import app.mealsmadeeasy.api.matchers.ContainsItemsMatcher;
import java.util.List;
public final class ContainsImagesMatcher extends ContainsItemsMatcher<Image, Image, Long> {
public final class ContainsImagesMatcher extends ContainsItemsMatcher<Image, Image, Integer> {
public static ContainsImagesMatcher containsImages(Image... expected) {
return new ContainsImagesMatcher(expected);

View File

@ -5,7 +5,7 @@ import app.mealsmadeeasy.api.recipe.view.RecipeInfoView;
import java.util.List;
public class ContainsRecipeInfoViewsForRecipesMatcher extends ContainsItemsMatcher<RecipeInfoView, Recipe, Long> {
public class ContainsRecipeInfoViewsForRecipesMatcher extends ContainsItemsMatcher<RecipeInfoView, Recipe, Integer> {
public static ContainsRecipeInfoViewsForRecipesMatcher containsRecipeInfoViewsForRecipes(Recipe... expected) {
return new ContainsRecipeInfoViewsForRecipesMatcher(List.of(expected));

View File

@ -4,7 +4,7 @@ import app.mealsmadeeasy.api.matchers.ContainsItemsMatcher;
import java.util.List;
public final class ContainsRecipesMatcher extends ContainsItemsMatcher<Recipe, Recipe, Long> {
public final class ContainsRecipesMatcher extends ContainsItemsMatcher<Recipe, Recipe, Integer> {
public static ContainsRecipesMatcher containsRecipes(Recipe... expected) {
return new ContainsRecipesMatcher(expected);

View File

@ -4,7 +4,7 @@ import app.mealsmadeeasy.api.matchers.ContainsItemsMatcher;
import java.util.List;
public class ContainsUsersMatcher extends ContainsItemsMatcher<User, User, Long> {
public class ContainsUsersMatcher extends ContainsItemsMatcher<User, User, Integer> {
public static ContainsUsersMatcher containsUsers(User... allExpected) {
return new ContainsUsersMatcher(allExpected);