Search in sources :

Example 1 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ComponentSummary method makeExportSummary.

private Component makeExportSummary(Component document, List<Release> releases) {
    if (releaseRepository == null) {
        throw new IllegalStateException("Cannot make export summary without database connection!");
    }
    Component copy = new Component();
    copyField(document, copy, Component._Fields.ID);
    copyField(document, copy, Component._Fields.NAME);
    copyField(document, copy, Component._Fields.LANGUAGES);
    copyField(document, copy, Component._Fields.OPERATING_SYSTEMS);
    copyField(document, copy, Component._Fields.SOFTWARE_PLATFORMS);
    copyField(document, copy, Component._Fields.CREATED_BY);
    copyField(document, copy, Component._Fields.CREATED_ON);
    copyField(document, copy, Component._Fields.VENDOR_NAMES);
    for (Release release : releases) {
        Release exportRelease = new Release();
        copyField(release, exportRelease, Release._Fields.NAME);
        copyField(release, exportRelease, Release._Fields.VERSION);
        exportRelease.setComponentId("");
        copy.addToReleases(exportRelease);
    }
    return copy;
}
Also used : Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 2 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ComponentHandlerTest method testGetByUploadId.

@Test
public void testGetByUploadId() throws Exception {
    Component originalComponent = new Component("name").setDescription("a desc");
    String componentId = componentHandler.addComponent(originalComponent, adminUser).getId();
    Release release = new Release("name", "version", componentId).setFossologyId("id");
    String releaseId = componentHandler.addRelease(release, adminUser).getId();
    Component component = componentHandler.getComponentForReportFromFossologyUploadId("id");
    assertThat(component, is(not(nullValue())));
    assertThat(component, is(equalTo(originalComponent, restrictedToFields(ID, NAME, DESCRIPTION))));
    assertThat(componentHandler.getReleaseById(releaseId, adminUser), is(not(nullValue())));
    assertThat(componentHandler.getComponentById(componentId, adminUser), is(not(nullValue())));
    assertThat(componentHandler.deleteRelease(releaseId, adminUser), is(RequestStatus.SUCCESS));
    assertThat(componentHandler.deleteComponent(componentId, adminUser), is(RequestStatus.SUCCESS));
    try {
        componentHandler.getReleaseById(releaseId, adminUser);
        fail("expected exception not thrown");
    } catch (SW360Exception e) {
        assertThat(e.getWhy(), containsString("Could not fetch"));
    }
    try {
        componentHandler.getComponentById(componentId, adminUser);
        fail("expected exception not thrown");
    } catch (SW360Exception e) {
        assertThat(e.getWhy(), containsString("Could not fetch"));
    }
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception) Test(org.junit.Test)

Example 3 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ComponentDatabaseHandlerTest method testDuplicateCheckDoesntMatchByPrefix.

@Test
public void testDuplicateCheckDoesntMatchByPrefix() throws Exception {
    String originalReleaseId = "R1A";
    final Release tmp = handler.getRelease(originalReleaseId, user1);
    tmp.unsetId();
    tmp.unsetRevision();
    tmp.setName(tmp.getName().substring(0, 4));
    String newReleaseId = handler.addRelease(tmp, email1).getId();
    assertThat(newReleaseId, not(isEmptyOrNullString()));
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString)

Example 4 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ComponentDatabaseHandlerTest method testEccUpdateSentToEccModeration.

@Test
public void testEccUpdateSentToEccModeration() throws Exception {
    Release release = releases.get(1);
    String expected = release.getEccInformation().getAL();
    release.getEccInformation().setAL("UPDATED");
    when(releaseModerator.updateReleaseEccInfo(release, user1)).thenReturn(RequestStatus.SENT_TO_MODERATOR);
    RequestStatus status = handler.updateRelease(release, user1, ThriftUtils.IMMUTABLE_OF_RELEASE);
    Release actual = handler.getRelease("R1B", user1);
    assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
    assertEquals(expected, actual.getEccInformation().getAL());
    verify(releaseModerator).updateReleaseEccInfo(release, user1);
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 5 with Release

use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.

the class ComponentDatabaseHandlerTest method testUpdateSentToModeration.

@Test
public void testUpdateSentToModeration() throws Exception {
    Release release = releases.get(1);
    String expected = release.getName();
    release.setName("UPDATED");
    when(releaseModerator.updateRelease(release, user1)).thenReturn(RequestStatus.SENT_TO_MODERATOR);
    RequestStatus status = handler.updateRelease(release, user1, ThriftUtils.IMMUTABLE_OF_RELEASE);
    Release actual = handler.getRelease("R1B", user1);
    assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
    assertEquals(expected, actual.getName());
    verify(releaseModerator).updateRelease(release, user1);
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Aggregations

Release (org.eclipse.sw360.datahandler.thrift.components.Release)93 User (org.eclipse.sw360.datahandler.thrift.users.User)39 TException (org.apache.thrift.TException)34 Test (org.junit.Test)22 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)20 Component (org.eclipse.sw360.datahandler.thrift.components.Component)18 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)15 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)13 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)13 FossologyStatus (org.eclipse.sw360.datahandler.thrift.components.FossologyStatus)11 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)10 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)9 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)9 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)7 Before (org.junit.Before)7 Collectors (java.util.stream.Collectors)6 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)6 FilledAttachment (org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment)6 IOException (java.io.IOException)5 java.util (java.util)5