Search in sources :

Example 11 with PluginMetaData

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);
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) PluginMetaData(org.thingsboard.server.common.data.plugin.PluginMetaData) PluginId(org.thingsboard.server.common.data.id.PluginId)

Example 12 with PluginMetaData

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);
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) PluginMetaData(org.thingsboard.server.common.data.plugin.PluginMetaData) AbstractServiceTest(org.thingsboard.server.dao.service.AbstractServiceTest) Test(org.junit.Test)

Example 13 with PluginMetaData

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());
}
Also used : PluginMetaData(org.thingsboard.server.common.data.plugin.PluginMetaData) AbstractServiceTest(org.thingsboard.server.dao.service.AbstractServiceTest) Test(org.junit.Test)

Example 14 with PluginMetaData

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());
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) TextPageLink(org.thingsboard.server.common.data.page.TextPageLink) PluginMetaData(org.thingsboard.server.common.data.plugin.PluginMetaData) AbstractServiceTest(org.thingsboard.server.dao.service.AbstractServiceTest) Test(org.junit.Test)

Example 15 with PluginMetaData

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);
}
Also used : PluginMetaData(org.thingsboard.server.common.data.plugin.PluginMetaData) RuleMetaData(org.thingsboard.server.common.data.rule.RuleMetaData) AbstractServiceTest(org.thingsboard.server.dao.service.AbstractServiceTest) Test(org.junit.Test)

Aggregations

PluginMetaData (org.thingsboard.server.common.data.plugin.PluginMetaData)50 Test (org.junit.Test)24 TenantId (org.thingsboard.server.common.data.id.TenantId)17 AbstractServiceTest (org.thingsboard.server.dao.service.AbstractServiceTest)14 TextPageLink (org.thingsboard.server.common.data.page.TextPageLink)13 RuleMetaData (org.thingsboard.server.common.data.rule.RuleMetaData)13 PluginId (org.thingsboard.server.common.data.id.PluginId)8 TelemetryStoragePlugin (org.thingsboard.server.extensions.core.plugin.telemetry.TelemetryStoragePlugin)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 ThingsboardException (org.thingsboard.server.exception.ThingsboardException)5 ArrayList (java.util.ArrayList)4 TextPageData (org.thingsboard.server.common.data.page.TextPageData)4 List (java.util.List)3 UUID (java.util.UUID)3 Before (org.junit.Before)3 Tenant (org.thingsboard.server.common.data.Tenant)3 ComponentDescriptor (org.thingsboard.server.common.data.plugin.ComponentDescriptor)3 IncorrectParameterException (org.thingsboard.server.dao.exception.IncorrectParameterException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)2