From 6b47e0abdb420d658d1afbf91954ebca2e6b3361 Mon Sep 17 00:00:00 2001 From: gs97ahn Date: Sun, 7 Jan 2024 23:45:35 +0900 Subject: [PATCH] [TEST] add exception test for update profile API --- .../profile/ProfileControllerTest.java | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileControllerTest.java b/src/test/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileControllerTest.java index 319c3fb8..fa429809 100644 --- a/src/test/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileControllerTest.java +++ b/src/test/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileControllerTest.java @@ -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)); @@ -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); @@ -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"); @@ -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("대학"); @@ -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)); @@ -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); @@ -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); @@ -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(""); @@ -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 {