Skip to content

Commit

Permalink
Correct headers as part of the reqeust
Browse files Browse the repository at this point in the history
  • Loading branch information
vinothon84 committed Apr 12, 2024
1 parent 4ddfd50 commit 7084fa0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ private void sendMessage(NotifyCommand command, LogEvent event) {
} catch (JsonProcessingException e) {
log.error("Failed to send email message of type {}", command.getCommand(),
value(LogEvent.EVENT, LogEvent.NOTIFY_EMAIL_FAILED), value(LogEvent.EXCEPTION, e));
} catch(Exception ex) {
ex.printStackTrace();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ private void sendAuditMessage(LocalDateTime localDateTime,
/*var publishRequest = new PublishRequest(auditQueue,
objectMapper.writeValueAsString(request)).withMessageAttributes(getQueueHeaders(eventType.toString()));*/

var publishRequest = PublishRequest.builder().messageAttributes(getQueueHeaders(eventType.toString())).build();
//log.info("auditSearchSnsClient.listTopics(): ", auditSearchSnsClient.listTopics());

var publishRequest = PublishRequest.builder()
.topicArn(auditQueue)
.messageAttributes(getQueueHeaders(eventType.toString())).build();

auditSearchSnsClient.publish(publishRequest);
log.info("Create audit of type {} for Case UUID: {}, correlationID: {}, UserID: {}, event: {}", eventType,
Expand All @@ -146,9 +149,9 @@ private void sendAuditMessage(LocalDateTime localDateTime,
private Map<String, MessageAttributeValue> getQueueHeaders(String eventType) {
return Map.of(EVENT_TYPE_HEADER, MessageAttributeValue.builder().dataType("String").stringValue(eventType).build(),
RequestData.CORRELATION_ID_HEADER, MessageAttributeValue.builder().stringValue(requestData.correlationId()).build(),
RequestData.CORRELATION_ID_HEADER, MessageAttributeValue.builder().stringValue(requestData.userId()).build(),
RequestData.CORRELATION_ID_HEADER, MessageAttributeValue.builder().stringValue(requestData.username()).build(),
RequestData.CORRELATION_ID_HEADER, MessageAttributeValue.builder().stringValue(requestData.groups()).build());
RequestData.USER_ID_HEADER, MessageAttributeValue.builder().stringValue(requestData.userId()).build(),
RequestData.USERNAME_HEADER, MessageAttributeValue.builder().stringValue(requestData.username()).build(),
RequestData.GROUP_HEADER, MessageAttributeValue.builder().stringValue(requestData.groups()).build());
}

private void logFailedToParseDataPayload(JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public void setup() {
when(requestData.username()).thenReturn("some username");

sqsMessageResult = new ResultCaptor<>();
// doAnswer(sqsMessageResult).when(notifySqsClient).sendMessage(any());
doAnswer(sqsMessageResult).when(notifySqsClient).sendMessage((SendMessageRequest) any());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ public void shouldSetHeaders() {
var caseData = new CaseData(caseType, caseID, new HashMap<>(), LocalDate.now());
Map<String, MessageAttributeValue> expectedHeaders =
Map.of("event_type", MessageAttributeValue.builder().stringValue(EventType.CASE_CREATED.toString()).build(),
RequestData.CORRELATION_ID_HEADER, MessageAttributeValue.builder().stringValue(requestData.correlationId()).build(),
RequestData.USER_ID_HEADER, MessageAttributeValue.builder().stringValue(userId).build(),
RequestData.USERNAME_HEADER, MessageAttributeValue.builder().stringValue(userName).build());
RequestData.CORRELATION_ID_HEADER, MessageAttributeValue.builder().stringValue(requestData.correlationId()).build(),
RequestData.USER_ID_HEADER, MessageAttributeValue.builder().stringValue(userId).build(),
RequestData.USERNAME_HEADER, MessageAttributeValue.builder().stringValue(userName).build()
);

migrationAuditClient.createCaseAudit(caseData);

Expand Down

0 comments on commit 7084fa0

Please sign in to comment.