Skip to content
Snippets Groups Projects
Commit 6e6aeaa6 authored by evilimkova's avatar evilimkova
Browse files

Fixing findForUserAndCourse tests

parent 069a40ed
No related branches found
No related tags found
4 merge requests!31M2,!29M2 exercise,!27Draft: M2 user,!19M2 certificate
Pipeline #
...@@ -9,12 +9,16 @@ import org.fuseri.model.dto.course.ProficiencyLevelDto; ...@@ -9,12 +9,16 @@ import org.fuseri.model.dto.course.ProficiencyLevelDto;
import org.fuseri.model.dto.user.AddressDto; import org.fuseri.model.dto.user.AddressDto;
import org.fuseri.model.dto.user.UserDto; import org.fuseri.model.dto.user.UserDto;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springdoc.core.converters.models.Pageable;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc; 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.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
...@@ -101,30 +105,30 @@ class CertificateControllerTests { ...@@ -101,30 +105,30 @@ class CertificateControllerTests {
@Test @Test
void findCertificateIdForUserAndCourse() throws Exception { void findCertificateIdForUserAndCourse() throws Exception {
mockMvc.perform(get("/certificates/getId") mockMvc.perform(get("/certificates/findForUserAndCourse")
.param("userId", "0") .param("userId", "0")
.param("courseId", "0")) .param("courseId", "0"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().string("0")); .andExpect(content().string("[]"));
} }
@Test @Test
void findCertificateIdWithoutUserId() throws Exception { void findCertificateIdWithoutUserId() throws Exception {
mockMvc.perform(get("/certificates/getId") mockMvc.perform(get("/certificates/findForUserAndCourse")
.param("courseId", "0")) .param("courseId", "0"))
.andExpect(status().is4xxClientError()); .andExpect(status().is4xxClientError());
} }
@Test @Test
void findCertificateIdWithoutCourseId() throws Exception { void findCertificateIdWithoutCourseId() throws Exception {
mockMvc.perform(get("/certificates/getId") mockMvc.perform(get("/certificates/findForUserAndCourse")
.param("userId", "0")) .param("userId", "0"))
.andExpect(status().is4xxClientError()); .andExpect(status().is4xxClientError());
} }
@Test @Test
void findCertificateIdWithoutParams() throws Exception { void findCertificateIdWithoutParams() throws Exception {
mockMvc.perform(get("/certificates/getId")) mockMvc.perform(get("/certificates/findForUserAndCourse"))
.andExpect(status().is4xxClientError()); .andExpect(status().is4xxClientError());
} }
...@@ -144,8 +148,14 @@ class CertificateControllerTests { ...@@ -144,8 +148,14 @@ class CertificateControllerTests {
@Test @Test
void findAllCertificates() throws Exception { 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") mockMvc.perform(get("/certificates/findAll")
.param("page", "1")) .content("{ \"page\": 0, \"size\": 1, \"sort\": []}")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()); .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