Search in sources :

Example 1 with AdminSettings

use of org.thingsboard.server.common.data.AdminSettings in project thingsboard by thingsboard.

the class BaseAdminSettingsServiceTest method testSaveAdminSettings.

@Test
public void testSaveAdminSettings() throws Exception {
    AdminSettings adminSettings = adminSettingsService.findAdminSettingsByKey("general");
    JsonNode json = adminSettings.getJsonValue();
    ((ObjectNode) json).put("baseUrl", "http://myhost.org");
    adminSettings.setJsonValue(json);
    adminSettingsService.saveAdminSettings(adminSettings);
    AdminSettings savedAdminSettings = adminSettingsService.findAdminSettingsByKey("general");
    Assert.assertNotNull(savedAdminSettings);
    Assert.assertEquals(adminSettings.getJsonValue(), savedAdminSettings.getJsonValue());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) AdminSettings(org.thingsboard.server.common.data.AdminSettings) Test(org.junit.Test)

Example 2 with AdminSettings

use of org.thingsboard.server.common.data.AdminSettings in project thingsboard by thingsboard.

the class BaseAdminSettingsServiceTest method testFindAdminSettingsByKey.

@Test
public void testFindAdminSettingsByKey() {
    AdminSettings adminSettings = adminSettingsService.findAdminSettingsByKey("general");
    Assert.assertNotNull(adminSettings);
    adminSettings = adminSettingsService.findAdminSettingsByKey("mail");
    Assert.assertNotNull(adminSettings);
    adminSettings = adminSettingsService.findAdminSettingsByKey("unknown");
    Assert.assertNull(adminSettings);
}
Also used : AdminSettings(org.thingsboard.server.common.data.AdminSettings) Test(org.junit.Test)

Example 3 with AdminSettings

use of org.thingsboard.server.common.data.AdminSettings in project thingsboard by thingsboard.

the class BaseAdminSettingsServiceTest method testChangeAdminSettingsKey.

@Test(expected = DataValidationException.class)
public void testChangeAdminSettingsKey() {
    AdminSettings adminSettings = adminSettingsService.findAdminSettingsByKey("mail");
    adminSettings.setKey("newKey");
    adminSettingsService.saveAdminSettings(adminSettings);
}
Also used : AdminSettings(org.thingsboard.server.common.data.AdminSettings) Test(org.junit.Test)

Example 4 with AdminSettings

use of org.thingsboard.server.common.data.AdminSettings in project thingsboard by thingsboard.

the class AdminSettingsEntity method toData.

@Override
public AdminSettings toData() {
    AdminSettings adminSettings = new AdminSettings(new AdminSettingsId(UUIDConverter.fromString(id)));
    adminSettings.setCreatedTime(UUIDs.unixTimestamp(UUIDConverter.fromString(id)));
    adminSettings.setKey(key);
    adminSettings.setJsonValue(jsonValue);
    return adminSettings;
}
Also used : AdminSettingsId(org.thingsboard.server.common.data.id.AdminSettingsId) AdminSettings(org.thingsboard.server.common.data.AdminSettings)

Example 5 with AdminSettings

use of org.thingsboard.server.common.data.AdminSettings in project thingsboard by thingsboard.

the class BaseAdminControllerTest method testSendTestMail.

@Test
public void testSendTestMail() throws Exception {
    loginSysAdmin();
    AdminSettings adminSettings = doGet("/api/admin/settings/mail", AdminSettings.class);
    doPost("/api/admin/settings/testMail", adminSettings).andExpect(status().isOk());
}
Also used : AdminSettings(org.thingsboard.server.common.data.AdminSettings) Test(org.junit.Test)

Aggregations

AdminSettings (org.thingsboard.server.common.data.AdminSettings)16 Test (org.junit.Test)13 JsonNode (com.fasterxml.jackson.databind.JsonNode)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 AdminSettingsId (org.thingsboard.server.common.data.id.AdminSettingsId)2 IncorrectParameterException (org.thingsboard.server.dao.exception.IncorrectParameterException)1