FINERACT-1909: Retry feature for commands - no wrap for retryable exceptions

This commit is contained in:
jmarta
2023-11-03 16:56:23 +01:00
committed by Adam Saghy
parent 224dbdc040
commit a42f46957d
78 changed files with 375 additions and 446 deletions
@@ -23,7 +23,6 @@ import static org.mockito.ArgumentMatchers.any;
import java.time.ZoneId;
import java.util.Optional;
import org.apache.fineract.batch.exception.ErrorHandler;
import org.apache.fineract.batch.exception.ErrorInfo;
import org.apache.fineract.commands.domain.CommandSource;
import org.apache.fineract.commands.domain.CommandSourceRepository;
@@ -31,6 +30,7 @@ import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.infrastructure.codes.exception.CodeNotFoundException;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
import org.apache.fineract.infrastructure.core.exception.ErrorHandler;
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
import org.apache.fineract.useradministration.domain.AppUser;
import org.junit.jupiter.api.AfterEach;
@@ -40,6 +40,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -108,7 +109,9 @@ public class CommandSourceServiceTest {
@Test
public void testGenerateErrorException() {
Mockito.when(errorHandler.getMappable(any())).thenAnswer(i -> i.getArguments()[0]);
try (MockedStatic<ErrorHandler> mockedStatic = Mockito.mockStatic(ErrorHandler.class)) {
mockedStatic.when(() -> ErrorHandler.getMappable(any(CodeNotFoundException.class))).thenAnswer(i -> i.getArguments()[0]);
}
Mockito.when(errorHandler.handle(any(CodeNotFoundException.class)))
.thenReturn(new ErrorInfo(404, 1001, "Code with name `foo` does not exist", null));
ErrorInfo result = underTest.generateErrorInfo(new CodeNotFoundException("foo"));