Skip to content

Commit

Permalink
MODSOURMAN-1200 Remove not updated titles from logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrokrutii authored Sep 3, 2024
1 parent 3d31621 commit ba03f4d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ FROM (
) AS records_actions
LEFT JOIN (SELECT journal_records.source_id, journal_records.title
FROM journal_records
WHERE journal_records.job_execution_id = ''%1$s'') AS rec_titles
ON rec_titles.source_id = records_actions.source_id AND rec_titles.title IS NOT NULL
WHERE journal_records.job_execution_id = ''%1$s'' AND (journal_records.entity_id IS NOT NULL OR journal_records.action_status = ''ERROR'' or journal_records.action_type = ''NON_MATCH'') )
AS rec_titles ON rec_titles.source_id = records_actions.source_id AND rec_titles.title IS NOT NULL
LEFT JOIN (
SELECT instances.action_type AS action_type,
instances.job_execution_id AS job_execution_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void shouldReturnOneEntryIfWithAllMultipleHoldingsTwoErrorsDuringMultiple
String errorMsg2 = "test error2";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, instanceHrid, null, 0, CREATE, INSTANCE, COMPLETED, null, null))
.compose(v -> createJournalRecordAllFields(createdJobExecution.getId(), sourceRecordId, holdingsId[0], holdingsHrid[0], null, 0, CREATE, HOLDINGS, COMPLETED, null, null, instanceId, null, permanentLocation[0]))
.compose(v -> createJournalRecordAllFields(createdJobExecution.getId(), sourceRecordId, holdingsId[1], null, null, 0, CREATE, HOLDINGS, ERROR, errorMsg1, null, null, null, null))
Expand Down Expand Up @@ -325,10 +325,11 @@ public void shouldReturnDiscardedForMarcBibAndInstanceIfMarcBibMatchedAndNoOther
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String entityId = UUID.randomUUID().toString();
String recordTitle = "test title";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, MATCH, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, null, recordTitle, 0, MATCH, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, MATCH, INSTANCE, COMPLETED, null, null))
.onFailure(context::fail);

Expand Down Expand Up @@ -387,10 +388,11 @@ public void shouldReturnDiscardedForHoldingsIfHoldingsMatchedAndNoOtherAction(Te
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String entityId = UUID.randomUUID().toString();
String recordTitle = "test title";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, MATCH, HOLDINGS, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, null, recordTitle, 0, MATCH, HOLDINGS, COMPLETED, null, null))
.onFailure(context::fail);

future.onComplete(ar -> context.verify(v -> {
Expand Down Expand Up @@ -418,10 +420,11 @@ public void shouldReturnDiscardedForItemIfItemMatchedAndNoOtherAction(TestContex
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String entityId = UUID.randomUUID().toString();
String recordTitle = "test title";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, MATCH, ITEM, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, null, recordTitle, 0, MATCH, ITEM, COMPLETED, null, null))
.onFailure(context::fail);

future.onComplete(ar -> context.verify(v -> {
Expand Down Expand Up @@ -449,10 +452,11 @@ public void shouldReturnDiscardedForAuthorityIfAuthorityMatchedAndNoOtherAction(
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String entityId = UUID.randomUUID().toString();
String recordTitle = "test title";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, MATCH, MARC_AUTHORITY, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, null, recordTitle, 0, MATCH, MARC_AUTHORITY, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, MATCH, AUTHORITY, COMPLETED, null, null))
.onFailure(context::fail);

Expand Down Expand Up @@ -850,10 +854,11 @@ public void shouldReturnHoldingsMultipleWhenMultipleHoldingsWereProcessed(TestCo
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String entityId = UUID.randomUUID().toString();
String recordTitle = "test title";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, null, 0, CREATE, HOLDINGS, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, null, 0, UPDATE, HOLDINGS, COMPLETED, null, null))
.onFailure(context::fail);
Expand Down Expand Up @@ -903,6 +908,38 @@ public void shouldReturnHoldingsTitleWithHoldingsHrid(TestContext context) {
}));
}

@Test
public void shouldReturnCorrectInstanceTitle(TestContext context) {
var async = context.async();
var createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
var sourceRecordId = UUID.randomUUID().toString();
var entityId = UUID.randomUUID().toString();
var instanceTitle = "instance title";
var sourceTitle = "source title";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, null, instanceTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, null, instanceTitle, 0, MATCH, INSTANCE, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, sourceTitle, 0, MATCH, INSTANCE, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, instanceTitle, 0, UPDATE, INSTANCE, COMPLETED, null, null))
.onFailure(context::fail);

future.onComplete(ar -> context.verify(v -> {
RestAssured.given()
.spec(spec)
.when()
.get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + createdJobExecution.getId())
.then()
.statusCode(HttpStatus.SC_OK)
.body("entries.size()", is(1))
.body("totalRecords", is(1))
.body("entries[0].incomingRecordId", is(sourceRecordId))
.body("entries[0].sourceRecordTitle", is(instanceTitle));

async.complete();
}));
}

@Test
public void shouldReturnSortedEntriesWhenSortByParameterSpecified(TestContext context) {
Async async = context.async();
Expand Down Expand Up @@ -1152,7 +1189,7 @@ public void shouldReturnMarcBibAndAllEntitiesWithoutErrorsRecordProcessingLogDTO
String poLineHrid = "po001";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, instanceHrid, null, 0, CREATE, INSTANCE, COMPLETED, null, null))
.compose(v -> createJournalRecordAllFields(createdJobExecution.getId(), sourceRecordId, holdingsId, holdingsHrid, null, 0, CREATE, HOLDINGS, COMPLETED, null, null, instanceId, null, null))
.compose(v -> createJournalRecordAllFields(createdJobExecution.getId(), sourceRecordId, itemId, itemHrid, null, 0, CREATE, ITEM, COMPLETED, null, null, instanceId, holdingsId, null))
Expand Down Expand Up @@ -1684,7 +1721,7 @@ public void shouldReturnMarcBibAndAllEntitiesWithMultipleItemsAndHoldings(TestCo
String errorMsg = "test error";

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, instanceHrid, null, 0, CREATE, INSTANCE, COMPLETED, null, null))

.compose(v -> createJournalRecordAllFields(createdJobExecution.getId(), sourceRecordId, holdingsId[0], holdingsHrid[0], null, 0, CREATE, HOLDINGS, COMPLETED, null, null, instanceId, null, permanentLocation[0]))
Expand Down Expand Up @@ -1929,7 +1966,7 @@ public void shouldReturnMarcBibAndAllEntitiesWithMultipleItemsUpdateRecordProces
String[] itemHrid = {"it001", "it002"};

Future<JournalRecord> future = Future.succeededFuture()
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null, null))
.compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, instanceHrid, null, 0, CREATE, INSTANCE, COMPLETED, null, null))
.compose(v -> createJournalRecordAllFields(createdJobExecution.getId(), sourceRecordId, itemId[0], itemHrid[0], null, 0, UPDATE, ITEM, COMPLETED, null, null, instanceId, holdingsId[0], null))
.compose(v -> createJournalRecordAllFields(createdJobExecution.getId(), sourceRecordId, itemId[1], itemHrid[1], null, 0, UPDATE, ITEM, COMPLETED, null, null, instanceId, holdingsId[1], null))
Expand Down

0 comments on commit ba03f4d

Please sign in to comment.