implemented scheduled tasks and notification scheduler so that whole chain task -> detected trends -> scheduled notification -> notification sent by worker is working
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package SuMoC.backend.trend.services;
|
||||
|
||||
import SuMoC.backend.trend.WeeklyMobilityStatsRepository;
|
||||
import SuMoC.backend.trend.config.TrendDetectionProperties;
|
||||
import SuMoC.backend.trend.config.TrendProperties;
|
||||
import SuMoC.backend.trend.dto.TrendDetectionDTO;
|
||||
import SuMoC.backend.trend.enums.DeltaType;
|
||||
import SuMoC.backend.trend.enums.StatAttribute;
|
||||
@@ -28,7 +28,7 @@ public class TrendDetectorServiceTest {
|
||||
private WeeklyMobilityStatsRepository weeklyMobilityStatsRepository;
|
||||
|
||||
@Mock
|
||||
private TrendDetectionProperties trendDetectionProperties;
|
||||
private TrendProperties trendProperties;
|
||||
|
||||
@InjectMocks
|
||||
private TrendDetectorService trendDetectorService;
|
||||
@@ -56,8 +56,8 @@ public class TrendDetectorServiceTest {
|
||||
int weekNumber = 2;
|
||||
|
||||
// Set threshold values for this test
|
||||
when(trendDetectionProperties.getPositiveThreshold()).thenReturn(25.0);
|
||||
when(trendDetectionProperties.getNegativeThreshold()).thenReturn(-25.0);
|
||||
when(trendProperties.getPositiveThreshold()).thenReturn(25.0);
|
||||
when(trendProperties.getNegativeThreshold()).thenReturn(-25.0);
|
||||
|
||||
// User 1: Significant increase (100m -> 400m = +300%)
|
||||
WeeklyMobilityStats user1Previous = createWeeklyStats(user1, year, weekNumber - 1, 100L);
|
||||
@@ -84,7 +84,7 @@ public class TrendDetectorServiceTest {
|
||||
|
||||
// Verify increasing trend for user1
|
||||
TrendDetectionDTO user1Trend = detectedTrends.stream()
|
||||
.filter(t -> t.getUser().getId().equals(user1.getId()))
|
||||
.filter(t -> t.getUserId().equals(user1.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
assertNotNull(user1Trend, "User 1 should have a detected trend");
|
||||
@@ -96,7 +96,7 @@ public class TrendDetectorServiceTest {
|
||||
|
||||
// Verify decreasing trend for user2
|
||||
TrendDetectionDTO user2Trend = detectedTrends.stream()
|
||||
.filter(t -> t.getUser().getId().equals(user2.getId()))
|
||||
.filter(t -> t.getUserId().equals(user2.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
assertNotNull(user2Trend, "User 2 should have a detected trend");
|
||||
@@ -108,7 +108,7 @@ public class TrendDetectorServiceTest {
|
||||
|
||||
// Verify no trend detected for user3
|
||||
boolean user3HasTrend = detectedTrends.stream()
|
||||
.anyMatch(t -> t.getUser().getId().equals(user3.getId()));
|
||||
.anyMatch(t -> t.getUserId().equals(user3.getId()));
|
||||
assertFalse(user3HasTrend, "User 3 should not have a detected trend (change below threshold)");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user