From 6845bc6e717e85f3de895d8b0036606c6f21e00b Mon Sep 17 00:00:00 2001 From: jkuznik Date: Mon, 2 Dec 2024 07:31:28 +0100 Subject: [PATCH 1/3] Change project structure --- .../OpenWeatherClient.java | 2 +- .../API/WeatherMonitoringFacade.java | 11 ++++++ .../WeatherMonitoringService.java | 18 +++++---- .../RiskAssessmentFacade.java | 2 +- .../RiskAssessmentService.java | 2 +- .../{disasteralert => alert}/Alert.java | 4 +- .../disasteralerts/alert/AlertFacade.java | 17 +++++++++ .../{disasteralert => alert}/AlertMapper.java | 6 +-- .../AlertRepository.java | 2 +- .../AlertService.java | 6 +-- .../AlertServiceImpl.java | 20 +++++----- .../dto/AlertAddDTO.java | 3 +- .../dto/AlertDTO.java | 2 +- .../{disasteralert => disaster}/Disaster.java | 3 +- .../DisasterController.java | 6 +-- .../DisasterFacade.java} | 12 ++++-- .../DisasterMapper.java | 6 +-- .../DisasterRepository.java | 3 +- .../DisasterService.java | 6 +-- .../DisasterServiceImpl.java | 14 ++++--- .../DisasterType.java | 2 +- .../dto/DisasterAddDTO.java | 4 +- .../dto/DisasterDTO.java | 6 +-- .../enums}/DisasterStatus.java | 2 +- .../EmailService.java | 7 +--- .../notification/NotificationFacade.java | 37 +++++++++++++++++++ .../NotificationListener.java | 4 +- .../NotificationManager.java | 4 +- .../SMSService.java | 4 +- .../web/DisasterViewController.java | 12 +++--- .../WeatherMonitoringServiceTest.java | 11 +++--- .../DisasterAlertsApplicationTests.java | 3 -- .../TestDisasterAlertsApplication.java | 11 ------ .../TestcontainersConfiguration.java | 8 ---- .../RiskAssessmentServiceTest.java | 4 +- .../AlertServiceImplTest.java | 14 +++---- .../DisasterControllerTest.java | 7 ++-- .../DisasterFacadeTest.java} | 16 ++++---- .../DisasterServiceImplTest.java | 12 +++--- .../DisasteralertIT.java | 13 ++----- .../PSQLTestConatiner.java | 2 +- .../EmailServiceTest.java | 2 +- 42 files changed, 187 insertions(+), 143 deletions(-) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => API}/OpenWeatherClient.java (95%) create mode 100644 src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringFacade.java rename src/main/java/pl/ateam/disasteralerts/{disasteralert => API}/WeatherMonitoringService.java (80%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => alert}/Alert.java (83%) create mode 100644 src/main/java/pl/ateam/disasteralerts/alert/AlertFacade.java rename src/main/java/pl/ateam/disasteralerts/{disasteralert => alert}/AlertMapper.java (59%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => alert}/AlertRepository.java (76%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => alert}/AlertService.java (59%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => alert}/AlertServiceImpl.java (72%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => alert}/dto/AlertAddDTO.java (78%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => alert}/dto/AlertDTO.java (74%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/Disaster.java (90%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasterController.java (91%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert/DisasterAlertFacade.java => disaster/DisasterFacade.java} (71%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasterMapper.java (61%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasterRepository.java (83%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasterService.java (80%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasterServiceImpl.java (89%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasterType.java (88%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/dto/DisasterAddDTO.java (76%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster}/dto/DisasterDTO.java (73%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => disaster/enums}/DisasterStatus.java (55%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => notification}/EmailService.java (93%) create mode 100644 src/main/java/pl/ateam/disasteralerts/notification/NotificationFacade.java rename src/main/java/pl/ateam/disasteralerts/{disasteralert => notification}/NotificationListener.java (59%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => notification}/NotificationManager.java (90%) rename src/main/java/pl/ateam/disasteralerts/{disasteralert => notification}/SMSService.java (97%) rename src/test/java/pl/ateam/disasteralerts/{disasteralert => API}/WeatherMonitoringServiceTest.java (87%) delete mode 100644 src/test/java/pl/ateam/disasteralerts/TestDisasterAlertsApplication.java delete mode 100644 src/test/java/pl/ateam/disasteralerts/TestcontainersConfiguration.java rename src/test/java/pl/ateam/disasteralerts/{disasteralert => alert}/AlertServiceImplTest.java (88%) rename src/test/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasterControllerTest.java (94%) rename src/test/java/pl/ateam/disasteralerts/{disasteralert/DisasterAlertFacadeTest.java => disaster/DisasterFacadeTest.java} (85%) rename src/test/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasterServiceImplTest.java (89%) rename src/test/java/pl/ateam/disasteralerts/{disasteralert => disaster}/DisasteralertIT.java (89%) rename src/test/java/pl/ateam/disasteralerts/{disasteralert => disaster}/PSQLTestConatiner.java (97%) rename src/test/java/pl/ateam/disasteralerts/{disasteralert => notification}/EmailServiceTest.java (98%) diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/OpenWeatherClient.java b/src/main/java/pl/ateam/disasteralerts/API/OpenWeatherClient.java similarity index 95% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/OpenWeatherClient.java rename to src/main/java/pl/ateam/disasteralerts/API/OpenWeatherClient.java index 66e4f572..fc829cbf 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/OpenWeatherClient.java +++ b/src/main/java/pl/ateam/disasteralerts/API/OpenWeatherClient.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.API; import com.fasterxml.jackson.databind.JsonNode; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringFacade.java b/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringFacade.java new file mode 100644 index 00000000..00f0cdd5 --- /dev/null +++ b/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringFacade.java @@ -0,0 +1,11 @@ +package pl.ateam.disasteralerts.API; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class WeatherMonitoringFacade { + + private final WeatherMonitoringService weatherMonitoringService; +} diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/WeatherMonitoringService.java b/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringService.java similarity index 80% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/WeatherMonitoringService.java rename to src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringService.java index e76c39f2..269e6c0d 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/WeatherMonitoringService.java +++ b/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringService.java @@ -1,12 +1,14 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.API; import com.fasterxml.jackson.databind.JsonNode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.DisasterFacade; +import pl.ateam.disasteralerts.disaster.DisasterType; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import pl.ateam.disasteralerts.util.CitiesInPoland; import java.util.List; @@ -22,7 +24,7 @@ class WeatherMonitoringService { public static final String DESCRIPTION_HURRICANE = "Uwaga! Silne wichury"; public static final String DESCRIPTION_HEAT = "Uwaga! Upały"; private final OpenWeatherClient openWeatherClient; - private final DisasterService disasterService; + private final DisasterFacade disasterFacade; private final String API_AS_DISASTER_SOURCE = "Weather Monitoring System"; private final List monitoredLocations = CitiesInPoland.getList(); @@ -48,7 +50,7 @@ void monitorWeather() { private void handleWindDisaster(double windSpeed, String location) { if (windSpeed > 10.0) { - Optional existingDisaster = disasterService.getActiveDisasterForTypeAndLocation(DisasterType.HURRICANE, location); + Optional existingDisaster = disasterFacade.getActiveDisasterForTypeAndLocation(DisasterType.HURRICANE, location); if (existingDisaster.isEmpty()) { DisasterAddDTO disaster = new DisasterAddDTO( DisasterType.HURRICANE, @@ -56,7 +58,7 @@ private void handleWindDisaster(double windSpeed, String location) { location, UUID.randomUUID() //TODO: wygenerować uuid dedykowane dla WeatherMonitoring i na sztywno przypisać ); - disasterService.createDisaster(disaster, API_AS_DISASTER_SOURCE); + disasterFacade.createDisaster(disaster, API_AS_DISASTER_SOURCE); log.info("New wind disaster recorded for location: {}", location); } else { log.info("Wind disaster already exists for location: {}. Skipping.", location); @@ -66,7 +68,7 @@ private void handleWindDisaster(double windSpeed, String location) { private void handleHeatDisaster(double temperature, String location) { if (temperature > 35.0) { - Optional existingDisaster = disasterService.getActiveDisasterForTypeAndLocation(DisasterType.HEAT, location); + Optional existingDisaster = disasterFacade.getActiveDisasterForTypeAndLocation(DisasterType.HEAT, location); if (existingDisaster.isEmpty()) { DisasterAddDTO disaster = new DisasterAddDTO( DisasterType.DROUGHT, @@ -74,7 +76,7 @@ private void handleHeatDisaster(double temperature, String location) { location, UUID.randomUUID() //TODO: wygenerować uuid dedykowane dla WeatherMonitoring i na sztywno przypisać ); - disasterService.createDisaster(disaster, API_AS_DISASTER_SOURCE); + disasterFacade.createDisaster(disaster, API_AS_DISASTER_SOURCE); log.info("New heat disaster recorded for location: {}", location); } else { log.info("Heat disaster already exists for location: {}. Skipping.", location); diff --git a/src/main/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentFacade.java b/src/main/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentFacade.java index e87b2e33..91a46c02 100644 --- a/src/main/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentFacade.java +++ b/src/main/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentFacade.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; @Component @RequiredArgsConstructor diff --git a/src/main/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentService.java b/src/main/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentService.java index 2cd76696..180e5b46 100644 --- a/src/main/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentService.java +++ b/src/main/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentService.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; @Service @RequiredArgsConstructor diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/Alert.java b/src/main/java/pl/ateam/disasteralerts/alert/Alert.java similarity index 83% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/Alert.java rename to src/main/java/pl/ateam/disasteralerts/alert/Alert.java index 4c21f16a..71a2c171 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/Alert.java +++ b/src/main/java/pl/ateam/disasteralerts/alert/Alert.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.alert; import jakarta.persistence.*; import lombok.AllArgsConstructor; @@ -7,8 +7,6 @@ import lombok.Setter; import pl.ateam.disasteralerts.util.EntityAudit; -import java.time.Instant; -import java.time.LocalDateTime; import java.util.UUID; @Entity diff --git a/src/main/java/pl/ateam/disasteralerts/alert/AlertFacade.java b/src/main/java/pl/ateam/disasteralerts/alert/AlertFacade.java new file mode 100644 index 00000000..da2a3e26 --- /dev/null +++ b/src/main/java/pl/ateam/disasteralerts/alert/AlertFacade.java @@ -0,0 +1,17 @@ +package pl.ateam.disasteralerts.alert; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertDTO; + +@Component +@RequiredArgsConstructor +public class AlertFacade { + + private final AlertServiceImpl alertService; + + public AlertDTO createAlert(AlertAddDTO alertAddDTO) { + return alertService.createAlert(alertAddDTO); + } +} diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/AlertMapper.java b/src/main/java/pl/ateam/disasteralerts/alert/AlertMapper.java similarity index 59% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/AlertMapper.java rename to src/main/java/pl/ateam/disasteralerts/alert/AlertMapper.java index a2f376f9..63830726 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/AlertMapper.java +++ b/src/main/java/pl/ateam/disasteralerts/alert/AlertMapper.java @@ -1,8 +1,8 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.alert; import org.mapstruct.Mapper; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.AlertDTO; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertDTO; @Mapper(componentModel = "spring") interface AlertMapper { diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/AlertRepository.java b/src/main/java/pl/ateam/disasteralerts/alert/AlertRepository.java similarity index 76% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/AlertRepository.java rename to src/main/java/pl/ateam/disasteralerts/alert/AlertRepository.java index a97aa023..88120e84 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/AlertRepository.java +++ b/src/main/java/pl/ateam/disasteralerts/alert/AlertRepository.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.alert; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/AlertService.java b/src/main/java/pl/ateam/disasteralerts/alert/AlertService.java similarity index 59% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/AlertService.java rename to src/main/java/pl/ateam/disasteralerts/alert/AlertService.java index 5afac660..c4832ebb 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/AlertService.java +++ b/src/main/java/pl/ateam/disasteralerts/alert/AlertService.java @@ -1,10 +1,10 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.alert; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import org.springframework.validation.annotation.Validated; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.AlertDTO; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertDTO; @Validated interface AlertService { diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/AlertServiceImpl.java b/src/main/java/pl/ateam/disasteralerts/alert/AlertServiceImpl.java similarity index 72% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/AlertServiceImpl.java rename to src/main/java/pl/ateam/disasteralerts/alert/AlertServiceImpl.java index 63db0367..21eb1033 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/AlertServiceImpl.java +++ b/src/main/java/pl/ateam/disasteralerts/alert/AlertServiceImpl.java @@ -1,11 +1,12 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.alert; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.AlertDTO; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertDTO; +import pl.ateam.disasteralerts.notification.NotificationFacade; import pl.ateam.disasteralerts.user.UserFacade; import pl.ateam.disasteralerts.user.dto.UserDTO; @@ -16,7 +17,7 @@ class AlertServiceImpl implements AlertService { private final AlertRepository alertRepository; - private final NotificationManager notificationManager; + private final NotificationFacade notificationFacade; private final UserFacade userFacade; private final AlertMapper mapper; @@ -37,17 +38,16 @@ public AlertDTO createAlert(AlertAddDTO alertAddDTO) { void sendNotifications(AlertAddDTO alertAddDTO) { Set interestedUsers = userFacade.getInterestedUsers(alertAddDTO.location()); - interestedUsers.stream() - .forEach(user -> { + interestedUsers.forEach(user -> { if (user.phoneNumber() != null && !user.phoneNumber().isEmpty()) { - notificationManager.addSMSService(); + notificationFacade.addSMSService(); } if (user.email() != null && !user.email().isEmpty()) { - notificationManager.addEmailService(); + notificationFacade.addEmailService(); } - notificationManager.sendNotifications(alertAddDTO, user); - notificationManager.clearNotificationServices(); + notificationFacade.sendNotifications(alertAddDTO, user); + notificationFacade.clearNotificationServices(); }); } } diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/dto/AlertAddDTO.java b/src/main/java/pl/ateam/disasteralerts/alert/dto/AlertAddDTO.java similarity index 78% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/dto/AlertAddDTO.java rename to src/main/java/pl/ateam/disasteralerts/alert/dto/AlertAddDTO.java index 2f2016ce..c0fdf53d 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/dto/AlertAddDTO.java +++ b/src/main/java/pl/ateam/disasteralerts/alert/dto/AlertAddDTO.java @@ -1,9 +1,8 @@ -package pl.ateam.disasteralerts.disasteralert.dto; +package pl.ateam.disasteralerts.alert.dto; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; import java.util.UUID; public record AlertAddDTO(@NotNull UUID disasterId, diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/dto/AlertDTO.java b/src/main/java/pl/ateam/disasteralerts/alert/dto/AlertDTO.java similarity index 74% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/dto/AlertDTO.java rename to src/main/java/pl/ateam/disasteralerts/alert/dto/AlertDTO.java index a8503d5b..198ec0e6 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/dto/AlertDTO.java +++ b/src/main/java/pl/ateam/disasteralerts/alert/dto/AlertDTO.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert.dto; +package pl.ateam.disasteralerts.alert.dto; import java.util.UUID; diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/Disaster.java b/src/main/java/pl/ateam/disasteralerts/disaster/Disaster.java similarity index 90% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/Disaster.java rename to src/main/java/pl/ateam/disasteralerts/disaster/Disaster.java index 6bad65d4..5e1995c4 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/Disaster.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/Disaster.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -10,6 +10,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; import pl.ateam.disasteralerts.util.EntityAudit; import java.time.LocalDateTime; diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterController.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterController.java similarity index 91% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterController.java rename to src/main/java/pl/ateam/disasteralerts/disaster/DisasterController.java index b8d74c55..57320af4 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterController.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterController.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; @@ -9,8 +9,8 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import pl.ateam.disasteralerts.security.AppUser; @RestController diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterAlertFacade.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterFacade.java similarity index 71% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterAlertFacade.java rename to src/main/java/pl/ateam/disasteralerts/disaster/DisasterFacade.java index e3601260..e883730a 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterAlertFacade.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterFacade.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; @@ -6,8 +6,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import java.util.List; import java.util.Map; @@ -16,7 +16,7 @@ @Component @Validated @RequiredArgsConstructor -public class DisasterAlertFacade { +public class DisasterFacade { private final DisasterService disasterService; public DisasterDTO createDisaster(@NotNull @Valid DisasterAddDTO disasterAddDTO, @NotNull @NotBlank String source) { @@ -30,4 +30,8 @@ public List interestingDisasters(Optional type, Optio public Map inLocationDisastersAmount() { return disasterService.inLocationDisastersAmount(); } + + public Optional getActiveDisasterForTypeAndLocation(DisasterType type, String location) { + return disasterService.getActiveDisasterForTypeAndLocation(type, location); + } } diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterMapper.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterMapper.java similarity index 61% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterMapper.java rename to src/main/java/pl/ateam/disasteralerts/disaster/DisasterMapper.java index ef18ffe1..77ce94cc 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterMapper.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterMapper.java @@ -1,8 +1,8 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import org.mapstruct.Mapper; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; @Mapper(componentModel = "spring") interface DisasterMapper { diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterRepository.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterRepository.java similarity index 83% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterRepository.java rename to src/main/java/pl/ateam/disasteralerts/disaster/DisasterRepository.java index b4bbb3c7..7dabdc14 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterRepository.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterRepository.java @@ -1,6 +1,7 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import org.springframework.data.jpa.repository.JpaRepository; +import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; import java.util.List; import java.util.Optional; diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterService.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterService.java similarity index 80% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterService.java rename to src/main/java/pl/ateam/disasteralerts/disaster/DisasterService.java index ea83d36b..9bae9f5f 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterService.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterService.java @@ -1,11 +1,11 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import org.springframework.validation.annotation.Validated; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import java.util.List; import java.util.Map; diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterServiceImpl.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterServiceImpl.java similarity index 89% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterServiceImpl.java rename to src/main/java/pl/ateam/disasteralerts/disaster/DisasterServiceImpl.java index 8c8d6ef9..3432991c 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterServiceImpl.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterServiceImpl.java @@ -1,12 +1,14 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import pl.ateam.disasteralerts.airiskassessment.RiskAssessmentFacade; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.alert.AlertFacade; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; import java.util.*; import java.util.stream.Collectors; @@ -15,7 +17,7 @@ @RequiredArgsConstructor class DisasterServiceImpl implements DisasterService { private final DisasterRepository disasterRepository; - private final AlertService alertService; + private final AlertFacade alertFacade; private final DisasterMapper mapper; private final RiskAssessmentFacade riskAssessment; @@ -49,7 +51,7 @@ void generateAlert(UUID disasterId) { disasterDTO.description(), disasterDTO.location()); - alertService.createAlert(alertAddDTO); + alertFacade.createAlert(alertAddDTO); } @Override diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterType.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterType.java similarity index 88% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterType.java rename to src/main/java/pl/ateam/disasteralerts/disaster/DisasterType.java index 46b87c07..5d394a5f 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterType.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterType.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; public enum DisasterType { STORM("Burza"), diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/dto/DisasterAddDTO.java b/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterAddDTO.java similarity index 76% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/dto/DisasterAddDTO.java rename to src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterAddDTO.java index acf51e18..107ad3a0 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/dto/DisasterAddDTO.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterAddDTO.java @@ -1,8 +1,8 @@ -package pl.ateam.disasteralerts.disasteralert.dto; +package pl.ateam.disasteralerts.disaster.dto; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import pl.ateam.disasteralerts.disasteralert.DisasterType; +import pl.ateam.disasteralerts.disaster.DisasterType; import java.util.UUID; diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/dto/DisasterDTO.java b/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterDTO.java similarity index 73% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/dto/DisasterDTO.java rename to src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterDTO.java index 7c2283a5..6606e39b 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/dto/DisasterDTO.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterDTO.java @@ -1,7 +1,7 @@ -package pl.ateam.disasteralerts.disasteralert.dto; +package pl.ateam.disasteralerts.disaster.dto; -import pl.ateam.disasteralerts.disasteralert.DisasterStatus; -import pl.ateam.disasteralerts.disasteralert.DisasterType; +import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; +import pl.ateam.disasteralerts.disaster.DisasterType; import java.time.LocalDateTime; import java.util.UUID; diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterStatus.java b/src/main/java/pl/ateam/disasteralerts/disaster/enums/DisasterStatus.java similarity index 55% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterStatus.java rename to src/main/java/pl/ateam/disasteralerts/disaster/enums/DisasterStatus.java index 08f82df8..4b2b9d22 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterStatus.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/enums/DisasterStatus.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster.enums; public enum DisasterStatus { ACTIVE, FINISHED, FAKE diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/EmailService.java b/src/main/java/pl/ateam/disasteralerts/notification/EmailService.java similarity index 93% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/EmailService.java rename to src/main/java/pl/ateam/disasteralerts/notification/EmailService.java index 1a544e36..24dc4de4 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/EmailService.java +++ b/src/main/java/pl/ateam/disasteralerts/notification/EmailService.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.notification; import jakarta.mail.MessagingException; import jakarta.mail.internet.MimeMessage; @@ -13,12 +13,9 @@ import org.springframework.retry.annotation.Recover; import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; import pl.ateam.disasteralerts.user.dto.UserDTO; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - @Service @RequiredArgsConstructor class EmailService implements NotificationListener { diff --git a/src/main/java/pl/ateam/disasteralerts/notification/NotificationFacade.java b/src/main/java/pl/ateam/disasteralerts/notification/NotificationFacade.java new file mode 100644 index 00000000..239aa1f0 --- /dev/null +++ b/src/main/java/pl/ateam/disasteralerts/notification/NotificationFacade.java @@ -0,0 +1,37 @@ +package pl.ateam.disasteralerts.notification; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.user.dto.UserDTO; + +@Component +@RequiredArgsConstructor +public class NotificationFacade { + + private final NotificationManager notificationManager; + + public void sendNotifications(AlertAddDTO alertAddDTO, UserDTO interestedUser) { + notificationManager.sendNotifications(alertAddDTO, interestedUser); + } + + public void addEmailService() { + notificationManager.addEmailService(); + } + + public void addSMSService() { + notificationManager.addSMSService(); + } + + public void removeEmailService() { + notificationManager.removeEmailService(); + } + + public void removeSMSService() { + notificationManager.removeSMSService(); + } + + public void clearNotificationServices() { + notificationManager.clearNotificationServices(); + } +} diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/NotificationListener.java b/src/main/java/pl/ateam/disasteralerts/notification/NotificationListener.java similarity index 59% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/NotificationListener.java rename to src/main/java/pl/ateam/disasteralerts/notification/NotificationListener.java index 893ea34d..2d194c07 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/NotificationListener.java +++ b/src/main/java/pl/ateam/disasteralerts/notification/NotificationListener.java @@ -1,6 +1,6 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.notification; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; import pl.ateam.disasteralerts.user.dto.UserDTO; interface NotificationListener { diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/NotificationManager.java b/src/main/java/pl/ateam/disasteralerts/notification/NotificationManager.java similarity index 90% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/NotificationManager.java rename to src/main/java/pl/ateam/disasteralerts/notification/NotificationManager.java index 9a7ec812..7b4d0b5a 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/NotificationManager.java +++ b/src/main/java/pl/ateam/disasteralerts/notification/NotificationManager.java @@ -1,8 +1,8 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.notification; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; import pl.ateam.disasteralerts.user.dto.UserDTO; import java.util.ArrayList; diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/SMSService.java b/src/main/java/pl/ateam/disasteralerts/notification/SMSService.java similarity index 97% rename from src/main/java/pl/ateam/disasteralerts/disasteralert/SMSService.java rename to src/main/java/pl/ateam/disasteralerts/notification/SMSService.java index fab56c43..e9576d4a 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/SMSService.java +++ b/src/main/java/pl/ateam/disasteralerts/notification/SMSService.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.notification; import com.twilio.Twilio; import com.twilio.rest.api.v2010.account.Message; @@ -14,7 +14,7 @@ import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; import pl.ateam.disasteralerts.user.dto.UserDTO; import pl.ateam.disasteralerts.util.EntityAudit; diff --git a/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java b/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java index c65d1f00..2a5ffb1c 100644 --- a/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java +++ b/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java @@ -9,11 +9,11 @@ import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.support.RedirectAttributes; -import pl.ateam.disasteralerts.disasteralert.DisasterAlertFacade; -import pl.ateam.disasteralerts.disasteralert.DisasterStatus; -import pl.ateam.disasteralerts.disasteralert.DisasterType; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.DisasterFacade; +import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; +import pl.ateam.disasteralerts.disaster.DisasterType; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import pl.ateam.disasteralerts.security.AppUser; import pl.ateam.disasteralerts.util.CitiesInPoland; @@ -29,7 +29,7 @@ public class DisasterViewController { @Value("${google.maps.api.key}") private String googleApiKey; - private final DisasterAlertFacade disasterAlertFacade; + private final DisasterFacade disasterAlertFacade; private final String USER_AS_DISASTER_SOURCE = "user"; diff --git a/src/test/java/pl/ateam/disasteralerts/disasteralert/WeatherMonitoringServiceTest.java b/src/test/java/pl/ateam/disasteralerts/API/WeatherMonitoringServiceTest.java similarity index 87% rename from src/test/java/pl/ateam/disasteralerts/disasteralert/WeatherMonitoringServiceTest.java rename to src/test/java/pl/ateam/disasteralerts/API/WeatherMonitoringServiceTest.java index 478b23c9..f34628c3 100644 --- a/src/test/java/pl/ateam/disasteralerts/disasteralert/WeatherMonitoringServiceTest.java +++ b/src/test/java/pl/ateam/disasteralerts/API/WeatherMonitoringServiceTest.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.API; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -9,7 +9,8 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.jupiter.MockitoExtension; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.DisasterFacade; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.util.CitiesInPoland; import java.util.List; @@ -28,7 +29,7 @@ class WeatherMonitoringServiceTest { private OpenWeatherClient openWeatherClient; @Mock - private DisasterService disasterService; + private DisasterFacade disasterFacade; @InjectMocks private WeatherMonitoringService weatherMonitoringService; @@ -42,7 +43,7 @@ private JsonNode createWeatherData(double windSpeed, double temperature) throws void setUp() { MockitoAnnotations.openMocks(this); openWeatherClient = mock(OpenWeatherClient.class); - weatherMonitoringService = new WeatherMonitoringService(openWeatherClient, disasterService); + weatherMonitoringService = new WeatherMonitoringService(openWeatherClient, disasterFacade); } @Test @@ -70,6 +71,6 @@ void shouldNotRecordDisastersWhenThresholdsNotExceeded() throws Exception { weatherMonitoringService.monitorWeather(); // Then - verify(disasterService, never()).createDisaster(any(DisasterAddDTO.class), any(String.class)); + verify(disasterFacade, never()).createDisaster(any(DisasterAddDTO.class), any(String.class)); } } diff --git a/src/test/java/pl/ateam/disasteralerts/DisasterAlertsApplicationTests.java b/src/test/java/pl/ateam/disasteralerts/DisasterAlertsApplicationTests.java index 83713cf9..42c9cafe 100644 --- a/src/test/java/pl/ateam/disasteralerts/DisasterAlertsApplicationTests.java +++ b/src/test/java/pl/ateam/disasteralerts/DisasterAlertsApplicationTests.java @@ -1,10 +1,7 @@ package pl.ateam.disasteralerts; -import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -@Import(TestcontainersConfiguration.class) @SpringBootTest class DisasterAlertsApplicationTests { diff --git a/src/test/java/pl/ateam/disasteralerts/TestDisasterAlertsApplication.java b/src/test/java/pl/ateam/disasteralerts/TestDisasterAlertsApplication.java deleted file mode 100644 index 2763cf95..00000000 --- a/src/test/java/pl/ateam/disasteralerts/TestDisasterAlertsApplication.java +++ /dev/null @@ -1,11 +0,0 @@ -package pl.ateam.disasteralerts; - -import org.springframework.boot.SpringApplication; - -public class TestDisasterAlertsApplication { - - public static void main(String[] args) { - SpringApplication.from(DisasterAlertsApplication::main).with(TestcontainersConfiguration.class).run(args); - } - -} diff --git a/src/test/java/pl/ateam/disasteralerts/TestcontainersConfiguration.java b/src/test/java/pl/ateam/disasteralerts/TestcontainersConfiguration.java deleted file mode 100644 index c91bd393..00000000 --- a/src/test/java/pl/ateam/disasteralerts/TestcontainersConfiguration.java +++ /dev/null @@ -1,8 +0,0 @@ -package pl.ateam.disasteralerts; - -import org.springframework.boot.test.context.TestConfiguration; - -@TestConfiguration(proxyBeanMethods = false) -class TestcontainersConfiguration { - -} diff --git a/src/test/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentServiceTest.java b/src/test/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentServiceTest.java index 21dfa1a5..3c0230f4 100644 --- a/src/test/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentServiceTest.java +++ b/src/test/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentServiceTest.java @@ -6,8 +6,8 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import pl.ateam.disasteralerts.disasteralert.DisasterType; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.DisasterType; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.util.CitiesInPoland; import java.util.List; diff --git a/src/test/java/pl/ateam/disasteralerts/disasteralert/AlertServiceImplTest.java b/src/test/java/pl/ateam/disasteralerts/alert/AlertServiceImplTest.java similarity index 88% rename from src/test/java/pl/ateam/disasteralerts/disasteralert/AlertServiceImplTest.java rename to src/test/java/pl/ateam/disasteralerts/alert/AlertServiceImplTest.java index 7b14d213..5a5c1358 100644 --- a/src/test/java/pl/ateam/disasteralerts/disasteralert/AlertServiceImplTest.java +++ b/src/test/java/pl/ateam/disasteralerts/alert/AlertServiceImplTest.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.alert; import jakarta.validation.ConstraintViolationException; import org.assertj.core.api.Assertions; @@ -8,12 +8,12 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; -import pl.ateam.disasteralerts.disasteralert.dto.AlertAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.AlertDTO; +import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; +import pl.ateam.disasteralerts.alert.dto.AlertDTO; +import pl.ateam.disasteralerts.notification.NotificationFacade; import pl.ateam.disasteralerts.user.UserFacade; import pl.ateam.disasteralerts.user.dto.UserDTO; -import java.util.Set; import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; @@ -21,7 +21,7 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.when; -@SpringJUnitConfig(classes = {AlertServiceImpl.class, NotificationManager.class, UserFacade.class, AlertMapper.class, MethodValidationPostProcessor.class}) +@SpringJUnitConfig(classes = {AlertServiceImpl.class, NotificationFacade.class, UserFacade.class, AlertMapper.class, MethodValidationPostProcessor.class}) class AlertServiceImplTest { @Autowired @@ -31,7 +31,7 @@ class AlertServiceImplTest { private AlertRepository alertRepository; @MockBean - private NotificationManager notificationManager; + private NotificationFacade notificationFacade; @MockBean private UserFacade userFacade; @@ -58,7 +58,7 @@ void shouldReturnAlertDto_whenAlertAddDtoIsValid() { when(alertMapper.mapAlertAddDtoToAlert(alertAddDto)).thenReturn(alert); when(alertMapper.mapAlertToAlertDto(alert)).thenReturn(alertDto); - doNothing().when(notificationManager).sendNotifications(any(AlertAddDTO.class), any(UserDTO.class)); + doNothing().when(notificationFacade).sendNotifications(any(AlertAddDTO.class), any(UserDTO.class)); //then AlertDTO result = alertService.createAlert(alertAddDto); diff --git a/src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterControllerTest.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterControllerTest.java similarity index 94% rename from src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterControllerTest.java rename to src/test/java/pl/ateam/disasteralerts/disaster/DisasterControllerTest.java index 79b40ecc..9041275b 100644 --- a/src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterControllerTest.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterControllerTest.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -8,11 +8,10 @@ import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.security.test.context.support.WithUserDetails; import org.springframework.test.web.servlet.MockMvc; import pl.ateam.disasteralerts._config.TestProfileConfig; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import pl.ateam.disasteralerts.security.AppUser; import pl.ateam.disasteralerts.user.dto.UserDTO; diff --git a/src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterAlertFacadeTest.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterFacadeTest.java similarity index 85% rename from src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterAlertFacadeTest.java rename to src/test/java/pl/ateam/disasteralerts/disaster/DisasterFacadeTest.java index 4f99200f..e1026123 100644 --- a/src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterAlertFacadeTest.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterFacadeTest.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import jakarta.validation.ConstraintViolationException; import org.assertj.core.api.Assertions; @@ -8,8 +8,10 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.alert.AlertFacade; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; import java.time.LocalDateTime; import java.util.UUID; @@ -18,17 +20,17 @@ import static org.mockito.Mockito.when; -@SpringJUnitConfig(classes = {DisasterAlertFacade.class, AlertServiceImpl.class, DisasterServiceImpl.class, MethodValidationPostProcessor.class}) -class DisasterAlertFacadeTest { +@SpringJUnitConfig(classes = {DisasterFacade.class, AlertFacade.class, DisasterServiceImpl.class, MethodValidationPostProcessor.class}) +class DisasterFacadeTest { @Autowired - DisasterAlertFacade disasterAlertFacade; + DisasterFacade disasterAlertFacade; @MockBean DisasterService disasterService; @MockBean - AlertService alertService; + AlertFacade alertService; private final UUID testUserId = UUID.randomUUID(); private final DisasterAddDTO disasterAddDTO = getDisasterAddDTO(); diff --git a/src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterServiceImplTest.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterServiceImplTest.java similarity index 89% rename from src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterServiceImplTest.java rename to src/test/java/pl/ateam/disasteralerts/disaster/DisasterServiceImplTest.java index 5814a98e..7d4705b2 100644 --- a/src/test/java/pl/ateam/disasteralerts/disasteralert/DisasterServiceImplTest.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterServiceImplTest.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import jakarta.validation.ConstraintViolationException; import org.assertj.core.api.Assertions; @@ -9,8 +9,10 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; import pl.ateam.disasteralerts.airiskassessment.RiskAssessmentFacade; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterAddDTO; -import pl.ateam.disasteralerts.disasteralert.dto.DisasterDTO; +import pl.ateam.disasteralerts.alert.AlertFacade; +import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; +import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; +import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; import java.time.LocalDateTime; import java.util.Optional; @@ -19,7 +21,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -@SpringJUnitConfig(classes = {DisasterServiceImpl.class, AlertServiceImpl.class, DisasterMapperImpl.class, MethodValidationPostProcessor.class}) +@SpringJUnitConfig(classes = {DisasterServiceImpl.class, AlertFacade.class, DisasterMapperImpl.class, MethodValidationPostProcessor.class}) class DisasterServiceImplTest { @Autowired @@ -29,7 +31,7 @@ class DisasterServiceImplTest { DisasterRepository disasterRepository; @MockBean - AlertService alertService; + AlertFacade alertFacade; @MockBean DisasterMapper disasterMapper; diff --git a/src/test/java/pl/ateam/disasteralerts/disasteralert/DisasteralertIT.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java similarity index 89% rename from src/test/java/pl/ateam/disasteralerts/disasteralert/DisasteralertIT.java rename to src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java index 1bb0e9b1..bd05654e 100644 --- a/src/test/java/pl/ateam/disasteralerts/disasteralert/DisasteralertIT.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java @@ -1,14 +1,13 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; import pl.ateam.disasteralerts.security.AppUser; -import pl.ateam.disasteralerts.user.UserService; import pl.ateam.disasteralerts.user.dto.UserDTO; import java.util.List; @@ -17,22 +16,16 @@ import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -public class DisasteralertIT extends PSQLTestConatiner{ +public class DisasteralertIT extends PSQLTestConatiner { @Autowired DisasterRepository disasterRepository; - @Autowired - UserService userService; - @Autowired MockMvc mockMvc; AppUser appUser = getTestAppUser(); - @MockBean - WeatherMonitoringService weatherMonitoringService; - @BeforeEach public void setUp() { disasterRepository.deleteAll(); diff --git a/src/test/java/pl/ateam/disasteralerts/disasteralert/PSQLTestConatiner.java b/src/test/java/pl/ateam/disasteralerts/disaster/PSQLTestConatiner.java similarity index 97% rename from src/test/java/pl/ateam/disasteralerts/disasteralert/PSQLTestConatiner.java rename to src/test/java/pl/ateam/disasteralerts/disaster/PSQLTestConatiner.java index 92f39fec..6e13b909 100644 --- a/src/test/java/pl/ateam/disasteralerts/disasteralert/PSQLTestConatiner.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/PSQLTestConatiner.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.disaster; import org.junit.jupiter.api.Test; diff --git a/src/test/java/pl/ateam/disasteralerts/disasteralert/EmailServiceTest.java b/src/test/java/pl/ateam/disasteralerts/notification/EmailServiceTest.java similarity index 98% rename from src/test/java/pl/ateam/disasteralerts/disasteralert/EmailServiceTest.java rename to src/test/java/pl/ateam/disasteralerts/notification/EmailServiceTest.java index 3f81e762..c7bf21b6 100644 --- a/src/test/java/pl/ateam/disasteralerts/disasteralert/EmailServiceTest.java +++ b/src/test/java/pl/ateam/disasteralerts/notification/EmailServiceTest.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disasteralert; +package pl.ateam.disasteralerts.notification; import jakarta.mail.internet.MimeMessage; import org.junit.jupiter.api.BeforeEach; From 96a77f4284fd56f5c26e0a202279b370acc3c9df Mon Sep 17 00:00:00 2001 From: jkuznik Date: Mon, 2 Dec 2024 08:38:43 +0100 Subject: [PATCH 2/3] Update tests --- .../ateam/disasteralerts/disaster/DisasteralertIT.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java index bd05654e..e824e019 100644 --- a/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java @@ -4,10 +4,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import pl.ateam.disasteralerts.API.WeatherMonitoringFacade; import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; import pl.ateam.disasteralerts.security.AppUser; +import pl.ateam.disasteralerts.user.UserFacade; import pl.ateam.disasteralerts.user.dto.UserDTO; import java.util.List; @@ -21,9 +24,15 @@ public class DisasteralertIT extends PSQLTestConatiner { @Autowired DisasterRepository disasterRepository; + @Autowired + UserFacade userFacade; + @Autowired MockMvc mockMvc; + @MockBean + WeatherMonitoringFacade weatherMonitoringFacade; + AppUser appUser = getTestAppUser(); @BeforeEach From 6143a2ebb08b6e6a7ada866ce3a9aa09d01641a9 Mon Sep 17 00:00:00 2001 From: jkuznik Date: Mon, 2 Dec 2024 08:42:35 +0100 Subject: [PATCH 3/3] Replace enums --- .../pl/ateam/disasteralerts/API/WeatherMonitoringService.java | 2 +- src/main/java/pl/ateam/disasteralerts/disaster/Disaster.java | 3 ++- .../pl/ateam/disasteralerts/disaster/DisasterController.java | 1 + .../java/pl/ateam/disasteralerts/disaster/DisasterFacade.java | 1 + .../pl/ateam/disasteralerts/disaster/DisasterRepository.java | 3 ++- .../pl/ateam/disasteralerts/disaster/DisasterService.java | 1 + .../pl/ateam/disasteralerts/disaster/DisasterServiceImpl.java | 3 ++- .../pl/ateam/disasteralerts/disaster/dto/DisasterAddDTO.java | 2 +- .../pl/ateam/disasteralerts/disaster/dto/DisasterDTO.java | 4 ++-- .../{disaster => util}/enums/DisasterStatus.java | 2 +- .../disasteralerts/{disaster => util/enums}/DisasterType.java | 2 +- .../pl/ateam/disasteralerts/web/DisasterViewController.java | 4 ++-- .../airiskassessment/RiskAssessmentServiceTest.java | 2 +- .../ateam/disasteralerts/disaster/DisasterControllerTest.java | 1 + .../pl/ateam/disasteralerts/disaster/DisasterFacadeTest.java | 3 ++- .../disasteralerts/disaster/DisasterServiceImplTest.java | 3 ++- .../pl/ateam/disasteralerts/disaster/DisasteralertIT.java | 3 ++- 17 files changed, 25 insertions(+), 15 deletions(-) rename src/main/java/pl/ateam/disasteralerts/{disaster => util}/enums/DisasterStatus.java (55%) rename src/main/java/pl/ateam/disasteralerts/{disaster => util/enums}/DisasterType.java (89%) diff --git a/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringService.java b/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringService.java index 269e6c0d..da8d29c9 100644 --- a/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringService.java +++ b/src/main/java/pl/ateam/disasteralerts/API/WeatherMonitoringService.java @@ -6,7 +6,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import pl.ateam.disasteralerts.disaster.DisasterFacade; -import pl.ateam.disasteralerts.disaster.DisasterType; +import pl.ateam.disasteralerts.util.enums.DisasterType; import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import pl.ateam.disasteralerts.util.CitiesInPoland; diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/Disaster.java b/src/main/java/pl/ateam/disasteralerts/disaster/Disaster.java index 5e1995c4..b5a5467c 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/Disaster.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/Disaster.java @@ -10,8 +10,9 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterStatus; import pl.ateam.disasteralerts.util.EntityAudit; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.time.LocalDateTime; import java.util.UUID; diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterController.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterController.java index 57320af4..57f41f0f 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterController.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterController.java @@ -12,6 +12,7 @@ import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import pl.ateam.disasteralerts.security.AppUser; +import pl.ateam.disasteralerts.util.enums.DisasterType; @RestController @RequestMapping(DisasterController.DISASTERS_BASE_URL) diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterFacade.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterFacade.java index e883730a..855845cd 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterFacade.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterFacade.java @@ -8,6 +8,7 @@ import org.springframework.validation.annotation.Validated; import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.util.List; import java.util.Map; diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterRepository.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterRepository.java index 7dabdc14..c197fefb 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterRepository.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterRepository.java @@ -1,7 +1,8 @@ package pl.ateam.disasteralerts.disaster; import org.springframework.data.jpa.repository.JpaRepository; -import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.util.List; import java.util.Optional; diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterService.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterService.java index 9bae9f5f..df108abc 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterService.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterService.java @@ -6,6 +6,7 @@ import org.springframework.validation.annotation.Validated; import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.util.List; import java.util.Map; diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterServiceImpl.java b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterServiceImpl.java index 3432991c..3edd59fb 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterServiceImpl.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/DisasterServiceImpl.java @@ -8,7 +8,8 @@ import pl.ateam.disasteralerts.alert.dto.AlertAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; -import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterAddDTO.java b/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterAddDTO.java index 107ad3a0..d9785d8c 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterAddDTO.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterAddDTO.java @@ -2,7 +2,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import pl.ateam.disasteralerts.disaster.DisasterType; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.util.UUID; diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterDTO.java b/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterDTO.java index 6606e39b..ad0df025 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterDTO.java +++ b/src/main/java/pl/ateam/disasteralerts/disaster/dto/DisasterDTO.java @@ -1,7 +1,7 @@ package pl.ateam.disasteralerts.disaster.dto; -import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; -import pl.ateam.disasteralerts.disaster.DisasterType; +import pl.ateam.disasteralerts.util.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.time.LocalDateTime; import java.util.UUID; diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/enums/DisasterStatus.java b/src/main/java/pl/ateam/disasteralerts/util/enums/DisasterStatus.java similarity index 55% rename from src/main/java/pl/ateam/disasteralerts/disaster/enums/DisasterStatus.java rename to src/main/java/pl/ateam/disasteralerts/util/enums/DisasterStatus.java index 4b2b9d22..9f09f642 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/enums/DisasterStatus.java +++ b/src/main/java/pl/ateam/disasteralerts/util/enums/DisasterStatus.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disaster.enums; +package pl.ateam.disasteralerts.util.enums; public enum DisasterStatus { ACTIVE, FINISHED, FAKE diff --git a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterType.java b/src/main/java/pl/ateam/disasteralerts/util/enums/DisasterType.java similarity index 89% rename from src/main/java/pl/ateam/disasteralerts/disaster/DisasterType.java rename to src/main/java/pl/ateam/disasteralerts/util/enums/DisasterType.java index 5d394a5f..352a58c4 100644 --- a/src/main/java/pl/ateam/disasteralerts/disaster/DisasterType.java +++ b/src/main/java/pl/ateam/disasteralerts/util/enums/DisasterType.java @@ -1,4 +1,4 @@ -package pl.ateam.disasteralerts.disaster; +package pl.ateam.disasteralerts.util.enums; public enum DisasterType { STORM("Burza"), diff --git a/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java b/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java index 2a5ffb1c..aa31d226 100644 --- a/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java +++ b/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java @@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import pl.ateam.disasteralerts.disaster.DisasterFacade; -import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; -import pl.ateam.disasteralerts.disaster.DisasterType; +import pl.ateam.disasteralerts.util.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterType; import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import pl.ateam.disasteralerts.security.AppUser; diff --git a/src/test/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentServiceTest.java b/src/test/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentServiceTest.java index 3c0230f4..8824f369 100644 --- a/src/test/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentServiceTest.java +++ b/src/test/java/pl/ateam/disasteralerts/airiskassessment/RiskAssessmentServiceTest.java @@ -6,7 +6,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import pl.ateam.disasteralerts.disaster.DisasterType; +import pl.ateam.disasteralerts.util.enums.DisasterType; import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.util.CitiesInPoland; diff --git a/src/test/java/pl/ateam/disasteralerts/disaster/DisasterControllerTest.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterControllerTest.java index 9041275b..aad51bb0 100644 --- a/src/test/java/pl/ateam/disasteralerts/disaster/DisasterControllerTest.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterControllerTest.java @@ -14,6 +14,7 @@ import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; import pl.ateam.disasteralerts.security.AppUser; import pl.ateam.disasteralerts.user.dto.UserDTO; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.util.UUID; diff --git a/src/test/java/pl/ateam/disasteralerts/disaster/DisasterFacadeTest.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterFacadeTest.java index e1026123..6ca0adac 100644 --- a/src/test/java/pl/ateam/disasteralerts/disaster/DisasterFacadeTest.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterFacadeTest.java @@ -11,7 +11,8 @@ import pl.ateam.disasteralerts.alert.AlertFacade; import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; -import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.time.LocalDateTime; import java.util.UUID; diff --git a/src/test/java/pl/ateam/disasteralerts/disaster/DisasterServiceImplTest.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterServiceImplTest.java index 7d4705b2..243d24b4 100644 --- a/src/test/java/pl/ateam/disasteralerts/disaster/DisasterServiceImplTest.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasterServiceImplTest.java @@ -12,7 +12,8 @@ import pl.ateam.disasteralerts.alert.AlertFacade; import pl.ateam.disasteralerts.disaster.dto.DisasterAddDTO; import pl.ateam.disasteralerts.disaster.dto.DisasterDTO; -import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.time.LocalDateTime; import java.util.Optional; diff --git a/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java b/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java index e824e019..194cadf3 100644 --- a/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java +++ b/src/test/java/pl/ateam/disasteralerts/disaster/DisasteralertIT.java @@ -8,10 +8,11 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import pl.ateam.disasteralerts.API.WeatherMonitoringFacade; -import pl.ateam.disasteralerts.disaster.enums.DisasterStatus; +import pl.ateam.disasteralerts.util.enums.DisasterStatus; import pl.ateam.disasteralerts.security.AppUser; import pl.ateam.disasteralerts.user.UserFacade; import pl.ateam.disasteralerts.user.dto.UserDTO; +import pl.ateam.disasteralerts.util.enums.DisasterType; import java.util.List; import java.util.UUID;