use of org.eclipse.sw360.datahandler.thrift.attachments.Attachment in project sw360portal by sw360.
the class PortletUtilsTest method testUpdateAttachmentsRemoveAndUpdate.
@Test
public void testUpdateAttachmentsRemoveAndUpdate() {
PortletRequest request = Mockito.mock(PortletRequest.class);
new TestUserCacheHolder().enable();
// fill existing data
Set<Attachment> documentAttachments = createAttachments("1", "2", "3");
// fill request
new TestUserCacheHolder().enable(createUser("tid", "test@example.org", "tpd"));
setAttachmentIds(request, "2");
setAttachmentFilenames(request, "B");
setAttachmentTypes(request, AttachmentType.SCREENSHOT);
setAttachmenCreatedComments(request, "CC2");
setAttachmentCheckStatus(request, CheckStatus.ACCEPTED);
setAttachmentCheckComment(request, "CCK2");
// run tests
Set<Attachment> updatedAttachments = PortletUtils.updateAttachmentsFromRequest(request, documentAttachments);
// assertThat(documentAttachments.size(), is(3));
assertThat(updatedAttachments.size(), is(1));
Attachment updatedAttachment = updatedAttachments.iterator().next();
assertThat(updatedAttachment.getAttachmentContentId(), is("2"));
assertThat(updatedAttachment.getCheckStatus(), is(CheckStatus.ACCEPTED));
assertThat(updatedAttachment.getCheckedBy(), is("test@example.org"));
assertThat(updatedAttachment.getCheckedTeam(), is("tpd"));
assertThat(updatedAttachment.getCheckedComment(), is("CCK2"));
}
use of org.eclipse.sw360.datahandler.thrift.attachments.Attachment in project sw360portal by sw360.
the class PortletUtilsTest method testUpdateAttachmentsFromRequestIdsAreNull.
@Test
public void testUpdateAttachmentsFromRequestIdsAreNull() {
PortletRequest request = Mockito.mock(PortletRequest.class);
new TestUserCacheHolder().enable();
// use immutable set to ensure that set is not changed.
Set<Attachment> documentAttachments = ImmutableSet.of();
assertThat(PortletUtils.updateAttachmentsFromRequest(request, documentAttachments), is(empty()));
}
use of org.eclipse.sw360.datahandler.thrift.attachments.Attachment in project sw360portal by sw360.
the class DisplayDownloadApprovedClearingReportTest method testThatImageDependsOnStatus.
@Test
public void testThatImageDependsOnStatus() {
Attachment attachment = createAttachment("test.file");
DisplayDownloadApprovedClearingReport displayDownloadAttachment = new DisplayDownloadApprovedClearingReport();
displayDownloadAttachment.setAttachment(attachment);
assertEquals(DisplayDownloadAbstract.DOWNLOAD_IMAGE_ENABLED, displayDownloadAttachment.getImage());
}
use of org.eclipse.sw360.datahandler.thrift.attachments.Attachment in project sw360portal by sw360.
the class DisplayDownloadApprovedClearingReportTest method createAttachment.
private Attachment createAttachment(String filename) {
Attachment attachment = new Attachment();
attachment.setFilename(filename);
return attachment;
}
use of org.eclipse.sw360.datahandler.thrift.attachments.Attachment in project sw360portal by sw360.
the class ComponentAttachmentCSVRecord method getAttachment.
public Attachment getAttachment() {
final Attachment attachment = new Attachment().setAttachmentContentId(attachmentContentId).setFilename(filename);
if (!isNullOrEmpty(attachmentType)) {
final AttachmentType attachmentTypeCandidate = ThriftEnumUtils.stringToEnum(attachmentType, AttachmentType.class);
if (attachmentTypeCandidate != null)
attachment.setAttachmentType(attachmentTypeCandidate);
}
attachment.setCreatedComment(nullToEmpty(comment)).setCreatedOn(nullToEmpty(createdOn)).setCreatedBy(nullToEmpty(createdBy));
return attachment;
}
Aggregations