2020-09-25 16:17:52 +02:00
|
|
|
package com.plannaplan.controllers;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
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 org.springframework.web.context.WebApplicationContext;
|
|
|
|
|
|
|
|
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 {
|
2020-10-30 17:22:40 +01:00
|
|
|
private static final String GROUPS_BY_COURSE_ENDPOINT = "/api/v1/groups/course";
|
2020-09-25 16:17:52 +02:00
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private WebApplicationContext webApplicationContext;
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void shouldFailWithNoParaeter() throws Exception {
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
|
2020-10-30 17:22:40 +01:00
|
|
|
mockMvc.perform(get(GROUPS_BY_COURSE_ENDPOINT)).andExpect(status().isNotFound());
|
2020-09-25 16:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void shouldReturnGroupsOk() throws Exception {
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
|
2020-10-30 17:22:40 +01:00
|
|
|
mockMvc.perform(get(GROUPS_BY_COURSE_ENDPOINT + "/2" )).andExpect(status().isOk());
|
2020-09-25 16:17:52 +02:00
|
|
|
}
|
|
|
|
}
|