@Test public void getAttachments() throws Exception { Query query = mock(Query.class); when(this.queryManager.createQuery("select doc.space, doc.name, doc.version, attachment" + " from XWikiDocument as doc, XWikiAttachment as attachment" + " where attachment.docId = doc.id and upper(doc.space) like :space", Query.HQL)).thenReturn(query); mockContainsQueryParam(query, "space", "ABC"); when(query.setOffset(0)).thenReturn(query); when(query.setLimit(10)).thenReturn(query); XWikiAttachment xwikiAttachment = mock(XWikiAttachment.class); List<Object> results = Collections.singletonList(new Object[] {"Path.To", "Page", "1.3", xwikiAttachment}); when(query.execute()).thenReturn(results); when(this.defaultSpaceReferenceResover.resolve(eq("Path.To"), any())) .thenReturn(new SpaceReference("test", "Path", "To")); Attachment attachment = mock(Attachment.class); when(this.modelFactory.toRestAttachment(eq(this.uriInfo.getBaseUri()), any(), eq(true), eq(false))) .thenReturn(attachment); Attachments attachments = this.wikiAttachmentsResource.getAttachments("test", "", "", "abc", "", "", 0, 10, true); assertEquals(Collections.singletonList(attachment), attachments.getAttachments()); }
@Override public Attachments getAttachments(String wiki, String name, String page, String space, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("space", space); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new WikiReference(wiki), filters, offset, limit, withPrettyNames); }
WikiAttachmentsResourceImpl extends BaseAttachmentsResource implements WikiAttachmentsResource { @Override public Attachments getAttachments(String wiki, String name, String page, String space, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("space", space); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new WikiReference(wiki), filters, offset, limit, withPrettyNames); } }
WikiAttachmentsResourceImpl extends BaseAttachmentsResource implements WikiAttachmentsResource { @Override public Attachments getAttachments(String wiki, String name, String page, String space, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("space", space); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new WikiReference(wiki), filters, offset, limit, withPrettyNames); }  }
WikiAttachmentsResourceImpl extends BaseAttachmentsResource implements WikiAttachmentsResource { @Override public Attachments getAttachments(String wiki, String name, String page, String space, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("space", space); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new WikiReference(wiki), filters, offset, limit, withPrettyNames); }  @Override Attachments getAttachments(String wiki, String name, String page, String space, String author,
        String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames); }
WikiAttachmentsResourceImpl extends BaseAttachmentsResource implements WikiAttachmentsResource { @Override public Attachments getAttachments(String wiki, String name, String page, String space, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("space", space); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new WikiReference(wiki), filters, offset, limit, withPrettyNames); }  @Override Attachments getAttachments(String wiki, String name, String page, String space, String author,
        String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames);  }