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

Implementing LectureMapperTest - in progress

parent 9bc28484
No related branches found
No related tags found
2 merge requests!31M2,!23M2 course tests
Pipeline #
package org.fuseri.modulelanguageschool.lecture;
import org.fuseri.model.dto.course.LanguageTypeDto;
import org.fuseri.model.dto.course.ProficiencyLevelDto;
import org.fuseri.model.dto.lecture.LectureCreateDto;
import org.fuseri.model.dto.lecture.LectureDto;
import org.fuseri.modulelanguageschool.course.Course;
import org.fuseri.modulelanguageschool.course.Language;
import org.fuseri.modulelanguageschool.course.ProficiencyLevel;
import org.fuseri.modulelanguageschool.lecture.Lecture;
import org.fuseri.modulelanguageschool.lecture.LectureMapper;
import org.fuseri.modulelanguageschool.user.Address;
import org.fuseri.modulelanguageschool.user.User;
import org.fuseri.modulelanguageschool.user.UserType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@SpringBootTest
final class LectureMapperTest {
private final LectureCreateDto lectureCreateDto = new LectureCreateDto(
LocalDateTime.now().plusDays(2),
LocalDateTime.now().plusDays(2).plusHours(2),
"Learning how to spell deprecated",
10, 0L);
private final LectureDto lectureDto = new LectureDto(
LocalDateTime.now().plusDays(2),
LocalDateTime.now().plusDays(2).plusHours(2),
"Learning how to spell deprecated",
10, 0L, 0L);
private final Course course = new Course("AJ1", 10,
Language.ENGLISH, ProficiencyLevel.A1, null);
private final User student = new User("novakovat", UserType.STUDENT,
"novakova@gmail.com", "password", "Tereza",
"Nováková", new Address(), List.of(), List.of());
private final User lecturer = new User("dolezelt", UserType.LECTURER,
"dolezel@gmail.com", "password", "Tomáš",
"Doležel", new Address(), List.of(), List.of());
private final Lecture lecture = new Lecture(
LocalDateTime.now().plusDays(2),
LocalDateTime.now().plusDays(2).plusHours(2),
"Learning how to spell deprecated",
10,
course, lecturer, new HashSet<>(List.of(student)));
@Autowired
private org.fuseri.modulelanguageschool.lecture.LectureMapper LectureMapper;
@BeforeEach
void setUp()
{
lecture.setId(1L);
lectureDto.setId(1L);
}
@Test
void mapNullToDto() {
var createdDto = LectureMapper.mapToDto(null);
Assertions.assertNull(createdDto);
}
@Test
void mapToDto() {
var createdDto = LectureMapper.mapToDto(lecture);
Assertions.assertEquals(lectureDto, createdDto);
}
@Test
void mapNullToLectureDto() {
var createdLecture = LectureMapper.mapToLecture((LectureDto) null);
Assertions.assertNull(createdLecture);
}
@Test
void mapToLectureDto() {
var createdLecture = LectureMapper.mapToLecture(lectureDto);
Assertions.assertEquals(lecture, createdLecture);
}
@Test
void mapNullToList() {
var lectureDtos = LectureMapper.mapToList(null);
Assertions.assertNull(lectureDtos);
}
@Test
void mapToEmptyList() {
var lectureDtos = LectureMapper.mapToList(Collections.emptyList());
Assertions.assertEquals(lectureDtos.size(), 0);
}
@Test
void mapToList() {
var lectureDtos = LectureMapper.mapToList(Collections.singletonList(lecture));
Assertions.assertEquals(1, lectureDtos.size());
Assertions.assertEquals(lectureDto, lectureDtos.get(0));
}
@Test
void mapNullToLectureLectureCreateDto() {
var createdLecture = LectureMapper.mapToLecture((LectureCreateDto) null);
Assertions.assertNull(createdLecture);
}
@Test
void mapToLectureLectureCreateDto() {
var createdLecture = LectureMapper.mapToLecture(lectureCreateDto);
Assertions.assertEquals(lecture, createdLecture);
}
}
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