implement trend detection logic
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

- for now aimed to detect weekly trends in car distances, easily extendable to all other attributes of the statsm model
- including test
This commit is contained in:
2026-01-07 15:28:35 +01:00
parent ec0615f6df
commit 6e458edd5c
13 changed files with 376 additions and 23 deletions
@@ -38,6 +38,7 @@ public class UserServiceTest {
@BeforeEach
void setUp() {
userRepository.deleteAll();
sender = userRepository.save(uniqueUser(1));
differentUser = userRepository.save(uniqueUser(2));
}
@@ -67,7 +68,7 @@ public class UserServiceTest {
assertEquals(differentUser.getPublicName(), publicSetting.getDisplayName());
}
}
@Test
@@ -86,7 +87,6 @@ public class UserServiceTest {
assertTrue(userRepository.findById(differentUser.getId()).isPresent());
}
@@ -101,14 +101,14 @@ public class UserServiceTest {
// Check if user can change his own password
// Too short password
assertThrows(RuntimeException.class, () -> userService.setPassword(sender.getId(), "test"));
// TODO: check why this assertion fails (most likely because of password encoding internals)
// assertTrue(passwordEncoder.matches("password1", userRepository.findById(sender.getId()).get().getPassword()));
// Too short password
assertThrows(RuntimeException.class, () -> userService.setPassword(sender.getId(), "test"));
// TODO: check why this assertion fails (most likely because of password encoding internals)
// assertTrue(passwordEncoder.matches("password1", userRepository.findById(sender.getId()).get().getPassword()));
// Valid password
userService.setPassword(sender.getId(), newPassword);
assertTrue(passwordEncoder.matches(newPassword, userRepository.findById(sender.getId()).get().getPassword()));
// Valid password
userService.setPassword(sender.getId(), newPassword);
assertTrue(passwordEncoder.matches(newPassword, userRepository.findById(sender.getId()).get().getPassword()));
}
@@ -125,17 +125,17 @@ public class UserServiceTest {
// Check if user can change his own email
// Other user's email
assertThrows(RuntimeException.class, () -> userService.setEmail(sender.getId(), differentUser.getEmail()));
assertEquals(sender.getEmail(), userRepository.findById(sender.getId()).get().getEmail());
// Other user's email
assertThrows(RuntimeException.class, () -> userService.setEmail(sender.getId(), differentUser.getEmail()));
assertEquals(sender.getEmail(), userRepository.findById(sender.getId()).get().getEmail());
// Invalid email format
assertThrows(RuntimeException.class, () -> userService.setEmail(sender.getId(), invalidEmail));
assertEquals(sender.getEmail(), userRepository.findById(sender.getId()).get().getEmail());
// Invalid email format
assertThrows(RuntimeException.class, () -> userService.setEmail(sender.getId(), invalidEmail));
assertEquals(sender.getEmail(), userRepository.findById(sender.getId()).get().getEmail());
// Valid email
userService.setEmail(sender.getId(), newEmail);
assertEquals(newEmail, userRepository.findById(sender.getId()).get().getEmail());
// Valid email
userService.setEmail(sender.getId(), newEmail);
assertEquals(newEmail, userRepository.findById(sender.getId()).get().getEmail());
}
@@ -178,5 +178,4 @@ public class UserServiceTest {
}
}