@Test(groups = "slow") public void testCustomFieldUpdate() throws Exception { final CustomField customField1 = new StringCustomField("gtqre", "value1", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); eventsListener.pushExpectedEvents(NextEvent.CUSTOM_FIELD); customFieldUserApi.addCustomFields(ImmutableList.<CustomField>of(customField1), callContext); assertListenerStatus(); final CustomField update1 = new StringCustomField(customField1.getId(), customField1.getFieldName(), "value2", customField1.getObjectType(), customField1.getObjectId(), callContext.getCreatedDate()); customFieldUserApi.updateCustomFields(ImmutableList.of(update1), callContext); List<CustomField> all = customFieldUserApi.getCustomFieldsForAccount(accountId, callContext); Assert.assertEquals(all.size(), 1); Assert.assertEquals(all.get(0).getId(), update1.getId()); Assert.assertEquals(all.get(0).getObjectType(), update1.getObjectType()); Assert.assertEquals(all.get(0).getObjectId(), update1.getObjectId()); Assert.assertEquals(all.get(0).getFieldName(), update1.getFieldName()); Assert.assertEquals(all.get(0).getFieldValue(), "value2"); try { customFieldUserApi.updateCustomFields(ImmutableList.<CustomField>of(new StringCustomField("gtqre", "value1", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate())), callContext); Assert.fail("Updating custom field should fail"); } catch (final CustomFieldApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.CUSTOM_FIELD_DOES_NOT_EXISTS_FOR_ID.getCode()); } try { customFieldUserApi.updateCustomFields(ImmutableList.<CustomField>of(new StringCustomField(customField1.getId(), "wrongName", "value2", customField1.getObjectType(), customField1.getObjectId(), callContext.getCreatedDate())), callContext); Assert.fail("Updating custom field should fail"); } catch (final CustomFieldApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.CUSTOM_FIELD_INVALID_UPDATE.getCode()); } }
private void verifyInternalCallContext(final InternalCallContext context) { Assert.assertEquals(context.getCallOrigin(), callContext.getCallOrigin()); Assert.assertEquals(context.getComments(), callContext.getComments()); Assert.assertTrue(context.getCreatedDate().compareTo(callContext.getCreatedDate()) >= 0); Assert.assertEquals(context.getReasonCode(), callContext.getReasonCode()); Assert.assertTrue(context.getUpdatedDate().compareTo(callContext.getUpdatedDate()) >= 0); Assert.assertEquals(context.getCreatedBy(), callContext.getUserName()); Assert.assertEquals(context.getUserToken(), callContext.getUserToken()); Assert.assertEquals(context.getContextUserType(), callContext.getUserType()); // Our test callcontext doesn't have a tenant id Assert.assertEquals(context.getTenantRecordId(), (Long) InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID); } }
@Test(groups = "slow") public void testCustomFieldBasic() throws Exception { final CustomField customField1 = new StringCustomField("some123", "some 456", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); final CustomField customField2 = new StringCustomField("other123", "other 456", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); eventsListener.pushExpectedEvents(NextEvent.CUSTOM_FIELD, NextEvent.CUSTOM_FIELD); customFieldUserApi.addCustomFields(ImmutableList.<CustomField>of(customField1, customField2), callContext); final CustomField customField3 = new StringCustomField("qrqrq123", "qrqrq 456", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); try { customFieldUserApi.addCustomFields(ImmutableList.<CustomField>of(customField3, customField1), callContext);
final CustomField customField = new StringCustomField(cfName, cfValue, ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); eventsListener.pushExpectedEvent(NextEvent.CUSTOM_FIELD); customFieldUserApi.addCustomFields(ImmutableList.<CustomField>of(customField), callContext); final CustomField newCustomField = new StringCustomField(cfName, cfValue, ObjectType.ACCOUNT, accountId, callContext.getCreatedDate());
private void verifyInternalCallContext(final InternalCallContext context) { Assert.assertEquals(context.getCallOrigin(), callContext.getCallOrigin()); Assert.assertEquals(context.getComments(), callContext.getComments()); Assert.assertTrue(context.getCreatedDate().compareTo(callContext.getCreatedDate()) >= 0); Assert.assertEquals(context.getReasonCode(), callContext.getReasonCode()); Assert.assertTrue(context.getUpdatedDate().compareTo(callContext.getUpdatedDate()) >= 0); Assert.assertEquals(context.getCreatedBy(), callContext.getUserName()); Assert.assertEquals(context.getUserToken(), callContext.getUserToken()); Assert.assertEquals(context.getContextUserType(), callContext.getUserType()); // Our test callcontext doesn't have a tenant id Assert.assertEquals(context.getTenantRecordId(), (Long) InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID); } }
@Test(groups = "slow") public void testCustomFieldBasic() throws Exception { final CustomField customField1 = new StringCustomField("some123", "some 456", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); final CustomField customField2 = new StringCustomField("other123", "other 456", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); eventsListener.pushExpectedEvents(NextEvent.CUSTOM_FIELD, NextEvent.CUSTOM_FIELD); customFieldUserApi.addCustomFields(ImmutableList.<CustomField>of(customField1, customField2), callContext); final CustomField customField3 = new StringCustomField("qrqrq123", "qrqrq 456", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); try { customFieldUserApi.addCustomFields(ImmutableList.<CustomField>of(customField3, customField1), callContext);
@Test(groups = "slow") public void testCustomFieldUpdate() throws Exception { final CustomField customField1 = new StringCustomField("gtqre", "value1", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); eventsListener.pushExpectedEvents(NextEvent.CUSTOM_FIELD); customFieldUserApi.addCustomFields(ImmutableList.<CustomField>of(customField1), callContext); assertListenerStatus(); final CustomField update1 = new StringCustomField(customField1.getId(), customField1.getFieldName(), "value2", customField1.getObjectType(), customField1.getObjectId(), callContext.getCreatedDate()); customFieldUserApi.updateCustomFields(ImmutableList.of(update1), callContext); List<CustomField> all = customFieldUserApi.getCustomFieldsForAccount(accountId, callContext); Assert.assertEquals(all.size(), 1); Assert.assertEquals(all.get(0).getId(), update1.getId()); Assert.assertEquals(all.get(0).getObjectType(), update1.getObjectType()); Assert.assertEquals(all.get(0).getObjectId(), update1.getObjectId()); Assert.assertEquals(all.get(0).getFieldName(), update1.getFieldName()); Assert.assertEquals(all.get(0).getFieldValue(), "value2"); try { customFieldUserApi.updateCustomFields(ImmutableList.<CustomField>of(new StringCustomField("gtqre", "value1", ObjectType.ACCOUNT, accountId, callContext.getCreatedDate())), callContext); Assert.fail("Updating custom field should fail"); } catch (final CustomFieldApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.CUSTOM_FIELD_DOES_NOT_EXISTS_FOR_ID.getCode()); } try { customFieldUserApi.updateCustomFields(ImmutableList.<CustomField>of(new StringCustomField(customField1.getId(), "wrongName", "value2", customField1.getObjectType(), customField1.getObjectId(), callContext.getCreatedDate())), callContext); Assert.fail("Updating custom field should fail"); } catch (final CustomFieldApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.CUSTOM_FIELD_INVALID_UPDATE.getCode()); } }
final CustomField customField = new StringCustomField(cfName, cfValue, ObjectType.ACCOUNT, accountId, callContext.getCreatedDate()); eventsListener.pushExpectedEvent(NextEvent.CUSTOM_FIELD); customFieldUserApi.addCustomFields(ImmutableList.<CustomField>of(customField), callContext); final CustomField newCustomField = new StringCustomField(cfName, cfValue, ObjectType.ACCOUNT, accountId, callContext.getCreatedDate());