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
3 changes: 2 additions & 1 deletion src/main/java/MakeItFit/activities/implementation/Trail.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public void calculateCaloricWaste(float index) {
* @return The calculated caloric waste as an integer.
*/
public int caloricWaste(float index) {
return (int) ((getDistance() * 0.5 + getElevationGain() * 0.1 - getElevationLoss() * 0.1) *
// Fix calories calculation formula
return (int) ((getDistance() * 0.5 + getElevationGain() * 0.1 + getElevationLoss() * 0.1) *
index * 0.01);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class RunningTest {
private Running running;
Expand Down Expand Up @@ -81,6 +84,13 @@ void testEquals() {
new Running(userCode, date, 45, "Warming", "Just for 45 minutes", 5000.0, 12.0);
assertFalse(running.equals(diff));
assertFalse(running.equals(null));
Running diffSpeed =
new Running(userCode, date, 45, "Warming", "Just for 45 minutes", 5000.0, 13.0);
assertFalse(running.equals(diffSpeed));

Running diffInSpeed =
new Running(userCode, date, 50, "Warming", "Just for 45 minutes", 5000.0, 10.0);
assertFalse(running.equals(diffInSpeed));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static MakeItFit.activities.implementation.Trail.*;
import static org.junit.jupiter.api.Assertions.*;
import static MakeItFit.activities.implementation.Trail.TRAIL_TYPE_EASY;
import static MakeItFit.activities.implementation.Trail.TRAIL_TYPE_HARD;
import static MakeItFit.activities.implementation.Trail.TRAIL_TYPE_MEDIUM;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class TrailTest {
private Trail trail;
Expand Down Expand Up @@ -75,15 +80,15 @@ void testSetTrailType() {
@Test
void testCalculateCaloricWaste() {
float index = 2.0f;
int expected = (int) ((10000 * 0.5 + 500 * 0.1 - 200 * 0.1) * index * 0.01);
int expected = (int) ((10000 * 0.5 + 500 * 0.1 + 200 * 0.1) * index * 0.01);
trail.calculateCaloricWaste(index);
assertEquals(expected, trail.getCaloricWaste());
}

@Test
void testCaloricWasteMethod() {
float index = 1.5f;
int expected = (int) ((10000 * 0.5 + 500 * 0.1 - 200 * 0.1) * index * 0.01);
int expected = (int) ((10000 * 0.5 + 500 * 0.1 + 200 * 0.1) * index * 0.01);
assertEquals(expected, trail.caloricWaste(index));
}

Expand Down Expand Up @@ -118,6 +123,17 @@ void testEquals() {
TRAIL_TYPE_HARD);
assertFalse(trail.equals(diff));
assertFalse(trail.equals(null));

Trail diff2 = new Trail(userCode,
date,
91,
"Easy peasy lemon squeezy",
"Trail",
10000,
500,
200,
TRAIL_TYPE_EASY);
assertFalse(trail.equals(diff2));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class DistanceWithAltimetryTest {
private TestDistanceWithAltimetry activity;
Expand Down Expand Up @@ -96,6 +99,26 @@ void testEquals() {
200.0);
assertFalse(activity.equals(null));
assertFalse(activity.equals(different));

TestDistanceWithAltimetry diff2 = new TestDistanceWithAltimetry(userCode,
date,
91,
"Biking",
"Bom Jesus Biking",
12345.0,
234.0,
200.0);
assertFalse(activity.equals(diff2));

TestDistanceWithAltimetry diff3 = new TestDistanceWithAltimetry(userCode,
date,
90,
"Biking",
"Bom Jesus Biking",
12345.0,
234.0,
210.0);
assertFalse(activity.equals(diff3));
}

@Test
Expand Down
14 changes: 10 additions & 4 deletions src/unittests/java/MakeItFit/activities/types/RepetitionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import java.util.UUID;

import MakeItFit.utils.MakeItFitDate;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import MakeItFit.utils.MakeItFitDate;

public class RepetitionsTest {
private TestRepetitions activity;
Expand Down Expand Up @@ -34,9 +37,9 @@ void testGetters() {
@Test
void testSetters() {
activity.setRepetitions(20);
activity.setSeries(5);
activity.setSeries(6);
assertEquals(20, activity.getRepetitions());
assertEquals(5, activity.getSeries());
assertEquals(6, activity.getSeries());
}

@Test
Expand Down Expand Up @@ -73,6 +76,9 @@ void testEquals() {
TestRepetitions diff = new TestRepetitions(userCode, date, 5, "Abs", "Plank", 12, 4);
assertFalse(activity.equals(diff));
assertFalse(activity.equals(null));

TestRepetitions diff2 = new TestRepetitions(userCode, date, 5, "Abs", "Plank", 15, 5);
assertFalse(activity.equals(diff2));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class RepetitionsWithWeightsTest {
private TestRepetitionsWithWeights activity;
Expand Down