use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginControllerTest method testSuspendPlugin.
@Test
public void testSuspendPlugin() throws Exception {
PluginMetaData plugin = new PluginMetaData();
plugin.setName("My plugin");
plugin.setApiToken("myplugin");
plugin.setConfiguration(mapper.readTree("{}"));
plugin.setClazz(TelemetryStoragePlugin.class.getName());
PluginMetaData savedPlugin = doPost("/api/plugin", plugin, PluginMetaData.class);
doPost("/api/plugin/" + savedPlugin.getId().getId().toString() + "/activate").andExpect(status().isOk());
RuleMetaData rule = BaseRuleControllerTest.createRuleMetaData(savedPlugin);
RuleMetaData savedRule = doPost("/api/rule", rule, RuleMetaData.class);
doPost("/api/rule/" + savedRule.getId().getId().toString() + "/activate").andExpect(status().isOk());
doPost("/api/plugin/" + savedPlugin.getId().getId().toString() + "/suspend").andExpect(status().isBadRequest());
doPost("/api/rule/" + savedRule.getId().getId().toString() + "/suspend").andExpect(status().isOk());
doPost("/api/plugin/" + savedPlugin.getId().getId().toString() + "/suspend").andExpect(status().isOk());
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginControllerTest method testPluginsCreation.
private List<PluginMetaData> testPluginsCreation(String url) throws Exception {
List<PluginMetaData> plugins = new ArrayList<>();
for (int i = 0; i < 111; i++) {
PluginMetaData plugin = new PluginMetaData();
plugin.setName("My plugin");
plugin.setApiToken("myplugin" + i);
plugin.setConfiguration(mapper.readTree("{}"));
plugin.setClazz(TelemetryStoragePlugin.class.getName());
plugins.add(doPost("/api/plugin", plugin, PluginMetaData.class));
}
List<PluginMetaData> loadedPlugins = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(23);
TextPageData<PluginMetaData> pageData;
do {
pageData = doGetTypedWithPageLink(url + "?", new TypeReference<TextPageData<PluginMetaData>>() {
}, pageLink);
loadedPlugins.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
loadedPlugins = loadedPlugins.stream().filter(p -> !p.getName().equals("System Telemetry Plugin")).filter(p -> !p.getName().equals("Mail Sender Plugin")).filter(p -> !p.getName().equals("System RPC Plugin")).collect(Collectors.toList());
Collections.sort(plugins, idComparator);
Collections.sort(loadedPlugins, idComparator);
Assert.assertEquals(plugins, loadedPlugins);
return loadedPlugins;
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginControllerTest method testFindSystemPlugins.
@Test
public void testFindSystemPlugins() throws Exception {
loginSysAdmin();
List<PluginMetaData> plugins = testPluginsCreation("/api/plugin/system");
for (PluginMetaData plugin : plugins) {
doDelete("/api/plugin/" + plugin.getId().getId()).andExpect(status().isOk());
}
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginControllerTest method testDeletePluginById.
@Test
public void testDeletePluginById() throws Exception {
PluginMetaData plugin = new PluginMetaData();
plugin.setName("My plugin");
plugin.setApiToken("myplugin");
plugin.setConfiguration(mapper.readTree("{}"));
plugin.setClazz(TelemetryStoragePlugin.class.getName());
PluginMetaData savedPlugin = doPost("/api/plugin", plugin, PluginMetaData.class);
RuleMetaData rule = BaseRuleControllerTest.createRuleMetaData(savedPlugin);
RuleMetaData savedRule = doPost("/api/rule", rule, RuleMetaData.class);
doDelete("/api/plugin/" + savedPlugin.getId().getId()).andExpect(status().isBadRequest());
doDelete("/api/rule/" + savedRule.getId().getId()).andExpect(status().isOk());
doDelete("/api/plugin/" + savedPlugin.getId().getId()).andExpect(status().isOk());
doGet("/api/plugin/" + savedPlugin.getId().getId().toString()).andExpect(status().isNotFound());
}
use of org.thingsboard.server.common.data.plugin.PluginMetaData in project thingsboard by thingsboard.
the class BasePluginControllerTest method testFindPluginByToken.
@Test
public void testFindPluginByToken() throws Exception {
PluginMetaData plugin = new PluginMetaData();
plugin.setName("My plugin");
plugin.setApiToken("myplugin");
plugin.setConfiguration(mapper.readTree("{}"));
plugin.setClazz(TelemetryStoragePlugin.class.getName());
PluginMetaData savedPlugin = doPost("/api/plugin", plugin, PluginMetaData.class);
PluginMetaData foundPlugin = doGet("/api/plugin/token/" + "myplugin", PluginMetaData.class);
Assert.assertNotNull(foundPlugin);
Assert.assertEquals(savedPlugin, foundPlugin);
}
Aggregations