diff --git a/pom.xml b/pom.xml index 8ac3a0f..2333716 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,19 @@ org.springframework.boot spring-boot-starter-websocket + + org.springframework.boot + spring-boot-starter-mail + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + com.google.api-client + google-api-client + 1.32.1 + com.mysql mysql-connector-j diff --git a/src/main/java/com/pet/foundation/pataamiga/config/security/SecurityConfigurations.java b/src/main/java/com/pet/foundation/pataamiga/config/security/SecurityConfigurations.java index a08de08..7d7e353 100644 --- a/src/main/java/com/pet/foundation/pataamiga/config/security/SecurityConfigurations.java +++ b/src/main/java/com/pet/foundation/pataamiga/config/security/SecurityConfigurations.java @@ -62,6 +62,7 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti .requestMatchers(HttpMethod.POST, "/api/v1/auth/login").permitAll() .requestMatchers(HttpMethod.POST, "/api/v1/auth/register").permitAll() .requestMatchers(HttpMethod.GET, "/api/v1/posts").permitAll() + .requestMatchers(HttpMethod.POST, "/api/v1/auth/login/google").permitAll() .anyRequest().authenticated() ) .addFilterBefore(securityFilter, UsernamePasswordAuthenticationFilter.class) diff --git a/src/main/java/com/pet/foundation/pataamiga/controller/AuthController.java b/src/main/java/com/pet/foundation/pataamiga/controller/AuthController.java index a41bd36..45107e0 100644 --- a/src/main/java/com/pet/foundation/pataamiga/controller/AuthController.java +++ b/src/main/java/com/pet/foundation/pataamiga/controller/AuthController.java @@ -3,6 +3,7 @@ import com.pet.foundation.pataamiga.controller.responses.LoginResponse; import com.pet.foundation.pataamiga.controller.responses.RegisterResponse; import com.pet.foundation.pataamiga.domain.user.dto.LoginDTO; +import com.pet.foundation.pataamiga.domain.user.dto.LoginGoogleDTO; import com.pet.foundation.pataamiga.domain.user.dto.UserCreateDTO; import com.pet.foundation.pataamiga.service.AuthService; import com.pet.foundation.pataamiga.swagger.annotatios.ConflictResponse; @@ -35,6 +36,15 @@ public ResponseEntity login(@RequestBody @Valid LoginDTO loginDTO return ResponseEntity.ok(authService.login(loginDTO)); } + @PostMapping("/login/google") + @Operation(summary = "Login with Google", description = "You can login with your Google account") + @Tag(name = "auth") + @OkResponse + @ForbiddenResponse + public ResponseEntity loginWithGoogle(@RequestBody LoginGoogleDTO loginInfo) throws Exception { + return ResponseEntity.ok(authService.loginWithGoogle(loginInfo.token())); + } + @PostMapping("/register") @Operation(summary = "Register", description = "You can register with your name, email and password") diff --git a/src/main/java/com/pet/foundation/pataamiga/controller/UserController.java b/src/main/java/com/pet/foundation/pataamiga/controller/UserController.java index 574a1c0..1c682d5 100644 --- a/src/main/java/com/pet/foundation/pataamiga/controller/UserController.java +++ b/src/main/java/com/pet/foundation/pataamiga/controller/UserController.java @@ -36,13 +36,14 @@ public ResponseEntity getUserByUuid(@PathVariable String uuid) UserResponseDTO response = UserResponseDTO.toResponse(user); return ResponseEntity.ok(response); } + @GetMapping("/themselves") @Operation(summary = "Get user by token") @Tag(name = "user") @OkResponse @ForbiddenResponse @NotFoundResponse - public ResponseEntity getUserByToken( @AuthenticationPrincipal UserDetails userDetails) { + public ResponseEntity getUserByToken(@AuthenticationPrincipal UserDetails userDetails) { User user = userService.getUserByEmail(userDetails.getUsername()); UserResponseDTO response = UserResponseDTO.toResponse(user); return ResponseEntity.ok(response); diff --git a/src/main/java/com/pet/foundation/pataamiga/domain/adoption/Adoption.java b/src/main/java/com/pet/foundation/pataamiga/domain/adoption/Adoption.java index a91ef55..21abc49 100644 --- a/src/main/java/com/pet/foundation/pataamiga/domain/adoption/Adoption.java +++ b/src/main/java/com/pet/foundation/pataamiga/domain/adoption/Adoption.java @@ -16,10 +16,11 @@ @AllArgsConstructor @NoArgsConstructor @Builder -@Entity(name = "adoptions") +@Entity +@Table(name = "adoptions") public class Adoption { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; diff --git a/src/main/java/com/pet/foundation/pataamiga/domain/email/Email.java b/src/main/java/com/pet/foundation/pataamiga/domain/email/Email.java new file mode 100644 index 0000000..06a7e3b --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/domain/email/Email.java @@ -0,0 +1,34 @@ +package com.pet.foundation.pataamiga.domain.email; + +import jakarta.persistence.*; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.UUID; + +@Entity +@Table(name = "email") +@Data +public class Email implements Serializable { + private static final Long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private UUID uuid; + + private String ownerRef; + + private String emailTo; + + private String emailFrom; + + private String subject; + + @Column(columnDefinition = "TEXT") + private String text; + + private LocalDateTime sendDataEmail; + + private StatusEmail statusEmail; +} diff --git a/src/main/java/com/pet/foundation/pataamiga/domain/email/StatusEmail.java b/src/main/java/com/pet/foundation/pataamiga/domain/email/StatusEmail.java new file mode 100644 index 0000000..4f37fbb --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/domain/email/StatusEmail.java @@ -0,0 +1,6 @@ +package com.pet.foundation.pataamiga.domain.email; + +public enum StatusEmail { + SENT, + ERROR +} diff --git a/src/main/java/com/pet/foundation/pataamiga/domain/email/dto/EmailDTO.java b/src/main/java/com/pet/foundation/pataamiga/domain/email/dto/EmailDTO.java new file mode 100644 index 0000000..9496113 --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/domain/email/dto/EmailDTO.java @@ -0,0 +1,18 @@ +package com.pet.foundation.pataamiga.domain.email.dto; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class EmailDTO { + private String ownerRef; + + private String emailTo; + + private String emailFrom; + + private String subject; + private String text; + private MailType mailType; +} diff --git a/src/main/java/com/pet/foundation/pataamiga/domain/email/dto/MailType.java b/src/main/java/com/pet/foundation/pataamiga/domain/email/dto/MailType.java new file mode 100644 index 0000000..576e1c8 --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/domain/email/dto/MailType.java @@ -0,0 +1,6 @@ +package com.pet.foundation.pataamiga.domain.email.dto; + +public enum MailType { + CREATE_USER, + CHANGE_PASSWORD, +} diff --git a/src/main/java/com/pet/foundation/pataamiga/domain/user/User.java b/src/main/java/com/pet/foundation/pataamiga/domain/user/User.java index 7e96e36..35e1d0f 100644 --- a/src/main/java/com/pet/foundation/pataamiga/domain/user/User.java +++ b/src/main/java/com/pet/foundation/pataamiga/domain/user/User.java @@ -27,7 +27,6 @@ public class User implements UserDetails { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id = 0L; - @GeneratedValue(strategy = GenerationType.UUID) private String uuid = ""; @Column(nullable = false) diff --git a/src/main/java/com/pet/foundation/pataamiga/domain/user/dto/LoginGoogleDTO.java b/src/main/java/com/pet/foundation/pataamiga/domain/user/dto/LoginGoogleDTO.java new file mode 100644 index 0000000..8207f8f --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/domain/user/dto/LoginGoogleDTO.java @@ -0,0 +1,6 @@ +package com.pet.foundation.pataamiga.domain.user.dto; + +public record LoginGoogleDTO( + String token +) { +} diff --git a/src/main/java/com/pet/foundation/pataamiga/domain/user/dto/UserCreateDTO.java b/src/main/java/com/pet/foundation/pataamiga/domain/user/dto/UserCreateDTO.java index 716ce45..cce53e9 100644 --- a/src/main/java/com/pet/foundation/pataamiga/domain/user/dto/UserCreateDTO.java +++ b/src/main/java/com/pet/foundation/pataamiga/domain/user/dto/UserCreateDTO.java @@ -4,7 +4,9 @@ import com.pet.foundation.pataamiga.domain.user.User; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; +import lombok.Builder; +@Builder public record UserCreateDTO( @NotBlank(message = "Name is mandatory") @Schema(description = "User name", example = "John Doe") diff --git a/src/main/java/com/pet/foundation/pataamiga/mapper/email/EmailMapper.java b/src/main/java/com/pet/foundation/pataamiga/mapper/email/EmailMapper.java new file mode 100644 index 0000000..6480834 --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/mapper/email/EmailMapper.java @@ -0,0 +1,14 @@ +package com.pet.foundation.pataamiga.mapper.email; + +import com.pet.foundation.pataamiga.domain.email.Email; +import com.pet.foundation.pataamiga.domain.email.dto.EmailDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper(componentModel = "spring") +public interface EmailMapper { + + EmailMapper INSTANCE = Mappers.getMapper(EmailMapper.class); + + Email toEntity(EmailDTO emailDTO); +} diff --git a/src/main/java/com/pet/foundation/pataamiga/repositories/EmailRepository.java b/src/main/java/com/pet/foundation/pataamiga/repositories/EmailRepository.java new file mode 100644 index 0000000..d842ee5 --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/repositories/EmailRepository.java @@ -0,0 +1,9 @@ +package com.pet.foundation.pataamiga.repositories; + +import com.pet.foundation.pataamiga.domain.email.Email; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface EmailRepository extends JpaRepository { +} diff --git a/src/main/java/com/pet/foundation/pataamiga/requests/ChatMessage.java b/src/main/java/com/pet/foundation/pataamiga/requests/ChatMessage.java deleted file mode 100644 index bce8461..0000000 --- a/src/main/java/com/pet/foundation/pataamiga/requests/ChatMessage.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.pet.foundation.pataamiga.requests; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class ChatMessage { - private String content; - private String sender; - private String recipient; -} diff --git a/src/main/java/com/pet/foundation/pataamiga/service/AuthService.java b/src/main/java/com/pet/foundation/pataamiga/service/AuthService.java index 1cfc5e8..c8d2465 100644 --- a/src/main/java/com/pet/foundation/pataamiga/service/AuthService.java +++ b/src/main/java/com/pet/foundation/pataamiga/service/AuthService.java @@ -5,8 +5,13 @@ import com.pet.foundation.pataamiga.domain.user.dto.LoginDTO; import com.pet.foundation.pataamiga.domain.user.dto.UserCreateDTO; +import java.io.IOException; +import java.security.GeneralSecurityException; + public interface AuthService { LoginResponse login(LoginDTO loginDTO); + LoginResponse loginWithGoogle(String token) throws Exception; + RegisterResponse register(UserCreateDTO userCreateDTO); } diff --git a/src/main/java/com/pet/foundation/pataamiga/service/EmailService.java b/src/main/java/com/pet/foundation/pataamiga/service/EmailService.java new file mode 100644 index 0000000..23924e7 --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/service/EmailService.java @@ -0,0 +1,7 @@ +package com.pet.foundation.pataamiga.service; + +import com.pet.foundation.pataamiga.domain.email.dto.EmailDTO; + +public interface EmailService { + void sendEmail(EmailDTO emailDTO); +} diff --git a/src/main/java/com/pet/foundation/pataamiga/service/impl/AuthServiceImpl.java b/src/main/java/com/pet/foundation/pataamiga/service/impl/AuthServiceImpl.java index 7aecc78..39fb97f 100644 --- a/src/main/java/com/pet/foundation/pataamiga/service/impl/AuthServiceImpl.java +++ b/src/main/java/com/pet/foundation/pataamiga/service/impl/AuthServiceImpl.java @@ -1,5 +1,10 @@ package com.pet.foundation.pataamiga.service.impl; +import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken; +import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload; +import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier; +import com.google.api.client.http.javanet.NetHttpTransport; +import com.google.api.client.json.gson.GsonFactory; import com.pet.foundation.pataamiga.controller.responses.LoginResponse; import com.pet.foundation.pataamiga.controller.responses.RegisterResponse; import com.pet.foundation.pataamiga.domain.user.User; @@ -9,13 +14,22 @@ import com.pet.foundation.pataamiga.service.TokenService; import com.pet.foundation.pataamiga.service.UserService; import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Service; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.util.List; +import java.util.UUID; + @Service -@AllArgsConstructor +@RequiredArgsConstructor +@Log4j2 public class AuthServiceImpl implements AuthService { private final UserService userService; @@ -24,6 +38,9 @@ public class AuthServiceImpl implements AuthService { private final TokenService tokenService; + @Value("${google.client.id}") + private String GOOGLE_CLIENT_ID; + @Override public LoginResponse login(LoginDTO loginDTO) { UsernamePasswordAuthenticationToken userNamePassword = @@ -34,9 +51,62 @@ public LoginResponse login(LoginDTO loginDTO) { return new LoginResponse(token); } + @Override + public LoginResponse loginWithGoogle(String token) throws Exception { + + log.info("token: {}", token); + GoogleIdTokenVerifier verifier = buildGoogleIdTokenVerifier(); + + log.info("verifier: {}", verifier); + + GoogleIdToken idToken = verifier.verify(token); + log.info("idToken: {}", idToken); + + if (idToken != null) { + Payload payload = idToken.getPayload(); + String email = payload.getEmail(); + String name = (String) payload.get("name"); + String picture = (String) payload.get("picture"); + + User user = userService.getUserByEmail(email); + + log.info("user: {}", user); + + if (user == null) { + UserCreateDTO userCreateDTO = buildUserCreateDTO(email, name, picture); + String userCreatedUuid = userService.createUser(userCreateDTO); + user = userService.getUserByUuid(userCreatedUuid); + String tokenGenerated = tokenService.generateToken(user); + return new LoginResponse(tokenGenerated); + } + + String tokenGenerated = tokenService.generateToken(user); + return new LoginResponse(tokenGenerated); + + } else { + throw new Exception("Invalid ID token"); + } + } + @Override public RegisterResponse register(UserCreateDTO userCreateDTO) { String userCreatedUuid = userService.createUser(userCreateDTO); return new RegisterResponse(userCreatedUuid); } + + private GoogleIdTokenVerifier buildGoogleIdTokenVerifier() { + return new GoogleIdTokenVerifier.Builder(new NetHttpTransport(), new GsonFactory()) + .setAudience(List.of(GOOGLE_CLIENT_ID)) + .build(); + } + + private UserCreateDTO buildUserCreateDTO(String email, String name, String picture) { + return UserCreateDTO.builder() + .email(email) + .name(name) + .profilePicture(picture) + .password(UUID.randomUUID().toString()) + .phone("9 9999-9999") + .build(); + } } diff --git a/src/main/java/com/pet/foundation/pataamiga/service/impl/EmailServiceImpl.java b/src/main/java/com/pet/foundation/pataamiga/service/impl/EmailServiceImpl.java new file mode 100644 index 0000000..d331e4e --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/service/impl/EmailServiceImpl.java @@ -0,0 +1,74 @@ +package com.pet.foundation.pataamiga.service.impl; + +import com.pet.foundation.pataamiga.domain.email.Email; +import com.pet.foundation.pataamiga.domain.email.StatusEmail; +import com.pet.foundation.pataamiga.domain.email.dto.EmailDTO; +import com.pet.foundation.pataamiga.repositories.EmailRepository; +import com.pet.foundation.pataamiga.service.EmailService; +import jakarta.mail.MessagingException; +import jakarta.mail.internet.MimeMessage; +import lombok.AllArgsConstructor; +import org.springframework.beans.BeanUtils; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.stereotype.Service; +import org.thymeleaf.TemplateEngine; +import org.thymeleaf.context.Context; + +import java.time.LocalDateTime; + +@Service +@AllArgsConstructor +public class EmailServiceImpl implements EmailService { + private final EmailRepository emailRepository; + private final JavaMailSender emailSender; + private final TemplateEngine templateEngine; + + @Override + public void sendEmail(EmailDTO emailDTO) { + Email email = new Email(); + BeanUtils.copyProperties(emailDTO, email); + email.setSendDataEmail(LocalDateTime.now()); + + try { + String html = chooseTemplate(emailDTO); + + MimeMessage message = emailSender.createMimeMessage(); + MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8"); + helper.setFrom(email.getEmailFrom()); + helper.setTo(email.getEmailTo()); + helper.setSubject(email.getSubject()); + helper.setText(html, true); + + emailSender.send(message); + + email.setStatusEmail(StatusEmail.SENT); + } catch (MessagingException e) { + email.setStatusEmail(StatusEmail.ERROR); + } finally { + emailRepository.save(email); + } + } + + private String chooseTemplate(EmailDTO emailDTO) { + String html = ""; + switch (emailDTO.getMailType()) { + case CREATE_USER: + html = getHtmlFromTemplate(emailDTO, "email"); + break; + case CHANGE_PASSWORD: + html = getHtmlFromTemplate(emailDTO, ""); + break; + default: + break; + } + return html; + } + + private String getHtmlFromTemplate(EmailDTO emailDTO, String templateName) { + Context context = new Context(); + context.setVariable("title", emailDTO.getSubject()); + context.setVariable("message", emailDTO.getText()); + return templateEngine.process(templateName, context); + } +} diff --git a/src/main/java/com/pet/foundation/pataamiga/service/impl/UserServiceImpl.java b/src/main/java/com/pet/foundation/pataamiga/service/impl/UserServiceImpl.java index 2694f9f..ec9a281 100644 --- a/src/main/java/com/pet/foundation/pataamiga/service/impl/UserServiceImpl.java +++ b/src/main/java/com/pet/foundation/pataamiga/service/impl/UserServiceImpl.java @@ -1,20 +1,26 @@ package com.pet.foundation.pataamiga.service.impl; +import com.pet.foundation.pataamiga.domain.email.dto.EmailDTO; +import com.pet.foundation.pataamiga.domain.email.dto.MailType; import com.pet.foundation.pataamiga.domain.user.User; import com.pet.foundation.pataamiga.domain.user.dto.UserCreateDTO; import com.pet.foundation.pataamiga.domain.user.dto.UserUpdateDTO; import com.pet.foundation.pataamiga.exceptions.EmailAlreadyExists; import com.pet.foundation.pataamiga.exceptions.UserNotFoundException; import com.pet.foundation.pataamiga.repositories.UserRepository; +import com.pet.foundation.pataamiga.service.EmailService; import com.pet.foundation.pataamiga.service.UserService; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import static com.pet.foundation.pataamiga.utils.email.EmailValues.*; + @AllArgsConstructor @Service public class UserServiceImpl implements UserService { private final UserRepository userRepository; + private final EmailService emailService; @Override public String createUser(UserCreateDTO userCreateDTO) { @@ -22,6 +28,16 @@ public String createUser(UserCreateDTO userCreateDTO) { throw new EmailAlreadyExists("Email already exists"); User userSaved = userRepository.save(userCreateDTO.toEntity()); + + EmailDTO emailToUser = EmailDTO.builder() + .emailTo(userSaved.getEmail()) + .emailFrom(EMAIL_FROM) + .subject(CREATE_USER_EMAIL_SUBJECT) + .text(CREATE_USER_EMAIL_TEXT) + .mailType(MailType.CREATE_USER) + .build(); + + emailService.sendEmail(emailToUser); return userSaved.getUuid(); } diff --git a/src/main/java/com/pet/foundation/pataamiga/utils/email/EmailValues.java b/src/main/java/com/pet/foundation/pataamiga/utils/email/EmailValues.java new file mode 100644 index 0000000..baed16a --- /dev/null +++ b/src/main/java/com/pet/foundation/pataamiga/utils/email/EmailValues.java @@ -0,0 +1,7 @@ +package com.pet.foundation.pataamiga.utils.email; + +public class EmailValues { + public static final String EMAIL_FROM = "matheusvictorhenrique@gmail.com"; + public static final String CREATE_USER_EMAIL_SUBJECT = "Seja Bem vindo - Pata Amiga"; + public static final String CREATE_USER_EMAIL_TEXT = "Sua conta foi criada com sucesso"; +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 1b24024..d735ecf 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -4,17 +4,17 @@ spring: url: jdbc:mysql://localhost:3306/pataamiga?useTimezone=true&serverTimezone=UTC username: root password: - #security: - # filter: - # cors: - # allowed-origins: "*" - # allowed-methods: "*" - # allowed-headers: "*" - #allow-credentials: true - #redis: - # host: localhost - #port: 6379 - #password: + mail: + host: smtp.gmail.com + port: 587 + username: ${userMailName} + password: ${userMailPassword} + properties: + mail: + smtp: + auth: true + starttls: + enable: true jpa: hibernate: ddl-auto: update diff --git a/src/main/resources/templates/change_password.html b/src/main/resources/templates/change_password.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/src/main/resources/templates/change_password.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/email.html b/src/main/resources/templates/email.html new file mode 100644 index 0000000..4a1a220 --- /dev/null +++ b/src/main/resources/templates/email.html @@ -0,0 +1,1845 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/images/Beefree-logo.png b/src/main/resources/templates/images/Beefree-logo.png new file mode 100644 index 0000000..7441f8f Binary files /dev/null and b/src/main/resources/templates/images/Beefree-logo.png differ diff --git a/src/main/resources/templates/images/Santa_dog.png b/src/main/resources/templates/images/Santa_dog.png new file mode 100644 index 0000000..cb0f964 Binary files /dev/null and b/src/main/resources/templates/images/Santa_dog.png differ diff --git a/src/main/resources/templates/images/bg_1.png b/src/main/resources/templates/images/bg_1.png new file mode 100644 index 0000000..d010db1 Binary files /dev/null and b/src/main/resources/templates/images/bg_1.png differ diff --git a/src/main/resources/templates/images/bg_2_1.png b/src/main/resources/templates/images/bg_2_1.png new file mode 100644 index 0000000..940020a Binary files /dev/null and b/src/main/resources/templates/images/bg_2_1.png differ diff --git a/src/main/resources/templates/images/bg_3.png b/src/main/resources/templates/images/bg_3.png new file mode 100644 index 0000000..13e05d3 Binary files /dev/null and b/src/main/resources/templates/images/bg_3.png differ diff --git a/src/main/resources/templates/images/bg_hero_.png b/src/main/resources/templates/images/bg_hero_.png new file mode 100644 index 0000000..00c1cbf Binary files /dev/null and b/src/main/resources/templates/images/bg_hero_.png differ diff --git a/src/main/resources/templates/images/bg_services.png b/src/main/resources/templates/images/bg_services.png new file mode 100644 index 0000000..2de1d5d Binary files /dev/null and b/src/main/resources/templates/images/bg_services.png differ diff --git a/src/main/resources/templates/images/cat_santa.png b/src/main/resources/templates/images/cat_santa.png new file mode 100644 index 0000000..e157091 Binary files /dev/null and b/src/main/resources/templates/images/cat_santa.png differ diff --git a/src/main/resources/templates/images/dewarming.png b/src/main/resources/templates/images/dewarming.png new file mode 100644 index 0000000..cdbf63a Binary files /dev/null and b/src/main/resources/templates/images/dewarming.png differ diff --git a/src/main/resources/templates/images/email.png b/src/main/resources/templates/images/email.png new file mode 100644 index 0000000..0b84274 Binary files /dev/null and b/src/main/resources/templates/images/email.png differ diff --git a/src/main/resources/templates/images/facebook2x.png b/src/main/resources/templates/images/facebook2x.png new file mode 100644 index 0000000..c5bda4c Binary files /dev/null and b/src/main/resources/templates/images/facebook2x.png differ diff --git a/src/main/resources/templates/images/instagram2x.png b/src/main/resources/templates/images/instagram2x.png new file mode 100644 index 0000000..a79311b Binary files /dev/null and b/src/main/resources/templates/images/instagram2x.png differ diff --git a/src/main/resources/templates/images/keyboard_arrow_right.png b/src/main/resources/templates/images/keyboard_arrow_right.png new file mode 100644 index 0000000..5468c03 Binary files /dev/null and b/src/main/resources/templates/images/keyboard_arrow_right.png differ diff --git a/src/main/resources/templates/images/linkedin2x.png b/src/main/resources/templates/images/linkedin2x.png new file mode 100644 index 0000000..f71e7fb Binary files /dev/null and b/src/main/resources/templates/images/linkedin2x.png differ diff --git a/src/main/resources/templates/images/location.png b/src/main/resources/templates/images/location.png new file mode 100644 index 0000000..4a7e29d Binary files /dev/null and b/src/main/resources/templates/images/location.png differ diff --git a/src/main/resources/templates/images/logo_santa_paws_W.png b/src/main/resources/templates/images/logo_santa_paws_W.png new file mode 100644 index 0000000..a932539 Binary files /dev/null and b/src/main/resources/templates/images/logo_santa_paws_W.png differ diff --git a/src/main/resources/templates/images/map_animal.png b/src/main/resources/templates/images/map_animal.png new file mode 100644 index 0000000..1c28492 Binary files /dev/null and b/src/main/resources/templates/images/map_animal.png differ diff --git a/src/main/resources/templates/images/puppy_sheet.png b/src/main/resources/templates/images/puppy_sheet.png new file mode 100644 index 0000000..013944a Binary files /dev/null and b/src/main/resources/templates/images/puppy_sheet.png differ diff --git a/src/main/resources/templates/images/time.png b/src/main/resources/templates/images/time.png new file mode 100644 index 0000000..6c0c48c Binary files /dev/null and b/src/main/resources/templates/images/time.png differ diff --git a/src/main/resources/templates/images/twitter2x.png b/src/main/resources/templates/images/twitter2x.png new file mode 100644 index 0000000..d5825f0 Binary files /dev/null and b/src/main/resources/templates/images/twitter2x.png differ diff --git a/src/test/java/com/pet/foundation/pataamiga/repositories/PostsRepositoryTest.java b/src/test/java/com/pet/foundation/pataamiga/repositories/PostsRepositoryTest.java index 721c3a8..83a42ab 100644 --- a/src/test/java/com/pet/foundation/pataamiga/repositories/PostsRepositoryTest.java +++ b/src/test/java/com/pet/foundation/pataamiga/repositories/PostsRepositoryTest.java @@ -16,10 +16,10 @@ class PostsRepositoryTest { @Autowired - private PostsRepository postsRepository; + private UserRepository userRepository; @Autowired - private UserRepository userRepository; + private PostsRepository postsRepository; @BeforeEach void setUp() { diff --git a/src/test/java/com/pet/foundation/pataamiga/service/impl/UserServiceTest.java b/src/test/java/com/pet/foundation/pataamiga/service/impl/UserServiceTest.java index ad784b7..5e3cad6 100644 --- a/src/test/java/com/pet/foundation/pataamiga/service/impl/UserServiceTest.java +++ b/src/test/java/com/pet/foundation/pataamiga/service/impl/UserServiceTest.java @@ -1,9 +1,11 @@ package com.pet.foundation.pataamiga.service.impl; +import com.pet.foundation.pataamiga.domain.email.dto.EmailDTO; import com.pet.foundation.pataamiga.domain.user.User; import com.pet.foundation.pataamiga.exceptions.EmailAlreadyExists; import com.pet.foundation.pataamiga.exceptions.UserNotFoundException; import com.pet.foundation.pataamiga.repositories.UserRepository; +import com.pet.foundation.pataamiga.service.EmailService; import com.pet.foundation.pataamiga.utils.CreateUserDTOCreator; import com.pet.foundation.pataamiga.utils.UserCreator; import org.junit.jupiter.api.AfterEach; @@ -30,6 +32,9 @@ class UserServiceTest { @Mock private UserRepository userRepository; + @Mock + private EmailService emailService; + @BeforeEach void setUp() { @@ -41,6 +46,8 @@ void setUp() { BDDMockito.when(userRepository.save(ArgumentMatchers.any(User.class))) .thenReturn(UserCreator.returnValidUser()); + + BDDMockito.doNothing().when(emailService).sendEmail(ArgumentMatchers.any(EmailDTO.class)); } @AfterEach