refactoring: tests DeviceProfile
This commit is contained in:
parent
fff137b8db
commit
bbbe6f043a
@ -41,6 +41,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
@ -126,7 +127,7 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
ArgumentMatcher<HasName> matcherEntityClassEquals = argument -> argument.getClass().equals(entity.getClass());
|
ArgumentMatcher<HasName> matcherEntityClassEquals = argument -> argument.getClass().equals(entity.getClass());
|
||||||
ArgumentMatcher<EntityId> matcherOriginatorId = argument -> argument.getClass().equals(originatorId.getClass());
|
ArgumentMatcher<EntityId> matcherOriginatorId = argument -> argument.getClass().equals(originatorId.getClass());
|
||||||
testLogEntityActionAdditionalInfo(matcherEntityClassEquals, matcherOriginatorId, tenantId, customerId, userId, userName, actionType, cntTime,
|
testLogEntityActionAdditionalInfo(matcherEntityClassEquals, matcherOriginatorId, tenantId, customerId, userId, userName, actionType, cntTime,
|
||||||
extractMatcherAdditionalInfo(additionalInfo));
|
extractMatcherAdditionalInfoClass(additionalInfo));
|
||||||
testPushMsgToRuleEngineTime(matcherOriginatorId, tenantId, cntTimeRuleEngine);
|
testPushMsgToRuleEngineTime(matcherOriginatorId, tenantId, cntTimeRuleEngine);
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
}
|
}
|
||||||
@ -158,6 +159,18 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void testNotifyEntityBroadcastEntityStateChangeEventOneTime(HasName entity, EntityId entityId, EntityId originatorId,
|
||||||
|
TenantId tenantId, CustomerId customerId, UserId userId, String userName,
|
||||||
|
ActionType actionType, Object... additionalInfo) {
|
||||||
|
int cntTime = 1;
|
||||||
|
testSendNotificationMsgToEdgeServiceTime(entityId, tenantId, actionType, cntTime);
|
||||||
|
testLogEntityAction(entity, originatorId, tenantId, customerId, userId, userName, actionType, cntTime, additionalInfo);
|
||||||
|
ArgumentMatcher<EntityId> matcherOriginatorId = argument -> argument.equals(originatorId);
|
||||||
|
testPushMsgToRuleEngineTime(matcherOriginatorId, tenantId, cntTime);
|
||||||
|
testBroadcastEntityStateChangeEventTime(entityId, tenantId, cntTime);
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
}
|
||||||
|
|
||||||
protected void testNotifyEntityBroadcastEntityStateChangeEventOneTimeMsgToEdgeServiceNever(HasName entity, EntityId entityId, EntityId originatorId,
|
protected void testNotifyEntityBroadcastEntityStateChangeEventOneTimeMsgToEdgeServiceNever(HasName entity, EntityId entityId, EntityId originatorId,
|
||||||
TenantId tenantId, CustomerId customerId, UserId userId, String userName,
|
TenantId tenantId, CustomerId customerId, UserId userId, String userName,
|
||||||
ActionType actionType, Object... additionalInfo) {
|
ActionType actionType, Object... additionalInfo) {
|
||||||
@ -170,7 +183,6 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void testNotifyEntityMsgToEdgePushMsgToCoreOneTime(HasName entity, EntityId entityId, EntityId originatorId,
|
protected void testNotifyEntityMsgToEdgePushMsgToCoreOneTime(HasName entity, EntityId entityId, EntityId originatorId,
|
||||||
TenantId tenantId, CustomerId customerId, UserId userId, String userName,
|
TenantId tenantId, CustomerId customerId, UserId userId, String userName,
|
||||||
ActionType actionType, Object... additionalInfo) {
|
ActionType actionType, Object... additionalInfo) {
|
||||||
@ -181,10 +193,9 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void testNotifyEntityEqualsOneTimeServiceNeverError(HasName entity, TenantId tenantId,
|
||||||
protected void testNotifyEntityEqualsOneTimeError(HasName entity, TenantId tenantId,
|
UserId userId, String userName, ActionType actionType, Exception exp,
|
||||||
UserId userId, String userName, ActionType actionType, Exception exp,
|
Object... additionalInfo) {
|
||||||
Object... additionalInfo) {
|
|
||||||
CustomerId customer_NULL_UUID = (CustomerId) EntityIdFactory.getByTypeAndUuid(EntityType.CUSTOMER, ModelConstants.NULL_UUID);
|
CustomerId customer_NULL_UUID = (CustomerId) EntityIdFactory.getByTypeAndUuid(EntityType.CUSTOMER, ModelConstants.NULL_UUID);
|
||||||
EntityId entity_originator_NULL_UUID = createEntityId_NULL_UUID(entity);
|
EntityId entity_originator_NULL_UUID = createEntityId_NULL_UUID(entity);
|
||||||
testNotificationMsgToEdgeServiceNever(entity_originator_NULL_UUID);
|
testNotificationMsgToEdgeServiceNever(entity_originator_NULL_UUID);
|
||||||
@ -196,9 +207,9 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
testPushMsgToRuleEngineNever(entity_originator_NULL_UUID);
|
testPushMsgToRuleEngineNever(entity_originator_NULL_UUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testNotifyEntityIsNullOneTimeError(HasName entity, TenantId tenantId,
|
protected void testNotifyEntityIsNullOneTimeEdgeServiceNeverError(HasName entity, TenantId tenantId,
|
||||||
UserId userId, String userName, ActionType actionType, Exception exp,
|
UserId userId, String userName, ActionType actionType, Exception exp,
|
||||||
Object... additionalInfo) {
|
Object... additionalInfo) {
|
||||||
CustomerId customer_NULL_UUID = (CustomerId) EntityIdFactory.getByTypeAndUuid(EntityType.CUSTOMER, ModelConstants.NULL_UUID);
|
CustomerId customer_NULL_UUID = (CustomerId) EntityIdFactory.getByTypeAndUuid(EntityType.CUSTOMER, ModelConstants.NULL_UUID);
|
||||||
EntityId entity_originator_NULL_UUID = createEntityId_NULL_UUID(entity);
|
EntityId entity_originator_NULL_UUID = createEntityId_NULL_UUID(entity);
|
||||||
testNotificationMsgToEdgeServiceNever(entity_originator_NULL_UUID);
|
testNotificationMsgToEdgeServiceNever(entity_originator_NULL_UUID);
|
||||||
@ -222,10 +233,6 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
Mockito.verify(gatewayNotificationsService, times(1)).onDeviceUpdated(Mockito.eq(device), Mockito.eq(oldDevice));
|
Mockito.verify(gatewayNotificationsService, times(1)).onDeviceUpdated(Mockito.eq(device), Mockito.eq(oldDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testNotificationUpdateGatewayTime(int cntTimes) {
|
|
||||||
Mockito.verify(gatewayNotificationsService, times(cntTimes)).onDeviceUpdated(Mockito.any(Device.class), Mockito.isNull());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void testNotificationUpdateGatewayNever() {
|
protected void testNotificationUpdateGatewayNever() {
|
||||||
Mockito.verify(gatewayNotificationsService, never()).onDeviceUpdated(Mockito.any(Device.class), Mockito.any(Device.class));
|
Mockito.verify(gatewayNotificationsService, never()).onDeviceUpdated(Mockito.any(Device.class), Mockito.any(Device.class));
|
||||||
}
|
}
|
||||||
@ -476,6 +483,14 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
return matcherAdditionalInfos;
|
return matcherAdditionalInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ArgumentMatcher<Object>> extractMatcherAdditionalInfoClass(Object... additionalInfos) {
|
||||||
|
List<ArgumentMatcher<Object>> matcherAdditionalInfos = new ArrayList<>(additionalInfos.length);
|
||||||
|
for (Object additionalInfo : additionalInfos) {
|
||||||
|
matcherAdditionalInfos.add(argument -> argument.getClass().equals(extractParameter(additionalInfo.getClass(), additionalInfo).getClass()));
|
||||||
|
}
|
||||||
|
return matcherAdditionalInfos;
|
||||||
|
}
|
||||||
|
|
||||||
private <T> T extractParameter(Class<T> clazz, Object additionalInfo) {
|
private <T> T extractParameter(Class<T> clazz, Object additionalInfo) {
|
||||||
T result = null;
|
T result = null;
|
||||||
if (additionalInfo != null) {
|
if (additionalInfo != null) {
|
||||||
@ -488,9 +503,7 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private EntityId createEntityId_NULL_UUID(HasName entity) {
|
private EntityId createEntityId_NULL_UUID(HasName entity) {
|
||||||
return EntityIdFactory.getByTypeAndUuid(EntityType.valueOf(entity.getClass().toString()
|
return EntityIdFactory.getByTypeAndUuid(entityClassToEntityTypeName(entity), ModelConstants.NULL_UUID);
|
||||||
.substring(entity.getClass().toString().lastIndexOf(".") + 1).toUpperCase(Locale.ENGLISH)),
|
|
||||||
ModelConstants.NULL_UUID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String msgErrorFieldLength(String fieldName){
|
protected String msgErrorFieldLength(String fieldName){
|
||||||
@ -500,4 +513,13 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
|
|||||||
protected String msgErrorNoFound(String entityClassName, String assetIdStr){
|
protected String msgErrorNoFound(String entityClassName, String assetIdStr){
|
||||||
return entityClassName + " with id [" + assetIdStr + "] is not found";
|
return entityClassName + " with id [" + assetIdStr + "] is not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String entityClassToEntityTypeName(HasName entity) {
|
||||||
|
String className = entity.getClass().toString()
|
||||||
|
.substring(entity.getClass().toString().lastIndexOf(".") + 1);
|
||||||
|
List str = className.chars()
|
||||||
|
.mapToObj(x -> (Character.isUpperCase(x)) ? "_" + Character.toString(x) : Character.toString(x))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return String.join("", str).toUpperCase(Locale.ENGLISH).substring(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,7 +127,7 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(asset, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(asset, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(asset, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(asset, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(asset, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(asset, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityIsNullOneTimeError(savedAsset1, savedTenant.getId(), tenantAdmin.getId(), tenantAdmin.getEmail(),
|
testNotifyEntityIsNullOneTimeEdgeServiceNeverError(savedAsset1, savedTenant.getId(), tenantAdmin.getId(), tenantAdmin.getEmail(),
|
||||||
ActionType.DELETED, new DataValidationException(msgError), savedAsset1.getId().getId().toString());
|
ActionType.DELETED, new DataValidationException(msgError), savedAsset1.getId().getId().toString());
|
||||||
|
|
||||||
savedView.setEntityId(savedAsset2.getId());
|
savedView.setEntityId(savedAsset2.getId());
|
||||||
@ -307,7 +307,7 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(asset, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(asset, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(asset, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(asset, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -132,7 +132,7 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
customer.setTenantId(savedTenant.getId());
|
customer.setTenantId(savedTenant.getId());
|
||||||
testNotifyEntityEqualsOneTimeError(customer,savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(customer,savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(customer,savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(customer,savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(customer,savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(customer,savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(customer,savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(customer,savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(customer,savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(customer,savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(customer,savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(customer,savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(customer,savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(customer,savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(customer, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(customer, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,7 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
dashboard.setTenantId(savedTenant.getId());
|
dashboard.setTenantId(savedTenant.getId());
|
||||||
testNotifyEntityEqualsOneTimeError(dashboard, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(dashboard, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
Mockito.reset(tbClusterService, auditLogService);
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(dashboard, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(dashboard, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -157,36 +157,36 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest {
|
|||||||
|
|
||||||
Mockito.reset(tbClusterService, auditLogService, gatewayNotificationsService);
|
Mockito.reset(tbClusterService, auditLogService, gatewayNotificationsService);
|
||||||
|
|
||||||
String msgError = "length of name must be equal or less than 255";
|
String msgError = msgErrorFieldLength("name");
|
||||||
doPost("/api/device", device)
|
doPost("/api/device", device)
|
||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(device, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(device, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
testNotificationUpdateGatewayNever();
|
testNotificationUpdateGatewayNever();
|
||||||
Mockito.reset(tbClusterService, auditLogService, gatewayNotificationsService);
|
Mockito.reset(tbClusterService, auditLogService, gatewayNotificationsService);
|
||||||
|
|
||||||
device.setTenantId(savedTenant.getId());
|
device.setTenantId(savedTenant.getId());
|
||||||
msgError = "length of type must be equal or less than 255";
|
msgError = msgErrorFieldLength("type");
|
||||||
device.setType(RandomStringUtils.randomAlphabetic(300));
|
device.setType(RandomStringUtils.randomAlphabetic(300));
|
||||||
doPost("/api/device", device)
|
doPost("/api/device", device)
|
||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(device, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(device, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
testNotificationUpdateGatewayNever();
|
testNotificationUpdateGatewayNever();
|
||||||
Mockito.reset(tbClusterService, auditLogService, gatewayNotificationsService);
|
Mockito.reset(tbClusterService, auditLogService, gatewayNotificationsService);
|
||||||
|
|
||||||
msgError = "length of label must be equal or less than 255";
|
msgError = msgErrorFieldLength("label");
|
||||||
device.setType("Normal type");
|
device.setType("Normal type");
|
||||||
device.setLabel(RandomStringUtils.randomAlphabetic(300));
|
device.setLabel(RandomStringUtils.randomAlphabetic(300));
|
||||||
doPost("/api/device", device)
|
doPost("/api/device", device)
|
||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(device, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(device, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
testNotificationUpdateGatewayNever();
|
testNotificationUpdateGatewayNever();
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityEqualsOneTimeError(device, savedTenant.getId(),
|
testNotifyEntityEqualsOneTimeServiceNeverError(device, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
testNotificationUpdateGatewayNever();
|
testNotificationUpdateGatewayNever();
|
||||||
}
|
}
|
||||||
@ -506,7 +506,7 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityIsNullOneTimeError(device, savedTenant.getId(),
|
testNotifyEntityIsNullOneTimeEdgeServiceNeverError(device, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.CREDENTIALS_UPDATED,
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.CREDENTIALS_UPDATED,
|
||||||
new DataValidationException(msgError), deviceCredentials);
|
new DataValidationException(msgError), deviceCredentials);
|
||||||
testNotificationUpdateGatewayNever();
|
testNotificationUpdateGatewayNever();
|
||||||
@ -529,7 +529,7 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityIsNullOneTimeError(device, savedTenant.getId(),
|
testNotifyEntityIsNullOneTimeEdgeServiceNeverError(device, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.CREDENTIALS_UPDATED,
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.CREDENTIALS_UPDATED,
|
||||||
new DeviceCredentialsValidationException(msgError), deviceCredentials);
|
new DeviceCredentialsValidationException(msgError), deviceCredentials);
|
||||||
testNotificationUpdateGatewayNever();
|
testNotificationUpdateGatewayNever();
|
||||||
@ -556,7 +556,7 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest {
|
|||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(msgError)));
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
testNotifyEntityIsNullOneTimeError(device, savedTenant.getId(),
|
testNotifyEntityIsNullOneTimeEdgeServiceNeverError(device, savedTenant.getId(),
|
||||||
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.CREDENTIALS_UPDATED,
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.CREDENTIALS_UPDATED,
|
||||||
new DeviceCredentialsValidationException(msgError), newDeviceCredentials);
|
new DeviceCredentialsValidationException(msgError), newDeviceCredentials);
|
||||||
testNotificationUpdateGatewayNever();
|
testNotificationUpdateGatewayNever();
|
||||||
|
|||||||
@ -26,8 +26,8 @@ import org.apache.commons.lang3.RandomStringUtils;
|
|||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
import org.thingsboard.server.common.data.DeviceProfile;
|
import org.thingsboard.server.common.data.DeviceProfile;
|
||||||
import org.thingsboard.server.common.data.DeviceProfileInfo;
|
import org.thingsboard.server.common.data.DeviceProfileInfo;
|
||||||
@ -36,6 +36,7 @@ import org.thingsboard.server.common.data.DeviceProfileType;
|
|||||||
import org.thingsboard.server.common.data.DeviceTransportType;
|
import org.thingsboard.server.common.data.DeviceTransportType;
|
||||||
import org.thingsboard.server.common.data.Tenant;
|
import org.thingsboard.server.common.data.Tenant;
|
||||||
import org.thingsboard.server.common.data.User;
|
import org.thingsboard.server.common.data.User;
|
||||||
|
import org.thingsboard.server.common.data.audit.ActionType;
|
||||||
import org.thingsboard.server.common.data.device.profile.DeviceProfileTransportConfiguration;
|
import org.thingsboard.server.common.data.device.profile.DeviceProfileTransportConfiguration;
|
||||||
import org.thingsboard.server.common.data.device.profile.JsonTransportPayloadConfiguration;
|
import org.thingsboard.server.common.data.device.profile.JsonTransportPayloadConfiguration;
|
||||||
import org.thingsboard.server.common.data.device.profile.MqttDeviceProfileTransportConfiguration;
|
import org.thingsboard.server.common.data.device.profile.MqttDeviceProfileTransportConfiguration;
|
||||||
@ -44,6 +45,7 @@ import org.thingsboard.server.common.data.device.profile.TransportPayloadTypeCon
|
|||||||
import org.thingsboard.server.common.data.page.PageData;
|
import org.thingsboard.server.common.data.page.PageData;
|
||||||
import org.thingsboard.server.common.data.page.PageLink;
|
import org.thingsboard.server.common.data.page.PageLink;
|
||||||
import org.thingsboard.server.common.data.security.Authority;
|
import org.thingsboard.server.common.data.security.Authority;
|
||||||
|
import org.thingsboard.server.dao.exception.DataValidationException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -95,6 +97,9 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
@Test
|
@Test
|
||||||
public void testSaveDeviceProfile() throws Exception {
|
public void testSaveDeviceProfile() throws Exception {
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
||||||
|
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
||||||
Assert.assertNotNull(savedDeviceProfile);
|
Assert.assertNotNull(savedDeviceProfile);
|
||||||
Assert.assertNotNull(savedDeviceProfile.getId());
|
Assert.assertNotNull(savedDeviceProfile.getId());
|
||||||
@ -105,23 +110,41 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
Assert.assertEquals(deviceProfile.isDefault(), savedDeviceProfile.isDefault());
|
Assert.assertEquals(deviceProfile.isDefault(), savedDeviceProfile.isDefault());
|
||||||
Assert.assertEquals(deviceProfile.getDefaultRuleChainId(), savedDeviceProfile.getDefaultRuleChainId());
|
Assert.assertEquals(deviceProfile.getDefaultRuleChainId(), savedDeviceProfile.getDefaultRuleChainId());
|
||||||
Assert.assertEquals(DeviceProfileProvisionType.DISABLED, savedDeviceProfile.getProvisionType());
|
Assert.assertEquals(DeviceProfileProvisionType.DISABLED, savedDeviceProfile.getProvisionType());
|
||||||
|
|
||||||
|
testNotifyEntityBroadcastEntityStateChangeEventOneTime(savedDeviceProfile, savedDeviceProfile.getId(), savedDeviceProfile.getId(),
|
||||||
|
savedTenant.getId(), tenantAdmin.getCustomerId(), tenantAdmin.getId(), tenantAdmin.getEmail(),
|
||||||
|
ActionType.ADDED);
|
||||||
|
|
||||||
savedDeviceProfile.setName("New device profile");
|
savedDeviceProfile.setName("New device profile");
|
||||||
doPost("/api/deviceProfile", savedDeviceProfile, DeviceProfile.class);
|
doPost("/api/deviceProfile", savedDeviceProfile, DeviceProfile.class);
|
||||||
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/"+savedDeviceProfile.getId().getId().toString(), DeviceProfile.class);
|
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString(), DeviceProfile.class);
|
||||||
Assert.assertEquals(savedDeviceProfile.getName(), foundDeviceProfile.getName());
|
Assert.assertEquals(savedDeviceProfile.getName(), foundDeviceProfile.getName());
|
||||||
|
|
||||||
|
testNotifyEntityBroadcastEntityStateChangeEventOneTime(foundDeviceProfile, foundDeviceProfile.getId(), foundDeviceProfile.getId(),
|
||||||
|
savedTenant.getId(), tenantAdmin.getCustomerId(), tenantAdmin.getId(), tenantAdmin.getEmail(),
|
||||||
|
ActionType.UPDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void saveDeviceProfileWithViolationOfValidation() throws Exception {
|
public void saveDeviceProfileWithViolationOfValidation() throws Exception {
|
||||||
doPost("/api/deviceProfile", this.createDeviceProfile(RandomStringUtils.randomAlphabetic(300)))
|
String msgError = msgErrorFieldLength("name");
|
||||||
.andExpect(statusReason(containsString("length of name must be equal or less than 255")));
|
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
|
DeviceProfile createDeviceProfile = this.createDeviceProfile(RandomStringUtils.randomAlphabetic(300));
|
||||||
|
doPost("/api/deviceProfile", createDeviceProfile)
|
||||||
|
.andExpect(status().isBadRequest())
|
||||||
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
|
testNotifyEntityEqualsOneTimeServiceNeverError(createDeviceProfile, savedTenant.getId(),
|
||||||
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindDeviceProfileById() throws Exception {
|
public void testFindDeviceProfileById() throws Exception {
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
||||||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
||||||
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/"+savedDeviceProfile.getId().getId().toString(), DeviceProfile.class);
|
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString(), DeviceProfile.class);
|
||||||
Assert.assertNotNull(foundDeviceProfile);
|
Assert.assertNotNull(foundDeviceProfile);
|
||||||
Assert.assertEquals(savedDeviceProfile, foundDeviceProfile);
|
Assert.assertEquals(savedDeviceProfile, foundDeviceProfile);
|
||||||
}
|
}
|
||||||
@ -132,15 +155,17 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
deviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
deviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
||||||
|
|
||||||
loginDifferentTenant();
|
loginDifferentTenant();
|
||||||
|
|
||||||
doGet("/api/deviceProfile/" + deviceProfile.getId())
|
doGet("/api/deviceProfile/" + deviceProfile.getId())
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden())
|
||||||
|
.andExpect(statusReason(containsString(msgErrorPermission)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindDeviceProfileInfoById() throws Exception {
|
public void testFindDeviceProfileInfoById() throws Exception {
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
||||||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
||||||
DeviceProfileInfo foundDeviceProfileInfo = doGet("/api/deviceProfileInfo/"+savedDeviceProfile.getId().getId().toString(), DeviceProfileInfo.class);
|
DeviceProfileInfo foundDeviceProfileInfo = doGet("/api/deviceProfileInfo/" + savedDeviceProfile.getId().getId().toString(), DeviceProfileInfo.class);
|
||||||
Assert.assertNotNull(foundDeviceProfileInfo);
|
Assert.assertNotNull(foundDeviceProfileInfo);
|
||||||
Assert.assertEquals(savedDeviceProfile.getId(), foundDeviceProfileInfo.getId());
|
Assert.assertEquals(savedDeviceProfile.getId(), foundDeviceProfileInfo.getId());
|
||||||
Assert.assertEquals(savedDeviceProfile.getName(), foundDeviceProfileInfo.getName());
|
Assert.assertEquals(savedDeviceProfile.getName(), foundDeviceProfileInfo.getName());
|
||||||
@ -154,7 +179,8 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
|
|
||||||
loginDifferentTenant();
|
loginDifferentTenant();
|
||||||
doGet("/api/deviceProfileInfo/" + deviceProfile.getId())
|
doGet("/api/deviceProfileInfo/" + deviceProfile.getId())
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden())
|
||||||
|
.andExpect(statusReason(containsString(msgErrorPermission)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -172,20 +198,35 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
public void testSetDefaultDeviceProfile() throws Exception {
|
public void testSetDefaultDeviceProfile() throws Exception {
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile 1");
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile 1");
|
||||||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
||||||
DeviceProfile defaultDeviceProfile = doPost("/api/deviceProfile/"+savedDeviceProfile.getId().getId().toString()+"/default", DeviceProfile.class);
|
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
|
DeviceProfile defaultDeviceProfile = doPost("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString() + "/default", DeviceProfile.class);
|
||||||
Assert.assertNotNull(defaultDeviceProfile);
|
Assert.assertNotNull(defaultDeviceProfile);
|
||||||
DeviceProfileInfo foundDefaultDeviceProfile = doGet("/api/deviceProfileInfo/default", DeviceProfileInfo.class);
|
DeviceProfileInfo foundDefaultDeviceProfile = doGet("/api/deviceProfileInfo/default", DeviceProfileInfo.class);
|
||||||
Assert.assertNotNull(foundDefaultDeviceProfile);
|
Assert.assertNotNull(foundDefaultDeviceProfile);
|
||||||
Assert.assertEquals(savedDeviceProfile.getName(), foundDefaultDeviceProfile.getName());
|
Assert.assertEquals(savedDeviceProfile.getName(), foundDefaultDeviceProfile.getName());
|
||||||
Assert.assertEquals(savedDeviceProfile.getId(), foundDefaultDeviceProfile.getId());
|
Assert.assertEquals(savedDeviceProfile.getId(), foundDefaultDeviceProfile.getId());
|
||||||
Assert.assertEquals(savedDeviceProfile.getType(), foundDefaultDeviceProfile.getType());
|
Assert.assertEquals(savedDeviceProfile.getType(), foundDefaultDeviceProfile.getType());
|
||||||
|
|
||||||
|
testNotifyEntityOneTimeMsgToEdgeServiceNever(defaultDeviceProfile, defaultDeviceProfile.getId(), defaultDeviceProfile.getId(),
|
||||||
|
savedTenant.getId(), tenantAdmin.getCustomerId(), tenantAdmin.getId(), tenantAdmin.getEmail(),
|
||||||
|
ActionType.UPDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveDeviceProfileWithEmptyName() throws Exception {
|
public void testSaveDeviceProfileWithEmptyName() throws Exception {
|
||||||
DeviceProfile deviceProfile = new DeviceProfile();
|
DeviceProfile deviceProfile = new DeviceProfile();
|
||||||
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isBadRequest())
|
|
||||||
.andExpect(statusReason(containsString("Device profile name should be specified")));
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
|
String msgError = "Device profile name " + msgErrorShouldBeSpecified;
|
||||||
|
doPost("/api/deviceProfile", deviceProfile)
|
||||||
|
.andExpect(status().isBadRequest())
|
||||||
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
|
testNotifyEntityEqualsOneTimeServiceNeverError(deviceProfile, savedTenant.getId(),
|
||||||
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -193,8 +234,16 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
||||||
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isOk());
|
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isOk());
|
||||||
DeviceProfile deviceProfile2 = this.createDeviceProfile("Device Profile");
|
DeviceProfile deviceProfile2 = this.createDeviceProfile("Device Profile");
|
||||||
doPost("/api/deviceProfile", deviceProfile2).andExpect(status().isBadRequest())
|
|
||||||
.andExpect(statusReason(containsString("Device profile with such name already exists")));
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
|
String msgError = "Device profile with such name already exists";
|
||||||
|
doPost("/api/deviceProfile", deviceProfile2)
|
||||||
|
.andExpect(status().isBadRequest())
|
||||||
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
|
testNotifyEntityEqualsOneTimeServiceNeverError(deviceProfile, savedTenant.getId(),
|
||||||
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -204,24 +253,33 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isOk());
|
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isOk());
|
||||||
DeviceProfile deviceProfile2 = this.createDeviceProfile("Device Profile 2");
|
DeviceProfile deviceProfile2 = this.createDeviceProfile("Device Profile 2");
|
||||||
deviceProfile2.setProvisionDeviceKey("testProvisionDeviceKey");
|
deviceProfile2.setProvisionDeviceKey("testProvisionDeviceKey");
|
||||||
doPost("/api/deviceProfile", deviceProfile2).andExpect(status().isBadRequest())
|
|
||||||
.andExpect(statusReason(containsString("Device profile with such provision device key already exists")));
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
|
String msgError = "Device profile with such provision device key already exists";
|
||||||
|
doPost("/api/deviceProfile", deviceProfile2)
|
||||||
|
.andExpect(status().isBadRequest())
|
||||||
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
|
testNotifyEntityEqualsOneTimeServiceNeverError(deviceProfile, savedTenant.getId(),
|
||||||
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeDeviceProfileTypeWithExistingDevices() throws Exception {
|
public void testChangeDeviceProfileTypeNull() throws Exception {
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
||||||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
||||||
Device device = new Device();
|
|
||||||
device.setName("Test device");
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
device.setType("default");
|
|
||||||
device.setDeviceProfileId(savedDeviceProfile.getId());
|
savedDeviceProfile.setType(null);
|
||||||
doPost("/api/device", device, Device.class);
|
String msgError = "Device profile type " + msgErrorShouldBeSpecified;
|
||||||
//TODO uncomment once we have other device types;
|
doPost("/api/deviceProfile", savedDeviceProfile)
|
||||||
//savedDeviceProfile.setType(DeviceProfileType.LWM2M);
|
.andExpect(status().isBadRequest())
|
||||||
doPost("/api/deviceProfile", savedDeviceProfile).andExpect(status().isBadRequest())
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
.andExpect(statusReason(containsString("Can't change device profile type because devices referenced it")));
|
|
||||||
|
testNotifyEntityEqualsOneTimeServiceNeverError(deviceProfile, savedTenant.getId(),
|
||||||
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.UPDATED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -233,9 +291,17 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
device.setType("default");
|
device.setType("default");
|
||||||
device.setDeviceProfileId(savedDeviceProfile.getId());
|
device.setDeviceProfileId(savedDeviceProfile.getId());
|
||||||
doPost("/api/device", device, Device.class);
|
doPost("/api/device", device, Device.class);
|
||||||
|
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
|
String msgError = "Can't change device profile transport type because devices referenced it";
|
||||||
savedDeviceProfile.setTransportType(DeviceTransportType.MQTT);
|
savedDeviceProfile.setTransportType(DeviceTransportType.MQTT);
|
||||||
doPost("/api/deviceProfile", savedDeviceProfile).andExpect(status().isBadRequest())
|
doPost("/api/deviceProfile", savedDeviceProfile)
|
||||||
.andExpect(statusReason(containsString("Can't change device profile transport type because devices referenced it")));
|
.andExpect(status().isBadRequest())
|
||||||
|
.andExpect(statusReason(containsString(msgError)));
|
||||||
|
|
||||||
|
testNotifyEntityEqualsOneTimeServiceNeverError(deviceProfile, savedTenant.getId(),
|
||||||
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.UPDATED, new DataValidationException(msgError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -248,11 +314,15 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
device.setType("default");
|
device.setType("default");
|
||||||
device.setDeviceProfileId(savedDeviceProfile.getId());
|
device.setDeviceProfileId(savedDeviceProfile.getId());
|
||||||
|
|
||||||
Device savedDevice = doPost("/api/device", device, Device.class);
|
doPost("/api/device", device, Device.class);
|
||||||
|
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
doDelete("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString())
|
doDelete("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString())
|
||||||
.andExpect(status().isBadRequest())
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString("The device profile referenced by the devices cannot be deleted")));
|
.andExpect(statusReason(containsString("The device profile referenced by the devices cannot be deleted")));
|
||||||
|
|
||||||
|
testNotifyEntityNever(savedDeviceProfile.getId(), savedDeviceProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -260,11 +330,19 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile");
|
||||||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
||||||
|
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
doDelete("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString())
|
doDelete("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
|
String savedDeviceProfileIdFtr = savedDeviceProfile.getId().getId().toString();
|
||||||
|
testNotifyEntityBroadcastEntityStateChangeEventOneTime(savedDeviceProfile, savedDeviceProfile.getId(), savedDeviceProfile.getId(),
|
||||||
|
savedTenant.getId(), tenantAdmin.getCustomerId(), tenantAdmin.getId(), tenantAdmin.getEmail(),
|
||||||
|
ActionType.DELETED, savedDeviceProfileIdFtr);
|
||||||
|
|
||||||
doGet("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString())
|
doGet("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString())
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound())
|
||||||
|
.andExpect(statusReason(containsString(msgErrorNoFound("Device profile", savedDeviceProfileIdFtr))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -272,21 +350,30 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
List<DeviceProfile> deviceProfiles = new ArrayList<>();
|
List<DeviceProfile> deviceProfiles = new ArrayList<>();
|
||||||
PageLink pageLink = new PageLink(17);
|
PageLink pageLink = new PageLink(17);
|
||||||
PageData<DeviceProfile> pageData = doGetTypedWithPageLink("/api/deviceProfiles?",
|
PageData<DeviceProfile> pageData = doGetTypedWithPageLink("/api/deviceProfiles?",
|
||||||
new TypeReference<PageData<DeviceProfile>>(){}, pageLink);
|
new TypeReference<>() {
|
||||||
|
}, pageLink);
|
||||||
Assert.assertFalse(pageData.hasNext());
|
Assert.assertFalse(pageData.hasNext());
|
||||||
Assert.assertEquals(1, pageData.getTotalElements());
|
Assert.assertEquals(1, pageData.getTotalElements());
|
||||||
deviceProfiles.addAll(pageData.getData());
|
deviceProfiles.addAll(pageData.getData());
|
||||||
|
|
||||||
for (int i=0;i<28;i++) {
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"+i);
|
|
||||||
|
int cntEntity = 28;
|
||||||
|
for (int i = 0; i < cntEntity; i++) {
|
||||||
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile" + i);
|
||||||
deviceProfiles.add(doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class));
|
deviceProfiles.add(doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(new DeviceProfile(), new DeviceProfile(),
|
||||||
|
savedTenant.getId(), tenantAdmin.getCustomerId(), tenantAdmin.getId(), tenantAdmin.getEmail(),
|
||||||
|
ActionType.ADDED, ActionType.ADDED, cntEntity, cntEntity, cntEntity);
|
||||||
|
|
||||||
List<DeviceProfile> loadedDeviceProfiles = new ArrayList<>();
|
List<DeviceProfile> loadedDeviceProfiles = new ArrayList<>();
|
||||||
pageLink = new PageLink(17);
|
pageLink = new PageLink(17);
|
||||||
do {
|
do {
|
||||||
pageData = doGetTypedWithPageLink("/api/deviceProfiles?",
|
pageData = doGetTypedWithPageLink("/api/deviceProfiles?",
|
||||||
new TypeReference<PageData<DeviceProfile>>(){}, pageLink);
|
new TypeReference<>() {
|
||||||
|
}, pageLink);
|
||||||
loadedDeviceProfiles.addAll(pageData.getData());
|
loadedDeviceProfiles.addAll(pageData.getData());
|
||||||
if (pageData.hasNext()) {
|
if (pageData.hasNext()) {
|
||||||
pageLink = pageLink.nextPageLink();
|
pageLink = pageLink.nextPageLink();
|
||||||
@ -305,9 +392,14 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(loadedDeviceProfiles.get(0), loadedDeviceProfiles.get(0),
|
||||||
|
savedTenant.getId(), tenantAdmin.getCustomerId(), tenantAdmin.getId(), tenantAdmin.getEmail(),
|
||||||
|
ActionType.DELETED, ActionType.DELETED, cntEntity, cntEntity, cntEntity, loadedDeviceProfiles.get(0).getId().getId().toString());
|
||||||
|
|
||||||
pageLink = new PageLink(17);
|
pageLink = new PageLink(17);
|
||||||
pageData = doGetTypedWithPageLink("/api/deviceProfiles?",
|
pageData = doGetTypedWithPageLink("/api/deviceProfiles?",
|
||||||
new TypeReference<PageData<DeviceProfile>>(){}, pageLink);
|
new TypeReference<>() {
|
||||||
|
}, pageLink);
|
||||||
Assert.assertFalse(pageData.hasNext());
|
Assert.assertFalse(pageData.hasNext());
|
||||||
Assert.assertEquals(1, pageData.getTotalElements());
|
Assert.assertEquals(1, pageData.getTotalElements());
|
||||||
}
|
}
|
||||||
@ -317,13 +409,14 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
List<DeviceProfile> deviceProfiles = new ArrayList<>();
|
List<DeviceProfile> deviceProfiles = new ArrayList<>();
|
||||||
PageLink pageLink = new PageLink(17);
|
PageLink pageLink = new PageLink(17);
|
||||||
PageData<DeviceProfile> deviceProfilePageData = doGetTypedWithPageLink("/api/deviceProfiles?",
|
PageData<DeviceProfile> deviceProfilePageData = doGetTypedWithPageLink("/api/deviceProfiles?",
|
||||||
new TypeReference<PageData<DeviceProfile>>(){}, pageLink);
|
new TypeReference<PageData<DeviceProfile>>() {
|
||||||
|
}, pageLink);
|
||||||
Assert.assertFalse(deviceProfilePageData.hasNext());
|
Assert.assertFalse(deviceProfilePageData.hasNext());
|
||||||
Assert.assertEquals(1, deviceProfilePageData.getTotalElements());
|
Assert.assertEquals(1, deviceProfilePageData.getTotalElements());
|
||||||
deviceProfiles.addAll(deviceProfilePageData.getData());
|
deviceProfiles.addAll(deviceProfilePageData.getData());
|
||||||
|
|
||||||
for (int i=0;i<28;i++) {
|
for (int i = 0; i < 28; i++) {
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"+i);
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile" + i);
|
||||||
deviceProfiles.add(doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class));
|
deviceProfiles.add(doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +425,8 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
PageData<DeviceProfileInfo> pageData;
|
PageData<DeviceProfileInfo> pageData;
|
||||||
do {
|
do {
|
||||||
pageData = doGetTypedWithPageLink("/api/deviceProfileInfos?",
|
pageData = doGetTypedWithPageLink("/api/deviceProfileInfos?",
|
||||||
new TypeReference<PageData<DeviceProfileInfo>>(){}, pageLink);
|
new TypeReference<>() {
|
||||||
|
}, pageLink);
|
||||||
loadedDeviceProfileInfos.addAll(pageData.getData());
|
loadedDeviceProfileInfos.addAll(pageData.getData());
|
||||||
if (pageData.hasNext()) {
|
if (pageData.hasNext()) {
|
||||||
pageLink = pageLink.nextPageLink();
|
pageLink = pageLink.nextPageLink();
|
||||||
@ -357,7 +451,8 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
|
|
||||||
pageLink = new PageLink(17);
|
pageLink = new PageLink(17);
|
||||||
pageData = doGetTypedWithPageLink("/api/deviceProfileInfos?",
|
pageData = doGetTypedWithPageLink("/api/deviceProfileInfos?",
|
||||||
new TypeReference<PageData<DeviceProfileInfo>>(){}, pageLink);
|
new TypeReference<PageData<DeviceProfileInfo>>() {
|
||||||
|
}, pageLink);
|
||||||
Assert.assertFalse(pageData.hasNext());
|
Assert.assertFalse(pageData.hasNext());
|
||||||
Assert.assertEquals(1, pageData.getTotalElements());
|
Assert.assertEquals(1, pageData.getTotalElements());
|
||||||
}
|
}
|
||||||
@ -867,7 +962,7 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
Assert.assertTrue(savedDeviceProfile.getProfileData().getTransportConfiguration() instanceof MqttDeviceProfileTransportConfiguration);
|
Assert.assertTrue(savedDeviceProfile.getProfileData().getTransportConfiguration() instanceof MqttDeviceProfileTransportConfiguration);
|
||||||
MqttDeviceProfileTransportConfiguration transportConfiguration = (MqttDeviceProfileTransportConfiguration) savedDeviceProfile.getProfileData().getTransportConfiguration();
|
MqttDeviceProfileTransportConfiguration transportConfiguration = (MqttDeviceProfileTransportConfiguration) savedDeviceProfile.getProfileData().getTransportConfiguration();
|
||||||
Assert.assertTrue(transportConfiguration.isSendAckOnValidationException());
|
Assert.assertTrue(transportConfiguration.isSendAckOnValidationException());
|
||||||
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/"+ savedDeviceProfile.getId().getId().toString(), DeviceProfile.class);
|
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString(), DeviceProfile.class);
|
||||||
Assert.assertEquals(savedDeviceProfile, foundDeviceProfile);
|
Assert.assertEquals(savedDeviceProfile, foundDeviceProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,7 +972,7 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile", mqttDeviceProfileTransportConfiguration);
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile", mqttDeviceProfileTransportConfiguration);
|
||||||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
|
||||||
Assert.assertNotNull(savedDeviceProfile);
|
Assert.assertNotNull(savedDeviceProfile);
|
||||||
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/"+ savedDeviceProfile.getId().getId().toString(), DeviceProfile.class);
|
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString(), DeviceProfile.class);
|
||||||
Assert.assertEquals(savedDeviceProfile, foundDeviceProfile);
|
Assert.assertEquals(savedDeviceProfile, foundDeviceProfile);
|
||||||
return savedDeviceProfile;
|
return savedDeviceProfile;
|
||||||
}
|
}
|
||||||
@ -886,16 +981,30 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
ProtoTransportPayloadConfiguration protoTransportPayloadConfiguration = this.createProtoTransportPayloadConfiguration(schema, schema, null, null);
|
ProtoTransportPayloadConfiguration protoTransportPayloadConfiguration = this.createProtoTransportPayloadConfiguration(schema, schema, null, null);
|
||||||
MqttDeviceProfileTransportConfiguration mqttDeviceProfileTransportConfiguration = this.createMqttDeviceProfileTransportConfiguration(protoTransportPayloadConfiguration, false);
|
MqttDeviceProfileTransportConfiguration mqttDeviceProfileTransportConfiguration = this.createMqttDeviceProfileTransportConfiguration(protoTransportPayloadConfiguration, false);
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile", mqttDeviceProfileTransportConfiguration);
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile", mqttDeviceProfileTransportConfiguration);
|
||||||
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isBadRequest())
|
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
|
doPost("/api/deviceProfile", deviceProfile)
|
||||||
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(errorMsg)));
|
.andExpect(statusReason(containsString(errorMsg)));
|
||||||
|
|
||||||
|
testNotifyEntityEqualsOneTimeServiceNeverError(deviceProfile,savedTenant.getId(),
|
||||||
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(errorMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testSaveDeviceProfileWithInvalidRpcRequestProtoSchema(String schema, String errorMsg) throws Exception {
|
private void testSaveDeviceProfileWithInvalidRpcRequestProtoSchema(String schema, String errorMsg) throws Exception {
|
||||||
ProtoTransportPayloadConfiguration protoTransportPayloadConfiguration = this.createProtoTransportPayloadConfiguration(schema, schema, schema, null);
|
ProtoTransportPayloadConfiguration protoTransportPayloadConfiguration = this.createProtoTransportPayloadConfiguration(schema, schema, schema, null);
|
||||||
MqttDeviceProfileTransportConfiguration mqttDeviceProfileTransportConfiguration = this.createMqttDeviceProfileTransportConfiguration(protoTransportPayloadConfiguration, false);
|
MqttDeviceProfileTransportConfiguration mqttDeviceProfileTransportConfiguration = this.createMqttDeviceProfileTransportConfiguration(protoTransportPayloadConfiguration, false);
|
||||||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile", mqttDeviceProfileTransportConfiguration);
|
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile", mqttDeviceProfileTransportConfiguration);
|
||||||
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isBadRequest())
|
|
||||||
|
Mockito.reset(tbClusterService, auditLogService);
|
||||||
|
|
||||||
|
doPost("/api/deviceProfile", deviceProfile)
|
||||||
|
.andExpect(status().isBadRequest())
|
||||||
.andExpect(statusReason(containsString(errorMsg)));
|
.andExpect(statusReason(containsString(errorMsg)));
|
||||||
|
|
||||||
|
testNotifyEntityEqualsOneTimeServiceNeverError(deviceProfile,savedTenant.getId(),
|
||||||
|
tenantAdmin.getId(), tenantAdmin.getEmail(), ActionType.ADDED, new DataValidationException(errorMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
private DynamicSchema getDynamicSchema(String schema) throws Exception {
|
private DynamicSchema getDynamicSchema(String schema) throws Exception {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user