Skip to content

Commit

Permalink
Solved pull request erros
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianJitaru29 committed Mar 20, 2024
1 parent fad2ff3 commit d25590d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
}
6 changes: 0 additions & 6 deletions src/test/resources/features/CreateShelter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,3 @@ Feature: Create Shelter
When I create a shelter with a name "name", email "[email protected]" 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

0 comments on commit d25590d

Please sign in to comment.