Search in sources :

Example 66 with Release._Fields

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

the class FossologyFileHandlerTest method testGetStatusInFossology.

@Test
public void testGetStatusInFossology() throws Exception {
    final String id1 = "41";
    final FilledAttachment filledAttachment = getMockFilledAttachment(id1);
    final Release release = mock(Release.class);
    final Release updated = mock(Release.class);
    when(componentService.getReleaseById(releaseId, user)).thenReturn(release, updated);
    spyGetFilledSourceAttachment(filledAttachment);
    int fossologyId = 14;
    when(release.isSetFossologyId()).thenReturn(true);
    when(release.getFossologyId()).thenReturn("" + fossologyId);
    String clearingTeam2 = "anotherClearingTeam";
    when(fossologyUploader.getStatusInFossology(eq(fossologyId), eq(clearingTeam))).thenReturn(FossologyStatus.IN_PROGRESS);
    when(fossologyUploader.getStatusInFossology(eq(fossologyId), eq(clearingTeam2))).thenReturn(FossologyStatus.OPEN);
    doNothing().when(fossologyFileHandler).setFossologyStatus(eq(release), eq(clearingTeam), eq(FossologyStatus.IN_PROGRESS), eq("" + fossologyId), eq(id1));
    doReturn(ImmutableList.of(clearingTeam, clearingTeam2)).when(fossologyFileHandler).getAllClearingTeams(release, clearingTeam);
    final Release resultRelease = fossologyFileHandler.getStatusInFossology(releaseId, user, clearingTeam);
    assertThat(resultRelease, is(sameInstance(release)));
    verify(fossologyFileHandler).setFossologyStatus(release, clearingTeam, FossologyStatus.IN_PROGRESS);
    verify(fossologyFileHandler).setFossologyStatus(release, clearingTeam2, FossologyStatus.OPEN);
    verify(fossologyUploader).getStatusInFossology(fossologyId, clearingTeam);
    verify(fossologyUploader).getStatusInFossology(fossologyId, clearingTeam2);
    verify(componentService, atLeastOnce()).getReleaseById(releaseId, user);
    verify(componentService).updateReleaseFossology(release, user);
}
Also used : FilledAttachment(org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Example 67 with Release._Fields

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

the class FossologyFileHandlerTest method testGetStatusInFossologyDoesNotUpdateInDatabaseOnConnectionFailures.

@Test
public void testGetStatusInFossologyDoesNotUpdateInDatabaseOnConnectionFailures() throws Exception {
    final String id1 = "41";
    final FilledAttachment filledAttachment = getMockFilledAttachment(id1);
    final Release release = mock(Release.class);
    when(componentService.getReleaseById(releaseId, user)).thenReturn(release);
    spyGetFilledSourceAttachment(filledAttachment);
    int fossologyId = 14;
    when(release.isSetFossologyId()).thenReturn(true);
    when(release.getFossologyId()).thenReturn("" + fossologyId);
    String clearingTeam2 = "anotherClearingTeam";
    when(fossologyUploader.getStatusInFossology(eq(fossologyId), eq(clearingTeam))).thenReturn(FossologyStatus.IN_PROGRESS);
    when(fossologyUploader.getStatusInFossology(eq(fossologyId), eq(clearingTeam2))).thenReturn(FossologyStatus.CONNECTION_FAILED);
    doNothing().when(fossologyFileHandler).setFossologyStatus(eq(release), eq(clearingTeam), eq(FossologyStatus.IN_PROGRESS), eq("" + fossologyId), eq(id1));
    doReturn(ImmutableList.of(clearingTeam, clearingTeam2)).when(fossologyFileHandler).getAllClearingTeams(release, clearingTeam);
    final Release resultRelease = fossologyFileHandler.getStatusInFossology(releaseId, user, clearingTeam);
    assertThat(resultRelease, is(sameInstance(release)));
    verify(fossologyFileHandler).setFossologyStatus(release, clearingTeam, FossologyStatus.IN_PROGRESS);
    verify(fossologyFileHandler).setFossologyStatus(release, clearingTeam2, FossologyStatus.CONNECTION_FAILED);
    verify(fossologyUploader).getStatusInFossology(fossologyId, clearingTeam);
    verify(fossologyUploader).getStatusInFossology(fossologyId, clearingTeam2);
    verify(componentService, atLeastOnce()).getReleaseById(releaseId, user);
    verify(componentService, never()).updateReleaseFossology(release, user);
}
Also used : FilledAttachment(org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Example 68 with Release._Fields

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

the class FossologyFileHandlerTest method testNotUnlockingForNoClearing.

@Test
public void testNotUnlockingForNoClearing() throws Exception {
    Release release = mock(Release.class);
    doReturn(null).when(fossologyFileHandler).updateRelease(release, user, componentService);
    doReturn(release).when(componentService).getReleaseById(releaseId, user);
    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 69 with Release._Fields

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

the class FossologyFileHandlerTest method testGetAllClearingTeams.

@Test
public void testGetAllClearingTeams() throws Exception {
    Release release = mock(Release.class);
    String clearingTeam2 = "team2";
    String clearingTeam3 = "yetAnotherTeam";
    when(release.getClearingTeamToFossologyStatus()).thenReturn(ImmutableMap.of(clearingTeam, FossologyStatus.CLOSED, clearingTeam2, FossologyStatus.ERROR));
    assertThat(fossologyFileHandler.getAllClearingTeams(release, clearingTeam), containsInAnyOrder(clearingTeam, clearingTeam2));
    assertThat(fossologyFileHandler.getAllClearingTeams(release, clearingTeam3), containsInAnyOrder(clearingTeam, clearingTeam2, clearingTeam3));
}
Also used : Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Example 70 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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);
}
Also used : Release(org.eclipse.sw360.datahandler.thrift.components.Release) Test(org.junit.Test)

Aggregations

Release (org.eclipse.sw360.datahandler.thrift.components.Release)93 User (org.eclipse.sw360.datahandler.thrift.users.User)42 TException (org.apache.thrift.TException)38 Test (org.junit.Test)23 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)20 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)13 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)13 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)12 FieldMetaData (org.apache.thrift.meta_data.FieldMetaData)11 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 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