Search in sources :

Example 46 with RequestStatus

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

the class ProjectDatabaseHandlerTest method testSanityCheckFails.

@Test
public void testSanityCheckFails() throws Exception {
    Project project = handler.getProjectById("P1", user1);
    project.setReleaseIdToUsage(Collections.emptyMap());
    RequestStatus status = handler.updateProject(project, user1);
    assertThat(status, is(RequestStatus.FAILED_SANITY_CHECK));
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) Test(org.junit.Test)

Example 47 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testDontDeleteUsedRelease.

@Test
public void testDontDeleteUsedRelease() throws Exception {
    final Release r1A = handler.getRelease("R1A", user1);
    r1A.setReleaseIdToRelationship(ImmutableMap.of("R2A", ReleaseRelationship.CONTAINED));
    handler.updateRelease(r1A, user1, ThriftUtils.IMMUTABLE_OF_RELEASE);
    RequestStatus status = handler.deleteRelease("R2A", user1);
    assertEquals(RequestStatus.IN_USE, status);
    List<Release> releaseSummary = handler.getReleaseSummary();
    assertEquals(5, releaseSummary.size());
    assertTrue("Release not deleted", releasesContain(releaseSummary, "R2A"));
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 48 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testDontDeleteUsedComponent.

@Test
public void testDontDeleteUsedComponent() throws Exception {
    final Release r1A = handler.getRelease("R1A", user1);
    r1A.setReleaseIdToRelationship(ImmutableMap.of("R2A", ReleaseRelationship.CONTAINED));
    handler.updateRelease(r1A, user1, ThriftUtils.IMMUTABLE_OF_RELEASE);
    RequestStatus status = handler.deleteComponent("C2", user1);
    assertEquals(RequestStatus.IN_USE, status);
    List<Component> componentSummary = handler.getComponentSummary(user1);
    assertEquals(3, componentSummary.size());
    assertTrue("Component not deleted", componentsContain(componentSummary, "C2"));
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 49 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testUpdateComponentSentToModeration.

@Test
public void testUpdateComponentSentToModeration() throws Exception {
    // Make some changes in the component
    Component component = components.get(0);
    String expected = component.getName();
    component.setName("UPDATE");
    when(moderator.updateComponent(component, user2)).thenReturn(RequestStatus.SENT_TO_MODERATOR);
    RequestStatus status = handler.updateComponent(component, user2);
    Component actual = handler.getComponent("C1", user1);
    assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
    assertEquals(component.getId(), actual.getId());
    assertEquals(expected, actual.getName());
    verify(moderator).updateComponent(component, user2);
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 50 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testUpdateInconsistentComponent.

@Test
public void testUpdateInconsistentComponent() throws Exception {
    // Make some changes in the component
    Component expected = components.get(0);
    expected.unsetReleases();
    expected.unsetReleaseIds();
    List<Release> tmpReleases = new ArrayList<>();
    tmpReleases.add(releases.get(0));
    tmpReleases.add(releases.get(1));
    Set<String> tmpReleaseIds = new HashSet<>();
    tmpReleaseIds.add(tmpReleases.get(0).getId());
    tmpReleaseIds.add(tmpReleases.get(1).getId());
    expected.setName("UPDATE");
    expected.setReleaseIds(tmpReleaseIds);
    expected.setReleases(tmpReleases);
    RequestStatus status = handler.updateComponent(expected, user1);
    assertThat(RequestStatus.SUCCESS, is(status));
    Component actual = handler.getComponent("C1", user1);
    // Other asserts have been dealt with in testUpdateComponent
    // Check releases
    assertEquals(2, actual.getReleasesSize());
    assertEquals(0, actual.getReleaseIdsSize());
}
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