Browse Source

Fix tests

pull/7911/head
ViacheslavKlimov 4 years ago
parent
commit
54f9240c08
  1. 2
      application/src/main/java/org/thingsboard/server/controller/BaseController.java
  2. 2
      application/src/main/java/org/thingsboard/server/service/edge/rpc/processor/device/DeviceEdgeProcessor.java
  3. 2
      application/src/test/java/org/thingsboard/server/controller/BaseDeviceControllerTest.java
  4. 2
      application/src/test/java/org/thingsboard/server/controller/BaseTenantControllerTest.java
  5. 6
      application/src/test/java/org/thingsboard/server/service/entitiy/alarm/DefaultTbAlarmServiceTest.java
  6. 3
      common/data/src/main/java/org/thingsboard/server/common/data/EntityType.java

2
application/src/main/java/org/thingsboard/server/controller/BaseController.java

@ -605,7 +605,7 @@ public abstract class BaseController {
validateId((UUIDBased) entityId, "Invalid entity id");
SecurityUser user = getCurrentUser();
E entity = findingFunction.apply(user.getTenantId(), entityId);
checkNotNull(entity, entityId.getEntityType() + " with id [" + entityId + "] not found");
checkNotNull(entity, entityId.getEntityType().getNormalName() + " with id [" + entityId + "] is not found");
return checkEntity(user, entity, operation);
} catch (Exception e) {
throw handleException(e, false);

2
application/src/main/java/org/thingsboard/server/service/edge/rpc/processor/device/DeviceEdgeProcessor.java

@ -87,7 +87,7 @@ public class DeviceEdgeProcessor extends BaseDeviceProcessor {
return handleUnsupportedMsgType(deviceUpdateMsg.getMsgType());
}
} catch (DataValidationException e) {
if (e.getMessage().contains("Can't create more then")) {
if (e.getMessage().contains("limit reached")) {
log.warn("[{}] Number of allowed devices violated {}", tenantId, deviceUpdateMsg, e);
return Futures.immediateFuture(null);
} else {

2
application/src/test/java/org/thingsboard/server/controller/BaseDeviceControllerTest.java

@ -671,7 +671,7 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest {
doPost("/api/device/credentials", deviceCredentials)
.andExpect(status().isBadRequest())
.andExpect(statusReason(containsString("Incorrect deviceId null")));
.andExpect(statusReason(containsString("Invalid entity id")));
testNotifyEntityNever(deviceCredentials.getDeviceId(), new Device());
testNotificationUpdateGatewayNever();

2
application/src/test/java/org/thingsboard/server/controller/BaseTenantControllerTest.java

@ -511,7 +511,7 @@ public abstract class BaseTenantControllerTest extends AbstractControllerTest {
for (Queue queue : foundTenantQueues) {
doGet("/api/queues/" + queue.getId())
.andExpect(status().isNotFound())
.andExpect(statusReason(containsString(msgErrorNotFound)));
.andExpect(statusReason(containsString(msgErrorNoFound("Queue", queue.getId().toString()))));
}
loginSysAdmin();

6
application/src/test/java/org/thingsboard/server/service/entitiy/alarm/DefaultTbAlarmServiceTest.java

@ -67,7 +67,7 @@ public class DefaultTbAlarmServiceTest {
@MockBean
protected AlarmService alarmService;
@MockBean
protected AlarmCommentService alarmCommentService;
protected TbAlarmCommentService alarmCommentService;
@MockBean
protected AlarmSubscriptionService alarmSubscriptionService;
@MockBean
@ -101,7 +101,7 @@ public class DefaultTbAlarmServiceTest {
.thenReturn(AlarmApiCallResult.builder().successful(true).modified(true).build());
service.ack(alarm, new User(new UserId(UUID.randomUUID())));
verify(alarmCommentService, times(1)).createOrUpdateAlarmComment(any(), any());
verify(alarmCommentService, times(1)).saveAlarmComment(any(), any(), any());
verify(notificationEntityService, times(1)).notifyCreateOrUpdateAlarm(any(), any(), any());
verify(alarmSubscriptionService, times(1)).acknowledgeAlarm(any(), any(), anyLong());
}
@ -114,7 +114,7 @@ public class DefaultTbAlarmServiceTest {
.thenReturn(AlarmApiCallResult.builder().successful(true).cleared(true).build());
service.clear(alarm, new User(new UserId(UUID.randomUUID())));
verify(alarmCommentService, times(1)).createOrUpdateAlarmComment(any(), any());
verify(alarmCommentService, times(1)).saveAlarmComment(any(), any(), any());
verify(notificationEntityService, times(1)).notifyCreateOrUpdateAlarm(any(), any(), any());
verify(alarmSubscriptionService, times(1)).clearAlarm(any(), any(), anyLong(), any());
}

3
common/data/src/main/java/org/thingsboard/server/common/data/EntityType.java

@ -50,6 +50,7 @@ public enum EntityType {
NOTIFICATION_RULE;
@Getter
private final String normalName = StringUtils.capitalize(name().toLowerCase().replaceAll("_", " "));
private final String normalName = StringUtils.capitalize(StringUtils.removeStart(name(), "TB_")
.toLowerCase().replaceAll("_", " "));
}

Loading…
Cancel
Save