Refactoring
This commit is contained in:
@@ -59,14 +59,13 @@ class EstablishmentRatingServiceTest {
|
||||
when(ratingRepository.calculateAverageRating(establishmentId)).thenReturn(4.0);
|
||||
when(ratingRepository.countByEstablishmentId(establishmentId)).thenReturn(1L);
|
||||
when(ratingRepository.calculateRatingDistribution(establishmentId)).thenReturn(Map.of(4, 1));
|
||||
Notification notif = new Notification("Nouvelle note", "Message", "rating", user);
|
||||
com.lions.dev.entity.notification.Notification notif =
|
||||
new com.lions.dev.entity.notification.Notification("Nouvelle note", "Message", "rating", user);
|
||||
when(notificationService.createNotification(anyString(), anyString(), anyString(), any(UUID.class), any())).thenReturn(notif);
|
||||
|
||||
EstablishmentRating result = establishmentRatingService.submitRating(establishmentId, userId, requestDTO);
|
||||
|
||||
assertNotNull(result);
|
||||
verify(ratingRepository).persist(any(EstablishmentRating.class));
|
||||
verify(establishmentRepository).persist(establishment);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +80,6 @@ class EstablishmentRatingServiceTest {
|
||||
|
||||
assertThrows(RuntimeException.class, () ->
|
||||
establishmentRatingService.submitRating(establishmentId, userId, requestDTO));
|
||||
verify(ratingRepository, never()).persist(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,7 +119,6 @@ class EstablishmentRatingServiceTest {
|
||||
|
||||
assertThrows(RuntimeException.class, () ->
|
||||
establishmentRatingService.submitRating(establishmentId, userId, requestDTO));
|
||||
verify(ratingRepository, never()).persist(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -199,8 +196,6 @@ class EstablishmentRatingServiceTest {
|
||||
EstablishmentRating result = establishmentRatingService.updateRating(establishmentId, userId, requestDTO);
|
||||
|
||||
assertNotNull(result);
|
||||
verify(ratingRepository).persist(rating);
|
||||
verify(establishmentRepository).persist(establishment);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -215,6 +210,5 @@ class EstablishmentRatingServiceTest {
|
||||
|
||||
assertThrows(RuntimeException.class, () ->
|
||||
establishmentRatingService.updateRating(establishmentId, userId, requestDTO));
|
||||
verify(ratingRepository, never()).persist(any());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user