use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class OrderServiceTest method replaceCourierReplaceExTest.
@Test
public void replaceCourierReplaceExTest() {
User fakeUser = getFakeUserModerator();
Courier mockCourier = Mockito.mock(Courier.class);
Order fakeOrder = getFakeOrder();
fakeOrder.setStatus(OrderStatus.DELIVERED);
Assertions.assertThrows(CourierReplaceException.class, new Executable() {
@Override
public void execute() throws Throwable {
orderService.replaceCourier(fakeOrder, fakeUser);
}
});
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class OrderServiceTest method changeCourierRatingCourierNotSetTest.
@Test
public void changeCourierRatingCourierNotSetTest() {
User fakeUser = getFakeUserClient();
ChangeRatingDTO fakeDto = new ChangeRatingDTO();
Order fakeOrder = getFakeOrder();
fakeOrder.setCourier(null);
Assertions.assertThrows(CourierNotSetException.class, new Executable() {
@Override
public void execute() throws Throwable {
orderService.changeDeliveryRating(fakeOrder, fakeDto, fakeUser);
}
});
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class OrderServiceTest method changeCourierRatingSuccessTest.
@Test
public void changeCourierRatingSuccessTest() {
User fakeUser = getFakeUserClient();
ChangeRatingDTO fakeDto = new ChangeRatingDTO();
fakeDto.setRating(new BigDecimal(4.5));
Order fakeOrder = getFakeOrder();
Mockito.when(orderRepo.save(Mockito.any(Order.class))).thenReturn(fakeOrder);
orderService.changeDeliveryRating(fakeOrder, fakeDto, fakeUser);
Assertions.assertTrue(fakeOrder.getDeliveryRating().equals(new BigDecimal(4.5)));
Mockito.verify(orderRepo, Mockito.times(1)).save(fakeOrder);
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method getUserByIdSuccess.
@Test
public void getUserByIdSuccess() {
Long userId = 1L;
User sheldonCooper = UserUtils.adminSheldonCooper(userId);
when(userRepoMock.findById(userId)).thenReturn(Optional.of(sheldonCooper));
User result = userService.getUserById(userId);
assertEquals(sheldonCooper, result);
verify(userRepoMock, times(1)).findById(userId);
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method unlockUserSuccess.
@Test
public void unlockUserSuccess() {
User penny = UserUtils.clientPennyTeller(1L);
Timestamp current = new Timestamp(System.currentTimeMillis());
penny.setLockDate(current);
UserInfoDTO resultDTO = userService.unlockUser(penny);
assertEquals(null, resultDTO.getLockDate());
verify(userRepoMock, times(1)).save(any(User.class));
}
Aggregations