@ -29,10 +29,9 @@ import org.thingsboard.rule.engine.api.RuleEngineDeviceProfileCache;
import org.thingsboard.rule.engine.api.TbContext ;
import org.thingsboard.rule.engine.api.TbNodeConfiguration ;
import org.thingsboard.rule.engine.api.TbNodeException ;
import org.thingsboard.server.common.data.DataConstants ;
import org.thingsboard.server.common.data.AttributeScope ;
import org.thingsboard.server.common.data.Device ;
import org.thingsboard.server.common.data.DeviceProfile ;
import org.thingsboard.server.common.data.EntityType ;
import org.thingsboard.server.common.data.alarm.Alarm ;
import org.thingsboard.server.common.data.alarm.AlarmApiCallResult ;
import org.thingsboard.server.common.data.alarm.AlarmInfo ;
@ -59,7 +58,6 @@ import org.thingsboard.server.common.data.msg.TbMsgType;
import org.thingsboard.server.common.data.query.BooleanFilterPredicate ;
import org.thingsboard.server.common.data.query.DynamicValue ;
import org.thingsboard.server.common.data.query.DynamicValueSourceType ;
import org.thingsboard.server.common.data.query.EntityKeyType ;
import org.thingsboard.server.common.data.query.EntityKeyValueType ;
import org.thingsboard.server.common.data.query.FilterPredicateValue ;
import org.thingsboard.server.common.data.query.NumericFilterPredicate ;
@ -321,12 +319,13 @@ public class TbDeviceProfileNodeTest {
device . setCustomerId ( customerId ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "alarmEnabled"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setBooleanValue ( Boolean . TRUE ) ;
attributeKvEntity . setStrKey ( "alarmEnabled" ) ;
attributeKvEntity . setLastUpdateTs ( System . currentTimeMillis ( ) ) ;
AttributeKvEntry entry = attributeKvEntity . toData ( ) ;
@ -372,7 +371,7 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( attrListListenableFuture ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -403,11 +402,12 @@ public class TbDeviceProfileNodeTest {
device . setCustomerId ( customerId ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , tenantId . getId ( ) , "SERVER_SCOPE" , "alarmEnabled"
tenantId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "alarmEnabled" ) ;
attributeKvEntity . setBooleanValue ( Boolean . TRUE ) ;
attributeKvEntity . setLastUpdateTs ( System . currentTimeMillis ( ) ) ;
@ -455,11 +455,11 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( Futures . immediateFuture ( Collections . emptyList ( ) ) ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , Mockito . any ( AttributeScope . class ) , Mockito . anyString ( ) ) )
. thenReturn ( Futures . immediateFuture ( Optional . empty ( ) ) ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , Mockito . any ( AttributeScope . class ) , Mockito . anyString ( ) ) )
. thenReturn ( attrListListenableFuture ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -486,11 +486,12 @@ public class TbDeviceProfileNodeTest {
DeviceProfileData deviceProfileData = new DeviceProfileData ( ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "greaterAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "greaterAttribute" ) ;
attributeKvEntity . setLongValue ( 30L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -528,7 +529,7 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFutureWithLess ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -555,20 +556,22 @@ public class TbDeviceProfileNodeTest {
DeviceProfileData deviceProfileData = new DeviceProfileData ( ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "greaterAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "greaterAttribute" ) ;
attributeKvEntity . setLongValue ( 30L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
AttributeKvCompositeKey alarmDelayCompositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "alarm_delay"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 11
) ;
AttributeKvEntity alarmDelayAttributeKvEntity = new AttributeKvEntity ( ) ;
alarmDelayAttributeKvEntity . setId ( alarmDelayCompositeKey ) ;
alarmDelayAttributeKvEntity . setStrKey ( "alarm_delay" ) ;
long alarmDelayInSeconds = 5L ;
alarmDelayAttributeKvEntity . setLongValue ( alarmDelayInSeconds ) ;
alarmDelayAttributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -622,7 +625,7 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFuture ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -669,20 +672,22 @@ public class TbDeviceProfileNodeTest {
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "greaterAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "greaterAttribute" ) ;
attributeKvEntity . setLongValue ( 30L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
AttributeKvCompositeKey alarmDelayCompositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "alarm_delay"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 11
) ;
AttributeKvEntity alarmDelayAttributeKvEntity = new AttributeKvEntity ( ) ;
alarmDelayAttributeKvEntity . setId ( alarmDelayCompositeKey ) ;
alarmDelayAttributeKvEntity . setStrKey ( "alarm_delay" ) ;
long alarmDelayInSeconds = 5L ;
alarmDelayAttributeKvEntity . setLongValue ( alarmDelayInSeconds ) ;
alarmDelayAttributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -740,13 +745,13 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , Mockito . any ( AttributeScope . class ) , Mockito . anyString ( ) ) )
. thenReturn ( optionalDurationAttribute ) ;
Mockito . when ( ctx . getDeviceService ( ) . findDeviceById ( tenantId , deviceId ) )
. thenReturn ( device ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , eq ( DataConstants . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , eq ( AttributeScope . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
. thenReturn ( emptyOptional ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listNoDurationAttribute ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -788,20 +793,22 @@ public class TbDeviceProfileNodeTest {
DeviceProfileData deviceProfileData = new DeviceProfileData ( ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "greaterAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "greaterAttribute" ) ;
attributeKvEntity . setLongValue ( 30L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
AttributeKvCompositeKey alarmDelayCompositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "alarm_delay"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 11
) ;
AttributeKvEntity alarmDelayAttributeKvEntity = new AttributeKvEntity ( ) ;
alarmDelayAttributeKvEntity . setId ( alarmDelayCompositeKey ) ;
alarmDelayAttributeKvEntity . setStrKey ( "alarm_delay" ) ;
long alarmRepeating = 2 ;
alarmDelayAttributeKvEntity . setLongValue ( alarmRepeating ) ;
alarmDelayAttributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -855,7 +862,7 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFuture ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -891,7 +898,7 @@ public class TbDeviceProfileNodeTest {
DeviceProfileData deviceProfileData = new DeviceProfileData ( ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "greaterAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
Device device = new Device ( ) ;
@ -900,15 +907,17 @@ public class TbDeviceProfileNodeTest {
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "greaterAttribute" ) ;
attributeKvEntity . setLongValue ( 30L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
AttributeKvCompositeKey alarmDelayCompositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "alarm_delay"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 11
) ;
AttributeKvEntity alarmDelayAttributeKvEntity = new AttributeKvEntity ( ) ;
alarmDelayAttributeKvEntity . setId ( alarmDelayCompositeKey ) ;
alarmDelayAttributeKvEntity . setStrKey ( "alarm_delay" ) ;
long repeatingCondition = 2 ;
alarmDelayAttributeKvEntity . setLongValue ( repeatingCondition ) ;
alarmDelayAttributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -965,13 +974,13 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , Mockito . any ( AttributeScope . class ) , Mockito . anyString ( ) ) )
. thenReturn ( optionalDurationAttribute ) ;
Mockito . when ( ctx . getDeviceService ( ) . findDeviceById ( tenantId , deviceId ) )
. thenReturn ( device ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , eq ( DataConstants . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , eq ( AttributeScope . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
. thenReturn ( emptyOptional ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listNoDurationAttribute ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -1012,11 +1021,12 @@ public class TbDeviceProfileNodeTest {
device . setCustomerId ( customerId ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "greaterAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "greaterAttribute" ) ;
attributeKvEntity . setLongValue ( 30L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -1067,7 +1077,7 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFuture ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -1113,11 +1123,12 @@ public class TbDeviceProfileNodeTest {
device . setCustomerId ( customerId ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "greaterAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "greaterAttribute" ) ;
attributeKvEntity . setLongValue ( 30L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -1165,7 +1176,7 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFuture ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -1196,11 +1207,12 @@ public class TbDeviceProfileNodeTest {
device . setCustomerId ( customerId ) ;
AttributeKvCompositeKey compositeKeyActiveSchedule = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "dynamicValueActiveSchedule"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntityActiveSchedule = new AttributeKvEntity ( ) ;
attributeKvEntityActiveSchedule . setId ( compositeKeyActiveSchedule ) ;
attributeKvEntityActiveSchedule . setStrKey ( "dynamicValueActiveSchedule" ) ;
attributeKvEntityActiveSchedule . setJsonValue (
"{\"timezone\":\"Europe/Kiev\",\"items\":[{\"enabled\":true,\"dayOfWeek\":1,\"startsOn\":0,\"endsOn\":8.64e+7},{\"enabled\":true,\"dayOfWeek\":2,\"startsOn\":0,\"endsOn\":8.64e+7},{\"enabled\":true,\"dayOfWeek\":3,\"startsOn\":0,\"endsOn\":8.64e+7},{\"enabled\":true,\"dayOfWeek\":4,\"startsOn\":0,\"endsOn\":8.64e+7},{\"enabled\":true,\"dayOfWeek\":5,\"startsOn\":0,\"endsOn\":8.64e+7},{\"enabled\":true,\"dayOfWeek\":6,\"startsOn\":0,\"endsOn\":8.64e+7},{\"enabled\":true,\"dayOfWeek\":7,\"startsOn\":0,\"endsOn\":8.64e+7}],\"dynamicValue\":null}"
) ;
@ -1247,7 +1259,7 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFutureActiveSchedule ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -1280,11 +1292,12 @@ public class TbDeviceProfileNodeTest {
device . setCustomerId ( customerId ) ;
AttributeKvCompositeKey compositeKeyInactiveSchedule = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "dynamicValueInactiveSchedule"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntityInactiveSchedule = new AttributeKvEntity ( ) ;
attributeKvEntityInactiveSchedule . setId ( compositeKeyInactiveSchedule ) ;
attributeKvEntityInactiveSchedule . setStrKey ( "dynamicValueInactiveSchedule" ) ;
attributeKvEntityInactiveSchedule . setJsonValue (
"{\"timezone\":\"Europe/Kiev\",\"items\":[{\"enabled\":false,\"dayOfWeek\":1,\"startsOn\":0,\"endsOn\":0},{\"enabled\":false,\"dayOfWeek\":2,\"startsOn\":0,\"endsOn\":0},{\"enabled\":false,\"dayOfWeek\":3,\"startsOn\":0,\"endsOn\":0},{\"enabled\":false,\"dayOfWeek\":4,\"startsOn\":0,\"endsOn\":0},{\"enabled\":false,\"dayOfWeek\":5,\"startsOn\":0,\"endsOn\":0},{\"enabled\":false,\"dayOfWeek\":6,\"startsOn\":0,\"endsOn\":0},{\"enabled\":false,\"dayOfWeek\":7,\"startsOn\":0,\"endsOn\":0}],\"dynamicValue\":null}"
) ;
@ -1343,7 +1356,7 @@ public class TbDeviceProfileNodeTest {
Mockito . when ( alarmService . findLatestActiveByOriginatorAndType ( tenantId , deviceId , "highTemperatureAlarm" ) )
. thenReturn ( null ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFutureInactiveSchedule ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -1372,11 +1385,12 @@ public class TbDeviceProfileNodeTest {
device . setCustomerId ( customerId ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . CUSTOMER , deviceId . getId ( ) , "SERVER_SCOPE" , "lessAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "lessAttribute" ) ;
attributeKvEntity . setLongValue ( 30L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -1417,11 +1431,11 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFutureWithLess ) ;
Mockito . when ( ctx . getDeviceService ( ) . findDeviceById ( tenantId , deviceId ) )
. thenReturn ( device ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , eq ( DataConstants . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , eq ( AttributeScope . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
. thenReturn ( optionalListenableFutureWithLess ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -1447,11 +1461,12 @@ public class TbDeviceProfileNodeTest {
DeviceProfileData deviceProfileData = new DeviceProfileData ( ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "lessAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "lessAttribute" ) ;
attributeKvEntity . setLongValue ( 50L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -1492,9 +1507,9 @@ public class TbDeviceProfileNodeTest {
. thenReturn ( null ) ;
registerCreateAlarmMock ( alarmService . createAlarm ( any ( ) ) , true ) ;
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFutureWithLess ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , eq ( DataConstants . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , eq ( AttributeScope . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
. thenReturn ( optionalListenableFutureWithLess ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -1520,7 +1535,7 @@ public class TbDeviceProfileNodeTest {
DeviceProfileData deviceProfileData = new DeviceProfileData ( ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . TENANT , deviceId . getId ( ) , "SERVER_SCOPE" , "tenantAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
Device device = new Device ( ) ;
@ -1529,6 +1544,7 @@ public class TbDeviceProfileNodeTest {
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "tenantAttribute" ) ;
attributeKvEntity . setLongValue ( 100L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -1573,11 +1589,11 @@ public class TbDeviceProfileNodeTest {
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( ctx . getDeviceService ( ) . findDeviceById ( tenantId , deviceId ) )
. thenReturn ( device ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFutureWithLess ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , Mockito . any ( AttributeScope . class ) , Mockito . anyString ( ) ) )
. thenReturn ( emptyOptionalFuture ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , eq ( DataConstants . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , eq ( AttributeScope . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
. thenReturn ( optionalListenableFutureWithLess ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;
@ -1605,7 +1621,7 @@ public class TbDeviceProfileNodeTest {
DeviceProfileData deviceProfileData = new DeviceProfileData ( ) ;
AttributeKvCompositeKey compositeKey = new AttributeKvCompositeKey (
EntityType . DEVICE , deviceId . getId ( ) , EntityKeyType . SERVER_ATTRIBUTE . name ( ) , "tenantAttribute"
deviceId . getId ( ) , AttributeScope . SERVER_SCOPE . getId ( ) , 10
) ;
Device device = new Device ( ) ;
@ -1614,6 +1630,7 @@ public class TbDeviceProfileNodeTest {
AttributeKvEntity attributeKvEntity = new AttributeKvEntity ( ) ;
attributeKvEntity . setId ( compositeKey ) ;
attributeKvEntity . setStrKey ( "tenantAttribute" ) ;
attributeKvEntity . setLongValue ( 100L ) ;
attributeKvEntity . setLastUpdateTs ( 0L ) ;
@ -1658,11 +1675,11 @@ public class TbDeviceProfileNodeTest {
Mockito . when ( ctx . getAttributesService ( ) ) . thenReturn ( attributesService ) ;
Mockito . when ( ctx . getDeviceService ( ) . findDeviceById ( tenantId , deviceId ) )
. thenReturn ( device ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . anyString ( ) , Mockito . anySet ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( deviceId ) , Mockito . any ( AttributeScope . class ) , Mockito . anySet ( ) ) )
. thenReturn ( listListenableFutureWithLess ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( customerId ) , Mockito . any ( AttributeScope . class ) , Mockito . anyString ( ) ) )
. thenReturn ( emptyOptionalFuture ) ;
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , eq ( DataConstants . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
Mockito . when ( attributesService . find ( eq ( tenantId ) , eq ( tenantId ) , eq ( AttributeScope . SERVER_SCOPE ) , Mockito . anyString ( ) ) )
. thenReturn ( optionalListenableFutureWithLess ) ;
TbMsg theMsg = TbMsg . newMsg ( TbMsgType . ALARM , deviceId , TbMsgMetaData . EMPTY , TbMsg . EMPTY_STRING ) ;