use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class ReleaseClearingStateSummaryComputer method computeReleaseClearingStateSummary.
public static ReleaseClearingStateSummary computeReleaseClearingStateSummary(List<Release> releases, String clearingTeam) {
ReleaseClearingStateSummary summary = new ReleaseClearingStateSummary(0, 0, 0, 0, 0);
if (releases == null) {
return summary;
}
for (Release release : releases) {
Map<String, FossologyStatus> fossologyStatuses = nullToEmptyMap(release.getClearingTeamToFossologyStatus());
ViewedState globalState = getGlobalState(release.getClearingState());
ViewedState myTeamState = getStateOfFossology(fossologyStatuses.get(clearingTeam));
ViewedState otherTeamState = getBestStateOfFossologyForOtherTeams(clearingTeam, fossologyStatuses);
addReleaseWithStates(summary, globalState, myTeamState, otherTeamState);
}
return summary;
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyUploaderTest method testParseResult.
@Test
public void testParseResult() {
final FossologyStatus fossologyStatus = FossologyStatus.CLOSED;
assertThat(fossologyUploader.parseResultStatus("status=" + fossologyStatus), is(fossologyStatus));
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyUploaderTest method testGetStatusInFossology.
@Test
public void testGetStatusInFossology() throws Exception {
int uploadId = 42;
fossologyUploader = spy(fossologyUploader);
String clearingTeam = "team d";
final String output = "output result\nfrom the get status script";
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
final OutputStream os = (OutputStream) invocation.getArguments()[1];
os.write(output.getBytes());
return 0;
}
}).when(sshConnector).runInFossologyViaSsh(anyString(), any(OutputStream.class));
FossologyStatus parseResult = FossologyStatus.IN_PROGRESS;
doReturn(parseResult).when(fossologyUploader).parseResultStatus(output);
FossologyStatus statusInFossology = fossologyUploader.getStatusInFossology(uploadId, clearingTeam);
assertThat(statusInFossology, is(parseResult));
verify(fossologyUploader).parseResultStatus(output);
verify(sshConnector).runInFossologyViaSsh(anyString(), any(OutputStream.class));
verify(fossologyUploader).getStatusInFossology(uploadId, clearingTeam);
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyFileHandlerTest method testUpdateFossologyStatusForTheFirstTimeCreatesTheStatusMap.
@Test
public void testUpdateFossologyStatusForTheFirstTimeCreatesTheStatusMap() {
Release release = mock(Release.class);
fossologyFileHandler.setFossologyStatus(release, clearingTeam, FossologyStatus.SCANNING, "13", "14");
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
try {
@SuppressWarnings("unchecked") Map<String, FossologyStatus> statusMap = (Map<String, FossologyStatus>) invocation.getArguments()[0];
assertThat(statusMap, hasEntry(clearingTeam, FossologyStatus.SCANNING));
assertThat(statusMap.keySet(), containsInAnyOrder(clearingTeam));
} catch (ClassCastException e) {
fail("status was supposed to be a map :-/" + e.getMessage());
}
return null;
}
}).when(release).setClearingTeamToFossologyStatus(anyMapOf(String.class, FossologyStatus.class));
verify(release).setClearingTeamToFossologyStatus(anyMapOf(String.class, FossologyStatus.class));
verify(release).setFossologyId("13");
verify(release).setAttachmentInFossology("14");
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyFileHandlerTest method testUpdateFossologyStatusAddTheNewStatus.
@Test
public void testUpdateFossologyStatusAddTheNewStatus() {
Release release = mock(Release.class);
final String clearingTeam2 = "team2";
final Map<String, FossologyStatus> existingStatuses = newHashMap();
existingStatuses.put(clearingTeam, FossologyStatus.SENT);
existingStatuses.put(clearingTeam2, FossologyStatus.CLOSED);
when(release.getClearingTeamToFossologyStatus()).thenReturn(existingStatuses);
fossologyFileHandler.setFossologyStatus(release, clearingTeam, FossologyStatus.SCANNING);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
try {
@SuppressWarnings("unchecked") Map<String, FossologyStatus> statusMap = (Map<String, FossologyStatus>) invocation.getArguments()[0];
assertThat(statusMap, hasEntry(clearingTeam, FossologyStatus.SCANNING));
assertThat(statusMap, hasEntry(clearingTeam2, FossologyStatus.CLOSED));
assertThat(statusMap.keySet(), containsInAnyOrder(clearingTeam, clearingTeam2));
} catch (ClassCastException e) {
fail("status was supposed to be a map :-/" + e.getMessage());
}
return null;
}
}).when(release).setClearingTeamToFossologyStatus(anyMapOf(String.class, FossologyStatus.class));
verify(release).setClearingTeamToFossologyStatus(anyMapOf(String.class, FossologyStatus.class));
}
Aggregations