DependencyTrack / dependency-track

Dependency-Track is an intelligent Component Analysis platform that allows organizations to identify and reduce risk in the software supply chain.
https://dependencytrack.org/
Apache License 2.0
2.43k stars 529 forks source link

feat: autocreate project with tags #3843

Closed JCHacking closed 2 weeks ago

JCHacking commented 2 weeks ago

Description

To be able to upload a bom and auto-create the project with specific tags

Addressed Issue

https://github.com/DependencyTrack/dependency-track/issues/1674

Additional Details

I have added the optional property to the PUT method to upload BOM files, I have not programmed much in Java so any suggestion to improve this PR is welcome. Thanks!!!

Checklist

valentijnscholten commented 2 weeks ago

I like it. Can you add a test with tags populated?

JCHacking commented 2 weeks ago

Sure! Tests added

JCHacking commented 2 weeks ago

I see that the test has failed, I imagine that it is because it is not the same object since one is the tags only with name and the others are the tags obtained from the persistence that will have more properties.

I should only make an assertEquals of the list of strings with the name of the tags, right?

nscuro commented 2 weeks ago

I should only make an assertEquals of the list of strings with the name of the tags, right?

Yes. Consider using AssertJ's fluent assertions, like so:

assertThat(project.getTags())
    .extracting(Tag::getName)
    .containsExactlyInAnyOrder("foo", "bar");
JCHacking commented 2 weeks ago

Fixed it with your suggestion, thanks!!

codacy-production[bot] commented 2 weeks ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
:white_check_mark: +0.02% (target: -1.00%) :white_check_mark: 100.00% (target: 70.00%)
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (1a4857ffd8e8365023521dff400f6ff824b07a7c) | 21715 | 16485 | 75.92% | | | Head commit (df322b4b7de81fe388378d94b00c8936194d3ecc) | 21717 (+2) | 16490 (+5) | 75.93% (**+0.02%**) | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#3843) | 4 | 4 | **100.00%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences


:rocket: Don’t miss a bit, follow what’s new on Codacy.

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more