55import com .back .domain .cocktail .enums .AlcoholStrength ;
66import com .back .domain .cocktail .enums .CocktailType ;
77import com .back .domain .cocktail .repository .CocktailRepository ;
8- import com .back .domain .cocktail .service .CocktailService ;
8+ import com .back .domain .user .service .UserService ;
9+ import com .back .global .rq .Rq ;
10+ import jakarta .servlet .http .HttpServletRequest ;
11+ import jakarta .servlet .http .HttpServletResponse ;
912import org .junit .jupiter .api .DisplayName ;
1013import org .junit .jupiter .api .Test ;
14+ import org .mockito .Mockito ;
1115import org .springframework .beans .factory .annotation .Autowired ;
1216import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
1317import org .springframework .boot .test .context .SpringBootTest ;
18+ import org .springframework .boot .test .context .TestConfiguration ;
19+ import org .springframework .context .annotation .Bean ;
1420import org .springframework .http .MediaType ;
1521import org .springframework .test .context .ActiveProfiles ;
22+ import org .springframework .test .context .TestPropertySource ;
1623import org .springframework .test .web .servlet .MockMvc ;
1724import org .springframework .test .web .servlet .ResultActions ;
1825import org .springframework .transaction .annotation .Transactional ;
2633
2734@ ActiveProfiles ("test" )
2835@ SpringBootTest
36+ @ TestPropertySource (properties = {
37+ "custom.cookie.secure=false" ,
38+ "custom.cookie.same=Strict"
39+ })
2940@ AutoConfigureMockMvc (addFilters = false )
3041@ Transactional
3142public class CocktailControllerTest {
@@ -35,10 +46,6 @@ public class CocktailControllerTest {
3546 @ Autowired
3647 private CocktailRepository cocktailRepository ;
3748
38- @ Autowired
39- private CocktailService cocktailService ;
40-
41-
4249 @ Test
4350 @ DisplayName ("칵테일 단건 조회 - 로그인 없이 성공" )
4451 void t1 () throws Exception {
@@ -130,4 +137,17 @@ void t4() throws Exception {
130137 .andExpect (jsonPath ("$.message" ).value ("success" ))
131138 .andExpect (jsonPath ("$.data" ).isArray ());
132139 }
140+
141+ @ TestConfiguration
142+ static class TestConfig {
143+ @ Bean
144+ public Rq rq () {
145+ HttpServletRequest req = Mockito .mock (HttpServletRequest .class );
146+ HttpServletResponse resp = Mockito .mock (HttpServletResponse .class );
147+ UserService userService = Mockito .mock (UserService .class );
148+
149+ return new Rq (req , resp , userService );
150+ }
151+ }
152+
133153}
0 commit comments