// Path: src/main/java/com/nebhale/buildmonitor/domain/Project.java
// @Entity
// public final class Project {
// 
//     @Id
//     @Size(min = 1, max = 8)
//     private volatile String key;
// 
//     @Size(min = 1, max = 64)
//     private volatile String name;
// 
//     Project() {
//     }
// 
//     /**
//      * Creates a new instance
//      *
//      * @param key  the key of the project
//      * @param name the name of the project
//      */
//     public Project(String key, String name) {
//         this.key = key.toUpperCase();
//         this.name = name;
//     }
// 
//     /**
//      * Returns the key of the project
//      *
//      * @return the key of the project
//      */
//     public String getKey() {
//         return this.key;
//     }
// 
//     /**
//      * Returns the name of the project
//      *
//      * @return the name of the project
//      */
//     public String getName() {
//         return this.name;
//     }
// 
// }
// 
// Path: src/main/java/com/nebhale/buildmonitor/repository/ProjectRepository.java
// public interface ProjectRepository extends JpaRepository<Project, String> {
// 
// }


import com.nebhale.buildmonitor.domain.Project;
import com.nebhale.buildmonitor.repository.ProjectRepository;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
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.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
        this.mockMvc.perform(get("/projects").accept(MEDIA_TYPE))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$[0].key").value("ALPHA"))
                .andExpect(jsonPath("$[1].key").value("BRAVO"))
                .andExpect(jsonPath("$[2].key").value("CHARLIE"));
    }

    @Test
    public void read() throws Exception {
        this.projectRepository.saveAndFlush(new Project("TEST_KEY", "Test Name"));

        this.mockMvc.perform(get("/projects/TEST_KEY").accept(MEDIA_TYPE))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.key").value("TEST_KEY"))
                .andExpect(jsonPath("$.name").value("Test Name"))
                .andExpect(jsonPath("$._links.self.href").value("http://localhost/projects/TEST_KEY"))
                .andExpect(jsonPath("$._links.webhook.href").value("http://localhost/projects/TEST_KEY/webhook"));
    }

    @Test
    public void readNotFound() throws Exception {
        this.mockMvc.perform(get("/projects/TEST_KEY").accept(MEDIA_TYPE))
                .andExpect(status().isNotFound());
    }

    @Test
    public void del() throws Exception {
        this.projectRepository.saveAndFlush(new Project("TEST_KEY", "Test Name"));

        this.mockMvc.perform(delete("/projects/TEST_KEY").accept(MEDIA_TYPE))
// Path: src/main/java/com/nebhale/buildmonitor/domain/Project.java
// @Entity
// public final class Project {
// 
//     @Id
//     @Size(min = 1, max = 8)
//     private volatile String key;
// 
//     @Size(min = 1, max = 64)
//     private volatile String name;
// 
//     Project() {
//     }
// 
//     /**
//      * Creates a new instance
//      *
//      * @param key  the key of the project
//      * @param name the name of the project
//      */
//     public Project(String key, String name) {
//         this.key = key.toUpperCase();
//         this.name = name;
//     }
// 
//     /**
//      * Returns the key of the project
//      *
//      * @return the key of the project
//      */
//     public String getKey() {
//         return this.key;
//     }
// 
//     /**
//      * Returns the name of the project
//      *
//      * @return the name of the project
//      */
//     public String getName() {
//         return this.name;
//     }
// 
// }
// 
// Path: src/main/java/com/nebhale/buildmonitor/repository/ProjectRepository.java
// public interface ProjectRepository extends JpaRepository<Project, String> {
// 
// }


// Path: src/test/java/com/nebhale/buildmonitor/web/ProjectControllerTest.java
import com.nebhale.buildmonitor.domain.Project;
import com.nebhale.buildmonitor.repository.ProjectRepository;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
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.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

        this.mockMvc.perform(get("/projects").accept(MEDIA_TYPE))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$[0].key").value("ALPHA"))
                .andExpect(jsonPath("$[1].key").value("BRAVO"))
                .andExpect(jsonPath("$[2].key").value("CHARLIE"));
    }

    @Test
    public void read() throws Exception {
        this.projectRepository.saveAndFlush(new Project("TEST_KEY", "Test Name"));

        this.mockMvc.perform(get("/projects/TEST_KEY").accept(MEDIA_TYPE))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.key").value("TEST_KEY"))
                .andExpect(jsonPath("$.name").value("Test Name"))
                .andExpect(jsonPath("$._links.self.href").value("http://localhost/projects/TEST_KEY"))
                .andExpect(jsonPath("$._links.webhook.href").value("http://localhost/projects/TEST_KEY/webhook"));
    }

    @Test
    public void readNotFound() throws Exception {
        this.mockMvc.perform(get("/projects/TEST_KEY").accept(MEDIA_TYPE))
                .andExpect(status().isNotFound());
    }

    @Test
    public void del() throws Exception {
        this.projectRepository.saveAndFlush(new Project("TEST_KEY", "Test Name"));

        this.mockMvc.perform(delete("/projects/TEST_KEY").accept(MEDIA_TYPE))
                .andExpect(status().isOk());