Skip to content

Commit

Permalink
LPD-17781 Capture log to avoid PortalLogAssertorTest failures. The er…
Browse files Browse the repository at this point in the history
…ror traces are expected
  • Loading branch information
ccorreagg authored and brianchandotcom committed Feb 14, 2024
1 parent 1efce45 commit 5dbd2c2
Showing 1 changed file with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,22 @@ public void testCreateBlogPostingsWithInvalidCSVFileAndOnErrorContinue()

String content = sb.toString();

_importBlogPostings(
BatchEngineTaskOperation.CREATE,
_compressContent(content.getBytes(StandardCharsets.UTF_8), "CSV"),
"CSV", null,
BatchEngineImportTaskConstants.IMPORT_STRATEGY_ON_ERROR_CONTINUE);
try (LogCapture logCapture1 = LoggerTestUtil.configureLog4JLogger(
"com.liferay.batch.engine.internal.strategy." +
"OnErrorContinueBatchEngineImportStrategy",
LoggerTestUtil.ERROR);
LogCapture logCapture2 = LoggerTestUtil.configureLog4JLogger(
_CLASS_NAME_BATCH_ENGINE_IMPORT_TASK_EXECUTOR_IMPL,
LoggerTestUtil.ERROR)) {

_importBlogPostings(
BatchEngineTaskOperation.CREATE,
_compressContent(
content.getBytes(StandardCharsets.UTF_8), "CSV"),
"CSV", null,
BatchEngineImportTaskConstants.
IMPORT_STRATEGY_ON_ERROR_CONTINUE);
}

_assertInvalidFileImportWithOnErrorContinueStrategy(
Arrays.asList(
Expand Down Expand Up @@ -567,18 +578,24 @@ public void testImportAccountSystemObjectDefinitionsJSON()
)
).toString();

_batchEngineImportTask =
_batchEngineImportTaskLocalService.addBatchEngineImportTask(
null, TestPropsValues.getCompanyId(), user.getUserId(),
_BATCH_SIZE, null,
"com.liferay.headless.admin.user.dto.v1_0.Account",
_compressContent(json.getBytes(), "JSON"), "JSON",
BatchEngineTaskExecuteStatus.INITIAL.name(), null,
BatchEngineImportTaskConstants.IMPORT_STRATEGY_ON_ERROR_FAIL,
BatchEngineTaskOperation.CREATE.toString(), new HashMap<>(),
null);
try (LogCapture logCapture = LoggerTestUtil.configureLog4JLogger(
_CLASS_NAME_BATCH_ENGINE_IMPORT_TASK_EXECUTOR_IMPL,
LoggerTestUtil.ERROR)) {

_batchEngineImportTaskExecutor.execute(_batchEngineImportTask);
_batchEngineImportTask =
_batchEngineImportTaskLocalService.addBatchEngineImportTask(
null, TestPropsValues.getCompanyId(), user.getUserId(),
_BATCH_SIZE, null,
"com.liferay.headless.admin.user.dto.v1_0.Account",
_compressContent(json.getBytes(), "JSON"), "JSON",
BatchEngineTaskExecuteStatus.INITIAL.name(), null,
BatchEngineImportTaskConstants.
IMPORT_STRATEGY_ON_ERROR_FAIL,
BatchEngineTaskOperation.CREATE.toString(), new HashMap<>(),
null);

_batchEngineImportTaskExecutor.execute(_batchEngineImportTask);
}

Assert.assertEquals(
BatchEngineTaskExecuteStatus.FAILED.toString(),
Expand Down

0 comments on commit 5dbd2c2

Please sign in to comment.