use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentSummary method makeExportSummary.
private Component makeExportSummary(Component document, List<Release> releases) {
if (releaseRepository == null) {
throw new IllegalStateException("Cannot make export summary without database connection!");
}
Component copy = new Component();
copyField(document, copy, Component._Fields.ID);
copyField(document, copy, Component._Fields.NAME);
copyField(document, copy, Component._Fields.LANGUAGES);
copyField(document, copy, Component._Fields.OPERATING_SYSTEMS);
copyField(document, copy, Component._Fields.SOFTWARE_PLATFORMS);
copyField(document, copy, Component._Fields.CREATED_BY);
copyField(document, copy, Component._Fields.CREATED_ON);
copyField(document, copy, Component._Fields.VENDOR_NAMES);
for (Release release : releases) {
Release exportRelease = new Release();
copyField(release, exportRelease, Release._Fields.NAME);
copyField(release, exportRelease, Release._Fields.VERSION);
exportRelease.setComponentId("");
copy.addToReleases(exportRelease);
}
return copy;
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentHandlerTest method testGetByUploadId.
@Test
public void testGetByUploadId() throws Exception {
Component originalComponent = new Component("name").setDescription("a desc");
String componentId = componentHandler.addComponent(originalComponent, adminUser).getId();
Release release = new Release("name", "version", componentId).setFossologyId("id");
String releaseId = componentHandler.addRelease(release, adminUser).getId();
Component component = componentHandler.getComponentForReportFromFossologyUploadId("id");
assertThat(component, is(not(nullValue())));
assertThat(component, is(equalTo(originalComponent, restrictedToFields(ID, NAME, DESCRIPTION))));
assertThat(componentHandler.getReleaseById(releaseId, adminUser), is(not(nullValue())));
assertThat(componentHandler.getComponentById(componentId, adminUser), is(not(nullValue())));
assertThat(componentHandler.deleteRelease(releaseId, adminUser), is(RequestStatus.SUCCESS));
assertThat(componentHandler.deleteComponent(componentId, adminUser), is(RequestStatus.SUCCESS));
try {
componentHandler.getReleaseById(releaseId, adminUser);
fail("expected exception not thrown");
} catch (SW360Exception e) {
assertThat(e.getWhy(), containsString("Could not fetch"));
}
try {
componentHandler.getComponentById(componentId, adminUser);
fail("expected exception not thrown");
} catch (SW360Exception e) {
assertThat(e.getWhy(), containsString("Could not fetch"));
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method testDuplicateCheckDoesntMatchByPrefix.
@Test
public void testDuplicateCheckDoesntMatchByPrefix() throws Exception {
String originalReleaseId = "R1A";
final Release tmp = handler.getRelease(originalReleaseId, user1);
tmp.unsetId();
tmp.unsetRevision();
tmp.setName(tmp.getName().substring(0, 4));
String newReleaseId = handler.addRelease(tmp, email1).getId();
assertThat(newReleaseId, not(isEmptyOrNullString()));
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method testEccUpdateSentToEccModeration.
@Test
public void testEccUpdateSentToEccModeration() throws Exception {
Release release = releases.get(1);
String expected = release.getEccInformation().getAL();
release.getEccInformation().setAL("UPDATED");
when(releaseModerator.updateReleaseEccInfo(release, user1)).thenReturn(RequestStatus.SENT_TO_MODERATOR);
RequestStatus status = handler.updateRelease(release, user1, ThriftUtils.IMMUTABLE_OF_RELEASE);
Release actual = handler.getRelease("R1B", user1);
assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
assertEquals(expected, actual.getEccInformation().getAL());
verify(releaseModerator).updateReleaseEccInfo(release, user1);
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method testUpdateSentToModeration.
@Test
public void testUpdateSentToModeration() throws Exception {
Release release = releases.get(1);
String expected = release.getName();
release.setName("UPDATED");
when(releaseModerator.updateRelease(release, user1)).thenReturn(RequestStatus.SENT_TO_MODERATOR);
RequestStatus status = handler.updateRelease(release, user1, ThriftUtils.IMMUTABLE_OF_RELEASE);
Release actual = handler.getRelease("R1B", user1);
assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
assertEquals(expected, actual.getName());
verify(releaseModerator).updateRelease(release, user1);
}
Aggregations