fixed unit tests
This commit is contained in:
parent
e8d651a108
commit
b80069500b
@ -340,12 +340,6 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
Mockito.argThat(matcherOriginatorId), Mockito.any(TbMsg.class), Mockito.isNull());
|
Mockito.argThat(matcherOriginatorId), Mockito.any(TbMsg.class), Mockito.isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testPushMsgToRuleEngineTime(EntityId matcherOriginatorId, TenantId tenantId, HasName entity, int cntTime) {
|
|
||||||
tenantId = tenantId.isNullUid() && ((HasTenantId) entity).getTenantId() != null ? ((HasTenantId) entity).getTenantId() : tenantId;
|
|
||||||
Mockito.verify(tbClusterService, times(cntTime)).pushMsgToRuleEngine(Mockito.eq(tenantId),
|
|
||||||
Mockito.eq(matcherOriginatorId), Mockito.any(TbMsg.class), Mockito.isNull());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void testNotificationMsgToEdgeServiceTime(EntityId entityId, TenantId tenantId, ActionType actionType, int cntTime) {
|
private void testNotificationMsgToEdgeServiceTime(EntityId entityId, TenantId tenantId, ActionType actionType, int cntTime) {
|
||||||
EdgeEventActionType edgeEventActionType = ActionType.CREDENTIALS_UPDATED.equals(actionType) ?
|
EdgeEventActionType edgeEventActionType = ActionType.CREDENTIALS_UPDATED.equals(actionType) ?
|
||||||
EdgeEventActionType.CREDENTIALS_UPDATED : edgeTypeByActionType(actionType);
|
EdgeEventActionType.CREDENTIALS_UPDATED : edgeTypeByActionType(actionType);
|
||||||
|
|||||||
@ -105,8 +105,7 @@ public abstract class BaseAlarmCommentControllerTest extends AbstractControllerT
|
|||||||
|
|
||||||
AlarmComment createdComment = createAlarmComment(alarm.getId());
|
AlarmComment createdComment = createAlarmComment(alarm.getId());
|
||||||
|
|
||||||
testLogEntityAction(createdComment, createdComment.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.ADDED, 1);
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.ADDED_COMMENT, 1, createdComment);
|
||||||
testPushMsgToRuleEngineTime(createdComment.getId(), tenantId, createdComment, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -118,8 +117,7 @@ public abstract class BaseAlarmCommentControllerTest extends AbstractControllerT
|
|||||||
AlarmComment createdComment = createAlarmComment(alarm.getId());
|
AlarmComment createdComment = createAlarmComment(alarm.getId());
|
||||||
Assert.assertEquals(AlarmCommentType.OTHER, createdComment.getType());
|
Assert.assertEquals(AlarmCommentType.OTHER, createdComment.getType());
|
||||||
|
|
||||||
testLogEntityAction(createdComment, createdComment.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ADDED, 1);
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ADDED_COMMENT, 1, createdComment);
|
||||||
testPushMsgToRuleEngineTime(createdComment.getId(), tenantId, createdComment, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -138,8 +136,7 @@ public abstract class BaseAlarmCommentControllerTest extends AbstractControllerT
|
|||||||
Assert.assertEquals("true", updatedAlarmComment.getComment().get("edited").asText());
|
Assert.assertEquals("true", updatedAlarmComment.getComment().get("edited").asText());
|
||||||
Assert.assertNotNull(updatedAlarmComment.getComment().get("editedOn"));
|
Assert.assertNotNull(updatedAlarmComment.getComment().get("editedOn"));
|
||||||
|
|
||||||
testLogEntityAction(updatedAlarmComment, updatedAlarmComment.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.UPDATED, 1);
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.UPDATED_COMMENT, 1, savedComment);
|
||||||
testPushMsgToRuleEngineTime(updatedAlarmComment.getId(), tenantId, updatedAlarmComment, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -158,8 +155,7 @@ public abstract class BaseAlarmCommentControllerTest extends AbstractControllerT
|
|||||||
Assert.assertEquals("true", updatedAlarmComment.getComment().get("edited").asText());
|
Assert.assertEquals("true", updatedAlarmComment.getComment().get("edited").asText());
|
||||||
Assert.assertNotNull(updatedAlarmComment.getComment().get("editedOn"));
|
Assert.assertNotNull(updatedAlarmComment.getComment().get("editedOn"));
|
||||||
|
|
||||||
testLogEntityAction(updatedAlarmComment, updatedAlarmComment.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.UPDATED, 1);
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.UPDATED_COMMENT, 1, updatedAlarmComment);
|
||||||
testPushMsgToRuleEngineTime(updatedAlarmComment.getId(), tenantId, updatedAlarmComment, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -177,7 +173,7 @@ public abstract class BaseAlarmCommentControllerTest extends AbstractControllerT
|
|||||||
.andExpect(status().isForbidden())
|
.andExpect(status().isForbidden())
|
||||||
.andExpect(statusReason(containsString(msgErrorPermission)));
|
.andExpect(statusReason(containsString(msgErrorPermission)));
|
||||||
|
|
||||||
testNotifyEntityNever(savedComment.getId(), savedComment);
|
testNotifyEntityNever(alarm.getId(), savedComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -195,11 +191,11 @@ public abstract class BaseAlarmCommentControllerTest extends AbstractControllerT
|
|||||||
.andExpect(status().isForbidden())
|
.andExpect(status().isForbidden())
|
||||||
.andExpect(statusReason(containsString(msgErrorPermission)));
|
.andExpect(statusReason(containsString(msgErrorPermission)));
|
||||||
|
|
||||||
testNotifyEntityNever(savedComment.getId(), savedComment);
|
testNotifyEntityNever(alarm.getId(), savedComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteAlarmViaCustomer() throws Exception {
|
public void testDeleteAlarmСommentViaCustomer() throws Exception {
|
||||||
loginCustomerUser();
|
loginCustomerUser();
|
||||||
AlarmComment alarmComment = createAlarmComment(alarm.getId());
|
AlarmComment alarmComment = createAlarmComment(alarm.getId());
|
||||||
|
|
||||||
@ -208,8 +204,7 @@ public abstract class BaseAlarmCommentControllerTest extends AbstractControllerT
|
|||||||
doDelete("/api/alarm/" + alarm.getId() + "/comment/" + alarmComment.getId())
|
doDelete("/api/alarm/" + alarm.getId() + "/comment/" + alarmComment.getId())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
testNotifyEntityOneTimeMsgToEdgeServiceNever(alarmComment, alarmComment.getId(), alarmComment.getId(),
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.DELETED_COMMENT, 1, alarmComment);
|
||||||
tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.DELETED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -222,8 +217,7 @@ public abstract class BaseAlarmCommentControllerTest extends AbstractControllerT
|
|||||||
doDelete("/api/alarm/" + alarm.getId() + "/comment/" + alarmComment.getId())
|
doDelete("/api/alarm/" + alarm.getId() + "/comment/" + alarmComment.getId())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
testNotifyEntityOneTimeMsgToEdgeServiceNever(alarmComment, alarmComment.getId(), alarmComment.getId(),
|
testLogEntityAction(alarm, alarm.getId(), tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.DELETED_COMMENT, 1, alarmComment);
|
||||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.DELETED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user