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); } })); }
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)); }
@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); } } } } } }
@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) { } } }
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); } })); }
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)); }
@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); } } } } } }
@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) { } } }