Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

import jakarta.servlet.http.HttpServletRequest;

import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.http.HttpMethod;
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;

/** 기존 matches와 달리 request와 일치하지 않으면 True 반환 */
public class CustomRequestMatcher implements RequestMatcher {

private final AntPathRequestMatcher antPathRequestMatcher;
private final String httpMethod;
private final RequestMatcher requestMatcher;

public CustomRequestMatcher(String path, String httpMethod) {

this.httpMethod = httpMethod;
this.antPathRequestMatcher = new AntPathRequestMatcher(path, httpMethod);
this.requestMatcher =
PathPatternRequestMatcher.withDefaults().matcher(HttpMethod.valueOf(httpMethod), path);
}

@Override
public boolean matches(HttpServletRequest request) {

String requestMethod = request.getMethod();
return !(httpMethod.equalsIgnoreCase(requestMethod) && antPathRequestMatcher.matches(request));
return !requestMatcher.matches(request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -30,7 +30,7 @@ public class JwtControllerTest {

@Autowired private MockMvc mockMvc;

@MockBean private TokenReIssuer tokenReIssuer;
@MockitoBean private TokenReIssuer tokenReIssuer;

@Autowired private ObjectMapper objectMapper;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.inhabas.api.domain.lecture.usecase;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.bean.override.mockito.MockitoBean;

import com.inhabas.api.domain.lecture.repository.LectureRepository;
import com.inhabas.api.web.LectureController;
Expand All @@ -14,11 +14,11 @@ public class LectureSecurityCheckerTest {

@Autowired private LectureSecurityChecker securityChecker;

@MockBean private LectureRepository repository;
@MockitoBean private LectureRepository repository;

@MockBean private LectureServiceImpl lectureService;
@MockitoBean private LectureServiceImpl lectureService;

@MockBean private LectureStudentServiceImpl studentService;
@MockitoBean private LectureStudentServiceImpl studentService;

// @DisplayName("강의자만 접근할 수 있다.")
// @Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;

import com.inhabas.api.domain.signUpSchedule.domain.entity.SignUpSchedule;
import com.inhabas.api.domain.signUpSchedule.dto.SignUpScheduleDto;
Expand All @@ -29,7 +29,7 @@ public class StrictSignUpSchedulerTest {

@Autowired SignUpSchedulerStrict signUpScheduler;

@SpyBean SignUpScheduleRepository signUpScheduleRepository;
@MockitoSpyBean SignUpScheduleRepository signUpScheduleRepository;

@Autowired TestEntityManager entityManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public class RoleHierarchyTest {
// @Autowired
// NormalBoardController boardController;
//
// @MockBean
// @MockitoBean
// NormalBoardService boardService;
//
// @MockBean
// @MockitoBean
// MemberManageService memberService;
//
// @MockBean
// @MockitoBean
// JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
//
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;

Expand All @@ -46,8 +46,8 @@ public class BudgetApplicationControllerTest {

@Autowired private MockMvc mvc;
@Autowired private ObjectMapper objectMapper;
@MockBean private BudgetApplicationService budgetApplicationService;
@MockBean private BudgetApplicationProcessor applicationProcessor;
@MockitoBean private BudgetApplicationService budgetApplicationService;
@MockitoBean private BudgetApplicationProcessor applicationProcessor;

@DisplayName("예산지원요청 글 목록 조회 200")
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -37,7 +37,7 @@ public class BudgetHistoryControllerTest {

@Autowired private MockMvc mvc;
@Autowired private ObjectMapper objectMapper;
@MockBean private BudgetHistoryService budgetHistoryService;
@MockitoBean private BudgetHistoryService budgetHistoryService;

@DisplayName("회계 내역의 모든 연도 조회 200.")
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -42,7 +42,7 @@ public class ClubActivityControllerTest {

@Autowired private ObjectMapper objectMapper;

@MockBean private ClubActivityService clubActivityService;
@MockitoBean private ClubActivityService clubActivityService;

private String jsonOf(Object response) throws JsonProcessingException {
return objectMapper.writeValueAsString(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -38,7 +38,7 @@ public class ClubHistoryControllerTest {

@Autowired private ObjectMapper objectMapper;

@MockBean private ClubHistoryService clubHistoryService;
@MockitoBean private ClubHistoryService clubHistoryService;

private String jsonOf(Object response) throws JsonProcessingException {
return objectMapper.writeValueAsString(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
Expand Down Expand Up @@ -43,9 +43,9 @@ public class CommentControllerTest {

@Autowired private ObjectMapper objectMapper;

@MockBean private CommentServiceImpl commentService;
@MockitoBean private CommentServiceImpl commentService;

@MockBean private BoardSecurityChecker boardSecurityChecker;
@MockitoBean private BoardSecurityChecker boardSecurityChecker;

@BeforeEach
void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -47,8 +47,8 @@ public class ContestBoardControllerTest {
@Autowired private MockMvc mvc;
@Autowired private ObjectMapper objectMapper;

@MockBean private ContestBoardService contestBoardService;
@MockBean private BaseBoardRepository baseBoardRepository;
@MockitoBean private ContestBoardService contestBoardService;
@MockitoBean private BaseBoardRepository baseBoardRepository;

private String jsonOf(Object response) throws JsonProcessingException {
return objectMapper.writeValueAsString(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.inhabas.api.domain.lecture.usecase.LectureService;
Expand All @@ -24,9 +24,9 @@ public class LectureControllerTest {

@Autowired private MockMvc mockMvc;

@MockBean private LectureService lectureService;
@MockitoBean private LectureService lectureService;

@MockBean private LectureStudentService studentService;
@MockitoBean private LectureStudentService studentService;

// @DisplayName("강의 등록 uri 를 정상적으로 호출 및 응답.")
// @Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

Expand All @@ -45,9 +45,9 @@
public class MemberControllerTest {

@Autowired private MockMvc mvc;
@MockBean private MemberManageService memberManageService;
@MockBean private AnswerService answerService;
@MockBean private MemberRepository memberRepository;
@MockitoBean private MemberManageService memberManageService;
@MockitoBean private AnswerService answerService;
@MockitoBean private MemberRepository memberRepository;
@Autowired private ObjectMapper objectMapper;

@DisplayName("(신입)미승인 멤버 정보 목록을 불러온다")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.inhabas.api.domain.menu.domain.valueObject.MenuId;
Expand All @@ -28,7 +28,7 @@
@NoSecureWebMvcTest(MenuController.class)
public class MenuControllerTest {

@MockBean private MenuService menuService;
@MockitoBean private MenuService menuService;

@Autowired private MockMvc mvc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -41,8 +41,8 @@
class MyInfoControllerTest {

@Autowired private MockMvc mvc;
@MockBean private MemberProfileService memberProfileService;
@MockBean private MyInfoService myInfoService;
@MockitoBean private MemberProfileService memberProfileService;
@MockitoBean private MyInfoService myInfoService;
@Autowired private ObjectMapper objectMapper;

private String jsonOf(Object o) throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -44,8 +44,8 @@ public class NormalBoardControllerTest {

@Autowired private ObjectMapper objectMapper;

@MockBean private NormalBoardService normalBoardService;
@MockBean private BaseBoardRepository baseBoardRepository;
@MockitoBean private NormalBoardService normalBoardService;
@MockitoBean private BaseBoardRepository baseBoardRepository;

private String jsonOf(Object response) throws JsonProcessingException {
return objectMapper.writeValueAsString(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -36,7 +36,7 @@ public class PolicyTermControllerTest {

@Autowired private MockMvc mvc;

@MockBean private PolicyTermService policyTermService;
@MockitoBean private PolicyTermService policyTermService;

@Autowired private ObjectMapper objectMapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -44,8 +44,8 @@ public class ProjectBoardControllerTest {

@Autowired private ObjectMapper objectMapper;

@MockBean private ProjectBoardService projectBoardService;
@MockBean private BaseBoardRepository baseBoardRepository;
@MockitoBean private ProjectBoardService projectBoardService;
@MockitoBean private BaseBoardRepository baseBoardRepository;

private String jsonOf(Object response) throws JsonProcessingException {
return objectMapper.writeValueAsString(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -43,7 +43,7 @@ public class ScholarshipControllerTest {

@Autowired private ObjectMapper objectMapper;

@MockBean private ScholarshipBoardService scholarshipBoardService;
@MockitoBean private ScholarshipBoardService scholarshipBoardService;

private String jsonOf(Object response) throws JsonProcessingException {
return objectMapper.writeValueAsString(response);
Expand Down
Loading