Search in sources :

Example 11 with AdminSettings

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

the class BaseAdminSettingsServiceTest method testSaveAdminSettingsWithNewJsonStructure.

@Test(expected = DataValidationException.class)
public void testSaveAdminSettingsWithNewJsonStructure() throws Exception {
    AdminSettings adminSettings = adminSettingsService.findAdminSettingsByKey("mail");
    JsonNode json = adminSettings.getJsonValue();
    ((ObjectNode) json).put("newKey", "my new value");
    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)

Example 12 with AdminSettings

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

the class BaseAdminControllerTest method testSaveAdminSettingsWithNonTextValue.

@Test
public void testSaveAdminSettingsWithNonTextValue() throws Exception {
    loginSysAdmin();
    AdminSettings adminSettings = doGet("/api/admin/settings/mail", AdminSettings.class);
    JsonNode json = adminSettings.getJsonValue();
    ((ObjectNode) json).put("timeout", 10000L);
    adminSettings.setJsonValue(json);
    doPost("/api/admin/settings", adminSettings).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("Provided json structure can't contain non-text values")));
}
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 13 with AdminSettings

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

the class BaseAdminControllerTest method testSaveAdminSettings.

@Test
public void testSaveAdminSettings() throws Exception {
    loginSysAdmin();
    AdminSettings adminSettings = doGet("/api/admin/settings/general", AdminSettings.class);
    JsonNode jsonValue = adminSettings.getJsonValue();
    ((ObjectNode) jsonValue).put("baseUrl", "http://myhost.org");
    adminSettings.setJsonValue(jsonValue);
    doPost("/api/admin/settings", adminSettings).andExpect(status().isOk());
    doGet("/api/admin/settings/general").andExpect(status().isOk()).andExpect(content().contentType(contentType)).andExpect(jsonPath("$.jsonValue.baseUrl", is("http://myhost.org")));
    ((ObjectNode) jsonValue).put("baseUrl", "http://localhost:8080");
    adminSettings.setJsonValue(jsonValue);
    doPost("/api/admin/settings", adminSettings).andExpect(status().isOk());
}
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 14 with AdminSettings

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

the class BaseAdminControllerTest method testSaveAdminSettingsWithEmptyKey.

@Test
public void testSaveAdminSettingsWithEmptyKey() throws Exception {
    loginSysAdmin();
    AdminSettings adminSettings = doGet("/api/admin/settings/mail", AdminSettings.class);
    adminSettings.setKey(null);
    doPost("/api/admin/settings", adminSettings).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("Key should be specified")));
}
Also used : AdminSettings(org.thingsboard.server.common.data.AdminSettings) Test(org.junit.Test)

Example 15 with AdminSettings

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

the class BaseAdminControllerTest method testChangeAdminSettingsKey.

@Test
public void testChangeAdminSettingsKey() throws Exception {
    loginSysAdmin();
    AdminSettings adminSettings = doGet("/api/admin/settings/mail", AdminSettings.class);
    adminSettings.setKey("newKey");
    doPost("/api/admin/settings", adminSettings).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("is prohibited")));
}
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