Revert "FINERACT-2304: Fix auditing of failed batch request while enclosing t…"
This reverts commit 96eb744592.
This commit is contained in:
+1
-34
@@ -19,7 +19,6 @@
|
||||
package org.apache.fineract.batch.service;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -42,10 +41,7 @@ import org.apache.fineract.batch.domain.BatchRequest;
|
||||
import org.apache.fineract.batch.domain.BatchResponse;
|
||||
import org.apache.fineract.batch.exception.ErrorInfo;
|
||||
import org.apache.fineract.commands.configuration.RetryConfigurationAssembler;
|
||||
import org.apache.fineract.commands.domain.CommandSource;
|
||||
import org.apache.fineract.commands.service.CommandSourceService;
|
||||
import org.apache.fineract.infrastructure.core.config.FineractProperties;
|
||||
import org.apache.fineract.infrastructure.core.domain.BatchRequestContextHolder;
|
||||
import org.apache.fineract.infrastructure.core.domain.FineractRequestContextHolder;
|
||||
import org.apache.fineract.infrastructure.core.exception.ErrorHandler;
|
||||
import org.apache.fineract.infrastructure.core.filters.BatchRequestPreprocessor;
|
||||
@@ -78,9 +74,6 @@ class BatchApiServiceImplTest {
|
||||
@Mock
|
||||
private ErrorHandler errorHandler;
|
||||
|
||||
@Mock
|
||||
private CommandSourceService commandSourceService;
|
||||
|
||||
@Mock
|
||||
private RetryRegistry registry;
|
||||
|
||||
@@ -104,7 +97,7 @@ class BatchApiServiceImplTest {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
batchApiService = new BatchApiServiceImpl(strategyProvider, resolutionHelper, transactionManager, errorHandler, List.of(),
|
||||
batchPreprocessors, retryConfigurationAssembler, commandSourceService);
|
||||
batchPreprocessors, retryConfigurationAssembler);
|
||||
batchApiService.setEntityManager(entityManager);
|
||||
request = new BatchRequest();
|
||||
request.setRequestId(1L);
|
||||
@@ -234,32 +227,6 @@ class BatchApiServiceImplTest {
|
||||
Mockito.verifyNoInteractions(entityManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailedCommandSourceEntriesAreSavedOnBatchFailure() {
|
||||
final List<BatchRequest> requestList = List.of(request);
|
||||
when(strategyProvider.getCommandStrategy(any())).thenReturn(commandStrategy);
|
||||
when(commandStrategy.execute(any(), any())).thenThrow(new RuntimeException("Test failure"));
|
||||
|
||||
final ErrorInfo errorInfo = mock(ErrorInfo.class);
|
||||
when(errorInfo.getMessage()).thenReturn("Test failure");
|
||||
when(errorInfo.getStatusCode()).thenReturn(500);
|
||||
when(errorHandler.handle(any())).thenReturn(errorInfo);
|
||||
|
||||
when(transactionManager.getTransaction(any()))
|
||||
.thenReturn(new DefaultTransactionStatus("txn_name", null, true, true, false, false, false, null));
|
||||
|
||||
final CommandSource mockCommandSource = mock(CommandSource.class);
|
||||
BatchRequestContextHolder.setIsEnclosingTransaction(true);
|
||||
BatchRequestContextHolder.addCommandSource(mockCommandSource);
|
||||
|
||||
final BatchResponse result = batchApiService.handleBatchRequestsWithEnclosingTransaction(requestList, uriInfo).getFirst();
|
||||
assertNotNull(result);
|
||||
assertEquals(500, result.getStatusCode());
|
||||
assertTrue(result.getBody().contains("Test failure"));
|
||||
|
||||
verify(commandSourceService, times(1)).saveFailedCommandSourcesNewTransaction(any());
|
||||
}
|
||||
|
||||
private static final class RetryException extends RuntimeException {}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user