|
|
|
@ -46,6 +46,7 @@ import java.util.LinkedList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.containsString; |
|
|
|
import static org.hamcrest.Matchers.equalTo; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@ -104,7 +105,7 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
AlarmComment createdComment = createAlarmComment(alarm.getId()); |
|
|
|
|
|
|
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.ADDED_COMMENT, 1, createdComment); |
|
|
|
testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.ADDED_COMMENT, 1, createdComment); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@ -116,7 +117,7 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { |
|
|
|
AlarmComment createdComment = createAlarmComment(alarm.getId()); |
|
|
|
Assert.assertEquals(AlarmCommentType.OTHER, createdComment.getType()); |
|
|
|
|
|
|
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ADDED_COMMENT, 1, createdComment); |
|
|
|
testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ADDED_COMMENT, 1, createdComment); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@ -135,7 +136,7 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { |
|
|
|
Assert.assertEquals("true", updatedAlarmComment.getComment().get("edited").asText()); |
|
|
|
Assert.assertNotNull(updatedAlarmComment.getComment().get("editedOn")); |
|
|
|
|
|
|
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.UPDATED_COMMENT, 1, savedComment); |
|
|
|
testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.UPDATED_COMMENT, 1, savedComment); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@ -154,7 +155,7 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { |
|
|
|
Assert.assertEquals("true", updatedAlarmComment.getComment().get("edited").asText()); |
|
|
|
Assert.assertNotNull(updatedAlarmComment.getComment().get("editedOn")); |
|
|
|
|
|
|
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.UPDATED_COMMENT, 1, updatedAlarmComment); |
|
|
|
testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.UPDATED_COMMENT, 1, updatedAlarmComment); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@ -169,8 +170,8 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { |
|
|
|
savedComment.setComment(newComment); |
|
|
|
|
|
|
|
doPost("/api/alarm/" + alarm.getId() + "/comment", savedComment) |
|
|
|
.andExpect(status().isForbidden()) |
|
|
|
.andExpect(statusReason(containsString(msgErrorPermission))); |
|
|
|
.andExpect(status().isNotFound()) |
|
|
|
.andExpect(statusReason(equalTo(msgErrorNoFound("Alarm", alarm.getId().toString())))); |
|
|
|
|
|
|
|
testNotifyEntityNever(alarm.getId(), savedComment); |
|
|
|
} |
|
|
|
@ -209,7 +210,7 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { |
|
|
|
.comment(JacksonUtil.newObjectNode().put("text", String.format("User %s deleted his comment", |
|
|
|
CUSTOMER_USER_EMAIL))) |
|
|
|
.build(); |
|
|
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.DELETED_COMMENT, 1, expectedAlarmComment); |
|
|
|
testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.DELETED_COMMENT, 1, expectedAlarmComment); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@ -228,7 +229,7 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { |
|
|
|
.comment(JacksonUtil.newObjectNode().put("text", String.format("User %s deleted his comment", |
|
|
|
TENANT_ADMIN_EMAIL))) |
|
|
|
.build(); |
|
|
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.DELETED_COMMENT, 1, expectedAlarmComment); |
|
|
|
testLogEntityActionEntityEqClass(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.DELETED_COMMENT, 1, expectedAlarmComment); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@ -355,16 +356,18 @@ public class AlarmCommentControllerTest extends AbstractControllerTest { |
|
|
|
Assert.assertTrue("Created alarm doesn't match the found one!", equals); |
|
|
|
} |
|
|
|
|
|
|
|
private AlarmComment createAlarmComment(AlarmId alarmId, String text) { |
|
|
|
private AlarmComment createAlarmComment(AlarmId alarmId, String text) { |
|
|
|
AlarmComment alarmComment = AlarmComment.builder() |
|
|
|
.comment(JacksonUtil.newObjectNode().set("text", new TextNode(text))) |
|
|
|
.build(); |
|
|
|
|
|
|
|
return saveAlarmComment(alarmId, alarmComment); |
|
|
|
} |
|
|
|
private AlarmComment createAlarmComment(AlarmId alarmId) { |
|
|
|
|
|
|
|
private AlarmComment createAlarmComment(AlarmId alarmId) { |
|
|
|
return createAlarmComment(alarmId, "Please take a look"); |
|
|
|
} |
|
|
|
|
|
|
|
private AlarmComment saveAlarmComment(AlarmId alarmId, AlarmComment alarmComment) { |
|
|
|
alarmComment = doPost("/api/alarm/" + alarmId + "/comment", alarmComment, AlarmComment.class); |
|
|
|
Assert.assertNotNull(alarmComment); |
|
|
|
|