Skip to content

Commit

Permalink
Merge branch 'main' into refact/refatoracao-usuario
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasFortes12 committed Mar 6, 2024
2 parents cfd0bb1 + 69f45d6 commit a19be7d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.mandacarubroker.domain.auth.ResponseAuthUserDTO;
import com.mandacarubroker.domain.user.ResponseUserDTO;
import com.mandacarubroker.service.AuthService;
import com.mandacarubroker.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
Expand All @@ -24,11 +23,9 @@
@RequestMapping("/auth")
public class AuthController {
private final AuthService authService;
private final UserService userService;

public AuthController(final AuthService receivedAuthService, final UserService receivedUserService) {
public AuthController(final AuthService receivedAuthService) {
this.authService = receivedAuthService;
this.userService = receivedUserService;
}

@Operation(summary = "Login do usuário", description = "Realiza o login do usuário e retorna o token de autenticação")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mandacarubroker.domain.user.User;
import com.mandacarubroker.service.AuthService;
import com.mandacarubroker.service.ProfileService;
import com.mandacarubroker.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
Expand All @@ -24,11 +23,9 @@
@RequestMapping("/profile")
public class ProfileController {
private final ProfileService profileService;
private final UserService userService;

public ProfileController(final ProfileService receivedProfileService, final UserService receivedUserService) {
public ProfileController(final ProfileService receivedProfileService) {
this.profileService = receivedProfileService;
this.userService = receivedUserService;
}

@Operation(summary = "Retorna dados de um usuário", description = "Mostra dados de um usuário autenticado")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.mandacarubroker.security.SecuritySecretsMock;
import com.mandacarubroker.service.AuthService;
import com.mandacarubroker.service.PasswordHashingService;
import com.mandacarubroker.service.UserService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
Expand All @@ -22,7 +21,6 @@
class AuthControllerTest {
@MockBean
private AuthService authService;
private UserService userService;
private AuthController authController;

private static final String TOKEN_TYPE = "Bearer";
Expand Down Expand Up @@ -66,11 +64,10 @@ void setUp() {
SecuritySecretsMock.mockStatic();

authService = Mockito.mock(AuthService.class);
userService = Mockito.mock(UserService.class);
Mockito.when(authService.login(validRequestAuthUserDTO)).thenReturn(Optional.of(validResponseAuthUserDTO));
Mockito.when(authService.login(new RequestAuthUserDTO(invalidUsername, validPassword))).thenReturn(Optional.empty());
Mockito.when(authService.login(new RequestAuthUserDTO(validUsername, invalidPassword))).thenReturn(Optional.empty());
authController = new AuthController(authService, userService);
authController = new AuthController(authService);
}

@Test
Expand Down

0 comments on commit a19be7d

Please sign in to comment.