Search in sources :

Example 1 with RequestStatus

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

the class ProjectDatabaseHandlerTest method testUpdateProject2_1.

@Test
public void testUpdateProject2_1() throws Exception {
    Project project2 = handler.getProjectById("P2", user1);
    project2.setName("Project2new");
    Mockito.doReturn(RequestStatus.SENT_TO_MODERATOR).when(moderator).updateProject(project2, user1);
    RequestStatus status = handler.updateProject(project2, user1);
    // Now contributors can also change the project
    assertEquals(RequestStatus.SUCCESS, status);
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) Test(org.junit.Test)

Example 2 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testDeleteComponent.

@Test
public void testDeleteComponent() throws Exception {
    RequestStatus status = handler.deleteComponent("C3", user1);
    assertEquals(RequestStatus.SUCCESS, status);
    List<Component> componentSummary = handler.getComponentSummary(user1);
    assertEquals(2, componentSummary.size());
    assertFalse("Component deleted", componentsContain(componentSummary, "C3"));
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 3 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testEccUpdateSentToEccModeration.

@Test
public void testEccUpdateSentToEccModeration() throws Exception {
    Release release = releases.get(1);
    String expected = release.getEccInformation().getAL();
    release.getEccInformation().setAL("UPDATED");
    when(releaseModerator.updateReleaseEccInfo(release, user1)).thenReturn(RequestStatus.SENT_TO_MODERATOR);
    RequestStatus status = handler.updateRelease(release, user1, ThriftUtils.IMMUTABLE_OF_RELEASE);
    Release actual = handler.getRelease("R1B", user1);
    assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
    assertEquals(expected, actual.getEccInformation().getAL());
    verify(releaseModerator).updateReleaseEccInfo(release, user1);
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 4 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testDeleteComponentNotModerator.

@Test
public void testDeleteComponentNotModerator() throws Exception {
    when(moderator.deleteComponent(any(Component.class), eq(user2))).thenReturn(RequestStatus.SENT_TO_MODERATOR);
    RequestStatus status = handler.deleteComponent("C3", user2);
    assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
    List<Component> componentSummary = handler.getComponentSummary(user1);
    assertEquals(3, componentSummary.size());
    assertTrue("Component NOT deleted", componentsContain(componentSummary, "C1"));
    verify(moderator).deleteComponent(any(Component.class), eq(user2));
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 5 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testUpdateSentToModeration.

@Test
public void testUpdateSentToModeration() throws Exception {
    Release release = releases.get(1);
    String expected = release.getName();
    release.setName("UPDATED");
    when(releaseModerator.updateRelease(release, user1)).thenReturn(RequestStatus.SENT_TO_MODERATOR);
    RequestStatus status = handler.updateRelease(release, user1, ThriftUtils.IMMUTABLE_OF_RELEASE);
    Release actual = handler.getRelease("R1B", user1);
    assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
    assertEquals(expected, actual.getName());
    verify(releaseModerator).updateRelease(release, user1);
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

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