Ensuring consistency of nullable mainImage in recipe views and tests.

This commit is contained in:
Jesse Brault 2024-08-17 10:58:42 -05:00
parent c163e8ee1d
commit 0d86ab6d93
4 changed files with 11 additions and 8 deletions

View File

@ -147,6 +147,7 @@ public class RecipeControllerTests {
.andExpect(jsonPath("$.recipe.starCount").value(0)) .andExpect(jsonPath("$.recipe.starCount").value(0))
.andExpect(jsonPath("$.recipe.viewerCount").value(0)) .andExpect(jsonPath("$.recipe.viewerCount").value(0))
.andExpect(jsonPath("$.recipe.isPublic").value(true)) .andExpect(jsonPath("$.recipe.isPublic").value(true))
.andExpect(jsonPath("$.recipe.mainImage").value(nullValue()))
.andExpect(jsonPath("$.isStarred").value(nullValue())) .andExpect(jsonPath("$.isStarred").value(nullValue()))
.andExpect(jsonPath("$.isOwner").value(nullValue())); .andExpect(jsonPath("$.isOwner").value(nullValue()));
} }
@ -218,7 +219,8 @@ public class RecipeControllerTests {
.andExpect(jsonPath("$.content[0].owner.id").value(owner.getId())) .andExpect(jsonPath("$.content[0].owner.id").value(owner.getId()))
.andExpect(jsonPath("$.content[0].owner.username").value(owner.getUsername())) .andExpect(jsonPath("$.content[0].owner.username").value(owner.getUsername()))
.andExpect(jsonPath("$.content[0].isPublic").value(true)) .andExpect(jsonPath("$.content[0].isPublic").value(true))
.andExpect(jsonPath("$.content[0].starCount").value(0)); .andExpect(jsonPath("$.content[0].starCount").value(0))
.andExpect(jsonPath("$.content[0].mainImage").value(nullValue()));
} }
@Test @Test
@ -277,6 +279,7 @@ public class RecipeControllerTests {
.andExpect(jsonPath("$.recipe.starCount").value(0)) .andExpect(jsonPath("$.recipe.starCount").value(0))
.andExpect(jsonPath("$.recipe.viewerCount").value(0)) .andExpect(jsonPath("$.recipe.viewerCount").value(0))
.andExpect(jsonPath("$.recipe.isPublic").value(true)) .andExpect(jsonPath("$.recipe.isPublic").value(true))
.andExpect(jsonPath("$.recipe.mainImage").value(nullValue()))
.andExpect(jsonPath("$.isStarred").value(false)) .andExpect(jsonPath("$.isStarred").value(false))
.andExpect(jsonPath("$.isOwner").value(true)); .andExpect(jsonPath("$.isOwner").value(true));
} }

View File

@ -24,5 +24,5 @@ public interface Recipe {
boolean isPublic(); boolean isPublic();
Set<User> getViewers(); Set<User> getViewers();
Set<RecipeComment> getComments(); Set<RecipeComment> getComments();
Image getMainImage(); @Nullable Image getMainImage();
} }

View File

@ -224,11 +224,11 @@ public final class RecipeEntity implements Recipe {
} }
@Override @Override
public S3ImageEntity getMainImage() { public @Nullable S3ImageEntity getMainImage() {
return this.mainImage; return this.mainImage;
} }
public void setMainImage(S3ImageEntity image) { public void setMainImage(@Nullable S3ImageEntity image) {
this.mainImage = image; this.mainImage = image;
} }

View File

@ -17,7 +17,7 @@ public class FullRecipeView {
boolean includeRawText, boolean includeRawText,
int starCount, int starCount,
int viewerCount, int viewerCount,
ImageView mainImage @Nullable ImageView mainImage
) { ) {
final FullRecipeView view = new FullRecipeView(); final FullRecipeView view = new FullRecipeView();
view.setId(recipe.getId()); view.setId(recipe.getId());
@ -53,7 +53,7 @@ public class FullRecipeView {
private UserInfoView owner; private UserInfoView owner;
private int starCount; private int starCount;
private int viewerCount; private int viewerCount;
private ImageView mainImage; private @Nullable ImageView mainImage;
private boolean isPublic; private boolean isPublic;
public long getId() { public long getId() {
@ -161,11 +161,11 @@ public class FullRecipeView {
this.viewerCount = viewerCount; this.viewerCount = viewerCount;
} }
public ImageView getMainImage() { public @Nullable ImageView getMainImage() {
return this.mainImage; return this.mainImage;
} }
public void setMainImage(ImageView mainImage) { public void setMainImage(@Nullable ImageView mainImage) {
this.mainImage = mainImage; this.mainImage = mainImage;
} }