Search in sources :

Example 6 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.

the class ProjectSummaryTest method testAllRequiredFieldsAreSet.

@Test
public void testAllRequiredFieldsAreSet() throws Exception {
    Project project = new Project();
    Project copy = new Project();
    for (Project._Fields renderedField : PROJECT_RENDERED_FIELDS) {
        switch(renderedField) {
            case STATE:
                project.state = ProjectState.ACTIVE;
                break;
            case PERMISSIONS:
                project.permissions = Collections.emptyMap();
                break;
            case EXTERNAL_IDS:
                project.externalIds = Collections.emptyMap();
                break;
            case ATTACHMENTS:
                project.attachments = Collections.emptySet();
                break;
            case PROJECT_TYPE:
                project.projectType = ProjectType.INTERNAL;
                break;
            case MODERATORS:
                project.moderators = ImmutableSet.of("moderator@sw360.org");
                break;
            case CONTRIBUTORS:
                project.contributors = ImmutableSet.of("contributor1@sw360.org", "contributor2@sw360.org");
                break;
            case SECURITY_RESPONSIBLES:
                project.securityResponsibles = ImmutableSet.of("securityresponsible1@sw360.org", "securityresponsible2@sw360.org");
                break;
            case VISBILITY:
                project.visbility = Visibility.EVERYONE;
                break;
            case LINKED_PROJECTS:
                project.linkedProjects = Collections.emptyMap();
                break;
            case RELEASE_ID_TO_USAGE:
                project.releaseIdToUsage = Collections.emptyMap();
                break;
            case RELEASE_CLEARING_STATE_SUMMARY:
                project.releaseClearingStateSummary = new ReleaseClearingStateSummary();
                break;
            case CLEARING_STATE:
                project.clearingState = ProjectClearingState.OPEN;
                break;
            case ROLES:
                project.roles = Collections.emptyMap();
                break;
            case ENABLE_SVM:
                project.enableSvm = true;
                break;
            default:
                // most fields are string
                project.setFieldValue(renderedField, "asd");
                break;
        }
    }
    ProjectSummary.setSummaryFields(project, copy);
    for (Project._Fields renderedField : PROJECT_RENDERED_FIELDS) {
        assertNotNull(copy.getFieldValue(renderedField));
    }
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ReleaseClearingStateSummary(org.eclipse.sw360.datahandler.thrift.components.ReleaseClearingStateSummary) Test(org.junit.Test)

Example 7 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.

the class ComponentHandlerTest method testGetByUploadId.

@Test
public void testGetByUploadId() throws Exception {
    Component originalComponent = new Component("name").setDescription("a desc");
    String componentId = componentHandler.addComponent(originalComponent, adminUser).getId();
    Release release = new Release("name", "version", componentId).setFossologyId("id");
    String releaseId = componentHandler.addRelease(release, adminUser).getId();
    Component component = componentHandler.getComponentForReportFromFossologyUploadId("id");
    assertThat(component, is(not(nullValue())));
    assertThat(component, is(equalTo(originalComponent, restrictedToFields(ID, NAME, DESCRIPTION))));
    assertThat(componentHandler.getReleaseById(releaseId, adminUser), is(not(nullValue())));
    assertThat(componentHandler.getComponentById(componentId, adminUser), is(not(nullValue())));
    assertThat(componentHandler.deleteRelease(releaseId, adminUser), is(RequestStatus.SUCCESS));
    assertThat(componentHandler.deleteComponent(componentId, adminUser), is(RequestStatus.SUCCESS));
    try {
        componentHandler.getReleaseById(releaseId, adminUser);
        fail("expected exception not thrown");
    } catch (SW360Exception e) {
        assertThat(e.getWhy(), containsString("Could not fetch"));
    }
    try {
        componentHandler.getComponentById(componentId, adminUser);
        fail("expected exception not thrown");
    } catch (SW360Exception e) {
        assertThat(e.getWhy(), containsString("Could not fetch"));
    }
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception) Test(org.junit.Test)

Example 8 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.

the class ComponentDatabaseHandlerTest method testDuplicateCheckDoesntMatchByPrefix.

@Test
public void testDuplicateCheckDoesntMatchByPrefix() throws Exception {
    String originalReleaseId = "R1A";
    final Release tmp = handler.getRelease(originalReleaseId, user1);
    tmp.unsetId();
    tmp.unsetRevision();
    tmp.setName(tmp.getName().substring(0, 4));
    String newReleaseId = handler.addRelease(tmp, email1).getId();
    assertThat(newReleaseId, not(isEmptyOrNullString()));
}
Also used : TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString)

Example 9 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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 10 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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

Release (org.eclipse.sw360.datahandler.thrift.components.Release)93 User (org.eclipse.sw360.datahandler.thrift.users.User)42 TException (org.apache.thrift.TException)38 Test (org.junit.Test)23 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)20 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)13 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)13 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)12 FieldMetaData (org.apache.thrift.meta_data.FieldMetaData)11 FossologyStatus (org.eclipse.sw360.datahandler.thrift.components.FossologyStatus)11 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)10 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)9 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)7 Before (org.junit.Before)7 Collectors (java.util.stream.Collectors)6 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)6 FilledAttachment (org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment)6 IOException (java.io.IOException)5