use of org.eclipse.sw360.datahandler.thrift.projects.Project 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.projects.Project in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method testReleaseIdToProjects.
@Test
public void testReleaseIdToProjects() throws Exception {
Project p1 = handler.getProjectById("P1", user1);
p1.setLinkedProjects(ImmutableMap.<String, ProjectRelationship>builder().put("P2", ProjectRelationship.CONTAINED).build());
handler.updateProject(p1, user1);
Project p2 = handler.getProjectById("P2", user2);
SetMultimap<String, ProjectWithReleaseRelationTuple> releaseIdToProjects = handler.releaseIdToProjects(p1, user1);
Set<String> releaseIds = releaseIdToProjects.keySet();
assertThat(releaseIds, containsInAnyOrder("r1", "r2", "r3", "r4", "r5", "r6"));
assertThat(releaseIdToProjects.get("r1"), containsInAnyOrder(createTuple(p1), createTuple(p2)));
assertThat(releaseIdToProjects.get("r2"), containsInAnyOrder(createTuple(p1), createTuple(p2)));
assertThat(releaseIdToProjects.get("r3"), containsInAnyOrder(createTuple(p1), createTuple(p2)));
assertThat(releaseIdToProjects.get("r4"), containsInAnyOrder(createTuple(p1)));
assertThat(releaseIdToProjects.get("r5"), containsInAnyOrder(createTuple(p1)));
assertThat(releaseIdToProjects.get("r6"), containsInAnyOrder(createTuple(p1)));
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method testGetLinkedProjectsOfProjectForClonedProject.
@Test
public void testGetLinkedProjectsOfProjectForClonedProject() throws Exception {
Project p = handler.getProjectById("P4", user1);
Project clone = p.deepCopy();
clone.unsetId();
clone.unsetRevision();
List<ProjectLink> projectLinks = handler.getLinkedProjects(clone, false, user1);
assertThat(projectLinks.size(), is(1));
assertThat(projectLinks.get(0).getSubprojects().size(), is(1));
assertThat(projectLinks.get(0).getLinkedReleases().size(), is(2));
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method testUpdateProject2_1.
@Test
public void testUpdateProject2_1() throws Exception {
Project project2 = handler.getProjectById("P2", user1);
project2.setName("Project2new");
Mockito.doReturn(RequestStatus.SENT_TO_MODERATOR).when(moderator).updateProject(project2, user1);
RequestStatus status = handler.updateProject(project2, user1);
// Now contributors can also change the project
assertEquals(RequestStatus.SUCCESS, status);
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method testGetLinkedProjectsOfProject.
@Test
public void testGetLinkedProjectsOfProject() throws Exception {
Project p = handler.getProjectById("P4", user1);
List<ProjectLink> projectLinks = handler.getLinkedProjects(p, false, user1);
assertThat(projectLinks.size(), is(1));
assertThat(projectLinks.get(0).getSubprojects().size(), is(1));
assertThat(projectLinks.get(0).getLinkedReleases().size(), is(2));
}
Aggregations