use of org.eclipse.sw360.datahandler.thrift.attachments.LicenseInfoUsage in project sw360portal by sw360.
the class AttachmentHandlerTest method testDeleteAttachmentUsagesByUsageDataTypeWithEmptyType.
@Test
public void testDeleteAttachmentUsagesByUsageDataTypeWithEmptyType() throws Exception {
AttachmentUsage usage1 = createUsage("p1", "r1", "a11");
usage1.setUsageData(UsageData.licenseInfo(new LicenseInfoUsage(Sets.newHashSet("l1", "l2"))));
AttachmentUsage usage2 = createUsage("p1", "r1", "a12");
usage2.setUsageData(UsageData.licenseInfo(new LicenseInfoUsage(Sets.newHashSet())));
AttachmentUsage usage3 = createUsage("p1", "r2", "a21");
AttachmentUsage usage4 = createUsage("p2", "r1", "a11");
AttachmentUsage usage5 = createUsage("p3", "r1", "a11");
usage5.setUsageData(UsageData.licenseInfo(new LicenseInfoUsage(Sets.newHashSet("l3"))));
handler.makeAttachmentUsages(Lists.newArrayList(usage1, usage2, usage3, usage4, usage5));
handler.deleteAttachmentUsagesByUsageDataType(Source.projectId("p1"), null);
Assert.assertThat(handler.getUsedAttachments(Source.projectId("p1"), null), Matchers.containsInAnyOrder(usage1, usage2));
Assert.assertThat(handler.getUsedAttachments(Source.projectId("p2"), null), Matchers.containsInAnyOrder(usage4));
Assert.assertThat(handler.getUsedAttachments(Source.projectId("p3"), null), Matchers.containsInAnyOrder(usage5));
}
Aggregations