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