Search in sources :

Example 11 with Warehouse

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

the class WarehouseServiceTest method getMockActiveWarehouses.

private List<Warehouse> getMockActiveWarehouses() {
    List<Warehouse> mockWarehouses = new ArrayList<>();
    Point p1 = Mockito.mock(Point.class), p2 = Mockito.mock(Point.class), p3 = Mockito.mock(Point.class), p4 = Mockito.mock(Point.class);
    // setting fake distance between each warehouse and client
    Mockito.when(p1.distance(Mockito.any(Point.class))).thenReturn(10.0);
    Mockito.when(p2.distance(Mockito.any(Point.class))).thenReturn(5.0);
    Mockito.when(p3.distance(Mockito.any(Point.class))).thenReturn(15.0);
    Mockito.when(p4.distance(Mockito.any(Point.class))).thenReturn(1.0);
    Geometry g1 = Mockito.mock(Geometry.class), g2 = Mockito.mock(Geometry.class), g3 = Mockito.mock(Geometry.class), g4 = Mockito.mock(Geometry.class);
    // setting
    Mockito.when(g1.covers(Mockito.any(Point.class))).thenReturn(true);
    Mockito.when(g2.covers(Mockito.any(Point.class))).thenReturn(true);
    Mockito.when(g3.covers(Mockito.any(Point.class))).thenReturn(true);
    Mockito.when(g4.covers(Mockito.any(Point.class))).thenReturn(false);
    Warehouse w1 = new Warehouse(1L, p1, g1, "foo", "bar", true), w2 = new Warehouse(2L, p2, g2, "foo", "bar", true), w3 = new Warehouse(3L, p3, g3, "foo", "bar", true), w4 = new Warehouse(4L, p4, g4, "foo", "bar", true);
    mockWarehouses.addAll(Arrays.asList(w1, w2, w3, w4));
    return mockWarehouses;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Warehouse(com.ncedu.fooddelivery.api.v1.entities.Warehouse) ArrayList(java.util.ArrayList) Point(com.vividsolutions.jts.geom.Point)

Aggregations

ProductPosition (com.ncedu.fooddelivery.api.v1.entities.productPosition.ProductPosition)6 OrderProductPosition (com.ncedu.fooddelivery.api.v1.entities.orderProductPosition.OrderProductPosition)5 WarehouseInfoDTO (com.ncedu.fooddelivery.api.v1.dto.warehouseDTOs.WarehouseInfoDTO)4 Warehouse (com.ncedu.fooddelivery.api.v1.entities.Warehouse)4 Point (com.vividsolutions.jts.geom.Point)4 Order (com.ncedu.fooddelivery.api.v1.entities.order.Order)3 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ProductPositionsShipmentDTO (com.ncedu.fooddelivery.api.v1.dto.ProductPositionDTOs.ProductPositionsShipmentDTO)2 NotFoundEx (com.ncedu.fooddelivery.api.v1.errors.notfound.NotFoundEx)2 ProductAvailabilityEx (com.ncedu.fooddelivery.api.v1.errors.orderRegistration.ProductAvailabilityEx)2 WarehouseCoordsBindingEx (com.ncedu.fooddelivery.api.v1.errors.orderRegistration.WarehouseCoordsBindingEx)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 Executable (org.junit.jupiter.api.function.Executable)2 com.ncedu.fooddelivery.api.v1.dto.areCreatedDTO (com.ncedu.fooddelivery.api.v1.dto.areCreatedDTO)1 CourierAvailabilityEx (com.ncedu.fooddelivery.api.v1.errors.orderRegistration.CourierAvailabilityEx)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 ResponseEntity (org.springframework.http.ResponseEntity)1