feat(appointments): add four-type calendar sources and align release contracts
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
package com.baiyue.lastleg.calendar;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class WarehouseCalendarServiceTest {
|
||||
/** 读取资格不代替写权限,已有入库计划仍冻结时间。 */
|
||||
@Test void keepsReadAccessSeparateFromWriteAndFreezesExistingPlans() {
|
||||
var repository=mock(WarehouseCalendarRepository.class); var service=new WarehouseCalendarService(repository);
|
||||
var query=new WarehouseCalendarModels.Query(LocalDate.of(2026,11,1),LocalDate.of(2026,12,1),List.of("1"));
|
||||
var open=new WarehouseCalendarModels.Entry("1","CONT","Warehouse","W",null,null,0,0,false);
|
||||
var frozen=new WarehouseCalendarModels.Entry("2","CONT2","Warehouse","W",null,null,1,1,false);
|
||||
when(repository.calendar(query)).thenReturn(List.of(open,frozen));
|
||||
assertTrue(service.calendar(query,true).get(0).canEdit()); assertFalse(service.calendar(query,true).get(1).canEdit());
|
||||
assertTrue(service.calendar(query,false).stream().noneMatch(WarehouseCalendarModels.Entry::canEdit));
|
||||
assertThrows(ResponseStatusException.class,()->service.calendar(new WarehouseCalendarModels.Query(query.from(),query.to(),List.of("1","1")),true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user