7
7
import java .util .Map ;
8
8
import java .util .Set ;
9
9
import org .apache .maven .model .Developer ;
10
+ import org .apache .maven .model .Organization ;
11
+ import org .apache .maven .project .MavenProject ;
10
12
import org .cyclonedx .model .Component ;
11
13
import org .cyclonedx .model .Dependency ;
12
14
import org .cyclonedx .model .OrganizationalContact ;
@@ -30,10 +32,9 @@ protected String extractComponentsAndDependencies(Set<String> topLevelComponents
30
32
}
31
33
32
34
@ Test
33
- @ DisplayName ("" )
34
- void createListOfAuthors () {
35
+ @ DisplayName ("Using developers information only " )
36
+ void setManufacturer1 () {
35
37
BaseCycloneDxMojoImpl mojo = new BaseCycloneDxMojoImpl ();
36
- OrganizationalEntity manufacturer = new OrganizationalEntity ();
37
38
List <Developer > developers = new ArrayList <>();
38
39
Developer developer = new Developer ();
39
40
developer .setName ("Developer" );
@@ -47,21 +48,96 @@ void createListOfAuthors() {
47
48
developer = new Developer ();
48
49
developer .setOrganizationUrl ("http://foo.com" );
49
50
developers .add (developer );
50
- List <OrganizationalContact > listOfAuthors = mojo .createListOfAuthors (manufacturer , developers );
51
- assertNotNull (listOfAuthors );
52
- assertEquals (4 , listOfAuthors .size ());
53
- assertEquals ("Developer" , listOfAuthors .get (0 ).getName ());
51
+ Component projectBomComponent = new Component ();
52
+ MavenProject mavenProject = new MavenProject ();
53
+ mavenProject .setDevelopers (developers );
54
+ mojo .setManufacturer (mavenProject , projectBomComponent );
55
+ OrganizationalEntity manufacturer = projectBomComponent .getManufacturer ();
56
+ assertNotNull (manufacturer );
57
+ assertEquals (4 , manufacturer .getContacts ().size ());
58
+ assertEquals ("Developer" , manufacturer .getContacts ().get (0 ).getName ());
59
+ assertEquals ("My Organization" , manufacturer .getName ());
54
60
}
55
61
56
62
@ Test
57
- @ DisplayName ("Verify addContacts " )
58
- void addContacts () {
63
+ @ DisplayName ("Using developers information with empty organization " )
64
+ void setManufacturer2 () {
59
65
BaseCycloneDxMojoImpl mojo = new BaseCycloneDxMojoImpl ();
60
- OrganizationalEntity manufacturer = new OrganizationalEntity ();
61
- List <Developer > developers = new ArrayList <>();
62
- mojo .addContacts (manufacturer , developers );
63
- assertNotNull (manufacturer .getContacts ());
64
- assertTrue (manufacturer .getContacts ().isEmpty ());
66
+ List <Developer > developers = new ArrayList <>();
67
+ Developer developer = new Developer ();
68
+ developer .setName ("Developer" );
69
+ developers .add (developer );
70
+ developer = new Developer ();
71
+ developer .
setEmail (
"[email protected] " );
72
+ developers .add (developer );
73
+ developer = new Developer ();
74
+ developer .setOrganization ("My Organization" );
75
+ developers .add (developer );
76
+ developer = new Developer ();
77
+ developer .setOrganizationUrl ("http://foo.com" );
78
+ developers .add (developer );
79
+ Component projectBomComponent = new Component ();
80
+ MavenProject mavenProject = new MavenProject ();
81
+ mavenProject .setDevelopers (developers );
82
+ mavenProject .setOrganization (new Organization ());
83
+ mojo .setManufacturer (mavenProject , projectBomComponent );
84
+ OrganizationalEntity manufacturer = projectBomComponent .getManufacturer ();
85
+ assertNotNull (manufacturer );
86
+ assertEquals (4 , manufacturer .getContacts ().size ());
87
+ assertEquals ("Developer" , manufacturer .getContacts ().get (0 ).getName ());
88
+ assertEquals ("My Organization" , manufacturer .getName ());
89
+ }
90
+
91
+ @ Test
92
+ @ DisplayName ("Using developers and organization information" )
93
+ void setManufacturer3 () {
94
+ BaseCycloneDxMojoImpl mojo = new BaseCycloneDxMojoImpl ();
95
+
96
+ MavenProject mavenProject = new MavenProject ();
97
+ List <Developer > developers = new ArrayList <>();
98
+ Developer developer = new Developer ();
99
+ developer .setName ("Developer 2" );
100
+ developer .
setEmail (
"[email protected] " );
101
+ developer .setOrganization ("My Organization" );
102
+ developer .setOrganizationUrl ("http://foo.com" );
103
+ developers .add (developer );
104
+ mavenProject .setDevelopers (developers );
105
+
106
+ Organization organization = new Organization ();
107
+ organization .setName ("My Company" );
108
+ organization .setUrl ("http://example.com" );
109
+ mavenProject .setOrganization (organization );
110
+
111
+ Component projectBomComponent = new Component ();
112
+ mojo .setManufacturer (mavenProject , projectBomComponent );
113
+ OrganizationalEntity manufacturer = projectBomComponent .getManufacturer ();
114
+ assertNotNull (manufacturer );
115
+ assertEquals (1 , manufacturer .getContacts ().size ());
116
+ assertEquals ("Developer 2" , manufacturer .getContacts ().get (0 ).getName ());
117
+ assertEquals ("My Company" , manufacturer .getName ());
118
+ }
119
+
120
+ @ Test
121
+ @ DisplayName ("Using organization information only" )
122
+ void setManufacturer4 () {
123
+ BaseCycloneDxMojoImpl mojo = new BaseCycloneDxMojoImpl ();
124
+
125
+ MavenProject mavenProject = new MavenProject ();
126
+ List <Developer > developers = new ArrayList <>();
127
+ Organization organization = new Organization ();
128
+ organization .setName ("My Organization" );
129
+ organization .setUrl ("http://example.org" );
130
+ mavenProject .setOrganization (organization );
131
+
132
+ mavenProject .setDevelopers (developers );
133
+ mavenProject .setOrganization (organization );
134
+
135
+ Component projectBomComponent = new Component ();
136
+ mojo .setManufacturer (mavenProject , projectBomComponent );
137
+ OrganizationalEntity manufacturer = projectBomComponent .getManufacturer ();
138
+ assertNotNull (manufacturer );
139
+ assertNull (manufacturer .getContacts ());
140
+ assertEquals ("My Organization" , manufacturer .getName ());
65
141
}
66
142
67
143
@ Test
0 commit comments