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());
}
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());
}
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;
}
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());
// }
}
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");
}
}
}
Aggregations