Search in sources :

Example 6 with DeviceAttributes

use of org.thingsboard.server.extensions.api.device.DeviceAttributes in project thingsboard by thingsboard.

the class DeviceAttributesFilterTest method basicClientAttributesStressTest.

@Test(timeout = 30000)
public void basicClientAttributesStressTest() {
    DeviceAttributesFilter filter = new DeviceAttributesFilter();
    filter.init(wrap("doubleValue == 1.0 && booleanValue == false"));
    List<AttributeKvEntry> clientAttributes = new ArrayList<>();
    clientAttributes.add(new BaseAttributeKvEntry(new DoubleDataEntry("doubleValue", 1.0), 42));
    clientAttributes.add(new BaseAttributeKvEntry(new BooleanDataEntry("booleanValue", false), 42));
    DeviceAttributes attributes = new DeviceAttributes(clientAttributes, new ArrayList<>(), new ArrayList<>());
    Mockito.when(ruleCtx.getDeviceMetaData()).thenReturn(new DeviceMetaData(new DeviceId(UUID.randomUUID()), "A", "A", attributes));
    for (int i = 0; i < 10000; i++) {
        Assert.assertTrue(filter.filter(ruleCtx, null));
    }
    filter.stop();
}
Also used : BaseAttributeKvEntry(org.thingsboard.server.common.data.kv.BaseAttributeKvEntry) AttributeKvEntry(org.thingsboard.server.common.data.kv.AttributeKvEntry) DoubleDataEntry(org.thingsboard.server.common.data.kv.DoubleDataEntry) BooleanDataEntry(org.thingsboard.server.common.data.kv.BooleanDataEntry) DeviceId(org.thingsboard.server.common.data.id.DeviceId) ArrayList(java.util.ArrayList) DeviceAttributes(org.thingsboard.server.extensions.api.device.DeviceAttributes) BaseAttributeKvEntry(org.thingsboard.server.common.data.kv.BaseAttributeKvEntry) DeviceMetaData(org.thingsboard.server.extensions.api.device.DeviceMetaData) Test(org.junit.Test)

Aggregations

DeviceAttributes (org.thingsboard.server.extensions.api.device.DeviceAttributes)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 DeviceId (org.thingsboard.server.common.data.id.DeviceId)5 AttributeKvEntry (org.thingsboard.server.common.data.kv.AttributeKvEntry)5 BaseAttributeKvEntry (org.thingsboard.server.common.data.kv.BaseAttributeKvEntry)5 BooleanDataEntry (org.thingsboard.server.common.data.kv.BooleanDataEntry)5 DeviceMetaData (org.thingsboard.server.extensions.api.device.DeviceMetaData)5 DoubleDataEntry (org.thingsboard.server.common.data.kv.DoubleDataEntry)4 VelocityContext (org.apache.velocity.VelocityContext)1 DateTool (org.apache.velocity.tools.generic.DateTool)1