From a17ff4ec5d0e3c194756d1bb4508b183be89cb50 Mon Sep 17 00:00:00 2001 From: panuozzo77 Date: Tue, 2 Jan 2024 11:29:11 +0100 Subject: [PATCH] provided Unit Test for Getter and Setter Entities + DAOMessage test --- pom.xml | 7 ++ .../java/model/DAO/DAOConnectionTest.java | 43 ++++++++ src/test/java/model/DAO/DAOMessageTest.java | 102 ++++++++++++++++++ src/test/java/model/entity/AnalyticsTest.java | 64 +++++++++++ src/test/java/model/entity/ConditionTest.java | 38 +++++++ .../model/entity/ExerciseGlossaryTest.java | 54 ++++++++++ src/test/java/model/entity/ExerciseTest.java | 56 ++++++++++ src/test/java/model/entity/HelpTest.java | 39 +++++++ src/test/java/model/entity/LicenseTest.java | 44 ++++++++ src/test/java/model/entity/MessageTest.java | 61 +++++++++++ .../model/entity/PatientConditionTest.java | 39 +++++++ .../java/model/entity/PersonalInfoTest.java | 56 ++++++++++ src/test/java/model/entity/ScheduleTest.java | 44 ++++++++ src/test/java/model/entity/UserTest.java | 59 ++++++++++ 14 files changed, 706 insertions(+) create mode 100644 src/test/java/model/DAO/DAOConnectionTest.java create mode 100644 src/test/java/model/DAO/DAOMessageTest.java create mode 100644 src/test/java/model/entity/AnalyticsTest.java create mode 100644 src/test/java/model/entity/ConditionTest.java create mode 100644 src/test/java/model/entity/ExerciseGlossaryTest.java create mode 100644 src/test/java/model/entity/ExerciseTest.java create mode 100644 src/test/java/model/entity/HelpTest.java create mode 100644 src/test/java/model/entity/LicenseTest.java create mode 100644 src/test/java/model/entity/MessageTest.java create mode 100644 src/test/java/model/entity/PatientConditionTest.java create mode 100644 src/test/java/model/entity/PersonalInfoTest.java create mode 100644 src/test/java/model/entity/ScheduleTest.java create mode 100644 src/test/java/model/entity/UserTest.java diff --git a/pom.xml b/pom.xml index fe1dc31..be656b3 100644 --- a/pom.xml +++ b/pom.xml @@ -118,6 +118,13 @@ prepare-agent + + jacoco-report + test + + report + + report verify diff --git a/src/test/java/model/DAO/DAOConnectionTest.java b/src/test/java/model/DAO/DAOConnectionTest.java new file mode 100644 index 0000000..c6c9adb --- /dev/null +++ b/src/test/java/model/DAO/DAOConnectionTest.java @@ -0,0 +1,43 @@ +package model.DAO; + +import model.service.encryption.Encryption; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import java.sql.Connection; +import java.sql.SQLException; + +import static org.junit.jupiter.api.Assertions.*; + +public class DAOConnectionTest { + + private static Connection connection; + + @BeforeAll + static void setUp() { + try { + // Set up any necessary configurations or preparations before the tests + connection = DAOConnection.getConnection(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test + void testGetConnection() { + assertNotNull(connection, "Connection should not be null"); + } + + // Add more tests as needed for your specific use cases + + @AfterAll + static void tearDown() { + try { + // Release any resources or perform cleanup after the tests + DAOConnection.releaseConnection(connection); + } catch (SQLException e) { + e.printStackTrace(); + } + } +} diff --git a/src/test/java/model/DAO/DAOMessageTest.java b/src/test/java/model/DAO/DAOMessageTest.java new file mode 100644 index 0000000..85be589 --- /dev/null +++ b/src/test/java/model/DAO/DAOMessageTest.java @@ -0,0 +1,102 @@ +package model.DAO; + +import model.entity.Message; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.sql.SQLException; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +class DAOMessageTest { + + private DAOMessage daoMessage; + + @BeforeEach + void setup() { + daoMessage = new DAOMessage(); + } + + @Test + void retrieveUsersFromNoPatientsAssigned() { + // Mock the therapist ID + int therapistId = 8; //this therapist have NO patients. + + // Call the method to test + List userIds = daoMessage.retrieveUserIdsByTherapist(therapistId); + + // Check the returned list + assertNotNull(userIds, "Returned list should not be null"); + assertTrue(userIds.isEmpty(), "Returned list should be empty"); + assertEquals(0, userIds.size()); + } + + @Test + void retrieveUsersFromPatientsAssigned() { + // Mock the therapist ID + int therapistId = 11; //this therapist have 2 patients. + + // Call the method to test + List userIds = daoMessage.retrieveUserIdsByTherapist(therapistId); + + // Check the returned list + assertNotNull(userIds, "Returned list should not be null"); + assertFalse(userIds.isEmpty(), "Returned list should not be empty"); + assertEquals(2, userIds.size()); + } + + @Test + void testRetrieveMessages() { + // Mock the user ID and contact + int userId = 9; + int contact = 12; + + // Call the method to test + List messages = daoMessage.retrieveMessages(userId, contact); + + // Check the returned list + assertNotNull(messages, "Returned list should not be null"); + assertFalse(messages.isEmpty(), "Returned list should not be empty"); + assertNotEquals(0, messages.size()); // Assuming there are 2 messages between these users + } + + @Test + void testMarkMessagesAsRead() { + // Mock the sender ID and recipient ID + int senderId = 9; + int recipientId = 12; + + // Call the method to test + daoMessage.markMessagesAsRead(senderId, recipientId); + + // Since the method doesn't return anything, we can't really verify its correctness + // However, we can assume it worked correctly if no exceptions were thrown + } + + @Test + void testSendMessage() { + // Mock the sender ID, recipient ID and message text + int senderId = 9; + int recipientId = 12; + String text = "Test message"; + + // Call the method to test + daoMessage.sendMessage(senderId, recipientId, text); + + // Since the method doesn't return anything, we can't really verify its correctness + // However, we can assume it worked correctly if no exceptions were thrown + } + + @Test + void testCountReceivedMessages() { + // Mock the recipient ID + int recipientId = 9; + + // Call the method to test + int count = daoMessage.countReceivedMessages(recipientId); + + // Check the returned count + assertNotEquals(0, count); // Assuming the recipient has received + } +} diff --git a/src/test/java/model/entity/AnalyticsTest.java b/src/test/java/model/entity/AnalyticsTest.java new file mode 100644 index 0000000..e20a790 --- /dev/null +++ b/src/test/java/model/entity/AnalyticsTest.java @@ -0,0 +1,64 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import java.sql.Timestamp; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class AnalyticsTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the Analytics class + Analytics analytics = new Analytics(); + + // Set values using setter methods + int userId = 1; + Timestamp timestamp = Timestamp.valueOf("2022-01-01 12:00:00"); + String description = "Test Description"; + String type = "Test Type"; + + analytics.setIdUser(userId); + analytics.setTimestamp(timestamp); + analytics.setDescription(description); + analytics.setType(type); + + // Test getter methods + assertEquals(userId, analytics.getIdUser(), "getIdUser() should return the correct value"); + assertEquals(timestamp, analytics.getTimestamp(), "getTimestamp() should return the correct value"); + assertEquals(description, analytics.getDescription(), "getDescription() should return the correct value"); + assertEquals(type, analytics.getType(), "getType() should return the correct value"); + } + + @Test + void testConstructor() { + // Create an instance of the Analytics class using the constructor + int userId = 1; + Timestamp timestamp = Timestamp.valueOf("2022-01-01 12:00:00"); + String description = "Test Description"; + String type = "Test Type"; + + Analytics analytics = new Analytics(); + analytics.setIdUser(userId); + analytics.setTimestamp(timestamp); + analytics.setDescription(description); + analytics.setType(type); + + // Test getter methods + assertEquals(userId, analytics.getIdUser(), "getIdUser() should return the correct value"); + assertEquals(timestamp, analytics.getTimestamp(), "getTimestamp() should return the correct value"); + assertEquals(description, analytics.getDescription(), "getDescription() should return the correct value"); + assertEquals(type, analytics.getType(), "getType() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the Analytics class + Analytics analytics = new Analytics(); + + // Test that the object is not null + assertNotNull(analytics, "Analytics object should not be null"); + } +} diff --git a/src/test/java/model/entity/ConditionTest.java b/src/test/java/model/entity/ConditionTest.java new file mode 100644 index 0000000..2b9d63f --- /dev/null +++ b/src/test/java/model/entity/ConditionTest.java @@ -0,0 +1,38 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class ConditionTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the Condition class + Condition condition = new Condition(); + + // Set values using setter methods + int idCondition = 1; + String disorderDescription = "Test Disorder Description"; + String disorderName = "Test Disorder Name"; + + condition.setIdCondition(idCondition); + condition.setDisorderDescription(disorderDescription); + condition.setDisorderName(disorderName); + + // Test getter methods + assertEquals(idCondition, condition.getIdCondition(), "getIdCondition() should return the correct value"); + assertEquals(disorderDescription, condition.getDisorderDescription(), "getDisorderDescription() should return the correct value"); + assertEquals(disorderName, condition.getDisorderName(), "getDisorderName() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the Condition class + Condition condition = new Condition(); + + // Test that the object is not null + assertNotNull(condition, "Condition object should not be null"); + } +} diff --git a/src/test/java/model/entity/ExerciseGlossaryTest.java b/src/test/java/model/entity/ExerciseGlossaryTest.java new file mode 100644 index 0000000..a991114 --- /dev/null +++ b/src/test/java/model/entity/ExerciseGlossaryTest.java @@ -0,0 +1,54 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class ExerciseGlossaryTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the ExerciseGlossary class + ExerciseGlossary exerciseGlossary = new ExerciseGlossary(); + + // Set values using setter methods + int idExercise = 1; + String exerciseName = "Test Exercise Name"; + String exerciseDescription = "Test Exercise Description"; + String type = "Test Type"; + int difficulty = 3; + byte[] initialState = "Test Initial State".getBytes(); + byte[] solution = "Test Solution".getBytes(); + String target = "Test Target"; + + exerciseGlossary.setIdExercise(idExercise); + exerciseGlossary.setExerciseName(exerciseName); + exerciseGlossary.setExerciseDescription(exerciseDescription); + exerciseGlossary.setType(type); + exerciseGlossary.setDifficulty(difficulty); + exerciseGlossary.setInitialState(initialState); + exerciseGlossary.setSolution(solution); + exerciseGlossary.setTarget(target); + + // Test getter methods + assertEquals(idExercise, exerciseGlossary.getIdExercise(), "getIdExercise() should return the correct value"); + assertEquals(exerciseName, exerciseGlossary.getExerciseName(), "getExerciseName() should return the correct value"); + assertEquals(exerciseDescription, exerciseGlossary.getExerciseDescription(), "getExerciseDescription() should return the correct value"); + assertEquals(type, exerciseGlossary.getType(), "getType() should return the correct value"); + assertEquals(difficulty, exerciseGlossary.getDifficulty(), "getDifficulty() should return the correct value"); + assertEquals(initialState, exerciseGlossary.getInitialState(), "getInitialState() should return the correct value"); + assertEquals(solution, exerciseGlossary.getSolution(), "getSolution() should return the correct value"); + assertEquals(target, exerciseGlossary.getTarget(), "getTarget() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the ExerciseGlossary class + ExerciseGlossary exerciseGlossary = new ExerciseGlossary(); + + // Test that the object is not null + assertNotNull(exerciseGlossary, "ExerciseGlossary object should not be null"); + } +} + diff --git a/src/test/java/model/entity/ExerciseTest.java b/src/test/java/model/entity/ExerciseTest.java new file mode 100644 index 0000000..027977a --- /dev/null +++ b/src/test/java/model/entity/ExerciseTest.java @@ -0,0 +1,56 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import java.sql.Date; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class ExerciseTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the Exercise class + Exercise exercise = new Exercise(); + + // Set values using setter methods + int idUser = 1; + int idExercise = 2; + Date insertionDate = Date.valueOf("2022-01-01"); + Date completionDate = Date.valueOf("2022-01-02"); + byte[] execution = "Test Execution".getBytes(); + int evaluation = 5; + int recommended = 1; + int feedback = 3; + + exercise.setIdUser(idUser); + exercise.setIdExercise(idExercise); + exercise.setInsertionDate(insertionDate); + exercise.setCompletionDate(completionDate); + exercise.setExecution(execution); + exercise.setEvaluation(evaluation); + exercise.setRecommended(recommended); + exercise.setFeedback(feedback); + + // Test getter methods + assertEquals(idUser, exercise.getIdUser(), "getIdUser() should return the correct value"); + assertEquals(idExercise, exercise.getIdExercise(), "getIdExercise() should return the correct value"); + assertEquals(insertionDate, exercise.getInsertionDate(), "getInsertionDate() should return the correct value"); + assertEquals(completionDate, exercise.getCompletionDate(), "getCompletionDate() should return the correct value"); + assertEquals(execution, exercise.getExecution(), "getExecution() should return the correct value"); + assertEquals(evaluation, exercise.getEvaluation(), "getEvaluation() should return the correct value"); + assertEquals(recommended, exercise.getRecommended(), "getRecommended() should return the correct value"); + assertEquals(feedback, exercise.getFeedback(), "getFeedback() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the Exercise class + Exercise exercise = new Exercise(); + + // Test that the object is not null + assertNotNull(exercise, "Exercise object should not be null"); + } +} + diff --git a/src/test/java/model/entity/HelpTest.java b/src/test/java/model/entity/HelpTest.java new file mode 100644 index 0000000..8197ddc --- /dev/null +++ b/src/test/java/model/entity/HelpTest.java @@ -0,0 +1,39 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class HelpTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the Help class + Help help = new Help(); + + // Set values using setter methods + int idHelp = 1; + int idExercise = 2; + String helpText = "Test Help Text"; + + help.setIdHelp(idHelp); + help.setIdExercise(idExercise); + help.setHelpText(helpText); + + // Test getter methods + assertEquals(idHelp, help.getIdHelp(), "getIdHelp() should return the correct value"); + assertEquals(idExercise, help.getIdExercise(), "getIdExercise() should return the correct value"); + assertEquals(helpText, help.getHelpText(), "getHelpText() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the Help class + Help help = new Help(); + + // Test that the object is not null + assertNotNull(help, "Help object should not be null"); + } +} + diff --git a/src/test/java/model/entity/LicenseTest.java b/src/test/java/model/entity/LicenseTest.java new file mode 100644 index 0000000..c96be92 --- /dev/null +++ b/src/test/java/model/entity/LicenseTest.java @@ -0,0 +1,44 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import java.sql.Date; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class LicenseTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the License class + License license = new License(); + + // Set values using setter methods + String sequence = "Test Sequence"; + int idUser = 1; + Date expirationDate = Date.valueOf("2022-01-01"); + boolean active = true; + + license.setSequence(sequence); + license.setIdUser(idUser); + license.setExpirationDate(expirationDate); + license.setActive(active); + + // Test getter methods + assertEquals(sequence, license.getSequence(), "getSequence() should return the correct value"); + assertEquals(idUser, license.getIdUser(), "getIdUser() should return the correct value"); + assertEquals(expirationDate, license.getExpirationDate(), "getExpirationDate() should return the correct value"); + assertEquals(active, license.isActive(), "isActive() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the License class + License license = new License(); + + // Test that the object is not null + assertNotNull(license, "License object should not be null"); + } +} + diff --git a/src/test/java/model/entity/MessageTest.java b/src/test/java/model/entity/MessageTest.java new file mode 100644 index 0000000..28e7673 --- /dev/null +++ b/src/test/java/model/entity/MessageTest.java @@ -0,0 +1,61 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import java.sql.Timestamp; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class MessageTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the Message class + Message message = new Message(); + + // Set values using setter methods + int idMessage = 1; + int sender = 2; + int recipient = 3; + boolean read = true; + String body = "Test Body"; + Timestamp sent = Timestamp.valueOf("2022-01-01 12:00:00"); + + message.setIdMessage(idMessage); + message.setSender(sender); + message.setRecipient(recipient); + message.setRead(read); + message.setBody(body); + message.setSent(sent); + + // Test getter methods + assertEquals(idMessage, message.getIdMessage(), "getIdMessage() should return the correct value"); + assertEquals(sender, message.getSender(), "getSender() should return the correct value"); + assertEquals(recipient, message.getRecipient(), "getRecipient() should return the correct value"); + assertEquals(read, message.isRead(), "isRead() should return the correct value"); + assertEquals(body, message.getBody(), "getBody() should return the correct value"); + assertEquals(sent, message.getSent(), "getSent() should return the correct value"); + } + + @Test + void testToString() { + // Create an instance of the Message class + Message message = new Message(); + + // Call toString method + String result = message.toString(); + + // Add more assertions based on the expected output of toString + assertNotNull(result, "toString() result should not be null"); + } + + @Test + void testNotNull() { + // Create an instance of the Message class + Message message = new Message(); + + // Test that the object is not null + assertNotNull(message, "Message object should not be null"); + } +} diff --git a/src/test/java/model/entity/PatientConditionTest.java b/src/test/java/model/entity/PatientConditionTest.java new file mode 100644 index 0000000..5422cf2 --- /dev/null +++ b/src/test/java/model/entity/PatientConditionTest.java @@ -0,0 +1,39 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class PatientConditionTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the PatientCondition class + PatientCondition patientCondition = new PatientCondition(); + + // Set values using setter methods + int idCondition = 1; + int idPatient = 2; + int severity = 3; + + patientCondition.setIdCondition(idCondition); + patientCondition.setIdPatient(idPatient); + patientCondition.setSeverity(severity); + + // Test getter methods + assertEquals(idCondition, patientCondition.getIdCondition(), "getIdCondition() should return the correct value"); + assertEquals(idPatient, patientCondition.getIdPatient(), "getIdPatient() should return the correct value"); + assertEquals(severity, patientCondition.getSeverity(), "getSeverity() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the PatientCondition class + PatientCondition patientCondition = new PatientCondition(); + + // Test that the object is not null + assertNotNull(patientCondition, "PatientCondition object should not be null"); + } +} + diff --git a/src/test/java/model/entity/PersonalInfoTest.java b/src/test/java/model/entity/PersonalInfoTest.java new file mode 100644 index 0000000..2be76c5 --- /dev/null +++ b/src/test/java/model/entity/PersonalInfoTest.java @@ -0,0 +1,56 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import java.sql.Date; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class PersonalInfoTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the PersonalInfo class + PersonalInfo personalInfo = new PersonalInfo(); + + // Set values using setter methods + int idUser = 1; + String firstname = "John"; + String lastname = "Doe"; + Date dateOfBirth = Date.valueOf("1990-01-01"); + String gender = "Male"; + String address = "123 Main St"; + String ssn = "123-45-6789"; + String phone = "555-1234"; + + personalInfo.setIdUser(idUser); + personalInfo.setFirstname(firstname); + personalInfo.setLastname(lastname); + personalInfo.setDateOfBirth(dateOfBirth); + personalInfo.setGender(gender); + personalInfo.setAddress(address); + personalInfo.setSsn(ssn); + personalInfo.setPhone(phone); + + // Test getter methods + assertEquals(idUser, personalInfo.getIdUser(), "getIdUser() should return the correct value"); + assertEquals(firstname, personalInfo.getFirstname(), "getFirstname() should return the correct value"); + assertEquals(lastname, personalInfo.getLastname(), "getLastname() should return the correct value"); + assertEquals(dateOfBirth, personalInfo.getDateOfBirth(), "getDateOfBirth() should return the correct value"); + assertEquals(gender, personalInfo.getGender(), "getGender() should return the correct value"); + assertEquals(address, personalInfo.getAddress(), "getAddress() should return the correct value"); + assertEquals(ssn, personalInfo.getSsn(), "getSsn() should return the correct value"); + assertEquals(phone, personalInfo.getPhone(), "getPhone() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the PersonalInfo class + PersonalInfo personalInfo = new PersonalInfo(); + + // Test that the object is not null + assertNotNull(personalInfo, "PersonalInfo object should not be null"); + } +} + diff --git a/src/test/java/model/entity/ScheduleTest.java b/src/test/java/model/entity/ScheduleTest.java new file mode 100644 index 0000000..d024142 --- /dev/null +++ b/src/test/java/model/entity/ScheduleTest.java @@ -0,0 +1,44 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import java.sql.Date; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class ScheduleTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the Schedule class + Schedule schedule = new Schedule(); + + // Set values using setter methods + int idTherapist = 1; + Date date = Date.valueOf("2022-01-01"); + String timeSlot = "10:00 AM - 11:00 AM"; + int reserved = 2; + + schedule.setIdTherapist(idTherapist); + schedule.setDate(date); + schedule.setTimeSlot(timeSlot); + schedule.setReserved(reserved); + + // Test getter methods + assertEquals(idTherapist, schedule.getIdTherapist(), "getIdTherapist() should return the correct value"); + assertEquals(date, schedule.getDate(), "getDate() should return the correct value"); + assertEquals(timeSlot, schedule.getTimeSlot(), "getTimeSlot() should return the correct value"); + assertEquals(reserved, schedule.getReserved(), "getReserved() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the Schedule class + Schedule schedule = new Schedule(); + + // Test that the object is not null + assertNotNull(schedule, "Schedule object should not be null"); + } +} + diff --git a/src/test/java/model/entity/UserTest.java b/src/test/java/model/entity/UserTest.java new file mode 100644 index 0000000..6307830 --- /dev/null +++ b/src/test/java/model/entity/UserTest.java @@ -0,0 +1,59 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import java.sql.Timestamp; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class UserTest { + + @Test + void testGetterAndSetterMethods() { + // Create an instance of the User class + User user = new User(); + + // Set values using setter methods + int id = 1; + String email = "test@example.com"; + String password = "testPassword"; + int idTherapist = 2; + Timestamp activationDate = Timestamp.valueOf("2022-01-01 12:00:00"); + boolean active = true; + boolean analytics = false; + boolean emailNotifications = true; + String notificationTime = "09:00 AM"; + + user.setId(id); + user.setEmail(email); + user.setPassword(password); + user.setIdTherapist(idTherapist); + user.setActivationDate(activationDate); + user.setActive(active); + user.setAnalytics(analytics); + user.setEmailNotifications(emailNotifications); + user.setNotificationTime(notificationTime); + + // Test getter methods + assertEquals(id, user.getId(), "getId() should return the correct value"); + assertEquals(email, user.getEmail(), "getEmail() should return the correct value"); + assertEquals(password, user.getPassword(), "getPassword() should return the correct value"); + assertEquals(idTherapist, user.getIdTherapist(), "getIdTherapist() should return the correct value"); + assertEquals(activationDate, user.getActivationDate(), "getActivationDate() should return the correct value"); + assertEquals(active, user.isActive(), "isActive() should return the correct value"); + assertEquals(analytics, user.isAnalytics(), "isAnalytics() should return the correct value"); + assertEquals(emailNotifications, user.isEmailNotifications(), "isEmailNotifications() should return the correct value"); + assertEquals(notificationTime, user.getNotificationTime(), "getNotificationTime() should return the correct value"); + } + + @Test + void testNotNull() { + // Create an instance of the User class + User user = new User(); + + // Test that the object is not null + assertNotNull(user, "User object should not be null"); + } +} +