use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.
the class TestLdapProvAccount method renameAccountAlreadyExists.
@Test
public void renameAccountAlreadyExists() throws Exception {
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
String ACCT_NAME_EXISTS_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart("exists"));
Account acct = createAccount(ACCT_NAME_LOCALPART);
Account acctExists = createAccount(ACCT_NAME_EXISTS_LOCALPART);
String acctId = acct.getId();
String ACCT_NEW_NAME = acctExists.getName();
boolean caughtException = false;
try {
prov.renameAccount(acctId, ACCT_NEW_NAME);
} catch (AccountServiceException e) {
if (AccountServiceException.ACCOUNT_EXISTS.equals(e.getCode())) {
caughtException = true;
}
}
assertTrue(caughtException);
deleteAccount(acct);
deleteAccount(acctExists);
}
use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.
the class TestLdapProvSignature method createSignatureWithExistingId.
@Test
public void createSignatureWithExistingId() throws Exception {
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
String SIGNATURE_NAME = Names.makeSignatureName(genSignatureName());
Account acct = createAccount(ACCT_NAME_LOCALPART);
Signature signature = createSignature(acct, SIGNATURE_NAME);
String id = signature.getAttr("zimbraSignatureId");
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put("zimbraSignatureId", id);
try {
prov.createSignature(acct, SIGNATURE_NAME + "_NEW", attrs);
fail("Create signature should not have succeeded, as signatureId exists.");
} catch (AccountServiceException e) {
assertEquals(AccountServiceException.SIGNATURE_EXISTS, e.getCode());
}
}
use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.
the class TestLdapProvXMPPComponent method createXMPPComponentAlreadyExists.
@Test
public void createXMPPComponentAlreadyExists() throws Exception {
String XMPPCPNT_NAME = Names.makeXMPPName(genXMPPName());
XMPPComponent xmppCpnt = createXMPPComponent(XMPPCPNT_NAME);
boolean caughtException = false;
try {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraXMPPComponentCategory, "whatever");
attrs.put(Provisioning.A_zimbraXMPPComponentClassName, "whatever");
attrs.put(Provisioning.A_zimbraXMPPComponentType, "whatever");
prov.createXMPPComponent(XMPPCPNT_NAME, domain, server, attrs);
} catch (AccountServiceException e) {
if (AccountServiceException.IM_COMPONENT_EXISTS.equals(e.getCode())) {
caughtException = true;
}
}
assertTrue(caughtException);
deleteXMPPComponent(xmppCpnt);
}
use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.
the class TestLdapProvDomain method createDomainAlreadyExists.
@Test
public void createDomainAlreadyExists() throws Exception {
String DOMAIN_NAME = makeTestDomainName(genDomainSegmentName());
Domain domain = createDomain(DOMAIN_NAME);
boolean caughtException = false;
try {
prov.createDomain(DOMAIN_NAME, new HashMap<String, Object>());
} catch (AccountServiceException e) {
if (AccountServiceException.DOMAIN_EXISTS.equals(e.getCode())) {
caughtException = true;
}
}
assertTrue(caughtException);
deleteDomain(domain);
}
use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.
the class TestLdapProvModifyAttrs method invalidAttrValue.
@Test
public void invalidAttrValue() throws Exception {
// set multiple values to a single-valued attr
String ATTR_NAME = Provisioning.A_zimbraPrefSkin;
String ATTR_VALUE_1 = "invalidAttrValue-1";
String ATTR_VALUE_2 = "invalidAttrValue-2";
Account acct = createAccount(genAcctNameLocalPart());
boolean caughtException = false;
try {
modifyMultiValue(acct, "+" + ATTR_NAME, new String[] { ATTR_VALUE_1, ATTR_VALUE_2 });
} catch (AccountServiceException e) {
if (AccountServiceException.INVALID_ATTR_VALUE.equals(e.getCode())) {
caughtException = true;
}
} catch (ServiceException e) {
if (InMemoryLdapServer.isOn()) {
/*
* ubid InMemoryDirectoryServer returns OBJECT_CLASS_VIOLATION instead of
* CONSTRAINT_VIOLATION/INVALID_ATTRIBUTE_SYNTAX. OBJECT_CLASS_VIOLATION
* is mapped to FAILURE in LdapProvisioning
*/
if (AccountServiceException.FAILURE.equals(e.getCode())) {
caughtException = true;
}
}
}
assertTrue(caughtException);
deleteAccount(acct);
}
Aggregations