|
4 | 4 | package com.siemens.sbom.standardbom.model; |
5 | 5 |
|
6 | 6 | import java.util.Collections; |
| 7 | +import java.util.List; |
7 | 8 | import java.util.Set; |
8 | 9 | import java.util.TreeSet; |
9 | 10 |
|
10 | 11 | import org.cyclonedx.model.Component; |
11 | 12 | import org.cyclonedx.model.ExternalReference; |
12 | 13 | import org.cyclonedx.model.Hash; |
13 | 14 | import org.cyclonedx.model.License; |
| 15 | +import org.cyclonedx.model.OrganizationalContact; |
14 | 16 | import org.cyclonedx.model.Property; |
15 | 17 | import org.junit.Assert; |
16 | 18 | import org.junit.Test; |
@@ -314,4 +316,32 @@ public void testHashSyntaxValidation() |
314 | 316 | Assert.assertEquals("value is not a valid SHA-256 hash: INVALID HASH CODE", e.getMessage()); |
315 | 317 | } |
316 | 318 | } |
| 319 | + |
| 320 | + |
| 321 | + |
| 322 | + @Test |
| 323 | + public void testAuthors() |
| 324 | + { |
| 325 | + BomEntry underTest = new BomEntry(); |
| 326 | + underTest.setAuthors(null); |
| 327 | + |
| 328 | + OrganizationalContact authorX = new OrganizationalContact(); |
| 329 | + authorX.setName("authorX"); |
| 330 | + authorX.setEmail("authorX@example.com"); |
| 331 | + underTest.setAuthors(Collections.singletonList(authorX)); |
| 332 | + |
| 333 | + OrganizationalContact author1 = new OrganizationalContact(); |
| 334 | + author1.setName("author1"); |
| 335 | + author1.setEmail("author1@example.com"); |
| 336 | + underTest.setAuthors(Collections.singletonList(author1)); |
| 337 | + |
| 338 | + underTest.addAuthor("author2", null); |
| 339 | + underTest.addAuthor(null, "author3@example.com"); |
| 340 | + underTest.addAuthor(null, null); |
| 341 | + |
| 342 | + List<OrganizationalContact> actualAuthors = underTest.getAuthors(); |
| 343 | + Assert.assertEquals(3, actualAuthors.size()); |
| 344 | + Assert.assertEquals(author1, |
| 345 | + actualAuthors.stream().filter(a -> a.getName().equals("author1")).findFirst().orElse(null)); |
| 346 | + } |
317 | 347 | } |
0 commit comments