fix: complete development acceptance paths
This commit is contained in:
+29
@@ -4,6 +4,7 @@ import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.inventory.query.dto.InventoryQueryRequests;
|
||||
import com.baiyue.lastleg.inventory.query.service.InventoryQueryService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
@@ -13,6 +14,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class InventoryQueryControllerTest {
|
||||
private final InventoryQueryService service = mock(InventoryQueryService.class);
|
||||
@@ -44,6 +46,33 @@ class InventoryQueryControllerTest {
|
||||
verify(service).dashboard(eq(null), eq(query));
|
||||
}
|
||||
|
||||
@Test
|
||||
void balanceExportIsMaterializedBeforeReturningResponse() {
|
||||
byte[] csv = "\uFEFFcustomerId\r\n10001\r\n".getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
when(service.exportBalances("10001", query)).thenReturn(csv);
|
||||
|
||||
ResponseEntity<byte[]> response = controller.exportBalances(user(0L, "PLATFORM"), "10001", query);
|
||||
|
||||
org.junit.jupiter.api.Assertions.assertArrayEquals(csv, response.getBody());
|
||||
org.junit.jupiter.api.Assertions.assertEquals("text/csv;charset=UTF-8",
|
||||
response.getHeaders().getContentType().toString());
|
||||
verify(service).exportBalances("10001", query);
|
||||
}
|
||||
|
||||
@Test
|
||||
void ledgerExportIsMaterializedBeforeReturningResponse() {
|
||||
InventoryQueryRequests.LedgerQuery ledgerQuery = new InventoryQueryRequests.LedgerQuery(
|
||||
1L, 20L, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
||||
byte[] csv = "\uFEFFoccurredAt\r\n".getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
when(service.exportLedgers("10001", ledgerQuery)).thenReturn(csv);
|
||||
|
||||
ResponseEntity<byte[]> response = controller.exportLedgers(
|
||||
user(0L, "PLATFORM"), "10001", ledgerQuery);
|
||||
|
||||
org.junit.jupiter.api.Assertions.assertArrayEquals(csv, response.getBody());
|
||||
verify(service).exportLedgers("10001", ledgerQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unauthenticatedPositionDetailIsRejected() {
|
||||
InventoryQueryRequests.PositionQuery positionQuery =
|
||||
|
||||
Reference in New Issue
Block a user