@@ -0,0 +1,2263 @@
+package wepa.wepa.controller;%0A%0Aimport java.util.UUID;%0Aimport org.junit.After;%0Aimport org.junit.AfterClass;%0Aimport org.junit.Before;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0Aimport org.springframework.test.web.servlet.MockMvc;%0Aimport org.springframework.test.web.servlet.MvcResult;%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;%0Aimport org.springframework.test.web.servlet.setup.MockMvcBuilders;%0Aimport org.springframework.web.context.WebApplicationContext;%0Aimport wepa.wepa.domain.Course;%0Aimport wepa.wepa.repository.CourseRepository;%0A%0A@RunWith(SpringRunner.class)%0A@SpringBootTest%0Apublic class CourseControllerTest %7B%0A%0A    private MockMvc mockMvc;%0A%0A    @Autowired%0A    private CourseRepository courseRepository;%0A%0A    @Autowired%0A    private WebApplicationContext webAppContext;%0A%0A    @Before%0A    public void setUp() %7B%0A        this.mockMvc = MockMvcBuilders.webAppContextSetup(webAppContext).build();%0A    %7D%0A%0A    @Test%0A    public void getOk() throws Exception %7B%0A        mockMvc.perform(get(%22/courses%22)).andExpect(status().is2xxSuccessful());%0A    %7D%0A%0A    @Test%0A    public void getContainsCourses() throws Exception %7B%0A        mockMvc.perform(get(%22/courses%22)).andExpect(model().attributeExists(%22courses%22));%0A    %7D%0A%0A    @Test%0A    public void addedCourseIsListed() throws Exception %7B%0A        Course c = new Course();%0A        String name = UUID.randomUUID().toString();%0A        c.setName(name);%0A        c = courseRepository.save(c);%0A%0A        MvcResult res = mockMvc.perform(get(%22/courses%22)).andReturn();%0A        String content = res.getResponse().getContentAsString();%0A        assertTrue(content.contains(name));%0A%0A        res = mockMvc.perform(get(%22/courses/%22 + c.getId())).andReturn();%0A        content = res.getResponse().getContentAsString();%0A        assertTrue(content.contains(name));%0A%0A    %7D%0A%7D%0A

test course controller