From 3a58059931d06ed701ec80cd91a80f6f3130ab1c Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Thu, 20 Aug 2026 12:28:07 +0300 Subject: [PATCH] Compare deleted alarm comment audit log argument against the persisted comment --- .../controller/AlarmCommentControllerTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/application/src/test/java/org/thingsboard/server/controller/AlarmCommentControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/AlarmCommentControllerTest.java index bebfe832e8..782580002a 100644 --- a/application/src/test/java/org/thingsboard/server/controller/AlarmCommentControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/AlarmCommentControllerTest.java @@ -231,6 +231,10 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { .comment(JacksonUtil.newObjectNode().put("text", String.format("Comment was deleted by user %s", CUSTOMER_USER_EMAIL))) .build(); + // The audit log receives the persisted comment, and AlarmComment equality covers the + // inherited id and createdTime, which the builder cannot populate. + expectedAlarmComment.setId(alarmComment.getId()); + expectedAlarmComment.setCreatedTime(alarmComment.getCreatedTime()); testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.DELETED_COMMENT, 1, expectedAlarmComment); } @@ -255,6 +259,10 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { .comment(JacksonUtil.newObjectNode().put("text", String.format("Comment was deleted by user %s", TENANT_ADMIN_EMAIL))) .build(); + // The audit log receives the persisted comment, and AlarmComment equality covers the + // inherited id and createdTime, which the builder cannot populate. + expectedAlarmComment.setId(alarmComment.getId()); + expectedAlarmComment.setCreatedTime(alarmComment.getCreatedTime()); testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.DELETED_COMMENT, 1, expectedAlarmComment); } @@ -286,6 +294,10 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { .comment(JacksonUtil.newObjectNode().put("text", String.format("Comment was deleted by user %s", TENANT_ADMIN_EMAIL))) .build(); + // The audit log receives the persisted comment, and AlarmComment equality covers the + // inherited id and createdTime, which the builder cannot populate. + expectedAlarmComment.setId(alarmComment.getId()); + expectedAlarmComment.setCreatedTime(alarmComment.getCreatedTime()); testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.DELETED_COMMENT, 1, expectedAlarmComment); }