Skip to content

Commit

Permalink
test: 공고 끌어올리기 Controller 테스트 코드 추가 (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeong-hyeok committed Dec 14, 2024
1 parent 06e3e6d commit e542c22
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.pawwithu.connectdog.domain.post.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.pawwithu.connectdog.domain.dog.entity.DogGender;
import com.pawwithu.connectdog.domain.dog.entity.DogSize;
import com.pawwithu.connectdog.domain.post.dto.response.*;
import com.pawwithu.connectdog.domain.post.entity.PostStatus;
Expand All @@ -16,6 +15,7 @@
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
Expand All @@ -29,8 +29,7 @@
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@ExtendWith(MockitoExtension.class)
Expand Down Expand Up @@ -226,4 +225,20 @@ void setUp() {
get("/volunteers/posts/{postId}", postId)
);
}

@Test
void 이동봉사_공고_끌어올리기() throws Exception {
//given
Long postId = 1L;

//when
ResultActions result = mockMvc.perform(
patch("/intermediaries/posts/{postId}/boost", postId)
.contentType(MediaType.APPLICATION_JSON)
);

//then
result.andExpect(status().isNoContent());
verify(postService, times(1)).boostPost(anyString(), anyLong());
}
}

0 comments on commit e542c22

Please sign in to comment.