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