use of org.eclipse.sw360.datahandler.thrift.components.ComponentService in project sw360portal by sw360.
the class FossologyFileHandlerTest method testSendToFossologyWithNoSourcesIsSuccess.
@Test
public void testSendToFossologyWithNoSourcesIsSuccess() throws Exception {
final Release release = mock(Release.class);
when(componentService.getReleaseById(releaseId, user)).thenReturn(release);
assertThat(fossologyFileHandler.sendToFossology(releaseId, user, clearingTeam), is(RequestStatus.FAILURE));
verify(componentService).getReleaseById(releaseId, user);
verify(componentService).getSourceAttachments(releaseId);
}
use of org.eclipse.sw360.datahandler.thrift.components.ComponentService in project sw360portal by sw360.
the class FossologyFileHandlerTest method spyGetFilledSourceAttachment.
private void spyGetFilledSourceAttachment(FilledAttachment filledAttachment) throws TException {
final Attachment attachment = filledAttachment.getAttachment();
doReturn(ImmutableSet.of(attachment)).when(fossologyFileHandler).getSourceAttachment(releaseId, user, componentService);
doReturn(filledAttachment).when(fossologyFileHandler).fillAttachment(attachment);
}
use of org.eclipse.sw360.datahandler.thrift.components.ComponentService 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);
}
use of org.eclipse.sw360.datahandler.thrift.components.ComponentService 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);
}
use of org.eclipse.sw360.datahandler.thrift.components.ComponentService in project sw360portal by sw360.
the class FossologyFileHandlerTest method setUp.
@Before
public void setUp() throws TException {
ThriftClients thriftClients = TestUtils.failingMock(ThriftClients.class);
doReturn(componentService).when(thriftClients).makeComponentClient();
user = TestUtils.getAdminUser(getClass());
fossologyFileHandler = spy(new FossologyFileHandler(attachmentConnector, fossologyUploader, thriftClients));
}
Aggregations