优化
This commit is contained in:
+14
@@ -8,6 +8,7 @@ import com.baiyue.warehouse.entity.WarehousePalletEntity;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
@@ -66,6 +67,19 @@ class PalletLabelPrintServiceTest {
|
||||
verifyNoInteractions(print);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapsCircuitBreakerWrappedPrintFailureToServiceUnavailable() {
|
||||
when(print.generateInboundMarks(anyString(), anyString(), any()))
|
||||
.thenThrow(new NoFallbackAvailableException("No fallback available.",
|
||||
new IllegalStateException("No instances available for print-service")));
|
||||
|
||||
assertThatThrownBy(() -> service.print(200L, 9L, "request-1"))
|
||||
.isInstanceOfSatisfying(BizException.class, exception -> {
|
||||
assertThat(exception.getResultCode()).isEqualTo(ResultCode.SERVICE_UNAVAILABLE);
|
||||
assertThat(exception.getMessage()).contains("打印服务暂不可用");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsJsonErrorInsteadOfDownloadingItAsPdf() {
|
||||
when(print.generateInboundMarks(anyString(), anyString(), any()))
|
||||
|
||||
Reference in New Issue
Block a user