public void testEditSettings() throws Exception {
String newFromEmailAddress = "test" + random.nextInt(Integer.MAX_VALUE) + "@test.com";
Exception exception = null;
try {
OrgSettings newSettings = OrgSettings.builder()
.emailSettings(emailSettings.toBuilder().fromEmailAddress(newFromEmailAddress).build()).build();
OrgSettings modified = orgApi.editSettings(org.getId(), newSettings);
Checks.checkOrgSettings(settings);
assertTrue(equal(modified.getEmailSettings().getFromEmailAddress(), newFromEmailAddress),
String.format(OBJ_FIELD_UPDATABLE, "orgSettings", "emailSettings"));
} catch (Exception e) {
exception = e;
} finally {
try {
OrgSettings restorableSettings = OrgSettings.builder().emailSettings(emailSettings).build();
settings = orgApi.editSettings(org.getId(), restorableSettings);
} catch (Exception e) {
if (exception != null) {
logger.warn(e, "Error resetting settings; rethrowing original test exception...");