Search in sources :

Example 56 with Project

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

the class ProjectHandlerTest method testGetProjectByIdUser3_1.

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

Example 57 with Project

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

the class ProjectHandlerTest method testUpdateProject1_1.

// @Test
// public void testDuplicateProject() throws Exception {
// String id = handler.duplicateProject("P1", "Project1a", user3);
// Project projectNew = handler.getProjectById(id, user3);
// 
// assertEquals("Project1a", projectNew.getName());
// assertEquals("user3", projectNew.getCreatedBy());
// assertEquals(DataHandlerUtils.getCreatedOn(), projectNew.getCreatedOn());
// assertEquals("AB CD EF", projectNew.getBusinessUnit());
// 
// assertEquals(2, handler.getMyProjectsSummary(user1.getEmail()).size());
// assertEquals(1, handler.getMyProjectsSummary(user2.getEmail()).size());
// assertEquals(2, handler.getMyProjectsSummary(user3.getEmail()).size());
// 
// assertEquals(3, handler.getBUProjectsSummarySummary(user1.getDepartment()).size());
// assertEquals(1, handler.getBUProjectsSummarySummary(user2.getDepartment()).size());
// assertEquals(3, handler.getBUProjectsSummarySummary(user3.getDepartment()).size());
// 
// assertEquals(4, handler.getAccessibleProjectsSummarySummary(user1).size());
// assertEquals(1, handler.getAccessibleProjectsSummarySummary(user2).size());
// assertEquals(3, handler.getAccessibleProjectsSummarySummary(user3).size());
// }
@Test
public void testUpdateProject1_1() throws Exception {
    Project project1 = handler.getProjectById("P1", user1);
    project1.setName("Project1new");
    project1.setBusinessUnit("AB CD FE");
    RequestStatus status = handler.updateProject(project1, user1);
    assertEquals(RequestStatus.SUCCESS, status);
    assertEquals("Project1new", handler.getProjectById("P1", user1).getName());
    assertEquals("AB CD FE", handler.getProjectById("P1", user1).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(2, handler.getAccessibleProjectsSummary(user2).size());
    assertEquals(1, 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 58 with Project

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

the class PortletUtils method cloneProject.

public static Project cloneProject(String emailFromRequest, String department, Project project) {
    Project newProject = project.deepCopy();
    // new DB object
    newProject.unsetId();
    newProject.unsetRevision();
    // new Owner
    newProject.setCreatedBy(emailFromRequest);
    newProject.setCreatedOn(SW360Utils.getCreatedOn());
    newProject.setBusinessUnit(department);
    // project specifics
    newProject.unsetAttachments();
    newProject.setClearingState(ProjectClearingState.OPEN);
    return newProject;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project)

Example 59 with Project

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

the class TestProjectClient method main.

public static void main(String[] args) throws TException, IOException {
    THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/projects/thrift");
    TProtocol protocol = new TCompactProtocol(thriftClient);
    ProjectService.Iface client = new ProjectService.Client(protocol);
// User cedric = new User().setEmail("cedric.bodet@tngtech.com").setDepartment("CT BE OSS TNG CB");
// Project myProject = new Project().setName("First project").setDescription("My first project");
// client.addProject(myProject, cedric);
// List<Project> projects = client.getBUProjectsSummary("CT BE OSS");
// System.out.println("Fetched " + projects.size() + " from project service");
// for (Project project : projects) {
// System.out.println(project.toString());
// }
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) ProjectService(org.eclipse.sw360.datahandler.thrift.projects.ProjectService) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 60 with Project

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

the class FossologyUploaderFunctionalTest method testRealUpload.

@Ignore
@Test
public void testRealUpload() {
    doFirstConnectionAndTrust();
    String test = "this is the content\n";
    InputStream inputStream = new ByteArrayInputStream(test.getBytes());
    final CapturerOutputStream outputStream = new CapturerOutputStream();
    final String command = String.format(FossologyUploader.FOSSOLOGY_COMMAND_UPLOAD, "id", GROUP, "project");
    final int exitCode = fossologySshConnector.runInFossologyViaSsh(command, inputStream, outputStream);
    final long uploadId = FossologyUploader.parseResultUploadId(outputStream.getContent());
    System.out.println("uploaded as " + uploadId);
    assertThat("Send to fossology failed: " + outputStream.getContent(), exitCode, is(0));
    assertThat("bad uploadId received: " + outputStream.getContent(), uploadId, is(greaterThan(0L)));
    int i = 0;
    while (++i < 60) {
        ByteArrayOutputStream osget = new ByteArrayOutputStream();
        final String commandGet = String.format(FossologyUploader.FOSSOLOGY_COMMAND_GET_STATUS, uploadId, GROUP);
        final int exitCodeGet = fossologySshConnector.runInFossologyViaSsh(commandGet, osget);
        if (exitCodeGet != 0) {
            fail("check status script is broken");
            break;
        }
        final String outputget = new String(osget.toByteArray());
        final FossologyStatus status = fossologyUploader.parseResultStatus(outputget);
        System.out.println("status is " + status + ", try changing it from FOSSology");
        if (status.equals(FossologyStatus.CLOSED)) {
            break;
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            fail("interrupted");
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CapturerOutputStream(org.eclipse.sw360.fossology.ssh.FossologyUploader.CapturerOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FossologyStatus(org.eclipse.sw360.datahandler.thrift.components.FossologyStatus) FossologyHostFingerPrint(org.eclipse.sw360.datahandler.thrift.fossology.FossologyHostFingerPrint) Ignore(org.junit.Ignore) 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