Search in sources :

Example 1 with OrderService

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

the class DeliverySessionServiceTest method finishSessionActiveOrderExceptionTest.

@Test
public void finishSessionActiveOrderExceptionTest() {
    Order order = Mockito.mock(Order.class);
    Mockito.when(order.getId()).thenReturn(1L);
    Mockito.when(deliverySessionRepo.getActiveSession(targetUser.getId())).thenReturn(deliverySession);
    Mockito.when(orderService.findCouriersActiveOrder(targetCourier)).thenReturn(order);
    Assertions.assertThrows(DeliverySessionFinishException.class, new Executable() {

        @Override
        public void execute() throws Throwable {
            deliverySessionService.finishSession(targetUser);
        }
    });
    Mockito.verify(deliverySessionRepo, Mockito.times(1)).getActiveSession(targetUser.getId());
    Mockito.verify(orderService, Mockito.times(1)).findCouriersActiveOrder(targetCourier);
}
Also used : Order(com.ncedu.fooddelivery.api.v1.entities.order.Order) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Order (com.ncedu.fooddelivery.api.v1.entities.order.Order)1 Test (org.junit.jupiter.api.Test)1 Executable (org.junit.jupiter.api.function.Executable)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1