use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginServiceTest method findPluginById.
@Test
public void findPluginById() throws Exception {
PluginMetaData expected = pluginService.savePlugin(generatePlugin(null, null));
Assert.assertNotNull(expected.getId());
PluginMetaData found = pluginService.findPluginById(expected.getId());
Assert.assertEquals(expected, found);
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData 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());
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BaseRuleServiceTest method findRuleById.
@Test
public void findRuleById() 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);
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BaseRuleServiceTest method findPluginRules.
@Test
public void findPluginRules() throws Exception {
TenantId tenantIdA = new TenantId(UUIDs.timeBased());
TenantId tenantIdB = new TenantId(UUIDs.timeBased());
PluginMetaData pluginA = generatePlugin(tenantIdA, "testPluginToken" + ThreadLocalRandom.current().nextInt());
PluginMetaData pluginB = generatePlugin(tenantIdB, "testPluginToken" + ThreadLocalRandom.current().nextInt());
pluginService.savePlugin(pluginA);
pluginService.savePlugin(pluginB);
ruleService.saveRule(generateRule(tenantIdA, null, pluginA.getApiToken()));
ruleService.saveRule(generateRule(tenantIdA, null, pluginA.getApiToken()));
ruleService.saveRule(generateRule(tenantIdA, null, pluginA.getApiToken()));
ruleService.saveRule(generateRule(tenantIdB, null, pluginB.getApiToken()));
ruleService.saveRule(generateRule(tenantIdB, null, pluginB.getApiToken()));
List<RuleMetaData> foundA = ruleService.findPluginRules(pluginA.getApiToken());
Assert.assertEquals(3, foundA.size());
List<RuleMetaData> foundB = ruleService.findPluginRules(pluginB.getApiToken());
Assert.assertEquals(2, foundB.size());
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginControllerTest method testSavePlugin.
@Test
public void testSavePlugin() throws Exception {
PluginMetaData plugin = new PluginMetaData();
doPost("/api/plugin", plugin).andExpect(status().isBadRequest());
plugin.setName("My plugin");
doPost("/api/plugin", plugin).andExpect(status().isBadRequest());
plugin.setApiToken("myplugin");
doPost("/api/plugin", plugin).andExpect(status().isBadRequest());
plugin.setConfiguration(mapper.readTree("{}"));
doPost("/api/plugin", plugin).andExpect(status().isBadRequest());
plugin.setClazz(TelemetryStoragePlugin.class.getName());
PluginMetaData savedPlugin = doPost("/api/plugin", plugin, PluginMetaData.class);
Assert.assertNotNull(savedPlugin);
Assert.assertNotNull(savedPlugin.getId());
Assert.assertTrue(savedPlugin.getCreatedTime() > 0);
Assert.assertEquals(savedTenant.getId(), savedPlugin.getTenantId());
}
Aggregations