Search in sources :

Example 91 with Release

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

the class ComponentDatabaseHandlerTest method testDeleteReleaseNotModerator.

@Test
public void testDeleteReleaseNotModerator() throws Exception {
    when(releaseModerator.deleteRelease(any(Release.class), eq(user1))).thenReturn(RequestStatus.SENT_TO_MODERATOR);
    RequestStatus status = handler.deleteRelease("R1B", user1);
    assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
    List<Release> releaseSummary = handler.getReleaseSummary();
    assertEquals(5, releaseSummary.size());
    assertTrue("Component NOT deleted", releasesContain(releaseSummary, "R1B"));
    verify(releaseModerator).deleteRelease(any(Release.class), eq(user1));
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 92 with Release

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

the class ComponentDatabaseHandlerTest method testAddRelease.

@Test
public void testAddRelease() throws Exception {
    Release expected = new Release().setName("REL").setVersion("VER");
    expected.setComponentId("C1");
    String id = handler.addRelease(expected, "new@mail.com").getId();
    assertNotNull(id);
    Release actual = handler.getRelease(id, user1);
    // Check that object was added correctly
    assertEquals(expected.getName(), actual.getName());
    assertEquals(expected.getVersion(), actual.getVersion());
    // Check that the component was also updated
    Component component = handler.getComponent("C1", user1);
    assertTrue(releasesContain(component.getReleases(), id));
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString)

Example 93 with Release

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

the class ComponentDatabaseHandlerTest method testUpdateRelease.

@Test
public void testUpdateRelease() throws Exception {
    Release expected = releases.get(1);
    expected.setName("UPDATED");
    RequestStatus status = handler.updateRelease(expected, user2, ThriftUtils.IMMUTABLE_OF_RELEASE);
    Release actual = handler.getRelease("R1B", user1);
    assertEquals(RequestStatus.SUCCESS, status);
    assertEquals(expected.getId(), actual.getId());
    assertEquals(expected.getName(), actual.getName());
    assertEquals(expected.getVersion(), actual.getVersion());
    assertEquals(expected.getComponentId(), actual.getComponentId());
    assertEquals(email2, actual.getCreatedBy());
    // Check releases
    assertEquals(1, actual.getSubscribersSize());
    assertTrue(actual.getSubscribers().contains(email1));
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 94 with Release

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

the class ComponentDatabaseHandlerTest method addRelease.

private String addRelease(String componentId, Set<String> licenseIds) throws SW360Exception {
    Release release = new Release().setName("REL").setVersion(nextReleaseVersion + "").setMainLicenseIds(licenseIds).setComponentId(componentId);
    nextReleaseVersion++;
    String id = handler.addRelease(release, user1.getEmail()).getId();
    assertNotNull(id);
    return id;
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString)

Example 95 with Release

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

the class SearchLevels method addGuessingSearchLevels.

private void addGuessingSearchLevels(CveSearchApi cveSearchApi, int vendorThreshold, int productThreshold, int cutoff) {
    CveSearchGuesser cveSearchGuesser = new CveSearchGuesser(cveSearchApi);
    cveSearchGuesser.setVendorThreshold(vendorThreshold);
    cveSearchGuesser.setProductThreshold(productThreshold);
    cveSearchGuesser.setCutoff(cutoff);
    // Level 2. search by guessed vendors and products with version
    searchLevels.add(release -> guessForRelease(cveSearchGuesser, release, true));
    // Level 3. search by guessed vendors and products without version
    searchLevels.add(release -> guessForRelease(cveSearchGuesser, release, false));
}
Also used : CveSearchGuesser(org.eclipse.sw360.cvesearch.datasource.CveSearchGuesser)

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