use of org.thingsboard.server.common.data.rule.RuleMetaData in project thingsboard by thingsboard.
the class RuleMetaDataEntity method toData.
@Override
public RuleMetaData toData() {
RuleMetaData rule = new RuleMetaData(new RuleId(id));
rule.setTenantId(new TenantId(tenantId));
rule.setName(name);
rule.setState(state);
rule.setWeight(weight);
rule.setCreatedTime(UUIDs.unixTimestamp(id));
rule.setPluginToken(pluginToken);
rule.setFilters(filters);
rule.setProcessor(processor);
rule.setAction(action);
rule.setAdditionalInfo(additionalInfo);
return rule;
}
use of org.thingsboard.server.common.data.rule.RuleMetaData in project thingsboard by thingsboard.
the class RuleMetaDataEntity method toData.
@Override
public RuleMetaData toData() {
RuleMetaData rule = new RuleMetaData(new RuleId(getId()));
rule.setTenantId(new TenantId(toUUID(tenantId)));
rule.setName(name);
rule.setState(state);
rule.setWeight(weight);
rule.setCreatedTime(UUIDs.unixTimestamp(getId()));
rule.setPluginToken(pluginToken);
rule.setFilters(filters);
rule.setProcessor(processor);
rule.setAction(action);
rule.setAdditionalInfo(additionalInfo);
return rule;
}
use of org.thingsboard.server.common.data.rule.RuleMetaData in project thingsboard by thingsboard.
the class JpaBaseRuleDaoTest method getRuleMetaData.
private RuleMetaData getRuleMetaData(UUID id) throws IOException {
RuleMetaData ruleMetaData = new RuleMetaData();
ruleMetaData.setId(new RuleId(id));
ruleMetaData.setTenantId(new TenantId(UUIDs.timeBased()));
ruleMetaData.setName("test");
return ruleMetaData;
}
use of org.thingsboard.server.common.data.rule.RuleMetaData in project thingsboard by thingsboard.
the class JpaBaseRuleDaoTest method testFindAllTenantRulesByTenantId.
@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
public void testFindAllTenantRulesByTenantId() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
createTenantsAndSystemRules(tenantId1, tenantId2, "name_", "token");
List<RuleMetaData> rules1 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_"));
assertEquals(40, rules1.size());
List<RuleMetaData> rules2 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_", rules1.get(19).getId().getId(), null));
assertEquals(20, rules2.size());
List<RuleMetaData> rules3 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_", rules2.get(19).getId().getId(), null));
assertEquals(0, rules3.size());
}
use of org.thingsboard.server.common.data.rule.RuleMetaData in project thingsboard by thingsboard.
the class BaseRuleServiceTest method saveRule.
@Test
public void saveRule() throws Exception {
PluginMetaData plugin = generatePlugin(null, "testPluginToken" + ThreadLocalRandom.current().nextInt());
pluginService.savePlugin(plugin);
RuleMetaData ruleMetaData = ruleService.saveRule(generateRule(plugin.getTenantId(), null, plugin.getApiToken()));
Assert.assertNotNull(ruleMetaData.getId());
Assert.assertNotNull(ruleMetaData.getAdditionalInfo());
ruleMetaData.setAdditionalInfo(mapper.readTree("{\"description\":\"test\"}"));
RuleMetaData newRuleMetaData = ruleService.saveRule(ruleMetaData);
Assert.assertEquals(ruleMetaData.getAdditionalInfo(), newRuleMetaData.getAdditionalInfo());
}
Aggregations