Skip to content

Commit

Permalink
Merge pull request #179 from CEOS-Developers/feat/getApplications
Browse files Browse the repository at this point in the history
[fix] 지원자 목록 보기 swagger 에러 수정
  • Loading branch information
letskuku authored Aug 4, 2024
2 parents 1dd991c + c468d53 commit 907b10f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import ceos.backend.domain.application.service.ApplicationService;
import ceos.backend.global.common.entity.Part;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.nio.file.Path;
Expand All @@ -40,10 +42,13 @@ public class ApplicationController {
@Operation(summary = "지원자 목록 보기")
@GetMapping
public GetApplications getApplications(
@RequestParam(value = "part", required = false) Part part,
@RequestParam(value = "docPass", required = false) Pass docPass,
@RequestParam(value = "finalPass", required = false) Pass finalPass,
@RequestParam(value = "applicantName", required = false) String applicantName,
@Parameter(schema = @Schema(allowableValues = {"PRODUCT", "DESIGN", "FRONTEND", "BACKEND"}))
@RequestParam(value = "part", required = false, defaultValue = "") Part part,
@Parameter(schema = @Schema(allowableValues = {"PASS", "FAIL"}))
@RequestParam(value = "docPass", required = false, defaultValue = "") Pass docPass,
@Parameter(schema = @Schema(allowableValues = {"PASS", "FAIL"}))
@RequestParam(value = "finalPass", required = false, defaultValue = "") Pass finalPass,
@RequestParam(value = "applicantName", required = false, defaultValue = "") String applicantName,
@RequestParam("pageNum") int pageNum,
@RequestParam("limit") int limit) {
log.info("지원자 목록 보기");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.authentication.TestingAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
Expand All @@ -20,6 +23,50 @@ public class ApplicationControllerTest {
@Test
void getApplicationExcelCreationTime() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/applications/file/creationtime"))
.andExpect(MockMvcResultMatchers.status().is(401));
.andExpect(MockMvcResultMatchers.status().is(403));
}

@DisplayName("지원서 목록 보기 API - 필수 아닌 파라미터들 길이 0인 문자열로 처리")
@Test
void getApplicationsWithZeroStrings() throws Exception {
Authentication authentication = new TestingAuthenticationToken(null, null, "ROLE_ADMIN");

mockMvc.perform(MockMvcRequestBuilders
.get("/applications?part=&docPass=&finalPass=&applicantName=&pageNum=0&limit=7")
.with(SecurityMockMvcRequestPostProcessors.authentication(authentication)))
.andExpect(MockMvcResultMatchers.status().isOk());
}

@DisplayName("지원서 목록 보기 API - 필수 아닌 파라미터들 제외")
@Test
void getApplicationsWithoutRequiredFalse() throws Exception {
Authentication authentication = new TestingAuthenticationToken(null, null, "ROLE_ADMIN");

mockMvc.perform(MockMvcRequestBuilders
.get("/applications?pageNum=0&limit=7")
.with(SecurityMockMvcRequestPostProcessors.authentication(authentication)))
.andExpect(MockMvcResultMatchers.status().isOk());
}

@DisplayName("지원서 목록 보기 API - enum 타입 영어로 처리")
@Test
void successGetApplications() throws Exception {
Authentication authentication = new TestingAuthenticationToken(null, null, "ROLE_ADMIN");

mockMvc.perform(MockMvcRequestBuilders
.get("/applications?part=PRODUCT&docPass=PASS&finalPass=FAIL&applicantName=&pageNum=0&limit=7")
.with(SecurityMockMvcRequestPostProcessors.authentication(authentication)))
.andExpect(MockMvcResultMatchers.status().isOk());
}

@DisplayName("지원서 목록 보기 API - enum 타입 한글로 처리 시 예외 발생")
@Test
void failGetApplications() throws Exception {
Authentication authentication = new TestingAuthenticationToken(null, null, "ROLE_ADMIN");

mockMvc.perform(MockMvcRequestBuilders
.get("/applications?part=기획&docPass=합격&finalPass=불합격&applicantName=&pageNum=0&limit=7")
.with(SecurityMockMvcRequestPostProcessors.authentication(authentication)))
.andExpect(MockMvcResultMatchers.status().is(400));
}
}

0 comments on commit 907b10f

Please sign in to comment.