// Path: src/main/java/com/parrit/DTOs/RolePositionDTO.java
// @Getter
// @Setter
// @EqualsAndHashCode
// public class RolePositionDTO {
// 
//     @NotNull(message = "Where are you trying to go? Roles must be with a pairing board!")
//     private Long pairingBoardId;
// 
// }
// 
// Path: src/main/java/com/parrit/entities/PairingBoard.java
// @Entity
// @Table(name = "pairing_board",
//         indexes = {
//                 @Index(name = "pairing_board_pkey", unique = true, columnList = "id")
//         }
// )
// @Getter
// @Setter
// @NoArgsConstructor
// @EqualsAndHashCode
// @ToString
// public class PairingBoard {
// 
//     @Id
//     @Column(name = "id", nullable = false)
//     @ColumnDefault("nextval('pairing_board_id_seq')")
//     @SequenceGenerator(name = "pairing_board_id_gen", sequenceName = "pairing_board_id_seq", initialValue = 1, allocationSize = 1)
//     @GeneratedValue(generator = "pairing_board_id_gen", strategy = GenerationType.SEQUENCE)
//     private long id;
// 
//     @Column(name = "name", nullable = false, length = 255)
//     private String name;
// 
//     @Column(name = "exempt", nullable = false)
//     private boolean exempt;
// 
//     @OneToMany
//     @JoinColumn(name = "pairing_board_id", nullable = true, foreignKey = @ForeignKey(name = "pairing_board_id_fk"))
//     private List<Person> people = new ArrayList<>();
// 
//     @OneToMany(cascade = CascadeType.ALL)
//     @JoinColumn(name = "pairing_board_id", nullable = false, foreignKey = @ForeignKey(name = "pairing_board_id_fk"))
//     private List<Role> roles = new ArrayList<>();
// 
//     public PairingBoard(String name, boolean exempt, List<Person> people, List<Role> roles) {
//         this.name = name;
//         this.exempt = exempt;
//         this.people = people;
//         this.roles = roles;
//     }
// 
// }
// 
// Path: src/main/java/com/parrit/entities/Role.java
// @Entity
// @Table(name = "role",
//         indexes = {
//                 @Index(name = "role_pkey", unique = true, columnList = "id")
//         }
// )
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode
// @ToString
// public class Role {
// 
//     @Id
//     @Column(name = "id", nullable = false)
//     @ColumnDefault("nextval('role_id_seq')")
//     @SequenceGenerator(name = "role_id_gen", sequenceName = "role_id_seq", initialValue = 1, allocationSize = 1)
//     @GeneratedValue(generator = "role_id_gen", strategy = GenerationType.SEQUENCE)
//     private long id;
// 
//     @Column(name = "name", nullable = false, length = 255)
//     private String name;
// 
//     public Role(String name) {
//         this.name = name;
//     }
// 
// }
// 
// Path: src/main/java/com/parrit/repositories/ProjectRepository.java
// @Repository
// public interface ProjectRepository extends JpaRepository<Project, Long> {
// 
//     Optional<Project> findByName(String name);
// 
// }
// 
// Path: src/main/java/com/parrit/repositories/RoleRepository.java
// @Repository
// public interface RoleRepository extends JpaRepository<Role, Long> {
// 
// }


import com.fasterxml.jackson.databind.ObjectMapper;
import com.parrit.DTOs.ProjectDTO;
import com.parrit.DTOs.RoleDTO;
import com.parrit.DTOs.RolePositionDTO;
import com.parrit.entities.PairingBoard;
import com.parrit.entities.Project;
import com.parrit.entities.Role;
import com.parrit.repositories.ProjectRepository;
import com.parrit.repositories.RoleRepository;
import com.parrit.transformers.ProjectTransformer;
import com.parrit.transformers.RoleTransformer;
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.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import java.util.*;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
        verify(mockProjectRepository).findById(1L);
        verify(mockProjectRepository).save(expectedProject);
    }

    @Test
    public void addRole_whenNameIsEmpty_returnsError() throws Exception {
        RoleDTO roleDTO = new RoleDTO();
        roleDTO.setName("");

        mockMvc.perform(post("/api/project/1/pairingBoard/2/role")
                .contentType(MediaType.APPLICATION_JSON)
                .content(objectMapper.writeValueAsString(roleDTO)))
                .andExpect(status().isBadRequest())
                .andExpect(jsonPath("$.message", equalTo(null)))
                .andExpect(jsonPath("$.fieldErrors.name", equalTo("Hey! This name needs to be between 1 and 32 characters.")));
    }

    @Test
    public void addRole_whenNameIsNull_returnsError() throws Exception {
        RoleDTO roleDTO = new RoleDTO();
        roleDTO.setName(null);

        mockMvc.perform(post("/api/project/1/pairingBoard/2/role")
                .contentType(MediaType.APPLICATION_JSON)
                .content(objectMapper.writeValueAsString(roleDTO)))
                .andExpect(status().isBadRequest())
                .andExpect(jsonPath("$.message", equalTo(null)))
                .andExpect(jsonPath("$.fieldErrors.name", equalTo("Hey! This name needs to be between 1 and 32 characters.")));
    }

// Path: src/main/java/com/parrit/DTOs/RolePositionDTO.java
// @Getter
// @Setter
// @EqualsAndHashCode
// public class RolePositionDTO {
// 
//     @NotNull(message = "Where are you trying to go? Roles must be with a pairing board!")
//     private Long pairingBoardId;
// 
// }
// 
// Path: src/main/java/com/parrit/entities/PairingBoard.java
// @Entity
// @Table(name = "pairing_board",
//         indexes = {
//                 @Index(name = "pairing_board_pkey", unique = true, columnList = "id")
//         }
// )
// @Getter
// @Setter
// @NoArgsConstructor
// @EqualsAndHashCode
// @ToString
// public class PairingBoard {
// 
//     @Id
//     @Column(name = "id", nullable = false)
//     @ColumnDefault("nextval('pairing_board_id_seq')")
//     @SequenceGenerator(name = "pairing_board_id_gen", sequenceName = "pairing_board_id_seq", initialValue = 1, allocationSize = 1)
//     @GeneratedValue(generator = "pairing_board_id_gen", strategy = GenerationType.SEQUENCE)
//     private long id;
// 
//     @Column(name = "name", nullable = false, length = 255)
//     private String name;
// 
//     @Column(name = "exempt", nullable = false)
//     private boolean exempt;
// 
//     @OneToMany
//     @JoinColumn(name = "pairing_board_id", nullable = true, foreignKey = @ForeignKey(name = "pairing_board_id_fk"))
//     private List<Person> people = new ArrayList<>();
// 
//     @OneToMany(cascade = CascadeType.ALL)
//     @JoinColumn(name = "pairing_board_id", nullable = false, foreignKey = @ForeignKey(name = "pairing_board_id_fk"))
//     private List<Role> roles = new ArrayList<>();
// 
//     public PairingBoard(String name, boolean exempt, List<Person> people, List<Role> roles) {
//         this.name = name;
//         this.exempt = exempt;
//         this.people = people;
//         this.roles = roles;
//     }
// 
// }
// 
// Path: src/main/java/com/parrit/entities/Role.java
// @Entity
// @Table(name = "role",
//         indexes = {
//                 @Index(name = "role_pkey", unique = true, columnList = "id")
//         }
// )
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode
// @ToString
// public class Role {
// 
//     @Id
//     @Column(name = "id", nullable = false)
//     @ColumnDefault("nextval('role_id_seq')")
//     @SequenceGenerator(name = "role_id_gen", sequenceName = "role_id_seq", initialValue = 1, allocationSize = 1)
//     @GeneratedValue(generator = "role_id_gen", strategy = GenerationType.SEQUENCE)
//     private long id;
// 
//     @Column(name = "name", nullable = false, length = 255)
//     private String name;
// 
//     public Role(String name) {
//         this.name = name;
//     }
// 
// }
// 
// Path: src/main/java/com/parrit/repositories/ProjectRepository.java
// @Repository
// public interface ProjectRepository extends JpaRepository<Project, Long> {
// 
//     Optional<Project> findByName(String name);
// 
// }
// 
// Path: src/main/java/com/parrit/repositories/RoleRepository.java
// @Repository
// public interface RoleRepository extends JpaRepository<Role, Long> {
// 
// }


// Path: src/test/java/com/parrit/controllers/RoleControllerTest.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.parrit.DTOs.ProjectDTO;
import com.parrit.DTOs.RoleDTO;
import com.parrit.DTOs.RolePositionDTO;
import com.parrit.entities.PairingBoard;
import com.parrit.entities.Project;
import com.parrit.entities.Role;
import com.parrit.repositories.ProjectRepository;
import com.parrit.repositories.RoleRepository;
import com.parrit.transformers.ProjectTransformer;
import com.parrit.transformers.RoleTransformer;
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.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import java.util.*;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

        verify(mockProjectRepository).findById(1L);
        verify(mockProjectRepository).save(expectedProject);
    }

    @Test
    public void addRole_whenNameIsEmpty_returnsError() throws Exception {
        RoleDTO roleDTO = new RoleDTO();
        roleDTO.setName("");

        mockMvc.perform(post("/api/project/1/pairingBoard/2/role")
                .contentType(MediaType.APPLICATION_JSON)
                .content(objectMapper.writeValueAsString(roleDTO)))
                .andExpect(status().isBadRequest())
                .andExpect(jsonPath("$.message", equalTo(null)))
                .andExpect(jsonPath("$.fieldErrors.name", equalTo("Hey! This name needs to be between 1 and 32 characters.")));
    }

    @Test
    public void addRole_whenNameIsNull_returnsError() throws Exception {
        RoleDTO roleDTO = new RoleDTO();
        roleDTO.setName(null);

        mockMvc.perform(post("/api/project/1/pairingBoard/2/role")
                .contentType(MediaType.APPLICATION_JSON)
                .content(objectMapper.writeValueAsString(roleDTO)))
                .andExpect(status().isBadRequest())
                .andExpect(jsonPath("$.message", equalTo(null)))
                .andExpect(jsonPath("$.fieldErrors.name", equalTo("Hey! This name needs to be between 1 and 32 characters.")));
    }

    @Test