content: package com.alkl1m.taskmanager.controller;
  
  import com.alkl1m.taskmanager.TestBeans;
  import com.alkl1m.taskmanager.entity.User;
  import com.alkl1m.taskmanager.repository.UserRepository;
  import com.alkl1m.taskmanager.service.auth.UserDetailsImpl;
  import com.alkl1m.taskmanager.service.dashboard.DashboardService;
  import org.junit.jupiter.api.BeforeEach;
  import org.junit.jupiter.api.Test;
  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.UsernamePasswordAuthenticationToken;
  import org.springframework.security.core.Authentication;
  import org.springframework.security.core.context.SecurityContextHolder;
  import org.springframework.test.context.jdbc.Sql;
  import org.springframework.test.web.servlet.MockMvc;
  import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
  import org.springframework.transaction.annotation.Transactional;
  
  import java.util.Optional;
  
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
  
  @SpringBootTest(classes = TestBeans.class)
  @AutoConfigureMockMvc
  @Transactional
  public class DashboardControllerIT {
      @Autowired
      MockMvc mockMvc;
      @Autowired
      DashboardService dashboardService;
      @Autowired
      UserRepository userRepository;
      User user;
  
      @BeforeEach
      void setUp() {
          Optional<User> optionalUser = userRepository.findById(1L);
          user = optionalUser.get();
          UserDetailsImpl userDetails = UserDetailsImpl.build(user);
          Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null);
          SecurityContextHolder.getContext().setAuthentication(authentication);
      }
  
      @Test
      @Sql("/sql/user_and_dashboard.sql")
      public void getDashboardWithValidRequest_ReturnsValidResponseEntity() throws Exception {
          mockMvc.perform(MockMvcRequestBuilders.get("/api/user/dashboard"))
                  .andExpect(status().isOk())
                  .andExpect(jsonPath("$.projects").isArray())
                  .andExpect(jsonPath("$.tasks").isArray());
      }
  }
  