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