Skip to content

Commit

Permalink
[TEST] add exception test for update profile API
Browse files Browse the repository at this point in the history
  • Loading branch information
nogamsung committed Jan 7, 2024
1 parent c03c294 commit 6b47e0a
Showing 1 changed file with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void givenFormatPosition_whenUpdateProfile_thenReturn400() throws Exception {

@Test
@DisplayName("기술에 기술명 20자 초과일시 프로필 업데이트를 하면 400을 반환한다.")
void givenGreaterThan20SkillSkillName_whenUpdateProfile_thenReturn400() throws Exception {
void givenSkillGreaterThan20SkillName_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getSkills().get(0).setSkillName("가".repeat(21));
Expand All @@ -299,7 +299,7 @@ void givenGreaterThan20SkillSkillName_whenUpdateProfile_thenReturn400() throws E

@Test
@DisplayName("기술에 경험 여부 미입력시 프로필 업데이트를 하면 400을 반환한다.")
void givenBlankSkillIsExperienced_whenUpdateProfile_thenReturn400() throws Exception {
void givenSkillBlankIsExperienced_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getSkills().get(0).setIsExperienced(null);
Expand All @@ -322,7 +322,7 @@ void givenBlankSkillIsExperienced_whenUpdateProfile_thenReturn400() throws Excep

@Test
@DisplayName("기술에 올바르지 않은 레벨로 프로필 업데이트를 하면 400을 반환한다.")
void givenFormatSkillLevel_whenUpdateProfile_thenReturn400() throws Exception {
void givenSkillFormatLevel_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getSkills().get(0).setLevel("GOOD");
Expand All @@ -345,7 +345,7 @@ void givenFormatSkillLevel_whenUpdateProfile_thenReturn400() throws Exception {

@Test
@DisplayName("학력에 학교명 3자 미만일시 프로필 업데이트를 하면 400을 반환한다.")
void givenLessThan3EducationInstitutionName_whenUpdateProfile_thenReturn400() throws Exception {
void givenEducationLessThan3InstitutionName_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getEducations().get(0).setInstitutionName("대학");
Expand All @@ -368,7 +368,7 @@ void givenLessThan3EducationInstitutionName_whenUpdateProfile_thenReturn400() th

@Test
@DisplayName("학력에 학교명 3자 미만일시 프로필 업데이트를 하면 400을 반환한다.")
void givenGreaterThan20EducationInstitutionName_whenUpdateProfile_thenReturn400() throws Exception {
void givenEducationGreaterThan20InstitutionName_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getEducations().get(0).setInstitutionName("대".repeat(21));
Expand All @@ -391,7 +391,7 @@ void givenGreaterThan20EducationInstitutionName_whenUpdateProfile_thenReturn400(

@Test
@DisplayName("학력에 시작일 미입력시 프로필 업데이트를 하면 400을 반환한다.")
void givenBlankEducationStartedAt_whenUpdateProfile_thenReturn400() throws Exception {
void givenEducationBlankStartedAt_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getEducations().get(0).setStartedAt(null);
Expand All @@ -414,7 +414,7 @@ void givenBlankEducationStartedAt_whenUpdateProfile_thenReturn400() throws Excep

@Test
@DisplayName("학력에 현재 여부 미입력시 프로필 업데이트를 하면 400을 반환한다.")
void givenBlankEducationIsCurrent_whenUpdateProfile_thenReturn400() throws Exception {
void givenEducationBlankIsCurrent_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getEducations().get(0).setIsCurrent(null);
Expand All @@ -436,8 +436,8 @@ void givenBlankEducationIsCurrent_whenUpdateProfile_thenReturn400() throws Excep
}

@Test
@DisplayName("포트폴리오에 포트폴리오명 1자 미만일시 프로필 업데이트를 하면 400을 반환한다.")
void givenLessThan1PortfolioPortfolioName_whenUpdateProfile_thenReturn400() throws Exception {
@DisplayName("포트폴리오에 포트폴리오명이 1자 미만일시 프로필 업데이트를 하면 400을 반환한다.")
void givenPortfolioLessThan1PortfolioName_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getPortfolios().get(0).setPortfolioName("");
Expand All @@ -458,6 +458,29 @@ void givenLessThan1PortfolioPortfolioName_whenUpdateProfile_thenReturn400() thro
.value(PORTFOLIO_NAME_LENGTH_INVALID.getMessage()));
}

@Test
@DisplayName("포트폴리오에 포트폴리오명이 10자 초과일시 프로필 업데이트를 하면 400을 반환한다.")
void givenPortfolioGreaterThan10PortfolioName_whenUpdateProfile_thenReturn400() throws Exception {
// given
ProfileUpdateRequest request = createValidProfileUpdateRequest();
request.getPortfolios().get(0).setPortfolioName("a".repeat(11));

// when
ResultActions actions = mockMvc.perform(
post("/api/v1/user/profile")
.content(objectMapper.writeValueAsString(request))
.contentType(APPLICATION_JSON)
);

// then
actions.andDo(print())
.andExpect(status().isBadRequest())
.andExpect(jsonPath("$.responseCode")
.value(PORTFOLIO_NAME_LENGTH_INVALID.name()))
.andExpect(jsonPath("$.responseMessage")
.value(PORTFOLIO_NAME_LENGTH_INVALID.getMessage()));
}

@Test
@DisplayName("파일 포트폴리오를 하면 200을 반환한다.")
void givenValid_whenUploadPortfolioFile_thenReturn200() throws Exception {
Expand Down

0 comments on commit 6b47e0a

Please sign in to comment.