Search in sources :

Example 1 with ClientInfoDTO

use of com.ncedu.fooddelivery.api.v1.dto.user.ClientInfoDTO in project 2021-msk-food-delivery by netcracker-edu.

the class ProfileControllerTest method getClientProfile.

@Test
public void getClientProfile() {
    ClientInfoDTO clientInfoDTO = new ClientInfoDTO(1L, "CLIENT", "client@mail.ru");
    when(clientServiceMock.getClientDTOById(1L)).thenReturn(clientInfoDTO);
    User user = new User();
    user.setId(1L);
    user.setRole(Role.CLIENT);
    UserInfoDTO resultClientDTO = profileController.getProfile(user);
    assertEquals(clientInfoDTO, resultClientDTO);
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with ClientInfoDTO

use of com.ncedu.fooddelivery.api.v1.dto.user.ClientInfoDTO in project 2021-msk-food-delivery by netcracker-edu.

the class ClientServiceTest method getClientDTOByIdSuccess.

@Test
public void getClientDTOByIdSuccess() {
    Long userId = 1L;
    Client client = ClientUtils.createLeonardHofstadter(userId);
    when(clientRepoMock.findById(userId)).thenReturn(Optional.of(client));
    ClientInfoDTO resultClientDTO = clientService.getClientDTOById(userId);
    ClientInfoDTO perfectClientDTO = ClientUtils.createClientInfoDTO(client);
    verify(clientRepoMock, times(1)).findById(userId);
    assertEquals(perfectClientDTO, resultClientDTO);
}
Also used : ClientInfoDTO(com.ncedu.fooddelivery.api.v1.dto.user.ClientInfoDTO) Client(com.ncedu.fooddelivery.api.v1.entities.Client) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Test (org.junit.jupiter.api.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ClientInfoDTO (com.ncedu.fooddelivery.api.v1.dto.user.ClientInfoDTO)1 Client (com.ncedu.fooddelivery.api.v1.entities.Client)1 User (com.ncedu.fooddelivery.api.v1.entities.User)1