Skip to content
Snippets Groups Projects
Commit 46aa9fa4 authored by Ester Vilímková's avatar Ester Vilímková
Browse files

Fixing CourseDto constructor

parent fc819a2a
No related branches found
No related tags found
2 merge requests!31M2,!23M2 course tests
Pipeline #
......@@ -43,6 +43,7 @@ public class CourseDto extends DomainObjectDto {
@Valid
private List<Long> studentIds;
public CourseDto(String name, Integer capacity, LanguageTypeDto languageTypeDto, ProficiencyLevelDto proficiencyLevelDto) {
this.name = name;
this.capacity = capacity;
......@@ -51,8 +52,4 @@ public class CourseDto extends DomainObjectDto {
this.studentIds = new ArrayList<>();
}
public CourseDto(Long id, String name, Integer capacity, LanguageTypeDto languageTypeDto, ProficiencyLevelDto proficiencyLevelDto) {
this(name, capacity, languageTypeDto, proficiencyLevelDto);
this.setId(id);
}
}
......@@ -33,7 +33,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
public class CourseControllerTest {
private final CourseCreateDto courseCreateDto = new CourseCreateDto("english b2 course", 10, LanguageTypeDto.ENGLISH, ProficiencyLevelDto.B2);
private final CourseDto courseDto = new CourseDto(0L, "english b2 course", 10, LanguageTypeDto.ENGLISH, ProficiencyLevelDto.B2);
private final CourseDto courseDto = new CourseDto("english b2 course", 10, LanguageTypeDto.ENGLISH, ProficiencyLevelDto.B2);
@Autowired
ObjectMapper objectMapper;
@Autowired
......@@ -61,7 +61,6 @@ public class CourseControllerTest {
.andExpect(jsonPath("$.capacity").value(10))
.andExpect(jsonPath("$.language").value("ENGLISH"))
.andExpect(jsonPath("$.proficiency").value("B2"))
.andExpect(jsonPath("$.id").exists())
.andReturn().getResponse().getContentAsString();
}
......@@ -89,7 +88,6 @@ public class CourseControllerTest {
Mockito.when(courseController.find(id)).thenReturn(courseDto);
mockMvc.perform(get("/courses/find/" + id))
.andExpect(status().isOk())
.andExpect(jsonPath("$.id").value(id))
.andExpect(jsonPath("$.name").value("english b2 course"))
.andExpect(jsonPath("$.capacity").value(10))
.andExpect(jsonPath("$.language").value("ENGLISH"))
......@@ -228,7 +226,7 @@ public class CourseControllerTest {
UserDto student = new UserDto("novakovat", "novakova@gamil.com", "Tereza",
"Nováková", new AddressDto());
CourseDto courseDtoWithStudent = new CourseDto(id, "english b2 course", 10, LanguageTypeDto.ENGLISH, ProficiencyLevelDto.B2);
CourseDto courseDtoWithStudent = new CourseDto("english b2 course", 10, LanguageTypeDto.ENGLISH, ProficiencyLevelDto.B2);
courseDtoWithStudent.setStudentIds(new ArrayList<>(List.of(student.getId())));
Mockito.when(courseController.enrol(ArgumentMatchers.eq(id),
......
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