use of com.xpn.xwiki.api.Attachment in project celements-blog by celements.
the class NewsletterAttachmentServiceTest method testGetEmbedAttList_emptyList.
@Test
public void testGetEmbedAttList_emptyList() {
VelocityContext vcontext = (VelocityContext) getContext().get("vcontext");
List<Attachment> list = new ArrayList<>();
vcontext.put("nlEmbedAttList", list);
assertNull(service.getAttachmentList(true));
}
use of com.xpn.xwiki.api.Attachment in project celements-blog by celements.
the class NewsletterAttachmentServiceTest method testGetImageURL_embedded.
@Test
public void testGetImageURL_embedded() throws Exception {
DocumentReference docRef = new DocumentReference(getContext().getDatabase(), "Test", "Img");
String expectedResult = "cid:file.jpg";
XWikiDocument doc = createMockAndAddToDefault(XWikiDocument.class);
XWikiAttachment att = new XWikiAttachment();
expect(attService.getAttachmentNameEqual(same(doc), eq("file.jpg"))).andReturn(att).anyTimes();
expect(attService.getApiAttachment(same(att))).andReturn(new Attachment(new Document(doc, getContext()), att, getContext()));
expect(xwiki.getDocument(eq(docRef), same(getContext()))).andReturn(doc).once();
replayDefault();
assertEquals(expectedResult, service.getImageURL("Test.Img;file.jpg", true));
verifyDefault();
}
use of com.xpn.xwiki.api.Attachment in project celements-blog by celements.
the class NewsletterAttachmentServiceTest method testClearAttachmentList.
@Test
public void testClearAttachmentList() throws Exception {
DocumentReference docRef = new DocumentReference(getContext().getDatabase(), "Test", "Img");
XWikiDocument doc = createMockAndAddToDefault(XWikiDocument.class);
XWikiAttachment att = new XWikiAttachment();
expect(attService.getAttachmentNameEqual(same(doc), eq("file.pdf"))).andReturn(att).anyTimes();
expect(attService.getApiAttachment(same(att))).andReturn(new Attachment(new Document(doc, getContext()), att, getContext()));
expect(xwiki.getDocument(eq(docRef), same(getContext()))).andReturn(doc).once();
replayDefault();
service.addAttachment("Test.Img;file.pdf");
service.clearAttachmentList();
verifyDefault();
List<Attachment> atts = service.getAttachmentList(false);
assertTrue("clearAttachmentList must clear the list.", (atts == null) || atts.isEmpty());
List<Attachment> atts2 = service.getAttachmentList(true);
assertTrue("clearAttachmentList must clear both list.", (atts2 == null) || atts2.isEmpty());
}
Aggregations