From 837a9a989d601ec0157e476a48cc799a1b7ba03c Mon Sep 17 00:00:00 2001 From: whatIsLove Date: Tue, 3 Dec 2024 15:09:42 +0200 Subject: [PATCH] Refactor test to avoid multiple potential exceptions in lambda expression --- .../test/java/greencity/service/EventServiceImplTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/service/src/test/java/greencity/service/EventServiceImplTest.java b/service/src/test/java/greencity/service/EventServiceImplTest.java index ba8b00709..86c01cee8 100644 --- a/service/src/test/java/greencity/service/EventServiceImplTest.java +++ b/service/src/test/java/greencity/service/EventServiceImplTest.java @@ -191,14 +191,12 @@ void saveEventWithoutAddress() { User user = ModelUtils.getUser(); AddEventDtoRequest addEventDtoWithoutCoordinates = ModelUtils.addEventDtoWithoutAddressRequest; Event eventWithoutCoordinates = ModelUtils.getEventWithoutAddress(); - + String email = user.getEmail(); when(modelMapper.map(addEventDtoWithoutCoordinates, Event.class)).thenReturn(eventWithoutCoordinates); when(eventRepo.save(any(Event.class))).thenReturn(eventWithoutCoordinates); - BadRequestException exception = assertThrows( BadRequestException.class, - () -> eventService.save(addEventDtoWithoutCoordinates, user.getEmail(), null)); - + () -> eventService.save(addEventDtoWithoutCoordinates, email, null)); assertEquals(ErrorMessage.INVALID_COORDINATES, exception.getMessage()); verify(eventRepo, times(0)).save(eventWithoutCoordinates); }