Skip to content

Commit

Permalink
Merge pull request #61 from Nexters/main
Browse files Browse the repository at this point in the history
random question 경험질문 제외
  • Loading branch information
sanghunBaek authored Aug 18, 2023
2 parents cde6c81 + ecbcc36 commit 863103f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public List<QuestionEntity> RandomQuestion(
.selectFrom(QQuestionEntity.questionEntity)
.leftJoin(QQuestionEntity.questionEntity.categoryEntityList, QCategoryEntity.categoryEntity)
.distinct()
.where(eqJobGroup(jobGroup), neUserId(userId), eqCategory(category))
.where(eqJobGroup(jobGroup), neUserId(userId), eqCategory(category), notExperience())
.limit(count)
.orderBy(Expressions.numberTemplate(Double.class, "function('rand')").asc())
.fetch();
Expand Down Expand Up @@ -82,6 +82,10 @@ public Page<QuestionEntity> searchQuestion(
return new PageImpl<>(questionEntityList, pageRequest, count);
}

private BooleanExpression notExperience() {
return QQuestionEntity.questionEntity.experienceId.isNull();
}

private BooleanExpression containSubject(String subject) {
if (!StringUtils.hasText(subject)) return null;
return QQuestionEntity.questionEntity.subject.contains(subject);
Expand Down
11 changes: 6 additions & 5 deletions src/test/java/com/sirius/spurt/ExperienceControllerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sirius.spurt;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
Expand Down Expand Up @@ -40,7 +41,7 @@ public class ExperienceControllerTest extends BaseMvcTest {
.link("link")
.userId("admin")
.build();
when(saveExperienceBusiness.execute(dto)).thenReturn(new SaveExperienceBusiness.Result());
when(saveExperienceBusiness.execute(any())).thenReturn(new SaveExperienceBusiness.Result());
this.mockMvc
.perform(
post("/v1/experience")
Expand All @@ -62,7 +63,7 @@ public class ExperienceControllerTest extends BaseMvcTest {
.link("link")
.userId("admin")
.build();
when(updateExperienceBusiness.execute(dto)).thenReturn(new UpdateExperienceBusiness.Result());
when(updateExperienceBusiness.execute(any())).thenReturn(new UpdateExperienceBusiness.Result());
this.mockMvc
.perform(
put("/v1/experience")
Expand All @@ -76,7 +77,7 @@ public class ExperienceControllerTest extends BaseMvcTest {
void 본인_경험_삭제() throws Exception {
DeleteExperienceBusiness.Dto dto =
DeleteExperienceBusiness.Dto.builder().experienceId(1L).userId("admin").build();
when(deleteExperienceBusiness.execute(dto)).thenReturn(new DeleteExperienceBusiness.Result());
when(deleteExperienceBusiness.execute(any())).thenReturn(new DeleteExperienceBusiness.Result());
this.mockMvc
.perform(
delete("/v1/experience")
Expand Down Expand Up @@ -115,7 +116,7 @@ public class ExperienceControllerTest extends BaseMvcTest {
.build();
GetAllExperienceBusiness.Result result =
GetAllExperienceBusiness.Result.builder().experienceList(List.of(experience)).build();
when(getAllExperienceBusiness.execute(dto)).thenReturn(result);
when(getAllExperienceBusiness.execute(any())).thenReturn(result);
this.mockMvc.perform(get("/v1/experience")).andExpect(status().isOk()).andDo(print());
}

Expand Down Expand Up @@ -146,7 +147,7 @@ public class ExperienceControllerTest extends BaseMvcTest {
.link("link")
.questionList(questionList)
.build();
when(getExperienceBusiness.execute(dto)).thenReturn(result);
when(getExperienceBusiness.execute(any())).thenReturn(result);
this.mockMvc.perform(get("/v1/experience/1")).andExpect(status().isOk()).andDo(print());
}
}
7 changes: 4 additions & 3 deletions src/test/java/com/sirius/spurt/UserControllerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sirius.spurt;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
Expand All @@ -25,7 +26,7 @@ public class UserControllerTest extends BaseMvcTest {
CheckUserExistsBusiness.Dto.builder().userId("test-admin").build();
CheckUserExistsBusiness.Result result =
CheckUserExistsBusiness.Result.builder().isUserExists(false).build();
when(checkUserExistsBusiness.execute(dto)).thenReturn(result);
when(checkUserExistsBusiness.execute(any())).thenReturn(result);
this.mockMvc.perform(get("/v1/user/exist")).andExpect(status().isOk()).andDo(print());
}

Expand All @@ -35,7 +36,7 @@ public class UserControllerTest extends BaseMvcTest {
CheckUserHasPinedBusiness.Dto.builder().userId("admin").build();
CheckUserHasPinedBusiness.Result result =
CheckUserHasPinedBusiness.Result.builder().hasPined(false).build();
when(checkUserHasPinedBusiness.execute(dto)).thenReturn(result);
when(checkUserHasPinedBusiness.execute(any())).thenReturn(result);
this.mockMvc.perform(get("/v1/user/pin")).andExpect(status().isOk()).andDo(print());
}

Expand All @@ -45,7 +46,7 @@ public class UserControllerTest extends BaseMvcTest {
CheckUserHasPostedBusiness.Dto.builder().userId("admin").build();
CheckUserHasPostedBusiness.Result result =
CheckUserHasPostedBusiness.Result.builder().hasPosted(false).build();
when(checkUserHasPostedBusiness.execute(dto)).thenReturn(result);
when(checkUserHasPostedBusiness.execute(any())).thenReturn(result);
this.mockMvc.perform(get("/v1/user/posting")).andExpect(status().isOk()).andDo(print());
}
}

0 comments on commit 863103f

Please sign in to comment.