Search in sources :

Example 61 with Release

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

the class FossologyFileHandlerTest method testNotUnlockingIfATeamIsWorkingOnIt.

@Test
public void testNotUnlockingIfATeamIsWorkingOnIt() throws Exception {
    Release release = mock(Release.class);
    doReturn(null).when(fossologyFileHandler).updateRelease(release, user, componentService);
    doReturn(release).when(componentService).getReleaseById(releaseId, user);
    when(release.getClearingTeamToFossologyStatus()).thenReturn(ImmutableMap.of("a", FossologyStatus.OPEN, "b", FossologyStatus.REJECTED));
    fossologyFileHandler.getReleaseAndUnlockIt(releaseId, user, componentService);
    verify(fossologyFileHandler, never()).updateRelease(release, user, componentService);
    verify(componentService).getReleaseById(releaseId, user);
    verify(release).getClearingTeamToFossologyStatus();
    verifyNoMoreInteractions(release);
}
Also used : Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Example 62 with Release

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

the class FossologyFileHandlerTest method testSendToFossologySendsAnAttachment.

@Test
public void testSendToFossologySendsAnAttachment() throws Exception {
    final String id = "41";
    final FilledAttachment filledAttachment = getMockFilledAttachment(id);
    final AttachmentContent attachmentContent = filledAttachment.getAttachmentContent();
    final Release release = mock(Release.class);
    when(componentService.getReleaseById(releaseId, user)).thenReturn(release);
    spyGetFilledSourceAttachment(filledAttachment);
    final InputStream inputStream = mock(InputStream.class);
    when(release.isSetFossologyId()).thenReturn(false);
    when(release.getClearingState()).thenReturn(ClearingState.NEW_CLEARING);
    when(attachmentConnector.getAttachmentStream(attachmentContent, user, release)).thenReturn(inputStream);
    when(fossologyUploader.uploadToFossology(inputStream, attachmentContent, clearingTeam)).thenReturn(1);
    doNothing().when(fossologyFileHandler).setFossologyStatus(eq(release), anyString(), eq(FossologyStatus.SENT), eq("" + 1), eq(id));
    doReturn(true).when(fossologyFileHandler).checkSourceAttachment(release, filledAttachment);
    assertThat(fossologyFileHandler.sendToFossology(releaseId, user, clearingTeam), is(RequestStatus.SUCCESS));
    verify(inputStream).close();
    // the release should be updated
    verify(componentService).updateReleaseFossology(release, user);
    verify(fossologyFileHandler).setFossologyStatus(eq(release), anyString(), eq(FossologyStatus.SENT), eq("" + 1), eq(id));
    // unimportant verifies
    verify(componentService, times(1)).getReleaseById(releaseId, user);
    verify(attachmentConnector).getAttachmentStream(attachmentContent, user, release);
    verify(fossologyUploader).uploadToFossology(inputStream, attachmentContent, clearingTeam);
}
Also used : InputStream(java.io.InputStream) AttachmentContent(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent) FilledAttachment(org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Example 63 with Release

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

the class CveSearchWrapperTest method testLargeData.

@Ignore
@Test
public void testLargeData() throws IOException {
    Release release = new ReleaseBuilder().setName("server").get();
    Optional<List<CveSearchData>> resultWrapped = cveSearchWrapper.searchForRelease(release);
    assert (resultWrapped.isPresent());
    assert (resultWrapped.get() != null);
}
Also used : List(java.util.List) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 64 with Release

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

the class CveSearchWrapperTest method compareToSearchByCPE.

@Test
public void compareToSearchByCPE() throws IOException {
    Release release = new ReleaseBuilder().setName("blindstring").setVendorFullname("blindstring").setVendorShortname("blindstring").setCpe(CPE).get();
    List<CveSearchData> resultDirect = cveSearchApi.cvefor(CPE);
    Optional<List<CveSearchData>> resultWrapped = cveSearchWrapper.searchForRelease(release);
    assert (resultWrapped.isPresent());
    assert (resultWrapped.get() != null);
    assert (isEquivalent(resultDirect, resultWrapped.get()));
}
Also used : List(java.util.List) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Example 65 with Release

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

the class CveSearchWrapperTest method compareToWithoutWrapper.

@Ignore("meanwhile cveSearchWrapper implementation changed, test maybe suitable for later use")
@Test
public void compareToWithoutWrapper() throws IOException {
    Release release = new ReleaseBuilder().setName(PRODUCTNAME).setVendorFullname(VENDORNAME).get();
    List<CveSearchData> resultDirect = cveSearchApi.search(VENDORNAME, PRODUCTNAME);
    Optional<List<CveSearchData>> resultWrapped = cveSearchWrapper.searchForRelease(release);
    assert (resultWrapped.isPresent());
    assert (resultWrapped.get() != null);
    assert (resultWrapped.get().size() > 0);
    assert (isEquivalent(resultDirect, resultWrapped.get()));
}
Also used : List(java.util.List) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Ignore(org.junit.Ignore) Test(org.junit.Test)

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