Search in sources :

Example 6 with AdminSettings

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

the class DefaultMailService method updateMailConfiguration.

@Override
public void updateMailConfiguration() {
    AdminSettings settings = adminSettingsService.findAdminSettingsByKey("mail");
    if (settings != null) {
        JsonNode jsonConfig = settings.getJsonValue();
        mailSender = createMailSender(jsonConfig);
        mailFrom = jsonConfig.get("mailFrom").asText();
    } else {
        throw new IncorrectParameterException("Failed to date mail configuration. Settings not found!");
    }
}
Also used : IncorrectParameterException(org.thingsboard.server.dao.exception.IncorrectParameterException) JsonNode(com.fasterxml.jackson.databind.JsonNode) AdminSettings(org.thingsboard.server.common.data.AdminSettings)

Example 7 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(id));
    adminSettings.setCreatedTime(UUIDs.unixTimestamp(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 8 with AdminSettings

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

the class BaseAdminSettingsServiceTest method testFindAdminSettingsById.

@Test
public void testFindAdminSettingsById() {
    AdminSettings adminSettings = adminSettingsService.findAdminSettingsByKey("general");
    AdminSettings foundAdminSettings = adminSettingsService.findAdminSettingsById(adminSettings.getId());
    Assert.assertNotNull(foundAdminSettings);
    Assert.assertEquals(adminSettings, foundAdminSettings);
}
Also used : AdminSettings(org.thingsboard.server.common.data.AdminSettings) Test(org.junit.Test)

Example 9 with AdminSettings

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

the class BaseAdminSettingsServiceTest method testSaveAdminSettingsWithEmptyKey.

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

Example 10 with AdminSettings

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

the class BaseAdminSettingsServiceTest method testSaveAdminSettingsWithNonTextValue.

@Test(expected = DataValidationException.class)
public void testSaveAdminSettingsWithNonTextValue() throws Exception {
    AdminSettings adminSettings = adminSettingsService.findAdminSettingsByKey("mail");
    JsonNode json = adminSettings.getJsonValue();
    ((ObjectNode) json).put("timeout", 10000L);
    adminSettings.setJsonValue(json);
    adminSettingsService.saveAdminSettings(adminSettings);
}
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)

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