Search in sources :

Example 6 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testDontDeleteComponentWithReleaseContained.

@Test
public void testDontDeleteComponentWithReleaseContained() throws Exception {
    Component component = new Component().setId("Del").setName("delete").setDescription("d1").setCreatedBy(email1);
    Release release = new Release().setId("DelR").setComponentId("Del").setName("delete Release").setVersion("1.0").setCreatedBy(email1).setVendorId("V1").setClearingState(ClearingState.NEW_CLEARING);
    handler.addComponent(component, email1);
    handler.addRelease(release, email1);
    {
        Component del = handler.getComponent("Del", user1);
        assertThat(del.getName(), is("delete"));
        Release delR = handler.getRelease("DelR", user1);
        assertThat(delR.getName(), is("delete Release"));
    }
    RequestStatus status = handler.deleteComponent("Del", user1);
    assertThat(status, is(RequestStatus.IN_USE));
    {
        Component del = handler.getComponent("Del", user1);
        assertThat(del.getName(), is("delete"));
        Release delR = handler.getRelease("DelR", user1);
        assertThat(delR.getName(), is("delete Release"));
    }
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 7 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testUpdateComponent.

@Test
public void testUpdateComponent() throws Exception {
    // Make some changes in the component
    Component expected = components.get(0);
    expected.unsetReleases();
    expected.setName("UPDATE");
    RequestStatus status = handler.updateComponent(expected, user1);
    Component actual = handler.getComponent("C1", user1);
    assertEquals(RequestStatus.SUCCESS, status);
    assertEquals(expected.getId(), actual.getId());
    assertEquals(expected.getName(), actual.getName());
    assertEquals(expected.getDescription(), actual.getDescription());
    assertEquals(email1, actual.getCreatedBy());
    // Check releases
    assertEquals(2, actual.getReleasesSize());
    assertEquals(0, actual.getReleaseIdsSize());
    assertTrue(releasesContain(actual.getReleases(), "R1A"));
    assertTrue(releasesContain(actual.getReleases(), "R1B"));
    assertFalse(releasesContain(actual.getReleases(), "R2A"));
    assertFalse(releasesContain(actual.getReleases(), "R2B"));
    assertFalse(releasesContain(actual.getReleases(), "R2C"));
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 8 with RequestStatus

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

the class ComponentDatabaseHandlerTest method testDeleteRelease.

@Test
public void testDeleteRelease() throws Exception {
    RequestStatus status = handler.deleteRelease("R1B", user2);
    assertEquals(RequestStatus.SUCCESS, status);
    List<Release> releaseSummary = handler.getReleaseSummary();
    assertEquals(4, releaseSummary.size());
    assertFalse("Component deleted", releasesContain(releaseSummary, "R1B"));
    // Check deletion in component
    Component component = handler.getComponent("C1", user1);
    assertEquals(1, component.getReleasesSize());
    assertFalse("Release deleted", releasesContain(component.getReleases(), "R1B"));
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 9 with RequestStatus

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

the class Sw360ComponentService method updateComponent.

public RequestStatus updateComponent(Component component, User sw360User) throws TException {
    ComponentService.Iface sw360ComponentClient = getThriftComponentClient();
    RequestStatus requestStatus = sw360ComponentClient.updateComponent(component, sw360User);
    if (requestStatus != RequestStatus.SUCCESS) {
        throw new RuntimeException("sw360 component with name '" + component.getName() + " cannot be updated.");
    }
    return requestStatus;
}
Also used : ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) AddDocumentRequestStatus(org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 10 with RequestStatus

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

the class Sw360ReleaseService method updateRelease.

public RequestStatus updateRelease(Release release, User sw360User) throws TException {
    ComponentService.Iface sw360ComponentClient = getThriftComponentClient();
    RequestStatus requestStatus = sw360ComponentClient.updateRelease(release, sw360User);
    if (requestStatus != RequestStatus.SUCCESS) {
        throw new RuntimeException("sw360 release with name '" + release.getName() + " cannot be updated.");
    }
    return requestStatus;
}
Also used : ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) AddDocumentRequestStatus(org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus) 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