backend/restservice/src/test/java/com/plannaplan/controllers/CoursesControllerTest.java
BuildTools 0fbc6d6baa Merge
2020-11-05 15:27:51 +01:00

37 lines
1.4 KiB
Java
Executable File

package com.plannaplan.controllers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class CoursesControllerTest extends AbstractControllerTest {
private static final String COURSES_ENDPOINT = "/api/v1/courses/all";
private static final String COURSESGROUPS_ENDPOINT = "/api/v1/courses/all?groups=true";
@Test
public void shouldReturnAllCoursesOk() throws Exception {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
mockMvc.perform(get(COURSES_ENDPOINT)).andExpect(status().isOk());
}
@Test
public void shouldReturnAllCoursesWithGroupsOk() throws Exception {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
mockMvc.perform(get(COURSESGROUPS_ENDPOINT)).andExpect(status().isOk());
}
}