use of org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship in project sw360portal by sw360.
the class ProjectSpecTest method before.
@Before
public void before() throws TException {
Map<String, ProjectReleaseRelationship> linkedReleases = new HashMap<>();
Map<String, ProjectRelationship> linkedProjects = new HashMap<>();
ProjectReleaseRelationship projectReleaseRelationship = new ProjectReleaseRelationship(CONTAINED, MAINLINE);
List<Project> projectList = new ArrayList<>();
List<Project> projectListByName = new ArrayList<>();
project = new Project();
project.setId("376576");
project.setName("Emerald Web");
project.setProjectType(ProjectType.PRODUCT);
project.setVersion("1.0.2");
project.setDescription("Emerald Web provides a suite of components for Critical Infrastructures.");
project.setCreatedOn("2016-12-15");
project.setCreatedBy("admin@sw360.org");
project.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
project.setBusinessUnit("sw360 AR");
project.setExternalIds(Collections.singletonMap("mainline-id-project", "515432"));
project.setOwnerAccountingUnit("4822");
project.setOwnerCountry("DE");
project.setOwnerGroup("AA BB 123 GHV2-DE");
project.setTag("project test tag 1");
project.setPreevaluationDeadline("2018-07-17");
project.setSystemTestStart("2017-01-01");
project.setSystemTestEnd("2018-03-01");
linkedReleases.put("3765276512", projectReleaseRelationship);
project.setReleaseIdToUsage(linkedReleases);
linkedProjects.put("376576", ProjectRelationship.CONTAINED);
project.setLinkedProjects(linkedProjects);
projectList.add(project);
projectListByName.add(project);
Project project2 = new Project();
project2.setId("376570");
project2.setName("Orange Web");
project2.setVersion("2.0.1");
project2.setProjectType(ProjectType.PRODUCT);
project2.setDescription("Orange Web provides a suite of components for documentation.");
project2.setCreatedOn("2016-12-17");
project2.setCreatedBy("john@sw360.org");
project2.setBusinessUnit("sw360 EX DF");
project2.setOwnerAccountingUnit("5661");
project2.setOwnerCountry("FR");
project2.setOwnerGroup("SIM-KA12");
project2.setTag("project test tag 2");
project2.setPreevaluationDeadline("2018-07-17");
project2.setSystemTestStart("2017-01-01");
project2.setSystemTestEnd("2018-03-01");
project2.setExternalIds(Collections.singletonMap("mainline-id-project", "7657"));
linkedReleases = new HashMap<>();
linkedReleases.put("5578999", projectReleaseRelationship);
project2.setReleaseIdToUsage(linkedReleases);
projectList.add(project2);
Set<String> releaseIds = new HashSet<>(Arrays.asList("3765276512"));
Set<String> releaseIdsTransitive = new HashSet<>(Arrays.asList("3765276512", "5578999"));
given(this.projectServiceMock.getProjectsForUser(anyObject())).willReturn(projectList);
given(this.projectServiceMock.getProjectForUserById(eq(project.getId()), anyObject())).willReturn(project);
given(this.projectServiceMock.searchProjectByName(eq(project.getName()), anyObject())).willReturn(projectListByName);
given(this.projectServiceMock.getReleaseIds(eq(project.getId()), anyObject(), eq("false"))).willReturn(releaseIds);
given(this.projectServiceMock.getReleaseIds(eq(project.getId()), anyObject(), eq("true"))).willReturn(releaseIdsTransitive);
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");
EccInformation eccInformation = new EccInformation();
eccInformation.setEccStatus(ECCStatus.APPROVED);
release.setEccInformation(eccInformation);
release.setCreatedBy("admin@sw360.org");
release.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
release.setComponentId("12356115");
release.setClearingState(ClearingState.APPROVED);
release.setExternalIds(Collections.singletonMap("mainline-id-component", "1432"));
Release release2 = new Release();
release2.setId("5578999");
release2.setName("Spring 1.4.0");
release2.setCpeid("cpe:/a:Spring:1.4.0:");
release2.setReleaseDate("2017-05-06");
release2.setVersion("1.4.0");
release2.setCreatedOn("2017-11-19");
eccInformation.setEccStatus(ECCStatus.APPROVED);
release2.setEccInformation(eccInformation);
release2.setCreatedBy("admin@sw360.org");
release2.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
release2.setComponentId("12356115");
release2.setClearingState(ClearingState.APPROVED);
release2.setExternalIds(Collections.singletonMap("mainline-id-component", "1771"));
given(this.releaseServiceMock.getReleaseForUserById(eq(release.getId()), anyObject())).willReturn(release);
given(this.releaseServiceMock.getReleaseForUserById(eq(release2.getId()), anyObject())).willReturn(release2);
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);
}
use of org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship in project sw360portal by sw360.
the class JsonReleaseRelationSerializer method serialize.
@Override
public void serialize(Map<String, ProjectReleaseRelationship> releaseRelationMap, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException {
List<Map<String, String>> linkedReleases = new ArrayList<>();
for (Map.Entry<String, ProjectReleaseRelationship> releaseRelation : releaseRelationMap.entrySet()) {
String releaseLink = linkTo(ProjectController.class).slash("api" + ReleaseController.RELEASES_URL + "/" + releaseRelation.getKey()).withSelfRel().getHref();
Map<String, String> linkedRelease = new HashMap<>();
ProjectReleaseRelationship projectReleaseRelationship = releaseRelation.getValue();
linkedRelease.put("relation", projectReleaseRelationship.getReleaseRelation().name());
linkedRelease.put("mainlineState", projectReleaseRelationship.getMainlineState().name());
linkedRelease.put("release", releaseLink);
linkedReleases.add(linkedRelease);
}
gen.writeObject(linkedReleases);
}
Aggregations