Search in sources :

Example 36 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus 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)

Example 37 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus 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 38 with RequestStatus

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

the class VendorDatabaseHandler method deleteVendor.

public RequestStatus deleteVendor(String id, User user) throws SW360Exception {
    Vendor vendor = repository.get(id);
    assertNotNull(vendor);
    if (makePermission(vendor, user).isActionAllowed(RequestedAction.DELETE)) {
        repository.remove(id);
        return RequestStatus.SUCCESS;
    } else {
        log.error("User is not allowed to delete!");
        return RequestStatus.FAILURE;
    }
}
Also used : ThriftValidate.prepareVendor(org.eclipse.sw360.datahandler.thrift.ThriftValidate.prepareVendor) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor)

Example 39 with RequestStatus

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

the class FossologyHandlerTest method testSetFingerPrints.

@Test
public void testSetFingerPrints() throws Exception {
    @SuppressWarnings("unchecked") final List<FossologyHostFingerPrint> newFingerPrints = mock(List.class);
    final RequestStatus requestStatus = RequestStatus.FAILURE;
    doReturn(requestStatus).when(fossologyHostKeyHandler).setFingerPrints(newFingerPrints);
    assertThat(fossologyHandler.setFingerPrints(newFingerPrints), sameInstance(requestStatus));
    verify(fossologyHostKeyHandler).setFingerPrints(newFingerPrints);
}
Also used : FossologyHostFingerPrint(org.eclipse.sw360.datahandler.thrift.fossology.FossologyHostFingerPrint) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Example 40 with RequestStatus

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

the class FossologyHandlerTest method testCheckConnectionFailure.

@Test
public void testCheckConnectionFailure() throws Exception {
    final RequestStatus requestStatus = RequestStatus.FAILURE;
    doReturn(127).when(fossologySshConnector).runInFossologyViaSsh(anyString());
    assertThat(fossologyHandler.checkConnection(), is(requestStatus));
    verify(fossologySshConnector).runInFossologyViaSsh(anyString());
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Aggregations

RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)52 TException (org.apache.thrift.TException)27 User (org.eclipse.sw360.datahandler.thrift.users.User)24 Test (org.junit.Test)16 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)13 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)10 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)5 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)4 AddDocumentRequestStatus (org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus)4 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)4 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)4 VendorService (org.eclipse.sw360.datahandler.thrift.vendors.VendorService)4 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)3 Release (org.eclipse.sw360.datahandler.thrift.components.Release)3 Vulnerability (org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability)3 JSONObject (com.liferay.portal.kernel.json.JSONObject)2 PrintWriter (java.io.PrintWriter)2 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)2 Component (org.eclipse.sw360.datahandler.thrift.components.Component)2 UpdateType (org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType)2