AttachmentHandler implements AttachmentService.Iface { @Override public RequestSummary vacuumAttachmentDB(User user, Set<String> usedIds) throws TException { assertUser(user); return attachmentRepository.vacuumAttachmentDB(user, usedIds); } AttachmentHandler(); @Override AttachmentContent makeAttachmentContent(AttachmentContent attachmentContent); @Override List<AttachmentContent> makeAttachmentContents(List<AttachmentContent> attachmentContents); @Override AttachmentContent getAttachmentContent(String id); @Override void updateAttachmentContent(AttachmentContent attachment); @Override RequestSummary bulkDelete(List<String> ids); @Override RequestStatus deleteAttachmentContent(String attachmentId); @Override RequestSummary vacuumAttachmentDB(User user, Set<String> usedIds); @Override String getSha1FromAttachmentContentId(String attachmentContentId); @Override AttachmentUsage makeAttachmentUsage(AttachmentUsage attachmentUsage); @Override void makeAttachmentUsages(List<AttachmentUsage> attachmentUsages); @Override AttachmentUsage getAttachmentUsage(String id); @Override AttachmentUsage updateAttachmentUsage(AttachmentUsage attachmentUsage); @Override void updateAttachmentUsages(List<AttachmentUsage> attachmentUsages); @Override void deleteAttachmentUsage(AttachmentUsage attachmentUsage); @Override void deleteAttachmentUsages(List<AttachmentUsage> attachmentUsages); @Override void deleteAttachmentUsagesByUsageDataType(Source usedBy, UsageData usageData); @Override List<AttachmentUsage> getAttachmentUsages(Source owner, String attachmentContentId, UsageData filter); @Override List<AttachmentUsage> getUsedAttachments(Source usedBy, UsageData filter); @Override void replaceAttachmentUsages(Source usedBy, List<AttachmentUsage> attachmentUsages); @Override Map<Map<Source, String>, Integer> getAttachmentUsageCount(Map<Source, Set<String>> attachments, UsageData filter); static final String ATTACHMENTS_FIELD_NAME; }
@Test public void testVacuum_OnlyAdminCanRun() throws Exception { final RequestSummary requestSummary = handler.vacuumAttachmentDB(new User("a", "a", "a").setUserGroup(UserGroup.USER), ImmutableSet.of("A1", "A2")); assertThat(requestSummary.requestStatus, is(RequestStatus.FAILURE)); }