From 10a74811c0f14daf1fa12b51db5594a445a1819d Mon Sep 17 00:00:00 2001 From: ruan-pb Date: Thu, 11 Feb 2021 19:08:37 -0300 Subject: [PATCH] =?UTF-8?q?refs=20#1=20-=20Corre=C3=A7=C3=A3o=20do=20teste?= =?UTF-8?q?=20LoadUserByUsarnameTest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/service/LoadUserByUsarnameTest.java | 6 +-- .../api/v1/user/service/LoginImplTest.java | 50 ------------------- 2 files changed, 3 insertions(+), 53 deletions(-) delete mode 100644 src/test/java/org/ayty/hatcher/api/v1/user/service/LoginImplTest.java diff --git a/src/test/java/org/ayty/hatcher/api/v1/user/service/LoadUserByUsarnameTest.java b/src/test/java/org/ayty/hatcher/api/v1/user/service/LoadUserByUsarnameTest.java index d9f0556..0fcd48d 100644 --- a/src/test/java/org/ayty/hatcher/api/v1/user/service/LoadUserByUsarnameTest.java +++ b/src/test/java/org/ayty/hatcher/api/v1/user/service/LoadUserByUsarnameTest.java @@ -9,7 +9,7 @@ import org.ayty.hatcher.api.v1.user.entity.Profile; import org.ayty.hatcher.api.v1.user.entity.User; -import org.ayty.hatcher.api.v1.user.exception.UsernameNotFoundException; +import org.ayty.hatcher.api.v1.user.exception.IncorrectUserOrPassword; import org.ayty.hatcher.api.v1.user.jpa.UserRepository; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -59,8 +59,8 @@ void UserRolesTests() { @Test void UserNamenonexistent() { - - assertThrows(UsernameNotFoundException.class,() -> load.loadUserByUsername("cleyson")); + + assertThrows(IncorrectUserOrPassword.class,() -> load.loadUserByUsername("cleyson")); } diff --git a/src/test/java/org/ayty/hatcher/api/v1/user/service/LoginImplTest.java b/src/test/java/org/ayty/hatcher/api/v1/user/service/LoginImplTest.java deleted file mode 100644 index 9b0e093..0000000 --- a/src/test/java/org/ayty/hatcher/api/v1/user/service/LoginImplTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.ayty.hatcher.api.v1.user.service; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.ayty.hatcher.api.v1.user.entity.Profile; -import org.ayty.hatcher.api.v1.user.entity.User; -import org.junit.jupiter.api.Test; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.crypto.password.PasswordEncoder; - -class LoginImplTest { - - - PasswordEncoder passEnc = mock(PasswordEncoder.class); - LoadUserByUsarname load = mock(LoadUserByUsarname.class); - - private LoginImpl loginImp = new LoginImpl(passEnc , load, null); - - @Test - void test() { - - String roles ="ADMIN, USER" ; - User usuario2 = new User(2L,"vito", "senha", "ruan@gmail.com", "ruan cruz", "imagee 2", false, Profile.ALUNO); - - UserDetails userD = org.springframework.security.core.userdetails. - User.builder() - .username(usuario2.getLogin()) - .password(usuario2.getPassword()) - .roles(roles).build(); - - - when(load.loadUserByUsername("vito")).thenReturn(userD); - - - - System.out.println("-----"); - UserDetails login = loginImp.authenticate(usuario2); - System.out.println(login.getPassword()); - - - - - - - - - } - -}