use of org.thingsboard.server.extensions.api.device.DeviceMetaData in project thingsboard by thingsboard.
the class DeviceAttributesFilterTest method basicMissingAttributesTest.
@Test
public void basicMissingAttributesTest() {
DeviceAttributesFilter filter = new DeviceAttributesFilter();
filter.init(wrap("((typeof nonExistingVal === 'undefined') || nonExistingVal == true) && booleanValue == false"));
List<AttributeKvEntry> clientAttributes = new ArrayList<>();
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));
Assert.assertTrue(filter.filter(ruleCtx, null));
filter.stop();
}
use of org.thingsboard.server.extensions.api.device.DeviceMetaData in project thingsboard by thingsboard.
the class DeviceAttributesFilterTest method basicConflictServerAttributesTest.
@Test
public void basicConflictServerAttributesTest() {
DeviceAttributesFilter filter = new DeviceAttributesFilter();
filter.init(wrap("cs.doubleValue == 1.0 && cs.booleanValue == true && ss.doubleValue == 0.0 && ss.booleanValue == false"));
List<AttributeKvEntry> clientAttributes = new ArrayList<>();
clientAttributes.add(new BaseAttributeKvEntry(new DoubleDataEntry("doubleValue", 1.0), 42));
clientAttributes.add(new BaseAttributeKvEntry(new BooleanDataEntry("booleanValue", true), 42));
List<AttributeKvEntry> serverAttributes = new ArrayList<>();
serverAttributes.add(new BaseAttributeKvEntry(new DoubleDataEntry("doubleValue", 0.0), 42));
serverAttributes.add(new BaseAttributeKvEntry(new BooleanDataEntry("booleanValue", false), 42));
DeviceAttributes attributes = new DeviceAttributes(clientAttributes, serverAttributes, new ArrayList<>());
Mockito.when(ruleCtx.getDeviceMetaData()).thenReturn(new DeviceMetaData(new DeviceId(UUID.randomUUID()), "A", "A", attributes));
Assert.assertTrue(filter.filter(ruleCtx, null));
filter.stop();
}
use of org.thingsboard.server.extensions.api.device.DeviceMetaData in project thingsboard by thingsboard.
the class DeviceAttributesFilterTest method basicServerAttributesTest.
@Test
public void basicServerAttributesTest() {
DeviceAttributesFilter filter = new DeviceAttributesFilter();
filter.init(wrap("doubleValue == 1.0 && booleanValue == false"));
List<AttributeKvEntry> serverAttributes = new ArrayList<>();
serverAttributes.add(new BaseAttributeKvEntry(new DoubleDataEntry("doubleValue", 1.0), 42));
serverAttributes.add(new BaseAttributeKvEntry(new BooleanDataEntry("booleanValue", false), 42));
DeviceAttributes attributes = new DeviceAttributes(new ArrayList<>(), serverAttributes, new ArrayList<>());
Mockito.when(ruleCtx.getDeviceMetaData()).thenReturn(new DeviceMetaData(new DeviceId(UUID.randomUUID()), "A", "A", attributes));
Assert.assertTrue(filter.filter(ruleCtx, null));
filter.stop();
}
use of org.thingsboard.server.extensions.api.device.DeviceMetaData in project thingsboard by thingsboard.
the class DeviceAttributesFilterTest method basicClientAttributesTest.
@Test
public void basicClientAttributesTest() {
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));
Assert.assertTrue(filter.filter(ruleCtx, null));
filter.stop();
}
use of org.thingsboard.server.extensions.api.device.DeviceMetaData 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();
}
Aggregations