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"); validateId((UUIDBased) entityId, "Invalid entity id");
SecurityUser user = getCurrentUser(); SecurityUser user = getCurrentUser();
E entity = findingFunction.apply(user.getTenantId(), entityId); 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); return checkEntity(user, entity, operation);
} catch (Exception e) { } catch (Exception e) {
throw handleException(e, false); 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()); return handleUnsupportedMsgType(deviceUpdateMsg.getMsgType());
} }
} catch (DataValidationException e) { } 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); log.warn("[{}] Number of allowed devices violated {}", tenantId, deviceUpdateMsg, e);
return Futures.immediateFuture(null); return Futures.immediateFuture(null);
} else { } 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) doPost("/api/device/credentials", deviceCredentials)
.andExpect(status().isBadRequest()) .andExpect(status().isBadRequest())
.andExpect(statusReason(containsString("Incorrect deviceId null"))); .andExpect(statusReason(containsString("Invalid entity id")));
testNotifyEntityNever(deviceCredentials.getDeviceId(), new Device()); testNotifyEntityNever(deviceCredentials.getDeviceId(), new Device());
testNotificationUpdateGatewayNever(); 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) { for (Queue queue : foundTenantQueues) {
doGet("/api/queues/" + queue.getId()) doGet("/api/queues/" + queue.getId())
.andExpect(status().isNotFound()) .andExpect(status().isNotFound())
.andExpect(statusReason(containsString(msgErrorNotFound))); .andExpect(statusReason(containsString(msgErrorNoFound("Queue", queue.getId().toString()))));
} }
loginSysAdmin(); loginSysAdmin();

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

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