|
|
|
@ -51,7 +51,6 @@ import org.thingsboard.server.common.data.User; |
|
|
|
import org.thingsboard.server.common.data.alarm.Alarm; |
|
|
|
import org.thingsboard.server.common.data.alarm.AlarmInfo; |
|
|
|
import org.thingsboard.server.common.data.alarm.AlarmSeverity; |
|
|
|
import org.thingsboard.server.common.data.asset.Asset; |
|
|
|
import org.thingsboard.server.common.data.audit.ActionType; |
|
|
|
import org.thingsboard.server.common.data.edge.Edge; |
|
|
|
import org.thingsboard.server.common.data.id.CustomerId; |
|
|
|
@ -73,7 +72,9 @@ import org.thingsboard.server.dao.exception.DataValidationException; |
|
|
|
import org.thingsboard.server.dao.exception.DeviceCredentialsValidationException; |
|
|
|
import org.thingsboard.server.dao.model.ModelConstants; |
|
|
|
import org.thingsboard.server.dao.service.DaoSqlTest; |
|
|
|
import org.thingsboard.server.gen.transport.TransportProtos; |
|
|
|
import org.thingsboard.server.service.gateway_device.GatewayNotificationsService; |
|
|
|
import org.thingsboard.server.service.state.DeviceStateService; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
@ -82,6 +83,9 @@ import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.hamcrest.Matchers.containsString; |
|
|
|
import static org.mockito.ArgumentMatchers.any; |
|
|
|
import static org.mockito.ArgumentMatchers.argThat; |
|
|
|
import static org.mockito.ArgumentMatchers.eq; |
|
|
|
import static org.mockito.Mockito.never; |
|
|
|
import static org.mockito.Mockito.times; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
@ -106,6 +110,9 @@ public class DeviceControllerTest extends AbstractControllerTest { |
|
|
|
@SpyBean |
|
|
|
private GatewayNotificationsService gatewayNotificationsService; |
|
|
|
|
|
|
|
@SpyBean |
|
|
|
private DeviceStateService deviceStateService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DeviceDao deviceDao; |
|
|
|
|
|
|
|
@ -1340,6 +1347,28 @@ public class DeviceControllerTest extends AbstractControllerTest { |
|
|
|
ActionType.ASSIGNED_TO_TENANT, savedDifferentTenant.getId().getId().toString(), savedDifferentTenant.getTitle()); |
|
|
|
testNotificationUpdateGatewayNever(); |
|
|
|
|
|
|
|
Mockito.verify(deviceStateService, times(1)).onQueueMsg( |
|
|
|
argThat(proto -> |
|
|
|
proto.getTenantIdMSB() == savedTenant.getUuidId().getMostSignificantBits() && |
|
|
|
proto.getTenantIdLSB() == savedTenant.getUuidId().getLeastSignificantBits() && |
|
|
|
proto.getDeviceIdMSB() == savedDevice.getUuidId().getMostSignificantBits() && |
|
|
|
proto.getDeviceIdLSB() == savedDevice.getUuidId().getLeastSignificantBits() && |
|
|
|
proto.getDeleted() |
|
|
|
), |
|
|
|
any() |
|
|
|
); |
|
|
|
|
|
|
|
Mockito.verify(deviceStateService, times(1)).onQueueMsg( |
|
|
|
argThat(proto -> |
|
|
|
proto.getTenantIdMSB() == savedDifferentTenant.getUuidId().getMostSignificantBits() && |
|
|
|
proto.getTenantIdLSB() == savedDifferentTenant.getUuidId().getLeastSignificantBits() && |
|
|
|
proto.getDeviceIdMSB() == savedDevice.getUuidId().getMostSignificantBits() && |
|
|
|
proto.getDeviceIdLSB() == savedDevice.getUuidId().getLeastSignificantBits() && |
|
|
|
proto.getAdded() |
|
|
|
), |
|
|
|
any() |
|
|
|
); |
|
|
|
|
|
|
|
login("tenant9@thingsboard.org", "testPassword1"); |
|
|
|
|
|
|
|
Device foundDevice1 = doGet("/api/device/" + assignedDevice.getId().getId(), Device.class); |
|
|
|
|