fix(warehouse): allow platform resource scope
This commit is contained in:
@@ -55,7 +55,7 @@ public class LocationResourceService {
|
|||||||
@Resource
|
@Resource
|
||||||
private PickingPackageAllocator packageAllocator;
|
private PickingPackageAllocator packageAllocator;
|
||||||
|
|
||||||
public List<LocationEntity> findAvailable(@Min(1) long tenantId, @Min(1) long warehouseId,
|
public List<LocationEntity> findAvailable(@Min(0) long tenantId, @Min(1) long warehouseId,
|
||||||
@Min(1) @Max(200) int limit) {
|
@Min(1) @Max(200) int limit) {
|
||||||
requireLimit(limit);
|
requireLimit(limit);
|
||||||
requireActiveWarehouse(tenantId, warehouseId);
|
requireActiveWarehouse(tenantId, warehouseId);
|
||||||
@@ -561,7 +561,7 @@ public class LocationResourceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<ActiveResource> findActiveResources(@Min(1) long tenantId,
|
public List<ActiveResource> findActiveResources(@Min(0) long tenantId,
|
||||||
@NotBlank String sourceService,
|
@NotBlank String sourceService,
|
||||||
@Min(1) long businessId) {
|
@Min(1) long businessId) {
|
||||||
List<ActiveResource> result = new ArrayList<>();
|
List<ActiveResource> result = new ArrayList<>();
|
||||||
|
|||||||
@@ -35,6 +35,20 @@ import static org.mockito.Mockito.when;
|
|||||||
class LocationResourceServiceTest {
|
class LocationResourceServiceTest {
|
||||||
@MockBean private LocationRepository repository;
|
@MockBean private LocationRepository repository;
|
||||||
@Resource private LocationResourceService service;
|
@Resource private LocationResourceService service;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void supportsPlatformScopedWarehouseResourceQueries() {
|
||||||
|
WarehouseEntity platformWarehouse = warehouse();
|
||||||
|
platformWarehouse.setTenantId(0L);
|
||||||
|
when(repository.findWarehouse(0L, 88L)).thenReturn(platformWarehouse);
|
||||||
|
when(repository.findAvailable(0L, 88L, 10)).thenReturn(List.of());
|
||||||
|
when(repository.findReservationsByBusiness(0L, "firstleg-service", 901L)).thenReturn(List.of());
|
||||||
|
when(repository.findOccupanciesByBusiness(0L, "firstleg-service", 901L)).thenReturn(List.of());
|
||||||
|
|
||||||
|
assertThat(service.findAvailable(0L, 88L, 10)).isEmpty();
|
||||||
|
assertThat(service.findActiveResources(0L, "firstleg-service", 901L)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldHandleCase01() {
|
void shouldHandleCase01() {
|
||||||
when(repository.findWarehouse(10001L, 88L)).thenReturn(warehouse());
|
when(repository.findWarehouse(10001L, 88L)).thenReturn(warehouse());
|
||||||
|
|||||||
Reference in New Issue
Block a user