|
14 | 14 |
|
15 | 15 | package org.eclipse.edc.statemachine.retry;
|
16 | 16 |
|
| 17 | +import org.eclipse.edc.spi.EdcException; |
17 | 18 | import org.eclipse.edc.spi.monitor.Monitor;
|
18 | 19 | import org.eclipse.edc.spi.response.ResponseFailure;
|
19 | 20 | import org.eclipse.edc.spi.response.StatusResult;
|
|
29 | 30 | import static org.assertj.core.api.Assertions.assertThat;
|
30 | 31 | import static org.eclipse.edc.spi.response.ResponseStatus.ERROR_RETRY;
|
31 | 32 | import static org.eclipse.edc.spi.response.ResponseStatus.FATAL_ERROR;
|
| 33 | +import static org.mockito.ArgumentMatchers.any; |
| 34 | +import static org.mockito.ArgumentMatchers.same; |
32 | 35 | import static org.mockito.Mockito.mock;
|
33 | 36 | import static org.mockito.Mockito.verify;
|
| 37 | +import static org.mockito.Mockito.verifyNoInteractions; |
34 | 38 | import static org.mockito.Mockito.when;
|
35 | 39 |
|
36 | 40 | class StatusResultRetryProcessTest {
|
@@ -93,4 +97,19 @@ void shouldExecuteOnRetry_whenFailureAndRetriesHaveNotBeenExhausted() {
|
93 | 97 |
|
94 | 98 | verify(onFailure).accept(entity, statusResult.getFailure());
|
95 | 99 | }
|
| 100 | + |
| 101 | + |
| 102 | + @Test |
| 103 | + void shouldCallFatalError_whenExceptionIsThrown() { |
| 104 | + when(process.get()).thenThrow(new EdcException("code throws an exception")); |
| 105 | + var entity = TestEntity.Builder.newInstance().id(UUID.randomUUID().toString()).clock(clock).build(); |
| 106 | + var retryProcess = new StatusResultRetryProcess<>(entity, process, mock(Monitor.class), clock, configuration); |
| 107 | + |
| 108 | + var result = retryProcess.onSuccess(onSuccess).onFatalError(onFatalError).execute("any"); |
| 109 | + |
| 110 | + assertThat(result).isTrue(); |
| 111 | + verify(process).get(); |
| 112 | + verify(onFatalError).accept(same(entity), any()); |
| 113 | + verifyNoInteractions(onSuccess); |
| 114 | + } |
96 | 115 | }
|
0 commit comments