Skip to content
Snippets Groups Projects
Commit 42013ed6 authored by Dominika Zemanovičová's avatar Dominika Zemanovičová
Browse files

Fix merge errors

parent 276a790a
No related branches found
No related tags found
1 merge request!31M2
......@@ -41,7 +41,7 @@ public class CourseDto extends DomainObjectDto {
@NotNull(message = "Student's list is required")
@Valid
private List<String> studentIds;
private List<Long> studentIds;
public CourseDto(String name, Integer capacity, LanguageTypeDto languageTypeDto, ProficiencyLevelDto proficiencyLevelDto) {
this.name = name;
......
......@@ -10,14 +10,19 @@ import org.fuseri.model.dto.user.AddressDto;
import org.fuseri.model.dto.user.UserDto;
import org.fuseri.modulecertificate.service.CertificateFacade;
import org.junit.jupiter.api.Test;
import org.springdoc.core.converters.models.Pageable;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
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.boot.test.mock.mockito.MockBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import java.time.Instant;
import java.util.List;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
......@@ -105,11 +110,16 @@ class CertificateControllerTests {
@Test
void findCertificateIdForUserAndCourse() throws Exception {
Mockito.when(certificateFacade.findByUserIdAndCourseId(ArgumentMatchers.anyLong(),
ArgumentMatchers.anyLong()))
.thenReturn(List.of(certificateDto));
mockMvc.perform(get("/certificates/findForUserAndCourse")
.param("userId", "0")
.param("courseId", "0"))
.andExpect(status().isOk())
.andExpect(content().string("[]"));
.andExpect(jsonPath("$").isArray())
.andExpect(jsonPath("$").isNotEmpty());
}
@Test
......@@ -151,10 +161,12 @@ class CertificateControllerTests {
Mockito.when(certificateFacade.findAll(ArgumentMatchers.any(Pageable.class)))
.thenReturn(Page.empty(PageRequest.of(0, 1)));
mockMvc.perform(get("/certificates/findAll")
.content("{ \"page\": 0, \"size\": 1, \"sort\": []}")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
mockMvc.perform(get("/certificates")
.param("page", "0")
.param("size", "10"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.content").isEmpty());
}
@Test
......@@ -168,3 +180,4 @@ class CertificateControllerTests {
.andExpect(jsonPath("$.content").isEmpty());
}
}
......@@ -218,10 +218,9 @@ public class CourseControllerTest {
.andExpect(status().isOk())
.andExpect(jsonPath("$.name").value("english b2 course"))
.andExpect(jsonPath("$.capacity").value(10))
.andExpect(jsonPath("$.languageTypeDto").value("ENGLISH"))
.andExpect(jsonPath("$.proficiencyLevelDto").value("B2"))
.andExpect(jsonPath("$.studentIds").value(student.getId()))
.andReturn().getResponse().getContentAsString();
.andExpect(jsonPath("$.language").value("ENGLISH"))
.andExpect(jsonPath("$.proficiency").value("B2"))
.andExpect(jsonPath("$.studentIds").exists());
}
@Test
......
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