@@ -64,16 +64,22 @@ static void resetLocale() {
6464 void validPercentEncoding () throws MalformedPackageURLException {
6565 PackageURL purl = new PackageURL ("maven" , "com.google.summit" , "summit-ast" , "2.2.0\n " , null , null );
6666 assertEquals ("pkg:maven/com.google.summit/summit-ast@2.2.0%0A" , purl .toString ());
67- PackageURL purl2 = new PackageURL ("pkg:nuget/%D0%9Cicros%D0%BEft.%D0%95ntit%D1%83Fram%D0%B5work%D0%A1%D0%BEr%D0%B5" );
67+ PackageURL purl2 =
68+ new PackageURL ("pkg:nuget/%D0%9Cicros%D0%BEft.%D0%95ntit%D1%83Fram%D0%B5work%D0%A1%D0%BEr%D0%B5" );
6869 assertEquals ("Мicrosоft.ЕntitуFramеworkСоrе" , purl2 .getName ());
69- assertEquals ("pkg:nuget/%D0%9Cicros%D0%BEft.%D0%95ntit%D1%83Fram%D0%B5work%D0%A1%D0%BEr%D0%B5" , purl2 .toString ());
70+ assertEquals (
71+ "pkg:nuget/%D0%9Cicros%D0%BEft.%D0%95ntit%D1%83Fram%D0%B5work%D0%A1%D0%BEr%D0%B5" , purl2 .toString ());
7072 }
7173
7274 @ SuppressWarnings ("deprecation" )
7375 @ Test
7476 void invalidPercentEncoding () throws MalformedPackageURLException {
75- assertThrowsExactly (MalformedPackageURLException .class , () -> new PackageURL ("pkg:maven/com.google.summit/summit-ast@2.2.0%" ));
76- assertThrowsExactly (MalformedPackageURLException .class , () -> new PackageURL ("pkg:maven/com.google.summit/summit-ast@2.2.0%0" ));
77+ assertThrowsExactly (
78+ MalformedPackageURLException .class ,
79+ () -> new PackageURL ("pkg:maven/com.google.summit/summit-ast@2.2.0%" ));
80+ assertThrowsExactly (
81+ MalformedPackageURLException .class ,
82+ () -> new PackageURL ("pkg:maven/com.google.summit/summit-ast@2.2.0%0" ));
7783 PackageURL purl = new PackageURL ("pkg:maven/com.google.summit/summit-ast@2.2.0" );
7884 Throwable t1 = assertThrowsExactly (ValidationException .class , () -> purl .uriDecode ("%" ));
7985 assertEquals ("Incomplete percent encoding at offset 0 with value '%'" , t1 .getMessage ());
@@ -86,19 +92,20 @@ void invalidPercentEncoding() throws MalformedPackageURLException {
8692 }
8793
8894 static Stream <Arguments > constructorParsing () throws IOException {
89- return PurlParameters .getTestDataFromFiles ("test-suite-data.json" ,
90- "custom-suite.json" ,
91- "string-constructor-only.json" );
95+ return PurlParameters .getTestDataFromFiles (
96+ "test-suite-data.json" , "custom-suite.json" , "string-constructor-only.json" );
9297 }
9398
9499 @ DisplayName ("Test constructor parsing" )
95100 @ ParameterizedTest (name = "{0}: ''{1}''" )
96101 @ MethodSource
97- void constructorParsing (String description ,
98- @ Nullable String purlString ,
99- PurlParameters parameters ,
100- @ Nullable String canonicalPurl ,
101- boolean invalid ) throws Exception {
102+ void constructorParsing (
103+ String description ,
104+ @ Nullable String purlString ,
105+ PurlParameters parameters ,
106+ @ Nullable String canonicalPurl ,
107+ boolean invalid )
108+ throws Exception {
102109 if (invalid ) {
103110 assertThrows (getExpectedException (purlString ), () -> new PackageURL (purlString ));
104111 } else {
@@ -109,32 +116,38 @@ void constructorParsing(String description,
109116 }
110117
111118 static Stream <Arguments > constructorParameters () throws IOException {
112- return PurlParameters .getTestDataFromFiles ("test-suite-data.json" , "custom-suite.json" , "components-constructor-only.json" );
119+ return PurlParameters .getTestDataFromFiles (
120+ "test-suite-data.json" , "custom-suite.json" , "components-constructor-only.json" );
113121 }
114122
115123 @ DisplayName ("Test constructor parameters" )
116124 @ ParameterizedTest (name = "{0}: {2}" )
117125 @ MethodSource
118- void constructorParameters (String description ,
119- @ Nullable String purlString ,
120- PurlParameters parameters ,
121- @ Nullable String canonicalPurl ,
122- boolean invalid ) throws Exception {
126+ void constructorParameters (
127+ String description ,
128+ @ Nullable String purlString ,
129+ PurlParameters parameters ,
130+ @ Nullable String canonicalPurl ,
131+ boolean invalid )
132+ throws Exception {
123133 if (invalid ) {
124- assertThrows (getExpectedException (parameters ),
125- () -> new PackageURL (parameters .getType (),
134+ assertThrows (
135+ getExpectedException (parameters ),
136+ () -> new PackageURL (
137+ parameters .getType (),
138+ parameters .getNamespace (),
139+ parameters .getName (),
140+ parameters .getVersion (),
141+ parameters .getQualifiers (),
142+ parameters .getSubpath ()));
143+ } else {
144+ PackageURL purl = new PackageURL (
145+ parameters .getType (),
126146 parameters .getNamespace (),
127147 parameters .getName (),
128148 parameters .getVersion (),
129149 parameters .getQualifiers (),
130- parameters .getSubpath ()));
131- } else {
132- PackageURL purl = new PackageURL (parameters .getType (),
133- parameters .getNamespace (),
134- parameters .getName (),
135- parameters .getVersion (),
136- parameters .getQualifiers (),
137- parameters .getSubpath ());
150+ parameters .getSubpath ());
138151 assertPurlEquals (parameters , purl );
139152 assertEquals (canonicalPurl , purl .canonicalize (), "canonical PURL" );
140153 }
@@ -146,14 +159,16 @@ static Stream<Arguments> constructorTypeNameSpace() throws IOException {
146159
147160 @ ParameterizedTest
148161 @ MethodSource
149- void constructorTypeNameSpace (String description ,
150- @ Nullable String purlString ,
151- PurlParameters parameters ,
152- @ Nullable String canonicalPurl ,
153- boolean invalid ) throws Exception {
162+ void constructorTypeNameSpace (
163+ String description ,
164+ @ Nullable String purlString ,
165+ PurlParameters parameters ,
166+ @ Nullable String canonicalPurl ,
167+ boolean invalid )
168+ throws Exception {
154169 if (invalid ) {
155- assertThrows (getExpectedException ( parameters ),
156- () -> new PackageURL (parameters .getType (), parameters .getName ()));
170+ assertThrows (
171+ getExpectedException ( parameters ), () -> new PackageURL (parameters .getType (), parameters .getName ()));
157172 } else {
158173 PackageURL purl = new PackageURL (parameters .getType (), parameters .getName ());
159174 assertPurlEquals (parameters , purl );
@@ -173,7 +188,9 @@ private static void assertPurlEquals(PurlParameters expected, PackageURL actual)
173188 }
174189
175190 private static Class <? extends Exception > getExpectedException (PurlParameters json ) {
176- return json .getType () == null || json .getName () == null ? NullPointerException .class : MalformedPackageURLException .class ;
191+ return json .getType () == null || json .getName () == null
192+ ? NullPointerException .class
193+ : MalformedPackageURLException .class ;
177194 }
178195
179196 private static Class <? extends Exception > getExpectedException (@ Nullable String purl ) {
0 commit comments