@Test public void testCreate() throws Exception { when(mExportDescriptor.getId()).thenReturn(EXPORT_ID); when(mAttachmentDescriptor.getFileName()).thenReturn(ATTACHMENT_ID); when(mExportDescriptor.getAttachments()).thenReturn(Collections.singleton(mAttachmentDescriptor)); List<ReportAttachment> result = attachmentsFactory.create(mExportDescriptor, EXEC_ID); assertThat(result.size(), is(1)); verify(mExportDescriptor).getId(); verify(mExportDescriptor).getAttachments(); verify(mAttachmentDescriptor).getFileName(); }
public List<ReportAttachment> create(ExportDescriptor export, String execId) { String exportId = export.getId(); Set<AttachmentDescriptor> rawAttachments = export.getAttachments(); List<ReportAttachment> attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { String fileName = attachment.getFileName(); ReportAttachment reportAttachment = new ReportAttachment( mExportExecutionApi, execId, exportId, fileName ); attachments.add(reportAttachment); } return attachments; }
AttachmentsFactory { public List<ReportAttachment> create(ExportDescriptor export, String execId) { String exportId = export.getId(); Set<AttachmentDescriptor> rawAttachments = export.getAttachments(); List<ReportAttachment> attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { String fileName = attachment.getFileName(); ReportAttachment reportAttachment = new ReportAttachment( mExportExecutionApi, execId, exportId, fileName ); attachments.add(reportAttachment); } return attachments; } }
AttachmentsFactory { public List<ReportAttachment> create(ExportDescriptor export, String execId) { String exportId = export.getId(); Set<AttachmentDescriptor> rawAttachments = export.getAttachments(); List<ReportAttachment> attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { String fileName = attachment.getFileName(); ReportAttachment reportAttachment = new ReportAttachment( mExportExecutionApi, execId, exportId, fileName ); attachments.add(reportAttachment); } return attachments; } AttachmentsFactory(ExportExecutionApi exportExecutionApi); }
AttachmentsFactory { public List<ReportAttachment> create(ExportDescriptor export, String execId) { String exportId = export.getId(); Set<AttachmentDescriptor> rawAttachments = export.getAttachments(); List<ReportAttachment> attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { String fileName = attachment.getFileName(); ReportAttachment reportAttachment = new ReportAttachment( mExportExecutionApi, execId, exportId, fileName ); attachments.add(reportAttachment); } return attachments; } AttachmentsFactory(ExportExecutionApi exportExecutionApi); List<ReportAttachment> create(ExportDescriptor export, String execId); }
AttachmentsFactory { public List<ReportAttachment> create(ExportDescriptor export, String execId) { String exportId = export.getId(); Set<AttachmentDescriptor> rawAttachments = export.getAttachments(); List<ReportAttachment> attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { String fileName = attachment.getFileName(); ReportAttachment reportAttachment = new ReportAttachment( mExportExecutionApi, execId, exportId, fileName ); attachments.add(reportAttachment); } return attachments; } AttachmentsFactory(ExportExecutionApi exportExecutionApi); List<ReportAttachment> create(ExportDescriptor export, String execId);  }