Search in sources :

Example 11 with ComponentService

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

the class FossologyFileHandlerTest method testSendToFossologyDuplicates.

@Test
public void testSendToFossologyDuplicates() throws Exception {
    final FilledAttachment filledAttachment = getMockFilledAttachment("17");
    final Release release = mock(Release.class);
    when(componentService.getReleaseById(releaseId, user)).thenReturn(release);
    when(release.getFossologyId()).thenReturn("41");
    when(release.isSetFossologyId()).thenReturn(true);
    when(release.getClearingState()).thenReturn(ClearingState.SENT_TO_FOSSOLOGY);
    spyGetFilledSourceAttachment(filledAttachment);
    when(fossologyUploader.duplicateInFossology(41, clearingTeam)).thenReturn(true);
    doNothing().when(fossologyFileHandler).setFossologyStatus(eq(release), anyString(), any(FossologyStatus.class));
    doReturn(true).when(fossologyFileHandler).checkSourceAttachment(release, filledAttachment);
    assertThat(fossologyFileHandler.sendToFossology(releaseId, user, clearingTeam), is(RequestStatus.SUCCESS));
    verify(fossologyUploader).duplicateInFossology(41, clearingTeam);
    verify(fossologyUploader).getStatusInFossology(eq(41), eq(clearingTeam));
    verify(fossologyFileHandler).setFossologyStatus(eq(release), eq(clearingTeam), eq(FossologyStatus.SENT));
    verify(componentService).updateReleaseFossology(release, user);
    verify(componentService, atLeastOnce()).getReleaseById(releaseId, user);
    verifyNoMoreInteractions(attachmentConnector);
}
Also used : FilledAttachment(org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment) FossologyStatus(org.eclipse.sw360.datahandler.thrift.components.FossologyStatus) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Example 12 with ComponentService

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

the class FossologyFileHandlerTest method testUnlocking.

@Test
public void testUnlocking() 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.REJECTED, "b", FossologyStatus.REJECTED));
    fossologyFileHandler.getReleaseAndUnlockIt(releaseId, user, componentService);
    verify(fossologyFileHandler).updateRelease(release, user, componentService);
    verify(componentService).getReleaseById(releaseId, user);
    verify(release).unsetAttachmentInFossology();
    verify(release).unsetFossologyId();
}
Also used : Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Aggregations

Release (org.eclipse.sw360.datahandler.thrift.components.Release)10 Test (org.junit.Test)10 FilledAttachment (org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment)7 InputStream (java.io.InputStream)2 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)2 FossologyStatus (org.eclipse.sw360.datahandler.thrift.components.FossologyStatus)2 ThriftClients (org.eclipse.sw360.datahandler.thrift.ThriftClients)1 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)1 Before (org.junit.Before)1