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;
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