import domain.Nota; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import domain.Student; import domain.Tema; import repository.NotaXMLRepo; import repository.StudentXMLRepo; import repository.TemaXMLRepo; import service.Service; import validation.NotaValidator; import validation.StudentValidator; import validation.TemaValidator; import validation.ValidationException; import java.time.LocalDate; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @Tag("IntegrationTest") class IntegrationTest { StudentValidator studentValidator = new StudentValidator(); TemaValidator temaValidator = new TemaValidator(); String filenameStudent = "fisiere/Studenti.xml"; String filenameTema = "fisiere/Teme.xml"; String filenameNota = "fisiere/Note.xml"; StudentXMLRepo studentXMLRepository = new StudentXMLRepo(filenameStudent); TemaXMLRepo temaXMLRepository = new TemaXMLRepo(filenameTema); NotaValidator notaValidator = new NotaValidator(studentXMLRepository, temaXMLRepository); NotaXMLRepo notaXMLRepository = new NotaXMLRepo(filenameNota); Service service = new Service(studentXMLRepository, studentValidator, temaXMLRepository, temaValidator, notaXMLRepository, notaValidator); @Test void AddStudent() { // Arrange Student testStudent = new Student("1004", "Andrei", 932, "andrei@test.com"); // Act service.addStudent(testStudent); // Assert assertTrue(service.findStudent("1004") != null); service.deleteStudent("1004"); } @Test void AddAssignment() { // Arrange Tema testAssignment = new Tema("1111", "Test Assignment", 12, 6); // Act service.addTema(testAssignment); // Assert assertTrue(service.findTema("1111") != null); service.deleteTema("1111"); } @Test void AddGrade() { Nota testNota = new Nota("1234", "1", "1", 9.5, LocalDate.of(2018, 10, 9)); service.addNota(testNota, "Amazing work"); assertTrue(service.findNota("1234") != null); service.deleteNota("1234"); } @Test void IntegrationTest() { service.deleteNota("1234"); service.deleteTema("1111"); service.deleteStudent("1004"); Student testStudent = new Student("1004", "Andrei", 932, "andrei@test.com"); service.addStudent(testStudent); Tema testAssignment = new Tema("1111", "Test Assignment", 1, 6); service.addTema(testAssignment); Nota testNota = new Nota("1234", "1004", "1111", 9.5, LocalDate.of(2018, 10, 2)); service.addNota(testNota, "Amazing work"); assertTrue(service.findNota("1234") != null); service.deleteNota("1234"); service.deleteTema("1111"); service.deleteStudent("1004"); } }