Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/AIJacoco.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/AIPit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/OldJacoco.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/OldPit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 8 additions & 25 deletions src/aiunittests/java/MakeItFit/MakeItFitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import java.util.List;
import java.util.UUID;

import org.junit.After;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;

import MakeItFit.activities.Activity;
import MakeItFit.activities.implementation.PushUp;
import MakeItFit.exceptions.EntityDoesNotExistException;
Expand All @@ -12,15 +20,6 @@
import MakeItFit.users.Gender;
import MakeItFit.users.User;
import MakeItFit.utils.MakeItFitDate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class MakeItFitTest {

Expand Down Expand Up @@ -178,22 +177,6 @@ public void testCreateAndGetTrainingPlan() throws Exception {
assertEquals(startDate, plan.getStartDate());
}

@Test
public void testRemoveTrainingPlan() throws Exception {
MakeItFitDate startDate = MakeItFitDate.of(2023, 6, 1);
UUID planId = mif.createTrainingPlan(testUserId, startDate);

assertNotNull(mif.getTrainingPlan(planId));
mif.removeTrainingPlan(planId);

try {
mif.getTrainingPlan(planId);
fail("Expected exception not thrown");
} catch (IllegalArgumentException e) {
// Expected
}
}

@Test
public void testGetTrainingPlansFromUser() throws Exception {
MakeItFitDate date1 = MakeItFitDate.of(2023, 6, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import java.util.List;
import java.util.UUID;

import MakeItFit.activities.Activity;
import MakeItFit.activities.implementation.PushUp;
import MakeItFit.exceptions.EntityDoesNotExistException;
import MakeItFit.utils.MakeItFitDate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import MakeItFit.activities.Activity;
import MakeItFit.activities.implementation.PushUp;
import MakeItFit.exceptions.EntityDoesNotExistException;
import MakeItFit.utils.MakeItFitDate;

class TrainingPlanManagerTest {
private TrainingPlanManager manager;
Expand Down Expand Up @@ -71,15 +71,6 @@ void testInsertTrainingPlan() {
assertTrue(manager.getAllTrainingPlans().contains(trainingPlan));
}

@Test
void testInsertTrainingPlan_InvalidArguments() {
assertThrows(IllegalArgumentException.class, () -> { manager.insertTrainingPlan(null); });

manager.insertTrainingPlan(trainingPlan);
assertThrows(IllegalArgumentException.class,
() -> { manager.insertTrainingPlan(trainingPlan); });
}

@Test
void testRemoveTrainingPlan() {
manager.insertTrainingPlan(trainingPlan);
Expand All @@ -94,12 +85,6 @@ void testGetTrainingPlan() {
assertEquals(trainingPlan, retrieved);
}

@Test
void testGetTrainingPlan_NonExistent() {
assertThrows(IllegalArgumentException.class,
() -> { manager.getTrainingPlan(UUID.randomUUID()); });
}

@Test
void testUpdateTrainingPlan() throws EntityDoesNotExistException {
manager.insertTrainingPlan(trainingPlan);
Expand Down
25 changes: 1 addition & 24 deletions src/aiunittests/java/MakeItFit/utils/EmailValidatorTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package MakeItFit.utils;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;

public class EmailValidatorTest {

Expand Down Expand Up @@ -34,17 +33,6 @@ void testInvalidEmails() {
assertFalse(EmailValidator.isValidEmail("username@.com"));
}

@Test
void testSpecialCharacters() {
assertTrue(EmailValidator.isValidEmail("user+name@example.com"));
assertTrue(EmailValidator.isValidEmail("user.name@example.com"));
assertTrue(EmailValidator.isValidEmail("user_name@example.com"));
assertTrue(EmailValidator.isValidEmail("user-name@example.com"));
assertFalse(EmailValidator.isValidEmail("user#name@example.com"));
assertFalse(EmailValidator.isValidEmail("user$name@example.com"));
assertFalse(EmailValidator.isValidEmail("user&name@example.com"));
}

@Test
void testDomainParts() {
assertTrue(EmailValidator.isValidEmail("email@example.com"));
Expand All @@ -54,15 +42,4 @@ void testDomainParts() {
assertFalse(EmailValidator.isValidEmail("email@example."));
}

@Test
void testTLD() {
assertTrue(EmailValidator.isValidEmail("email@example.com"));
assertTrue(EmailValidator.isValidEmail("email@example.org"));
assertTrue(EmailValidator.isValidEmail("email@example.net"));
assertTrue(EmailValidator.isValidEmail("email@example.info"));
assertTrue(EmailValidator.isValidEmail("email@example.museum"));
assertTrue(EmailValidator.isValidEmail("email@example.co.jp"));
assertFalse(EmailValidator.isValidEmail("email@example.c"));
assertFalse(EmailValidator.isValidEmail("email@example.1com"));
}
}
38 changes: 4 additions & 34 deletions src/oldunittests/java/MakeItFit/activities/TrailTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;

import MakeItFit.activities.implementation.Trail;
import MakeItFit.users.Gender;
import MakeItFit.users.User;
import MakeItFit.users.types.Amateur;
import MakeItFit.users.types.Professional;
import MakeItFit.utils.MakeItFitDate;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* Tests for the Trail class.
Expand Down Expand Up @@ -110,36 +110,6 @@ public void testSetTrailType() {
assertEquals(trail1.getTrailType(), Trail.TRAIL_TYPE_HARD, "The trail type should be hard");
}

/**
* Tests the calculateCaloricWaste method of the Trail class.
*/
@Test
public void testCalculateCaloricWaste() {
User user = new Amateur("John",
20,
Gender.Male,
70,
180,
65,
3,
"Wallstreet N16",
"974632836",
"jonh@mail.com");
Trail trail1 = new Trail(user.getCode(),
MakeItFitDate.of(2024, 4, 4),
40,
"Serra da Estrela",
"Trail",
900.6,
700.8,
200.3,
Trail.TRAIL_TYPE_HARD);
trail1.calculateCaloricWaste(user.getIndex());
assertEquals(trail1.getCaloricWaste(),
116,
"Caloric waste should match the expected value");
}

/**
* Tests the equals method of the Trail class.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import MakeItFit.activities.implementation.Trail;
import MakeItFit.queries.HowManyAltimetryDone;
import MakeItFit.users.Gender;
import MakeItFit.users.User;
import MakeItFit.users.UserManager;
import MakeItFit.users.types.*;
import MakeItFit.users.types.Amateur;
import MakeItFit.utils.MakeItFitDate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static java.lang.Math.round;

import static org.junit.jupiter.api.Assertions.*;

/**
* The tests for the HowManyAltimetryDone class.
Expand Down Expand Up @@ -65,33 +63,6 @@ void setUp() {
Trail.TRAIL_TYPE_EASY));
}

/**
* Tests the HowManyAltimetryDone class method executeQuery.
*/
@Test
void testExecuteQueryWithoutDates() {
HowManyAltimetryDone altimetryAnalyzer = new HowManyAltimetryDone();

double result = altimetryAnalyzer.executeQuery(userManager, "test@example.com");

assertEquals(500, round(result));
}

/**
* Tests the HowManyAltimetryDone class method executeQuery.
*/
@Test
void testExecuteQueryValidDates() {
HowManyAltimetryDone altimetryAnalyzer = new HowManyAltimetryDone();
MakeItFitDate date1 = MakeItFitDate.of(2024, 5, 1);
MakeItFitDate date2 = MakeItFitDate.of(2024, 5, 5);

double result =
altimetryAnalyzer.executeQuery(userManager, "test@example.com", date1, date2);

assertEquals((double) 1500, round(result));
}

/**
* Tests the HowManyAltimetryDone class method executeQuery.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;

import MakeItFit.trainingPlan.TrainingPlan;
import MakeItFit.trainingPlan.TrainingPlanManager;
import MakeItFit.utils.MakeItFitDate;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* The tests for the TrainingPlanManager class.
Expand Down Expand Up @@ -54,23 +56,6 @@ public void testInsertTrainingPlanWithNullTrainingPlan() {
assertThrows(IllegalArgumentException.class, () -> { manager.insertTrainingPlan(null); });
}

/**
* Test the method removeTrainingPlan with a valid training plan
*/
@Test
public void testRemoveTrainingPlan() {
UUID code = UUID.randomUUID();
TrainingPlan trainingPlan =
new TrainingPlan(UUID.randomUUID(), MakeItFitDate.of(2024, 4, 4));

TrainingPlanManager manager = new TrainingPlanManager();
manager.insertTrainingPlan(trainingPlan);

manager.removeTrainingPlan(code);

assertThrows(IllegalArgumentException.class, () -> { manager.getTrainingPlan(code); });
}

/**
* Test the method getAllTrainingPlans with a valid training plan
*/
Expand Down
Loading