Skip to content
Snippets Groups Projects
Commit 23096249 authored by evilimkova's avatar evilimkova Committed by Martin Gargalovič
Browse files

Fixing findForUserAndCourse tests

parent 127f5ca0
No related branches found
No related tags found
3 merge requests!31M2,!28M2 user,!27Draft: M2 user
......@@ -9,12 +9,16 @@ import org.fuseri.model.dto.course.ProficiencyLevelDto;
import org.fuseri.model.dto.user.AddressDto;
import org.fuseri.model.dto.user.UserDto;
import org.junit.jupiter.api.Test;
import org.springdoc.core.converters.models.Pageable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import java.util.List;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
......@@ -101,30 +105,30 @@ class CertificateControllerTests {
@Test
void findCertificateIdForUserAndCourse() throws Exception {
mockMvc.perform(get("/certificates/getId")
mockMvc.perform(get("/certificates/findForUserAndCourse")
.param("userId", "0")
.param("courseId", "0"))
.andExpect(status().isOk())
.andExpect(content().string("0"));
.andExpect(content().string("[]"));
}
@Test
void findCertificateIdWithoutUserId() throws Exception {
mockMvc.perform(get("/certificates/getId")
mockMvc.perform(get("/certificates/findForUserAndCourse")
.param("courseId", "0"))
.andExpect(status().is4xxClientError());
}
@Test
void findCertificateIdWithoutCourseId() throws Exception {
mockMvc.perform(get("/certificates/getId")
mockMvc.perform(get("/certificates/findForUserAndCourse")
.param("userId", "0"))
.andExpect(status().is4xxClientError());
}
@Test
void findCertificateIdWithoutParams() throws Exception {
mockMvc.perform(get("/certificates/getId"))
mockMvc.perform(get("/certificates/findForUserAndCourse"))
.andExpect(status().is4xxClientError());
}
......@@ -144,8 +148,14 @@ class CertificateControllerTests {
@Test
void findAllCertificates() throws Exception {
mockMvc.perform(post("/certificates/generate")
.content(asJsonString(new CertificateCreateDto(USER, COURSE)))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
mockMvc.perform(get("/certificates/findAll")
.param("page", "1"))
.content("{ \"page\": 0, \"size\": 1, \"sort\": []}")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment