@Override public boolean apply(final AuditLog auditLog) { return objectType.equals(auditLog.getAuditedObjectType()); } };
@Override public int hashCode() { int result = customFieldId != null ? customFieldId.hashCode() : 0; result = 31 * result + (objectId != null ? objectId.hashCode() : 0); result = 31 * result + (objectType != null ? objectType.hashCode() : 0); return result; } }
@Test(groups = "slow", expectedExceptions = TagDefinitionApiException.class) public void testTagDefinitionCreationWithControlTagName() throws TagDefinitionApiException { final String definitionName = ControlTagType.AUTO_PAY_OFF.toString(); tagDefinitionDao.create(definitionName, "This should break", ObjectType.ACCOUNT.name(), internalCallContext); }
private static List<ObjectType> toObjectTypes(@Nullable final String input) { if (input == null) { return ImmutableList.copyOf(ObjectType.values()); } return ImmutableList.copyOf(Iterables.transform(SPLITTER.splitToList(input), new Function<String, ObjectType>() { @Override public ObjectType apply(final String input) { return ObjectType.valueOf(input); } })); }
@Override public ObjectType apply(final String input) { return ObjectType.valueOf(input); } }));
public NotificationJson(final ExtBusEvent event) { this(event.getEventType().toString(), event.getAccountId(), event.getObjectType().toString(), event.getObjectId(), event.getMetaData()); }
private static List<ObjectType> getApplicableObjectTypes(final UUID id, final Boolean isControlTag) { if (!isControlTag) { return ImmutableList.<ObjectType>copyOf(ObjectType.values()); } for (final ControlTagType cur : ControlTagType.values()) { if (cur.getId().equals(id)) { return cur.getApplicableObjectTypes(); } } throw new IllegalStateException(String.format("ControlTag id %s does not seem to exist", id)); }
@Override public ObjectType apply(final String input) { return ObjectType.valueOf(input); } }));
@Override public int hashCode() { int result = customFieldId != null ? customFieldId.hashCode() : 0; result = 31 * result + (objectId != null ? objectId.hashCode() : 0); result = 31 * result + (objectType != null ? objectType.hashCode() : 0); return result; } }
private TableName getTableNameFromObjectType(final ObjectType objectType) { for (final TableName tableName : TableName.values()) { if (objectType.equals(tableName.getObjectType())) { return tableName; } } return null; } }
@Test(groups = "fast") public void testCreateTagDefinitionWithLowerCase() throws Exception { final String tagDefinitionName = "lowercase"; final TagDefinitionModelDao tagDefinitionModelDao = new TagDefinitionModelDao(); tagDefinitionModelDao.setName(tagDefinitionName); tagDefinitionModelDao.setApplicableObjectTypes(ObjectType.ACCOUNT.name()); Mockito.when(tagDefinitionDao.create(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any(InternalCallContext.class))).thenReturn(tagDefinitionModelDao); final TagDefinition tagDefinition = tagUserApi.createTagDefinition(tagDefinitionName, "description", ImmutableSet.<ObjectType>of(ObjectType.ACCOUNT), context); assertEquals(tagDefinitionName, tagDefinition.getName()); } }
@Test(groups = "fast") public void testForObject() throws Exception { for (final ObjectType objectType : ObjectType.values()) { for (final UUID objectId : objectIds) { for (final AuditLevel level : AuditLevel.values()) { if (AuditLevel.NONE.equals(level)) { Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext).size(), 0); } else if (AuditLevel.MINIMAL.equals(level)) { Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext), ImmutableList.<AuditLog>of(auditLogs.get(0))); } else { Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext), auditLogs); } } } } } }
@Override public ObjectType apply(final String input) { return ObjectType.valueOf(input); } }));
@Override public int hashCode() { int result = tagId != null ? tagId.hashCode() : 0; result = 31 * result + (objectId != null ? objectId.hashCode() : 0); result = 31 * result + (objectType != null ? objectType.hashCode() : 0); result = 31 * result + (tagDefinition != null ? tagDefinition.hashCode() : 0); return result; } }
@Override public boolean apply(final TagModelDao input) { return objectType.equals(input.getObjectType()); } }));
@Test(groups = "slow", description = "Test Account DAO: tags") public void testTags() throws TagApiException, TagDefinitionApiException { final AccountModelDao account = createTestAccount(); final TagDefinitionModelDao tagDefinition = tagDefinitionDao.create(UUID.randomUUID().toString().substring(0, 4), UUID.randomUUID().toString(), ObjectType.ACCOUNT.name(), internalCallContext); final Tag tag = new DescriptiveTag(tagDefinition.getId(), ObjectType.ACCOUNT, account.getId(), internalCallContext.getCreatedDate()); tagDao.create(new TagModelDao(tag), internalCallContext); final List<TagModelDao> tags = tagDao.getTagsForObject(account.getId(), ObjectType.ACCOUNT, false, internalCallContext); Assert.assertEquals(tags.size(), 1); Assert.assertEquals(tags.get(0).getTagDefinitionId(), tagDefinition.getId()); Assert.assertEquals(tags.get(0).getObjectId(), account.getId()); Assert.assertEquals(tags.get(0).getObjectType(), ObjectType.ACCOUNT); }
@Test(groups = "fast") public void testDefaultTagDefinition() throws TagApiException, TagDefinitionApiException { final DefaultTagDefinition def1 = new DefaultTagDefinition(UUID.randomUUID(), "foo", "nothing", false); Assert.assertFalse(def1.getApplicableObjectTypes().isEmpty()); Assert.assertEquals(ImmutableList.<ObjectType>copyOf(ObjectType.values()), def1.getApplicableObjectTypes()); for (final ControlTagType cur : ControlTagType.values()) { final DefaultTagDefinition curDef = new DefaultTagDefinition(cur.getId(), cur.name(), cur.getDescription(), true); Assert.assertFalse(curDef.getApplicableObjectTypes().isEmpty()); Assert.assertEquals(curDef.getApplicableObjectTypes(), cur.getApplicableObjectTypes()); } try { new DefaultTagDefinition(UUID.randomUUID(), "bar", "nothing again", true); Assert.fail("Not a control tag type"); } catch (final IllegalStateException e) { } } }
@Override public int hashCode() { int result = tagId != null ? tagId.hashCode() : 0; result = 31 * result + (objectId != null ? objectId.hashCode() : 0); result = 31 * result + (objectType != null ? objectType.hashCode() : 0); result = 31 * result + (tagDefinition != null ? tagDefinition.hashCode() : 0); return result; } }
public static TableName fromObjectType(final ObjectType objectType) { for (final TableName tableName : values()) { if (tableName.getObjectType() != null && tableName.getObjectType().equals(objectType)) { return tableName; } } return null; }
final String description = "description-" + i; eventsListener.pushExpectedEvent(NextEvent.TAG_DEFINITION); tagDefinitionDao.create(definitionName, description, ObjectType.ACCOUNT.name(), internalCallContext); assertListenerStatus();