File tree Expand file tree Collapse file tree
main/java/org/dependencytrack
test/java/org/dependencytrack/resources/v1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -401,15 +401,17 @@ public String getPublisher() {
401401 }
402402
403403 @ Deprecated
404- @ JsonIgnore
404+ @ JsonInclude ( JsonInclude . Include . NON_EMPTY )
405405 public String getAuthor (){
406406 return ModelConverter .convertContactsToString (this .authors );
407407 }
408408
409409 @ Deprecated
410410 public void setAuthor (String author ){
411- if (this .authors == null ){
411+ if (this .authors == null ) {
412412 this .authors = new ArrayList <>();
413+ } else {
414+ this .authors .clear ();
413415 }
414416 this .authors .add (new OrganizationalContact () {{
415417 setName (author );
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ public void setAuthors(List<OrganizationalContact> authors) {
307307 }
308308
309309 @ Deprecated
310- @ JsonIgnore
310+ @ JsonInclude ( JsonInclude . Include . NON_EMPTY )
311311 public String getAuthor (){
312312 return ModelConverter .convertContactsToString (this .authors );
313313 }
@@ -316,6 +316,8 @@ public String getAuthor(){
316316 public void setAuthor (String author ){
317317 if (this .authors ==null ){
318318 this .authors = new ArrayList <>();
319+ } else {
320+ this .authors .clear ();
319321 }
320322 this .authors .add (new OrganizationalContact () {{
321323 setName (author );
Original file line number Diff line number Diff line change @@ -285,6 +285,7 @@ public Response createComponent(@Parameter(description = "The UUID of the projec
285285 final Validator validator = super .getValidator ();
286286 failOnValidationError (
287287 validator .validateProperty (jsonComponent , "authors" ),
288+ validator .validateProperty (jsonComponent , "author" ),
288289 validator .validateProperty (jsonComponent , "publisher" ),
289290 validator .validateProperty (jsonComponent , "name" ),
290291 validator .validateProperty (jsonComponent , "version" ),
Original file line number Diff line number Diff line change @@ -289,6 +289,7 @@ public Response getProjectsByClassifier(
289289 public Response createProject (Project jsonProject ) {
290290 final Validator validator = super .getValidator ();
291291 failOnValidationError (
292+ validator .validateProperty (jsonProject , "author" ),
292293 validator .validateProperty (jsonProject , "authors" ),
293294 validator .validateProperty (jsonProject , "publisher" ),
294295 validator .validateProperty (jsonProject , "group" ),
@@ -429,6 +430,7 @@ public Response patchProject(
429430 Project jsonProject ) {
430431 final Validator validator = getValidator ();
431432 failOnValidationError (
433+ validator .validateProperty (jsonProject , "author" ),
432434 validator .validateProperty (jsonProject , "authors" ),
433435 validator .validateProperty (jsonProject , "publisher" ),
434436 validator .validateProperty (jsonProject , "group" ),
Original file line number Diff line number Diff line change 4848import java .util .UUID ;
4949
5050import static net .javacrumbs .jsonunit .assertj .JsonAssertions .assertThatJson ;
51+ import static net .javacrumbs .jsonunit .assertj .JsonAssertions .json ;
5152import static org .assertj .core .api .Assertions .assertThat ;
5253
5354public class ComponentResourceTest extends ResourceTest {
@@ -515,6 +516,7 @@ public void createComponentTest() {
515516 Assert .assertNotNull (json );
516517 Assert .assertEquals ("My Component" , json .getString ("name" ));
517518 Assert .assertEquals ("SampleAuthor" ,json .getJsonArray ("authors" ).getJsonObject (0 ).getString ("name" ));
519+ Assert .assertEquals ("SampleAuthor" , json .getString ("author" ));
518520 Assert .assertEquals ("1.0" , json .getString ("version" ));
519521 Assert .assertTrue (UuidUtil .isValidUUID (json .getString ("uuid" )));
520522 }
You can’t perform that action at this time.
0 commit comments