package com.magistr.app.model;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class ScheduleLessonCategoryTest {

    @Test
    void mapsCanonicalLessonTypes() {
        assertThat(ScheduleLessonCategory.fromLessonType(lessonType("Лекция")))
                .isEqualTo(ScheduleLessonCategory.LECTURE);
        assertThat(ScheduleLessonCategory.fromLessonType(lessonType("Практика")))
                .isEqualTo(ScheduleLessonCategory.PRACTICE);
        assertThat(ScheduleLessonCategory.fromLessonType(lessonType("Лабораторная работа")))
                .isEqualTo(ScheduleLessonCategory.LABORATORY);
    }

    @Test
    void rejectsAmbiguousLessonType() {
        assertThatThrownBy(() -> ScheduleLessonCategory.fromLessonType(lessonType("Лабораторно-практическое занятие")))
                .isInstanceOf(IllegalArgumentException.class)
                .hasMessageContaining("неоднозначен");
    }

    @Test
    void rejectsUnsupportedLessonType() {
        assertThatThrownBy(() -> ScheduleLessonCategory.fromLessonType(lessonType("Консультация")))
                .isInstanceOf(IllegalArgumentException.class)
                .hasMessageContaining("должен быть лекцией");
    }

    private LessonType lessonType(String name) {
        LessonType lessonType = new LessonType();
        lessonType.setLessonType(name);
        return lessonType;
    }
}
