use of com.ncedu.fooddelivery.api.v1.dto.order.ChangeRatingDTO 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.dto.order.ChangeRatingDTO 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.dto.order.ChangeRatingDTO in project 2021-msk-food-delivery by netcracker-edu.
the class OrderServiceImpl1 method changeDeliveryRating.
@Override
public void changeDeliveryRating(Order order, ChangeRatingDTO dto, User user) {
if (order.getCourier() == null)
throw new CourierNotSetException();
if (!user.getId().equals(order.getClient().getId()))
throw new CustomAccessDeniedException();
order.setDeliveryRating(dto.getRating());
orderRepo.save(order);
}
use of com.ncedu.fooddelivery.api.v1.dto.order.ChangeRatingDTO in project 2021-msk-food-delivery by netcracker-edu.
the class OrderServiceImpl1 method changeClientRating.
@Override
public void changeClientRating(Order order, ChangeRatingDTO dto, User user) {
if (order.getCourier() == null || !user.getId().equals(order.getCourier().getId()))
throw new CustomAccessDeniedException();
order.setClientRating(dto.getRating());
orderRepo.save(order);
}
Aggregations