@Test public void toJSONWritesNoAuthorForGuestAuthor() throws ComponentLookupException { when(this.attachment1.getAuthorReference()).thenReturn(null); JSONObject json = this.mocker.getComponentUnderTest().fromXWikiAttachment(this.attachment1).toJSON(true); Assert.assertEquals("a1.pdf", json.get(JSON_FIELD_FILENAME)); Assert.assertEquals(4L, json.get(JSON_FIELD_FILESIZE)); Assert.assertFalse(json.has(JSON_FIELD_AUTHOR)); Assert.assertEquals("2017-01-01T12:00:00.000Z", json.get(JSON_FIELD_DATE)); Assert.assertEquals("YWJjZA==", json.get(JSON_FIELD_CONTENT)); }
public Attachment fromXWikiAttachment(XWikiAttachment attachment) { if (attachment == null) { return null; } return new Attachment(attachment, this.userResolver, this.userSerializer, this.contextProvider); }
AttachmentAdapterFactory { public Attachment fromXWikiAttachment(XWikiAttachment attachment) { if (attachment == null) { return null; } return new Attachment(attachment, this.userResolver, this.userSerializer, this.contextProvider); } }
AttachmentAdapterFactory { public Attachment fromXWikiAttachment(XWikiAttachment attachment) { if (attachment == null) { return null; } return new Attachment(attachment, this.userResolver, this.userSerializer, this.contextProvider); }  }
AttachmentAdapterFactory { public Attachment fromXWikiAttachment(XWikiAttachment attachment) { if (attachment == null) { return null; } return new Attachment(attachment, this.userResolver, this.userSerializer, this.contextProvider); }  Attachment fromXWikiAttachment(XWikiAttachment attachment); Attachment fromJSON(JSONObject attachment); }
AttachmentAdapterFactory { public Attachment fromXWikiAttachment(XWikiAttachment attachment) { if (attachment == null) { return null; } return new Attachment(attachment, this.userResolver, this.userSerializer, this.contextProvider); }  Attachment fromXWikiAttachment(XWikiAttachment attachment); Attachment fromJSON(JSONObject attachment);  }