Search in sources :

Example 51 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class ProjectHandlerTest method testUpdateProject2_2.

@Test
public void testUpdateProject2_2() throws Exception {
    Project project2 = handler.getProjectById("P2", user2);
    project2.setName("Project2new");
    project2.setBusinessUnit("AB CD EF");
    RequestStatus status = handler.updateProject(project2, user2);
    assertEquals(RequestStatus.SUCCESS, status);
    assertEquals("Project2new", handler.getProjectById("P2", user2).getName());
    assertEquals("AB CD EF", handler.getProjectById("P2", user2).getBusinessUnit());
    assertEquals(2, handler.getMyProjects(user1.getEmail()).size());
    assertEquals(1, handler.getMyProjects(user2.getEmail()).size());
    assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
    assertEquals(3, handler.getAccessibleProjectsSummary(user1).size());
    assertEquals(1, handler.getAccessibleProjectsSummary(user2).size());
    assertEquals(3, handler.getAccessibleProjectsSummary(user3).size());
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Example 52 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class ProjectHandlerTest method testAddProject.

@Test
public void testAddProject() throws Exception {
    Project project4 = new Project();
    project4.setName("Project4").setBusinessUnit("AB CD FE");
    String id = handler.addProject(project4, user2).getId();
    Project projectActual = handler.getProjectById(id, user2);
    assertEquals("Project4", projectActual.getName());
    assertEquals("user2", projectActual.getCreatedBy());
    assertEquals(SW360Utils.getCreatedOn(), projectActual.getCreatedOn());
    assertEquals("AB CD FE", projectActual.getBusinessUnit());
    assertEquals(2, handler.getMyProjects(user1.getEmail()).size());
    assertEquals(2, handler.getMyProjects(user2.getEmail()).size());
    assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
    assertEquals(3, handler.getAccessibleProjectsSummary(user1).size());
    assertEquals(2, handler.getAccessibleProjectsSummary(user2).size());
    assertEquals(2, handler.getAccessibleProjectsSummary(user3).size());
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) Test(org.junit.Test)

Example 53 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class ProjectHandlerTest method testGetProjectByIdUser1_1.

@Test
public void testGetProjectByIdUser1_1() throws Exception {
    Project project1 = handler.getProjectById("P1", user1);
    assertEquals("P1", project1.getId());
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) Test(org.junit.Test)

Example 54 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class ProjectHandlerTest method testUpdateProject3_3.

@Test
public void testUpdateProject3_3() throws Exception {
    Project project3 = handler.getProjectById("P3", user3);
    project3.setName("Project3new");
    project3.setBusinessUnit("AB CD FE");
    RequestStatus status = handler.updateProject(project3, user3);
    assertEquals(RequestStatus.SUCCESS, status);
    assertEquals("Project3new", handler.getProjectById("P3", user3).getName());
    assertEquals("AB CD FE", handler.getProjectById("P3", user3).getBusinessUnit());
    assertEquals(2, handler.getMyProjects(user1.getEmail()).size());
    assertEquals(1, handler.getMyProjects(user2.getEmail()).size());
    assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
    assertEquals(2, handler.getAccessibleProjectsSummary(user1).size());
    assertEquals(2, handler.getAccessibleProjectsSummary(user2).size());
    assertEquals(2, handler.getAccessibleProjectsSummary(user3).size());
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Example 55 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class ProjectHandlerTest method testDontDeleteUsedProject1_1.

@Test
public void testDontDeleteUsedProject1_1() throws Exception {
    final Project p2 = handler.getProjectById("P2", user2);
    p2.setLinkedProjects(ImmutableMap.of("P1", ProjectRelationship.CONTAINED));
    handler.updateProject(p2, user2);
    RequestStatus status = handler.deleteProject("P1", user1);
    assertEquals(RequestStatus.IN_USE, status);
    assertEquals(2, handler.getMyProjects(user1.getEmail()).size());
    assertEquals(1, handler.getMyProjects(user2.getEmail()).size());
    assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
    assertEquals(3, handler.getAccessibleProjectsSummary(user1).size());
    assertEquals(1, handler.getAccessibleProjectsSummary(user2).size());
    assertEquals(2, handler.getAccessibleProjectsSummary(user3).size());
    boolean deleted = (handler.getProjectById("P1", user1) == null);
    assertEquals(false, deleted);
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) 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