BuildTools 0fbc6d6baa Merge
2020-11-05 15:27:51 +01:00

33 lines
1.3 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 GroupControllerTest extends AbstractControllerTest {
private static final String GROUPS_BY_COURSE_ENDPOINT = "/api/v1/groups/course";
@Test
public void shouldFailWithNoParaeter() throws Exception {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
mockMvc.perform(get(GROUPS_BY_COURSE_ENDPOINT)).andExpect(status().isNotFound());
}
@Test
public void shouldReturnGroupsOk() throws Exception {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
mockMvc.perform(get(GROUPS_BY_COURSE_ENDPOINT + "/2")).andExpect(status().isOk());
}
}