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