Skip to content

Commit

Permalink
[MODORDSTOR-416] Process piece and poline outbox independently
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Sep 27, 2024
1 parent 346f299 commit 9f9401d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ protected Future<Void> processInventoryCreationEvent(ResourceEvent resourceEvent
processPoLinesUpdate(holdingId, tenantId, headers, conn),
processPiecesUpdate(holdingId, tenantId, headers, conn)
);
return GenericCompositeFuture.all(tenantIdUpdates)
.onSuccess(ar -> auditOutboxService.processOutboxEventLogs(headers))
.mapEmpty();
return GenericCompositeFuture.all(tenantIdUpdates).mapEmpty();
});
}

private Future<Void> processPoLinesUpdate(String holdingId, String tenantId, Map<String, String> headers, Conn conn) {
return poLinesService.getPoLinesByHoldingId(holdingId, conn)
.compose(poLines -> updatePoLines(poLines, holdingId, tenantId, conn))
.compose(poLines -> auditOutboxService.saveOrderLinesOutboxLogs(conn, poLines, OrderLineAuditEvent.Action.EDIT, headers))
.onSuccess(ar -> auditOutboxService.processOutboxEventLogs(headers))
.mapEmpty();
}

private Future<Void> processPiecesUpdate(String holdingId, String tenantId, Map<String, String> headers, Conn conn) {
return pieceService.getPiecesByHoldingId(holdingId, conn)
.compose(pieces -> updatePieces(pieces, holdingId, tenantId, conn))
.compose(pieces -> auditOutboxService.savePiecesOutboxLog(conn, pieces, PieceAuditEvent.Action.CREATE, headers))
.onSuccess(ar -> auditOutboxService.processOutboxEventLogs(headers))
.mapEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void initMocks() throws Exception {
doReturn(Future.succeededFuture(Optional.empty())).when(consortiumConfigurationService).getConsortiumConfiguration(any());
doReturn(Future.succeededFuture(true)).when(auditOutboxService).savePiecesOutboxLog(any(Conn.class), anyList(), any(), anyMap());
doReturn(Future.succeededFuture(true)).when(auditOutboxService).saveOrderLinesOutboxLogs(any(Conn.class), anyList(), any(), anyMap());
doReturn(Future.succeededFuture(true)).when(auditOutboxService).processOutboxEventLogs(anyMap());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void initMocks() throws Exception {
doReturn(pgClient).when(dbClient).getPgClient();
doReturn(Future.succeededFuture(Optional.empty())).when(consortiumConfigurationService).getConsortiumConfiguration(any());
doReturn(Future.succeededFuture(true)).when(auditOutboxService).savePiecesOutboxLog(any(Conn.class), anyList(), any(), anyMap());
doReturn(Future.succeededFuture(true)).when(auditOutboxService).processOutboxEventLogs(anyMap());
}
}

Expand Down

0 comments on commit 9f9401d

Please sign in to comment.