Search in sources :

Example 6 with AttachmentConnector

use of org.eclipse.sw360.datahandler.couchdb.AttachmentConnector in project sw360portal by sw360.

the class RemoteAttachmentDownloaderTest method setUp.

@Before
public void setUp() throws Exception {
    DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), dbName);
    attachmentConnector = new AttachmentConnector(DatabaseSettings.getConfiguredHttpClient(), dbName, downloadTimeout);
    repository = new AttachmentRepository(databaseConnector);
    garbage = new ArrayList<>();
}
Also used : DatabaseConnector(org.eclipse.sw360.datahandler.couchdb.DatabaseConnector) AttachmentConnector(org.eclipse.sw360.datahandler.couchdb.AttachmentConnector) Before(org.junit.Before)

Example 7 with AttachmentConnector

use of org.eclipse.sw360.datahandler.couchdb.AttachmentConnector 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));
}
Also used : ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients) Before(org.junit.Before)

Example 8 with AttachmentConnector

use of org.eclipse.sw360.datahandler.couchdb.AttachmentConnector 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)

Aggregations

FilledAttachment (org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment)4 Release (org.eclipse.sw360.datahandler.thrift.components.Release)4 Test (org.junit.Test)4 InputStream (java.io.InputStream)3 AttachmentConnector (org.eclipse.sw360.datahandler.couchdb.AttachmentConnector)3 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)3 DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)2 FossologyStatus (org.eclipse.sw360.datahandler.thrift.components.FossologyStatus)2 Before (org.junit.Before)2 IOException (java.io.IOException)1 AttachmentFrontendUtils (org.eclipse.sw360.commonIO.AttachmentFrontendUtils)1 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)1 ThriftClients (org.eclipse.sw360.datahandler.thrift.ThriftClients)1