use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class JpaBasePluginDaoTest method createPlugin.
private void createPlugin(UUID tenantId, String namePrefix, int i) {
PluginMetaData plugin = new PluginMetaData();
plugin.setId(new PluginId(UUIDs.timeBased()));
plugin.setTenantId(new TenantId(tenantId));
plugin.setName(namePrefix + i);
pluginDao.save(plugin);
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginServiceTest method findPluginByTenantIdAndApiToken.
@Test
public void findPluginByTenantIdAndApiToken() throws Exception {
String token = UUID.randomUUID().toString();
TenantId tenantId = new TenantId(UUIDs.timeBased());
pluginService.savePlugin(generatePlugin(null, null));
pluginService.savePlugin(generatePlugin(tenantId, null));
pluginService.savePlugin(generatePlugin(tenantId, null));
pluginService.savePlugin(generatePlugin(tenantId, null));
PluginMetaData expected = pluginService.savePlugin(generatePlugin(tenantId, token));
Assert.assertNotNull(expected.getId());
PluginMetaData found = pluginService.findPluginByApiToken(token);
Assert.assertEquals(expected, found);
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginServiceTest method savePlugin.
@Test
public void savePlugin() throws Exception {
PluginMetaData pluginMetaData = pluginService.savePlugin(generatePlugin(null, null));
Assert.assertNotNull(pluginMetaData.getId());
Assert.assertNotNull(pluginMetaData.getAdditionalInfo());
pluginMetaData.setAdditionalInfo(mapper.readTree("{\"description\":\"test\"}"));
PluginMetaData newPluginMetaData = pluginService.savePlugin(pluginMetaData);
Assert.assertEquals(pluginMetaData.getAdditionalInfo(), newPluginMetaData.getAdditionalInfo());
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginServiceTest method findSystemPlugins.
@Test
public void findSystemPlugins() throws Exception {
// system tenant id
TenantId systemTenant = new TenantId(ModelConstants.NULL_UUID);
pluginService.savePlugin(generatePlugin(null, null));
pluginService.savePlugin(generatePlugin(null, null));
pluginService.savePlugin(generatePlugin(systemTenant, null));
pluginService.savePlugin(generatePlugin(systemTenant, null));
TextPageData<PluginMetaData> found = pluginService.findSystemPlugins(new TextPageLink(100));
Assert.assertEquals(2, found.getData().size());
Assert.assertFalse(found.hasNext());
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BaseRuleServiceTest method deleteRuleById.
@Test
public void deleteRuleById() throws Exception {
PluginMetaData plugin = generatePlugin(null, "testPluginToken" + ThreadLocalRandom.current().nextInt());
pluginService.savePlugin(plugin);
RuleMetaData expected = ruleService.saveRule(generateRule(plugin.getTenantId(), null, plugin.getApiToken()));
Assert.assertNotNull(expected.getId());
RuleMetaData found = ruleService.findRuleById(expected.getId());
Assert.assertEquals(expected, found);
ruleService.deleteRuleById(expected.getId());
found = ruleService.findRuleById(expected.getId());
Assert.assertNull(found);
}
Aggregations