Search in sources :

Example 46 with User

use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.

the class UserServiceTest method lockUserSuccess.

@Test
public void lockUserSuccess() {
    User penny = UserUtils.clientPennyTeller(1L);
    when(userRepoMock.save(any(User.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
    UserInfoDTO resultDTO = userService.lockUser(penny);
    assertTrue(resultDTO.getLockDate() != null);
    verify(userRepoMock, times(1)).save(any(User.class));
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) UserInfoDTO(com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 47 with User

use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.

the class UserServiceTest method changeEmailPasswordMismatch.

@Test
public void changeEmailPasswordMismatch() {
    Long userId = 1L;
    User howard = UserUtils.courierHowardWolowitz(userId);
    String newEmail = "happy-howard@bigbang.theory";
    when(userRepoMock.findByEmail(newEmail)).thenReturn(null);
    String password = "wrong-password";
    EmailChangeDTO changeDTO = new EmailChangeDTO();
    changeDTO.setEmail(newEmail);
    changeDTO.setPassword(password);
    assertThrows(PasswordsMismatchException.class, () -> {
        userService.changeEmail(howard, changeDTO);
    });
    verify(userRepoMock, times(1)).findByEmail(newEmail);
    verify(userRepoMock, never()).save(any(User.class));
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) EmailChangeDTO(com.ncedu.fooddelivery.api.v1.dto.user.EmailChangeDTO) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 48 with User

use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.

the class UserUtils method clientPennyTeller.

public static User clientPennyTeller(Long id) {
    final String fullName = "Penny Teller";
    final String email = "penny@bigbang.theory";
    final Role role = Role.CLIENT;
    return createUser(id, fullName, email, role);
}
Also used : Role(com.ncedu.fooddelivery.api.v1.entities.Role)

Example 49 with User

use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.

the class UserUtils method adminSheldonCooper.

public static User adminSheldonCooper(Long id) {
    final String fullName = "Sheldon Lee Cooper";
    final String email = "cooper@bigbang.theory";
    final Role role = Role.ADMIN;
    return createUser(id, fullName, email, role);
}
Also used : Role(com.ncedu.fooddelivery.api.v1.entities.Role)

Example 50 with User

use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.

the class UserUtils method clientRajeshKoothrappali.

public static User clientRajeshKoothrappali(Long id) {
    final String fullName = "Rajesh Ramayan Koothrappali";
    final String email = "rajesh@bigbang.theory";
    final Role role = Role.CLIENT;
    return createUser(id, fullName, email, role);
}
Also used : Role(com.ncedu.fooddelivery.api.v1.entities.Role)

Aggregations

User (com.ncedu.fooddelivery.api.v1.entities.User)58 Test (org.junit.jupiter.api.Test)55 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)55 File (com.ncedu.fooddelivery.api.v1.entities.File)21 Path (java.nio.file.Path)19 MultipartFile (org.springframework.web.multipart.MultipartFile)19 CustomAccessDeniedException (com.ncedu.fooddelivery.api.v1.errors.security.CustomAccessDeniedException)18 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)18 FileLinkDTO (com.ncedu.fooddelivery.api.v1.dto.file.FileLinkDTO)15 Order (com.ncedu.fooddelivery.api.v1.entities.order.Order)14 BufferedImage (java.awt.image.BufferedImage)10 UserInfoDTO (com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO)9 Role (com.ncedu.fooddelivery.api.v1.entities.Role)7 NotFoundEx (com.ncedu.fooddelivery.api.v1.errors.notfound.NotFoundEx)7 IOException (java.io.IOException)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 ProductPosition (com.ncedu.fooddelivery.api.v1.entities.productPosition.ProductPosition)6 AlreadyExistsException (com.ncedu.fooddelivery.api.v1.errors.badrequest.AlreadyExistsException)6 PasswordsMismatchException (com.ncedu.fooddelivery.api.v1.errors.badrequest.PasswordsMismatchException)6 CommitAfter (org.apache.tapestry5.jpa.annotations.CommitAfter)6