Search in sources :

Example 1 with Project

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));
    }
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ReleaseClearingStateSummary(org.eclipse.sw360.datahandler.thrift.components.ReleaseClearingStateSummary) Test(org.junit.Test)

Example 2 with Project

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)));
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString) ProjectWithReleaseRelationTuple(org.eclipse.sw360.datahandler.thrift.projects.ProjectWithReleaseRelationTuple) Test(org.junit.Test)

Example 3 with Project

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));
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ProjectLink(org.eclipse.sw360.datahandler.thrift.projects.ProjectLink) Test(org.junit.Test)

Example 4 with Project

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);
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) Test(org.junit.Test)

Example 5 with Project

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));
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ProjectLink(org.eclipse.sw360.datahandler.thrift.projects.ProjectLink) Test(org.junit.Test)

Aggregations

Project (org.eclipse.sw360.datahandler.thrift.projects.Project)87 User (org.eclipse.sw360.datahandler.thrift.users.User)46 Test (org.junit.Test)42 TException (org.apache.thrift.TException)27 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)16 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)15 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)12 Release (org.eclipse.sw360.datahandler.thrift.components.Release)12 ProjectService (org.eclipse.sw360.datahandler.thrift.projects.ProjectService)10 StringReader (java.io.StringReader)8 ReaderInputStream (org.apache.commons.io.input.ReaderInputStream)8 ProjectLink (org.eclipse.sw360.datahandler.thrift.projects.ProjectLink)8 IOException (java.io.IOException)7 InputStream (java.io.InputStream)7 HashMap (java.util.HashMap)7 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)7 ProjectRelationship (org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship)6 JSONObject (com.liferay.portal.kernel.json.JSONObject)5 HashSet (java.util.HashSet)5 ResponseEntity (org.springframework.http.ResponseEntity)5