From d25590d29dd4c27210feb0473bec9909c59cd646 Mon Sep 17 00:00:00 2001 From: Sebastian Jitaru Date: Wed, 20 Mar 2024 19:15:41 +0100 Subject: [PATCH] Solved pull request erros --- .../demo/handler/ShelterEventHandler.java | 17 +---------------- .../resources/features/CreateShelter.feature | 6 ------ 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/handler/ShelterEventHandler.java b/src/main/java/cat/udl/eps/softarch/demo/handler/ShelterEventHandler.java index c626b4f4..78b2e537 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/handler/ShelterEventHandler.java +++ b/src/main/java/cat/udl/eps/softarch/demo/handler/ShelterEventHandler.java @@ -17,28 +17,13 @@ public ShelterEventHandler(ShelterRepository shelterRepository) { @HandleBeforeCreate public void handleShelterPreCreate(Shelter shelter) { - if (shelter.getRating() == null) { - shelter.setRating(0); - } if (shelter.getCreatedAt() == null) { throw new IllegalArgumentException("Shelter must have a creation date"); } if (shelter.getUpdatedAt() == null) { throw new IllegalArgumentException("Shelter must have an update date"); } - if (checkIfValidEmail(shelter)) { - shelterRepository.save(shelter); - } - } - private boolean checkIfValidEmail(Shelter shelter){ - if (shelter.getEmail() == null) { - throw new IllegalArgumentException("Shelter must have an email"); - }else if (!shelter.getEmail().contains("@")) { - throw new IllegalArgumentException("Shelter email must contain @"); - }else if (!shelter.getEmail().contains(".")) { - throw new IllegalArgumentException("Shelter email must contain ."); - } - return true; + } } diff --git a/src/test/resources/features/CreateShelter.feature b/src/test/resources/features/CreateShelter.feature index 26b01f36..5db8e08b 100644 --- a/src/test/resources/features/CreateShelter.feature +++ b/src/test/resources/features/CreateShelter.feature @@ -52,9 +52,3 @@ Feature: Create Shelter When I create a shelter with a name "name", email "shelter@sample.app" and phone "123123123" and location "location" Then The response code is 409 And There is 1 Shelter created - - Scenario: Create a shelter with invalid email - Given I login as "admin" with password "password" - When I create a shelter with a name "name", email "shelter@sample" and phone "123123123" and location "location" - Then The response code is 500 - And There is 0 Shelter created \ No newline at end of file