diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/DataBackwardsCompatibilityEnabler.java b/src/main/java/me/ezzedine/mohammed/personalspace/DataBackwardsCompatibilityEnabler.java index c9f5f1f..2886464 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/DataBackwardsCompatibilityEnabler.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/DataBackwardsCompatibilityEnabler.java @@ -7,7 +7,6 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; -import java.time.LocalDateTime; import java.util.List; @Slf4j @@ -22,16 +21,8 @@ public void run(String... args) { List articles = articleMongoRepository.findAll(); for (ArticleEntity article : articles) { - if (article.getCreatedDate() == null) { - article.setCreatedDate(LocalDateTime.now()); - } - - if (article.getLastModifiedDate() == null) { - article.setLastModifiedDate(LocalDateTime.now()); - } - - if (article.getVersion() == null) { - articleMongoRepository.deleteById(article.getId()); + if (article.getEstimatedReadingTime() == null) { + article.setEstimatedReadingTime(""); } articleMongoRepository.save(article); diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiMapper.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiMapper.java index 27cfb11..0a79c20 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiMapper.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiMapper.java @@ -6,14 +6,14 @@ public class ArticleApiMapper { public static ArticleApiModel toApiModel(Article article) { return ArticleApiModel.builder().id(article.getId()).title(article.getTitle()).description(article.getDescription()) .content(article.getContent()).categoryId(article.getCategoryId()).thumbnailImageUrl(article.getThumbnailImageUrl()) - .keywords(article.getKeywords()).createdDate(article.getCreatedDate().toString()) + .keywords(article.getKeywords()).createdDate(article.getCreatedDate().toString()).estimatedReadingTime(article.getEstimatedReadingTime()) .lastModifiedDate(article.getLastModifiedDate().toString()).hidden(article.isHidden()).build(); } public static ArticleSummaryApiModel toSummaryApiModel(Article article) { return ArticleSummaryApiModel.builder().id(article.getId()).title(article.getTitle()).description(article.getDescription()) .categoryId(article.getCategoryId()).thumbnailImageUrl(article.getThumbnailImageUrl()) - .keywords(article.getKeywords()).createdDate(article.getCreatedDate().toString()) + .keywords(article.getKeywords()).createdDate(article.getCreatedDate().toString()).estimatedReadingTime(article.getEstimatedReadingTime()) .lastModifiedDate(article.getLastModifiedDate().toString()).hidden(article.isHidden()).build(); } } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiModel.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiModel.java index 863e460..3cebcad 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiModel.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiModel.java @@ -8,8 +8,5 @@ @SuperBuilder @EqualsAndHashCode(callSuper = true) public class ArticleApiModel extends ArticleSummaryApiModel { - private String content; - - } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleController.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleController.java index 36deb13..9a59192 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleController.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleController.java @@ -75,12 +75,13 @@ private static ArticlesFetchCriteria getFetchCriteria(ArticlesFetchApiCriteria f private static ArticleUpdateRequest toDomainModel(String id, ArticleUpdateApiRequest request) { return ArticleUpdateRequest.builder().id(id).title(request.getTitle()).description(request.getDescription()) .content(request.getContent()).categoryId(request.getCategoryId()).thumbnailImageUrl(request.getThumbnailImageUrl()) - .keywords(request.getKeywords()).hidden(request.getHidden()).build(); + .keywords(request.getKeywords()).hidden(request.getHidden()).estimatedReadingTime(request.getEstimatedReadingTime()).build(); } private static ArticleCreationRequest toDomainModel(ArticleCreationApiRequest request) { return ArticleCreationRequest.builder().title(request.getTitle()).content(request.getContent()) .description(request.getDescription()).categoryId(request.getCategoryId()).hidden(request.getHidden()) - .thumbnailImageUrl(request.getThumbnailImageUrl()).keywords(request.getKeywords()).build(); + .thumbnailImageUrl(request.getThumbnailImageUrl()).keywords(request.getKeywords()) + .estimatedReadingTime(request.getEstimatedReadingTime()).build(); } } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleCreationApiRequest.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleCreationApiRequest.java index dda836b..66f7b07 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleCreationApiRequest.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleCreationApiRequest.java @@ -22,4 +22,6 @@ public class ArticleCreationApiRequest { private List keywords; @NonNull private Boolean hidden; + @NonNull + private String estimatedReadingTime; } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleSummaryApiModel.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleSummaryApiModel.java index 24e2dcb..f332d24 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleSummaryApiModel.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleSummaryApiModel.java @@ -17,4 +17,5 @@ public class ArticleSummaryApiModel { private String lastModifiedDate; private Boolean hidden; private List keywords; + private String estimatedReadingTime; } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleUpdateApiRequest.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleUpdateApiRequest.java index e7be637..d7a5980 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleUpdateApiRequest.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/api/ArticleUpdateApiRequest.java @@ -19,4 +19,5 @@ public class ArticleUpdateApiRequest { private String thumbnailImageUrl; private List keywords; private Boolean hidden; + private String estimatedReadingTime; } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/core/Article.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/core/Article.java index b8c8ad7..032dd39 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/core/Article.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/core/Article.java @@ -22,6 +22,8 @@ public class Article { @NonNull private String content; private String thumbnailImageUrl; + @NonNull + private String estimatedReadingTime; @Builder.Default private List keywords = new ArrayList<>(); private boolean hidden; diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleCreationRequest.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleCreationRequest.java index 979dcf6..344ab87 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleCreationRequest.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleCreationRequest.java @@ -22,4 +22,6 @@ public class ArticleCreationRequest { private List keywords; @NonNull private Boolean hidden; + @NonNull + private String estimatedReadingTime; } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleService.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleService.java index 6c3d3f9..973787d 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleService.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleService.java @@ -50,6 +50,7 @@ public void edit(ArticleUpdateRequest request) throws ArticleNotFoundException, request.getThumbnailImageUrl().ifPresent(article::setThumbnailImageUrl); request.getKeywords().ifPresent(article::setKeywords); request.getHidden().ifPresent(article::setHidden); + request.getEstimatedReadingTime().ifPresent(article::setEstimatedReadingTime); storage.save(article); } @@ -62,7 +63,7 @@ private String saveArticleInStorage(ArticleCreationRequest request) { String articleId = idGenerator.generate(); Article article = Article.builder().id(articleId).content(request.getContent()).categoryId(request.getCategoryId()) .description(request.getDescription()).title(request.getTitle()).thumbnailImageUrl(request.getThumbnailImageUrl()) - .keywords(request.getKeywords()).hidden(request.getHidden()).build(); + .keywords(request.getKeywords()).hidden(request.getHidden()).estimatedReadingTime(request.getEstimatedReadingTime()).build(); storage.save(article); return articleId; } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleUpdateRequest.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleUpdateRequest.java index 0bca600..b2ed25e 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleUpdateRequest.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/core/ArticleUpdateRequest.java @@ -17,6 +17,7 @@ public class ArticleUpdateRequest { private String thumbnailImageUrl; private List keywords; private Boolean hidden; + private String estimatedReadingTime; public Optional getTitle() { return Optional.ofNullable(title); @@ -45,4 +46,8 @@ public Optional> getKeywords() { public Optional getHidden() { return Optional.ofNullable(hidden); } + + public Optional getEstimatedReadingTime() { + return Optional.ofNullable(estimatedReadingTime); + } } diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleEntity.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleEntity.java index 3ad7bfd..3c794c0 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleEntity.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleEntity.java @@ -26,6 +26,7 @@ public class ArticleEntity { private String thumbnailImageUrl; private List keywords; private boolean hidden; + private String estimatedReadingTime; @CreatedDate private LocalDateTime createdDate; @LastModifiedDate diff --git a/src/main/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleStorageManager.java b/src/main/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleStorageManager.java index d8d96b5..29f7b91 100644 --- a/src/main/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleStorageManager.java +++ b/src/main/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleStorageManager.java @@ -96,7 +96,7 @@ private static ArticleEntity toEntity(Article article) { return ArticleEntity.builder().id(article.getId()).title(article.getTitle()).description(article.getDescription()) .content(article.getContent()).categoryId(article.getCategoryId()).thumbnailImageUrl(article.getThumbnailImageUrl()) .keywords(article.getKeywords()).version(article.getVersion()).createdDate(article.getCreatedDate()) - .lastModifiedDate(article.getLastModifiedDate()).hidden(article.isHidden()).build(); + .lastModifiedDate(article.getLastModifiedDate()).hidden(article.isHidden()).estimatedReadingTime(article.getEstimatedReadingTime()).build(); } private static Article fromEntity(ArticleEntity articleEntity) { @@ -104,6 +104,6 @@ private static Article fromEntity(ArticleEntity articleEntity) { .description(articleEntity.getDescription()).categoryId(articleEntity.getCategoryId()) .thumbnailImageUrl(articleEntity.getThumbnailImageUrl()).keywords(articleEntity.getKeywords()) .createdDate(articleEntity.getCreatedDate()).lastModifiedDate(articleEntity.getLastModifiedDate()) - .version(articleEntity.getVersion()).hidden(articleEntity.isHidden()).build(); + .version(articleEntity.getVersion()).hidden(articleEntity.isHidden()).estimatedReadingTime(articleEntity.getEstimatedReadingTime()).build(); } } diff --git a/src/test/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiTestUtil.java b/src/test/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiTestUtil.java index db9b21e..b7d5c93 100644 --- a/src/test/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiTestUtil.java +++ b/src/test/java/me/ezzedine/mohammed/personalspace/article/api/ArticleApiTestUtil.java @@ -17,11 +17,12 @@ public class ArticleApiTestUtil { public static final String CREATED_DATE = "2023-12-24T12:33:42.411"; public static final String LAST_MODIFIED_DATE = "2023-12-24T12:34:51.182"; public static final boolean HIDDEN = true; + public static final String ESTIMATED_READING_TIME = "estimatedReadingTime"; public static Article getArticle() { return Article.builder().id(ARTICLE_ID).title(TITLE).description(DESCRIPTION).content(CONTENT) .categoryId(CATEGORY_ID).thumbnailImageUrl(ARTICLE_THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)) .version(1L).createdDate(LocalDateTime.parse(CREATED_DATE)).lastModifiedDate(LocalDateTime.parse(LAST_MODIFIED_DATE)) - .hidden(HIDDEN).build(); + .hidden(HIDDEN).estimatedReadingTime(ESTIMATED_READING_TIME).build(); } } diff --git a/src/test/java/me/ezzedine/mohammed/personalspace/article/api/ArticleControllerIntegrationTest.java b/src/test/java/me/ezzedine/mohammed/personalspace/article/api/ArticleControllerIntegrationTest.java index 99f6303..1362232 100644 --- a/src/test/java/me/ezzedine/mohammed/personalspace/article/api/ArticleControllerIntegrationTest.java +++ b/src/test/java/me/ezzedine/mohammed/personalspace/article/api/ArticleControllerIntegrationTest.java @@ -191,7 +191,7 @@ void should_return_a_created_success_status_on_the_happy_path() throws Exception ArticleCreationRequest request = ArticleCreationRequest.builder().title(TITLE).description(DESCRIPTION) .content(CONTENT).categoryId(CATEGORY_ID).thumbnailImageUrl(ARTICLE_THUMBNAIL_IMAGE_URL) - .keywords(List.of(KEYWORD)).hidden(HIDDEN).build(); + .keywords(List.of(KEYWORD)).hidden(HIDDEN).estimatedReadingTime(ESTIMATED_READING_TIME).build(); verify(articleCreator).create(request); } @@ -234,7 +234,7 @@ void should_return_a_success_status_on_the_happy_path() throws Exception { ArticleUpdateRequest request = ArticleUpdateRequest.builder().id(ARTICLE_ID).title("updatedArticleTitle") .categoryId("updatedArticleCategoryId").content("updatedArticleContent").description("updatedArticleDescription") .thumbnailImageUrl("updatedArticleThumbnailImageUrl").keywords(List.of("updatedArticleKeyword")) - .hidden(true).build(); + .hidden(true).estimatedReadingTime("updatedEstimatedReadingTime").build(); verify(articleEditor).edit(request); } diff --git a/src/test/java/me/ezzedine/mohammed/personalspace/article/core/ArticleServiceTest.java b/src/test/java/me/ezzedine/mohammed/personalspace/article/core/ArticleServiceTest.java index f01f923..11be78d 100644 --- a/src/test/java/me/ezzedine/mohammed/personalspace/article/core/ArticleServiceTest.java +++ b/src/test/java/me/ezzedine/mohammed/personalspace/article/core/ArticleServiceTest.java @@ -38,6 +38,8 @@ class ArticleServiceTest { public static final LocalDateTime LAST_MODIFIED_DATE = mock(LocalDateTime.class); public static final boolean HIDDEN = true; public static final boolean UPDATED_HIDDEN = false; + public static final String ESTIMATED_READING_TIME = UUID.randomUUID().toString(); + public static final String UPDATED_ESTIMATED_READING_TIME = UUID.randomUUID().toString(); private ArticleStorage storage; private ArticleService service; private CategoryFetcher categoryFetcher; @@ -91,6 +93,7 @@ void should_save_the_new_article_in_the_storage() throws CategoryNotFoundExcepti assertEquals(THUMBNAIL_IMAGE_URL, argumentCaptor.getValue().getThumbnailImageUrl()); assertEquals(List.of(KEYWORD), argumentCaptor.getValue().getKeywords()); assertEquals(HIDDEN, argumentCaptor.getValue().isHidden()); + assertEquals(ESTIMATED_READING_TIME, argumentCaptor.getValue().getEstimatedReadingTime()); } @Test @@ -102,7 +105,7 @@ void should_return_the_id_of_the_newly_created_article() throws CategoryNotFound private static ArticleCreationRequest getRequest() { return ArticleCreationRequest.builder().categoryId(CATEGORY_ID).title(TITLE).content(CONTENT).description(DESCRIPTION) - .thumbnailImageUrl(THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)).hidden(HIDDEN).build(); + .thumbnailImageUrl(THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)).hidden(HIDDEN).estimatedReadingTime(ESTIMATED_READING_TIME).build(); } } @@ -137,7 +140,7 @@ void it_should_return_the_article_details() throws ArticleNotFoundException { assertEquals(CREATED_DATE, article.getCreatedDate()); assertEquals(LAST_MODIFIED_DATE, article.getLastModifiedDate()); assertEquals(HIDDEN, article.isHidden()); - + assertEquals(ESTIMATED_READING_TIME, article.getEstimatedReadingTime()); } } @@ -182,20 +185,21 @@ void the_new_changes_should_be_saved_successfully_on_the_happy_path() throws Art Article updatedArticle = Article.builder().id(ARTICLE_ID).categoryId(UPDATED_CATEGORY_ID).title(UPDATED_TITLE) .content(UPDATED_CONTENT).description(UPDATED_DESCRIPTION).thumbnailImageUrl(UPDATED_THUMBNAIL_IMAGE_URL) .keywords(List.of(UPDATED_KEYWORD)).version(VERSION).createdDate(CREATED_DATE).lastModifiedDate(LAST_MODIFIED_DATE) - .hidden(UPDATED_HIDDEN).build(); + .hidden(UPDATED_HIDDEN).estimatedReadingTime(UPDATED_ESTIMATED_READING_TIME).build(); verify(storage).save(updatedArticle); } private static ArticleUpdateRequest getRequest() { return ArticleUpdateRequest.builder().id(ARTICLE_ID).categoryId(UPDATED_CATEGORY_ID).title(UPDATED_TITLE) .content(UPDATED_CONTENT).description(UPDATED_DESCRIPTION).thumbnailImageUrl(UPDATED_THUMBNAIL_IMAGE_URL) - .keywords(List.of(UPDATED_KEYWORD)).hidden(UPDATED_HIDDEN).build(); + .keywords(List.of(UPDATED_KEYWORD)).hidden(UPDATED_HIDDEN).estimatedReadingTime(UPDATED_ESTIMATED_READING_TIME).build(); } } private Article getArticle() { return Article.builder().id(ARTICLE_ID).title(TITLE).description(DESCRIPTION).content(CONTENT) .categoryId(CATEGORY_ID).thumbnailImageUrl(THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)) - .version(VERSION).createdDate(CREATED_DATE).lastModifiedDate(LAST_MODIFIED_DATE).hidden(true).build(); + .version(VERSION).createdDate(CREATED_DATE).lastModifiedDate(LAST_MODIFIED_DATE).hidden(true) + .estimatedReadingTime(ESTIMATED_READING_TIME).build(); } } \ No newline at end of file diff --git a/src/test/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleStorageManagerIntegrationTest.java b/src/test/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleStorageManagerIntegrationTest.java index 4bfd9c3..d46ba89 100644 --- a/src/test/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleStorageManagerIntegrationTest.java +++ b/src/test/java/me/ezzedine/mohammed/personalspace/article/infra/ArticleStorageManagerIntegrationTest.java @@ -41,6 +41,7 @@ class ArticleStorageManagerIntegrationTest extends DatabaseIntegrationTest { public static final String THUMBNAIL_IMAGE_URL = UUID.randomUUID().toString(); public static final String KEYWORD = UUID.randomUUID().toString(); public static final boolean HIDDEN = true; + public static final String ESTIMATED_READING_TIME = UUID.randomUUID().toString(); @Autowired private ArticleMongoRepository repository; @@ -74,6 +75,7 @@ void the_article_should_be_persisted_in_the_storage() { assertEquals(THUMBNAIL_IMAGE_URL, allArticles.get(0).getThumbnailImageUrl()); assertEquals(List.of(KEYWORD), allArticles.get(0).getKeywords()); assertEquals(HIDDEN, allArticles.get(0).isHidden()); + assertEquals(ESTIMATED_READING_TIME, allArticles.get(0).getEstimatedReadingTime()); } @Test @@ -108,6 +110,7 @@ void should_override_any_existing_article_with_the_same_id() { assertEquals(THUMBNAIL_IMAGE_URL, allArticles.get(0).getThumbnailImageUrl()); assertEquals(List.of(KEYWORD), allArticles.get(0).getKeywords()); assertEquals(HIDDEN, allArticles.get(0).isHidden()); + assertEquals(ESTIMATED_READING_TIME, allArticles.get(0).getEstimatedReadingTime()); } @Test @@ -145,12 +148,12 @@ void should_not_update_the_created_date_when_overriding_an_existing_article() { private static ArticleEntity getRandomArticleEntity() { return ArticleEntity.builder().id(ID).title(UUID.randomUUID().toString()).categoryId(UUID.randomUUID().toString()) .content(UUID.randomUUID().toString()).description(UUID.randomUUID().toString()).thumbnailImageUrl(UUID.randomUUID().toString()) - .keywords(List.of(UUID.randomUUID().toString())).hidden(false).build(); + .keywords(List.of(UUID.randomUUID().toString())).hidden(false).estimatedReadingTime(UUID.randomUUID().toString()).build(); } private Article getArticle() { return Article.builder().id(ID).categoryId(CATEGORY_ID).title(TITLE).description(DESCRIPTION).content(CONTENT) - .thumbnailImageUrl(THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)).hidden(HIDDEN).build(); + .thumbnailImageUrl(THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)).hidden(HIDDEN).estimatedReadingTime(ESTIMATED_READING_TIME).build(); } } @@ -181,6 +184,7 @@ void it_should_return_the_article_when_it_exists() { assertNotNull(optionalArticle.get().getCreatedDate()); assertNotNull(optionalArticle.get().getLastModifiedDate()); assertEquals(HIDDEN, optionalArticle.get().isHidden()); + assertEquals(ESTIMATED_READING_TIME, optionalArticle.get().getEstimatedReadingTime()); } } @@ -218,6 +222,7 @@ void should_return_all_the_articles_when_they_are_less_than_the_size_of_the_firs assertNotNull(articles.getItems().get(0).getCreatedDate()); assertNotNull(articles.getItems().get(0).getLastModifiedDate()); assertEquals(HIDDEN, articles.getItems().get(0).isHidden()); + assertEquals(ESTIMATED_READING_TIME, articles.getItems().get(0).getEstimatedReadingTime()); } @Test @@ -434,7 +439,7 @@ void should_return_the_list_of_matching_articles() { } private ArticleEntity getEntity(String id, String categoryId) { - return ArticleEntity.builder().id(id).categoryId(categoryId).title(TITLE).description(DESCRIPTION) + return ArticleEntity.builder().id(id).categoryId(categoryId).title(TITLE).description(DESCRIPTION).estimatedReadingTime(ESTIMATED_READING_TIME) .content(CONTENT).thumbnailImageUrl(THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)).hidden(HIDDEN).build(); } } @@ -495,7 +500,8 @@ private static HighlightedArticleEntity getHighlightedArticle(String firstArticl private ArticleEntity getEntity(String id) { return ArticleEntity.builder().id(id).categoryId(CATEGORY_ID).title(TITLE).description(DESCRIPTION) - .content(CONTENT).thumbnailImageUrl(THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)).hidden(HIDDEN).build(); + .content(CONTENT).thumbnailImageUrl(THUMBNAIL_IMAGE_URL).keywords(List.of(KEYWORD)).hidden(HIDDEN) + .estimatedReadingTime(ESTIMATED_READING_TIME).build(); } private ArticleEntity getEntity() { diff --git a/src/test/resources/article/api/all_articles_details_response.json b/src/test/resources/article/api/all_articles_details_response.json index 2c80885..c8e284d 100644 --- a/src/test/resources/article/api/all_articles_details_response.json +++ b/src/test/resources/article/api/all_articles_details_response.json @@ -10,7 +10,8 @@ "createdDate": "2023-12-24T12:33:42.411", "lastModifiedDate": "2023-12-24T12:34:51.182", "hidden": true, - "keywords": ["keyword"] + "keywords": ["keyword"], + "estimatedReadingTime": "estimatedReadingTime" } ] } \ No newline at end of file diff --git a/src/test/resources/article/api/article_details_response.json b/src/test/resources/article/api/article_details_response.json index bc836d7..c1e597a 100644 --- a/src/test/resources/article/api/article_details_response.json +++ b/src/test/resources/article/api/article_details_response.json @@ -8,5 +8,6 @@ "lastModifiedDate": "2023-12-24T12:34:51.182", "hidden": true, "keywords": ["keyword"], + "estimatedReadingTime": "estimatedReadingTime", "content": "articleContent" } \ No newline at end of file diff --git a/src/test/resources/article/api/create_article_request.json b/src/test/resources/article/api/create_article_request.json index 8ff3616..826595e 100644 --- a/src/test/resources/article/api/create_article_request.json +++ b/src/test/resources/article/api/create_article_request.json @@ -5,5 +5,6 @@ "categoryId": "articleCategoryId", "thumbnailImageUrl": "articleThumbnailImageUrl", "keywords": ["keyword"], - "hidden": true + "hidden": true, + "estimatedReadingTime": "estimatedReadingTime" } \ No newline at end of file diff --git a/src/test/resources/article/api/edit_article_request.json b/src/test/resources/article/api/edit_article_request.json index 5e84763..fbc544e 100644 --- a/src/test/resources/article/api/edit_article_request.json +++ b/src/test/resources/article/api/edit_article_request.json @@ -5,5 +5,6 @@ "categoryId": "updatedArticleCategoryId", "thumbnailImageUrl": "updatedArticleThumbnailImageUrl", "keywords": ["updatedArticleKeyword"], - "hidden": true + "hidden": true, + "estimatedReadingTime": "updatedEstimatedReadingTime" } \ No newline at end of file diff --git a/src/test/resources/article/api/highlighted_articles_details_response.json b/src/test/resources/article/api/highlighted_articles_details_response.json index 377c2ab..1a86bc0 100644 --- a/src/test/resources/article/api/highlighted_articles_details_response.json +++ b/src/test/resources/article/api/highlighted_articles_details_response.json @@ -10,6 +10,7 @@ "hidden": true, "keywords": [ "keyword" - ] + ], + "estimatedReadingTime": "estimatedReadingTime" } ] \ No newline at end of file