use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class ProjectSummaryTest method testAllRequiredFieldsAreSet.
@Test
public void testAllRequiredFieldsAreSet() throws Exception {
Project project = new Project();
Project copy = new Project();
for (Project._Fields renderedField : PROJECT_RENDERED_FIELDS) {
switch(renderedField) {
case STATE:
project.state = ProjectState.ACTIVE;
break;
case PERMISSIONS:
project.permissions = Collections.emptyMap();
break;
case EXTERNAL_IDS:
project.externalIds = Collections.emptyMap();
break;
case ATTACHMENTS:
project.attachments = Collections.emptySet();
break;
case PROJECT_TYPE:
project.projectType = ProjectType.INTERNAL;
break;
case MODERATORS:
project.moderators = ImmutableSet.of("moderator@sw360.org");
break;
case CONTRIBUTORS:
project.contributors = ImmutableSet.of("contributor1@sw360.org", "contributor2@sw360.org");
break;
case SECURITY_RESPONSIBLES:
project.securityResponsibles = ImmutableSet.of("securityresponsible1@sw360.org", "securityresponsible2@sw360.org");
break;
case VISBILITY:
project.visbility = Visibility.EVERYONE;
break;
case LINKED_PROJECTS:
project.linkedProjects = Collections.emptyMap();
break;
case RELEASE_ID_TO_USAGE:
project.releaseIdToUsage = Collections.emptyMap();
break;
case RELEASE_CLEARING_STATE_SUMMARY:
project.releaseClearingStateSummary = new ReleaseClearingStateSummary();
break;
case CLEARING_STATE:
project.clearingState = ProjectClearingState.OPEN;
break;
case ROLES:
project.roles = Collections.emptyMap();
break;
case ENABLE_SVM:
project.enableSvm = true;
break;
default:
// most fields are string
project.setFieldValue(renderedField, "asd");
break;
}
}
ProjectSummary.setSummaryFields(project, copy);
for (Project._Fields renderedField : PROJECT_RENDERED_FIELDS) {
assertNotNull(copy.getFieldValue(renderedField));
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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._Fields 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._Fields 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._Fields 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