Search in sources :

Example 26 with Release._Fields

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

the class ComponentSpecTest method before.

@Before
public void before() throws TException {
    List<Component> componentList = new ArrayList<>();
    List<Component> componentListByName = new ArrayList<>();
    angularComponent = new Component();
    angularComponent.setId("17653524");
    angularComponent.setName("Angular");
    angularComponent.setComponentOwner("John");
    angularComponent.setDescription("Angular is a development platform for building mobile and desktop web applications.");
    angularComponent.setCreatedOn("2016-12-15");
    angularComponent.setCreatedBy("admin@sw360.org");
    angularComponent.setComponentType(ComponentType.OSS);
    angularComponent.setVendorNames(new HashSet<>(Collections.singletonList("Google")));
    angularComponent.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "john@sw360.org")));
    angularComponent.setOwnerAccountingUnit("4822");
    angularComponent.setOwnerCountry("DE");
    angularComponent.setOwnerGroup("AA BB 123 GHV2-DE");
    angularComponent.setCategories(ImmutableSet.of("java", "javascript", "sql"));
    angularComponent.setLanguages(ImmutableSet.of("EN", "DE"));
    angularComponent.setOperatingSystems(ImmutableSet.of("Windows", "Linux"));
    componentList.add(angularComponent);
    componentListByName.add(angularComponent);
    Component springComponent = new Component();
    springComponent.setId("678dstzd8");
    springComponent.setName("Spring Framework");
    springComponent.setComponentOwner("Jane");
    springComponent.setDescription("The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications.");
    springComponent.setCreatedOn("2016-12-18");
    springComponent.setCreatedBy("jane@sw360.org");
    springComponent.setComponentType(ComponentType.OSS);
    springComponent.setVendorNames(new HashSet<>(Collections.singletonList("Pivotal")));
    springComponent.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
    springComponent.setOwnerAccountingUnit("5661");
    springComponent.setOwnerCountry("FR");
    springComponent.setOwnerGroup("SIM-KA12");
    springComponent.setCategories(ImmutableSet.of("jdbc", "java"));
    springComponent.setLanguages(ImmutableSet.of("EN", "DE"));
    springComponent.setOperatingSystems(ImmutableSet.of("Windows", "Linux"));
    componentList.add(springComponent);
    when(this.componentServiceMock.createComponent(anyObject(), anyObject())).then(invocation -> {
        springComponent.setType("component");
        springComponent.setCreatedOn("2016-12-20");
        springComponent.setModerators(null);
        springComponent.setVendorNames(null);
        return springComponent;
    });
    given(this.componentServiceMock.getComponentsForUser(anyObject())).willReturn(componentList);
    given(this.componentServiceMock.getComponentForUserById(eq("17653524"), anyObject())).willReturn(angularComponent);
    given(this.componentServiceMock.searchComponentByName(eq(angularComponent.getName()))).willReturn(componentListByName);
    User user = new User();
    user.setId("admin@sw360.org");
    user.setEmail("admin@sw360.org");
    user.setFullname("John Doe");
    user.setDepartment("sw360");
    given(this.userServiceMock.getUserByEmail("admin@sw360.org")).willReturn(user);
    List<Release> releaseList = new ArrayList<>();
    Release release = new Release();
    release.setId("3765276512");
    release.setName("Angular 2.3.0");
    release.setCpeid("cpe:/a:Google:Angular:2.3.0:");
    release.setReleaseDate("2016-12-07");
    release.setVersion("2.3.0");
    release.setCreatedOn("2016-12-18");
    release.setCreatedBy("admin@sw360.org");
    release.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
    release.setComponentId(springComponent.getId());
    releaseList.add(release);
    Release release2 = new Release();
    release2.setId("3765276512");
    release2.setName("Angular 2.3.1");
    release2.setCpeid("cpe:/a:Google:Angular:2.3.1:");
    release2.setReleaseDate("2016-12-15");
    release2.setVersion("2.3.1");
    release2.setCreatedOn("2016-12-18");
    release2.setCreatedBy("admin@sw360.org");
    release2.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
    release2.setComponentId(springComponent.getId());
    releaseList.add(release2);
    angularComponent.setReleases(releaseList);
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Before(org.junit.Before)

Example 27 with Release._Fields

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

the class ReleaseResourceProcessor method process.

@Override
public Resource<Release> process(Resource<Release> resource) {
    Release release = resource.getContent();
    Link selfLink = linkTo(ReleaseController.class).slash("api" + ReleaseController.RELEASES_URL + "/" + release.getId()).withSelfRel();
    resource.add(selfLink);
    return resource;
}
Also used : Release(org.eclipse.sw360.datahandler.thrift.components.Release) Link(org.springframework.hateoas.Link)

Example 28 with Release._Fields

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

the class Sw360AttachmentService method getAttachmentByIdForUser.

public AttachmentInfo getAttachmentByIdForUser(String id, User sw360User) throws TException {
    ComponentService.Iface sw360ComponentClient = getThriftComponentClient();
    List<Release> releases = sw360ComponentClient.getReleaseSummary(sw360User);
    for (Release release : releases) {
        final Set<Attachment> attachments = release.getAttachments();
        if (attachments != null && attachments.size() > 0) {
            for (Attachment attachment : attachments) {
                if (id.equals(attachment.getAttachmentContentId())) {
                    return new AttachmentInfo(attachment, release);
                }
            }
        }
    }
    return null;
}
Also used : ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 29 with Release._Fields

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

the class WhenComputeClearingState method the_release_is_sent_for_clearing_to.

public WhenComputeClearingState the_release_is_sent_for_clearing_to(@Quoted String clearingTeam) {
    Release release = getFirstRelease();
    Map<String, FossologyStatus> clearingTeamToFossologyStatus = release.getClearingTeamToFossologyStatus();
    clearingTeamToFossologyStatus.put(clearingTeam, FossologyStatus.SENT);
    the_clearing_state_is_computed_for(lastTestedClearingTeam);
    return self();
}
Also used : TEnumToString(org.eclipse.sw360.datahandler.TEnumToString) FossologyStatus(org.eclipse.sw360.datahandler.thrift.components.FossologyStatus) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 30 with Release._Fields

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

the class AttachmentSpecTest method before.

@Before
public void before() throws TException {
    List<Attachment> attachmentList = new ArrayList<>();
    attachment = new Attachment();
    attachment.setAttachmentContentId("76537653");
    attachment.setFilename("spring-core-4.3.4.RELEASE.jar");
    attachment.setSha1("da373e491d3863477568896089ee9457bc316783");
    attachment.setAttachmentType(AttachmentType.BINARY_SELF);
    attachment.setCreatedTeam("Clearing Team 1");
    attachment.setCreatedComment("please check before Christmas :)");
    attachment.setCreatedOn("2016-12-18");
    attachment.setCreatedBy("admin@sw360.org");
    attachment.setCheckedTeam("Clearing Team 2");
    attachment.setCheckedComment("everything looks good");
    attachment.setCheckedOn("2016-12-18");
    attachment.setCheckStatus(CheckStatus.ACCEPTED);
    attachmentList.add(attachment);
    Release release = new Release();
    release.setId("874687");
    release.setName("Spring Core 4.3.4");
    release.setCpeid("cpe:/a:pivotal:spring-core:4.3.4:");
    release.setReleaseDate("2016-12-07");
    release.setVersion("4.3.4");
    release.setCreatedOn("2016-12-18");
    release.setCreatedBy("admin@sw360.org");
    release.setModerators(new HashSet<>(Arrays.asList(testUserId, testUserPassword)));
    release.setComponentId("678dstzd8");
    release.setClearingState(ClearingState.APPROVED);
    AttachmentInfo attachmentInfo = new AttachmentInfo(attachment, release);
    given(this.attachmentServiceMock.getAttachmentByIdForUser(eq(attachment.getAttachmentContentId()), anyObject())).willReturn(attachmentInfo);
    User user = new User();
    user.setId("admin@sw360.org");
    user.setEmail("admin@sw360.org");
    user.setFullname("John Doe");
    given(this.userServiceMock.getUserByEmail("admin@sw360.org")).willReturn(user);
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) ArrayList(java.util.ArrayList) AttachmentInfo(org.eclipse.sw360.rest.resourceserver.attachment.AttachmentInfo) Attachment(org.eclipse.sw360.datahandler.thrift.attachments.Attachment) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Before(org.junit.Before)

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