@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 " + "(doc.space = :localSpaceReference or doc.space like :localSpaceReferencePrefix) and " + "upper(doc.fullName) like :page", Query.HQL)).thenReturn(query); mockPreifxQueryParam(query, "localSpaceReferencePrefix", "Path.To."); mockContainsQueryParam(query, "page", "XYZ"); when(query.setOffset(10)).thenReturn(query); when(query.setLimit(5)).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); SpaceReference spaceReference = new SpaceReference("test", "Path", "To"); when(this.defaultSpaceReferenceResover.resolve(eq("Path.To"), any())).thenReturn(spaceReference); when(this.localEntityReferenceSerializer.serialize(spaceReference)).thenReturn("Path.To"); Attachment attachment = mock(Attachment.class); when(this.modelFactory.toRestAttachment(eq(this.uriInfo.getBaseUri()), any(), eq(false), eq(false))) .thenReturn(attachment); Attachments attachments = this.spaceAttachmentsResource.getAttachments("test", "Path/spaces/To", "", "xyz", "", "", 10, 5, false); verify(query).bindValue("localSpaceReference", "Path.To"); assertEquals(Collections.singletonList(attachment), attachments.getAttachments()); }
@Override public Attachments getAttachments(String wiki, String spaces, String name, String page, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new SpaceReference(wiki, parseSpaceSegments(spaces)), filters, offset, limit, withPrettyNames); }
SpaceAttachmentsResourceImpl extends BaseAttachmentsResource implements SpaceAttachmentsResource { @Override public Attachments getAttachments(String wiki, String spaces, String name, String page, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new SpaceReference(wiki, parseSpaceSegments(spaces)), filters, offset, limit, withPrettyNames); } }
SpaceAttachmentsResourceImpl extends BaseAttachmentsResource implements SpaceAttachmentsResource { @Override public Attachments getAttachments(String wiki, String spaces, String name, String page, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new SpaceReference(wiki, parseSpaceSegments(spaces)), filters, offset, limit, withPrettyNames); }  }
SpaceAttachmentsResourceImpl extends BaseAttachmentsResource implements SpaceAttachmentsResource { @Override public Attachments getAttachments(String wiki, String spaces, String name, String page, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new SpaceReference(wiki, parseSpaceSegments(spaces)), filters, offset, limit, withPrettyNames); }  @Override Attachments getAttachments(String wiki, String spaces, String name, String page, String author,
        String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames); }
SpaceAttachmentsResourceImpl extends BaseAttachmentsResource implements SpaceAttachmentsResource { @Override public Attachments getAttachments(String wiki, String spaces, String name, String page, String author, String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames) throws XWikiRestException { Map<String, String> filters = new HashMap<>(); filters.put("page", page); filters.put("name", name); filters.put("author", author); filters.put("fileTypes", fileTypes); return super.getAttachments(new SpaceReference(wiki, parseSpaceSegments(spaces)), filters, offset, limit, withPrettyNames); }  @Override Attachments getAttachments(String wiki, String spaces, String name, String page, String author,
        String fileTypes, Integer offset, Integer limit, Boolean withPrettyNames);  }