Search in sources :

Example 11 with LicenseInfoUsage

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));
}
Also used : AttachmentUsage(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentUsage) LicenseInfoUsage(org.eclipse.sw360.datahandler.thrift.attachments.LicenseInfoUsage)

Aggregations

AttachmentUsage (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentUsage)10 LicenseInfoUsage (org.eclipse.sw360.datahandler.thrift.attachments.LicenseInfoUsage)10 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Strings (com.google.common.base.Strings)1 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 Strings.nullToEmpty (com.google.common.base.Strings.nullToEmpty)1 com.google.common.collect (com.google.common.collect)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 JSONArray (com.liferay.portal.kernel.json.JSONArray)1 JSONException (com.liferay.portal.kernel.json.JSONException)1 JSONFactoryUtil (com.liferay.portal.kernel.json.JSONFactoryUtil)1 JSONFactoryUtil.createJSONArray (com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONArray)1 JSONFactoryUtil.createJSONObject (com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject)1 JSONObject (com.liferay.portal.kernel.json.JSONObject)1 PortletResponseUtil (com.liferay.portal.kernel.portlet.PortletResponseUtil)1 SessionMessages (com.liferay.portal.kernel.servlet.SessionMessages)1 Organization (com.liferay.portal.model.Organization)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1