Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a14da3f

Browse files
committed
Merge branch 'feature/14-get-articles-by-notFound-user' into develop
2 parents 49395f4 + 588f871 commit a14da3f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎src/main/java/io/github/raeperd/realworld/domain/article/ArticleService.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Page<Article> getArticleFavoritedByUsername(UserName username, Pageable p
5555
return userFindService.findByUsername(username)
5656
.map(user -> articleRepository.findAllByUserFavoritedContains(user, pageable)
5757
.map(article -> article.updateFavoriteByUser(user)))
58-
.orElseThrow(NoSuchElementException::new);
58+
.orElse(Page.empty());
5959
}
6060

6161
@Transactional(readOnly = true)

‎src/test/java/io/github/raeperd/realworld/IntegrationTest.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ void get_articles_favorited_by_username() throws Exception {
239239
.andExpect(jsonPath("articles[0].favorited", is(true)));
240240
}
241241

242+
@Order(13)
243+
@Test
244+
void get_articles_favorited_by_username_not_exists() throws Exception {
245+
mockMvc.perform(get("/articles?favorited={username}", "jane")
246+
.header(AUTHORIZATION, "Token " + token))
247+
.andExpect(status().isOk())
248+
.andExpect(jsonPath("articles").isEmpty())
249+
.andExpect(jsonPath("articlesCount", is(0)));
250+
}
251+
242252
@Order(13)
243253
@Test
244254
void get_feed() throws Exception {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /