Skip to content

Commit 6613050

Browse files
committed
Cleanup after jules
1 parent cec34fb commit 6613050

27 files changed

Lines changed: 508 additions & 820 deletions

File tree

gbfs-validator-java-api/pom.xml

Lines changed: 102 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
</scm>
2929
<properties>
3030
<java.version>17</java.version>
31+
<junit.version>5.10.2</junit.version>
32+
<mockito.version>5.11.0</mockito.version>
33+
<junit-platform.version>1.10.2</junit-platform.version>
3134
<openapi-generator-maven-plugin>6.0.0</openapi-generator-maven-plugin>
32-
<junit.version>5.12.0</junit.version>
3335
</properties>
3436
<dependencies>
3537
<dependency>
@@ -115,14 +117,79 @@
115117
<artifactId>spring-boot-starter-test</artifactId>
116118
<scope>test</scope>
117119
</dependency>
118-
119-
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
120-
<dependency>
121-
<groupId>org.junit.jupiter</groupId>
122-
<artifactId>junit-jupiter-api</artifactId>
123-
<version>${junit.version}</version>
124-
<scope>test</scope>
125-
</dependency>
120+
121+
<!-- JUnit dependencies with aligned versions -->
122+
<dependency>
123+
<groupId>org.junit.jupiter</groupId>
124+
<artifactId>junit-jupiter-api</artifactId>
125+
<version>${junit.version}</version>
126+
<scope>test</scope>
127+
</dependency>
128+
129+
<dependency>
130+
<groupId>org.junit.jupiter</groupId>
131+
<artifactId>junit-jupiter-engine</artifactId>
132+
<version>${junit.version}</version>
133+
<scope>test</scope>
134+
</dependency>
135+
136+
<dependency>
137+
<groupId>org.junit.platform</groupId>
138+
<artifactId>junit-platform-launcher</artifactId>
139+
<version>${junit-platform.version}</version>
140+
<scope>test</scope>
141+
</dependency>
142+
143+
<dependency>
144+
<groupId>org.junit.platform</groupId>
145+
<artifactId>junit-platform-engine</artifactId>
146+
<version>${junit-platform.version}</version>
147+
<scope>test</scope>
148+
</dependency>
149+
150+
<dependency>
151+
<groupId>org.junit.platform</groupId>
152+
<artifactId>junit-platform-commons</artifactId>
153+
<version>${junit-platform.version}</version>
154+
<scope>test</scope>
155+
</dependency>
156+
157+
<!-- Spring Boot Test dependencies -->
158+
<dependency>
159+
<groupId>org.springframework.boot</groupId>
160+
<artifactId>spring-boot-starter-test</artifactId>
161+
<scope>test</scope>
162+
</dependency>
163+
164+
<!-- JUnit dependencies with aligned versions -->
165+
<dependency>
166+
<groupId>org.junit.jupiter</groupId>
167+
<artifactId>junit-jupiter-api</artifactId>
168+
<version>${junit.version}</version>
169+
<scope>test</scope>
170+
</dependency>
171+
172+
<dependency>
173+
<groupId>org.springframework</groupId>
174+
<artifactId>spring-test</artifactId>
175+
<scope>test</scope>
176+
</dependency>
177+
178+
<!-- Jetty servlet dependency required by Spring Boot Test -->
179+
<dependency>
180+
<groupId>org.eclipse.jetty</groupId>
181+
<artifactId>jetty-servlet</artifactId>
182+
<version>9.4.53.v20231009</version>
183+
<scope>test</scope>
184+
</dependency>
185+
186+
<!-- Jetty util dependency required by Spring Boot Test -->
187+
<dependency>
188+
<groupId>org.eclipse.jetty</groupId>
189+
<artifactId>jetty-util</artifactId>
190+
<version>9.4.53.v20231009</version>
191+
<scope>test</scope>
192+
</dependency>
126193
</dependencies>
127194

128195
<build>
@@ -131,6 +198,32 @@
131198
<groupId>org.springframework.boot</groupId>
132199
<artifactId>spring-boot-maven-plugin</artifactId>
133200
</plugin>
201+
202+
<!-- Configure Surefire plugin for JUnit 5 -->
203+
<plugin>
204+
<groupId>org.apache.maven.plugins</groupId>
205+
<artifactId>maven-surefire-plugin</artifactId>
206+
<version>3.5.2</version>
207+
<configuration>
208+
<includes>
209+
<include>**/*Test.java</include>
210+
</includes>
211+
<useModulePath>false</useModulePath>
212+
</configuration>
213+
<dependencies>
214+
<dependency>
215+
<groupId>org.junit.jupiter</groupId>
216+
<artifactId>junit-jupiter-engine</artifactId>
217+
<version>${junit.version}</version>
218+
</dependency>
219+
<dependency>
220+
<groupId>org.junit.platform</groupId>
221+
<artifactId>junit-platform-launcher</artifactId>
222+
<version>${junit-platform.version}</version>
223+
</dependency>
224+
</dependencies>
225+
</plugin>
226+
134227
<plugin>
135228
<groupId>org.openapitools</groupId>
136229
<artifactId>openapi-generator-maven-plugin</artifactId>

gbfs-validator-java-api/src/main/java/org/entur/gbfs/validator/api/handler/ValidateApiDelegateHandler.java

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,21 @@
2929
import org.entur.gbfs.validation.model.FileValidationResult;
3030
import org.entur.gbfs.validation.model.ValidationResult;
3131
import org.entur.gbfs.validator.api.gen.ValidateApiDelegate;
32+
import org.entur.gbfs.validator.api.model.BasicAuth;
33+
import org.entur.gbfs.validator.api.model.BearerTokenAuth;
3234
import org.entur.gbfs.validator.api.model.FileError;
3335
import org.entur.gbfs.validator.api.model.GbfsFile;
34-
// Import for API SystemError
35-
import org.entur.gbfs.validator.api.model.SystemError as ApiSystemError;
36+
import org.entur.gbfs.validator.api.model.OAuthClientCredentialsGrantAuth;
37+
import org.entur.gbfs.validator.api.model.SystemError;
3638
import org.entur.gbfs.validator.api.model.ValidatePostRequest;
3739
import org.entur.gbfs.validator.api.model.ValidationResultSummary;
3840
import org.entur.gbfs.validator.loader.LoadedFile;
3941
import org.entur.gbfs.validator.loader.Loader;
40-
import org.entur.gbfs.validator.loader.Authentication;
41-
import org.entur.gbfs.validator.loader.BasicAuth as LoaderBasicAuth;
42-
import org.entur.gbfs.validator.loader.BearerTokenAuth as LoaderBearerTokenAuth;
43-
import org.entur.gbfs.validator.loader.OAuthClientCredentialsGrantAuth as LoaderOAuthClientCredentialsGrantAuth;
44-
import org.entur.gbfs.validator.loader.SystemError as LoaderSystemError; // Explicitly for loader
45-
import org.entur.gbfs.validation.model.SystemError as ValidatorSystemError; // Explicitly for validator model
42+
import org.entur.gbfs.validator.loader.auth.Authentication;
43+
import org.entur.gbfs.validator.loader.LoaderError;
44+
import org.entur.gbfs.validation.model.ValidatorError;
4645
import org.openapitools.jackson.nullable.JsonNullable;
47-
// OpenAPI generated auth models
4846
import org.entur.gbfs.validator.api.model.ValidatePostRequestAuth;
49-
import org.entur.gbfs.validator.api.model.BasicAuth;
50-
import org.entur.gbfs.validator.api.model.BearerTokenAuth;
51-
import org.entur.gbfs.validator.api.model.OAuthClientCredentialsGrantAuth;
5247

5348
import org.slf4j.Logger;
5449
import org.slf4j.LoggerFactory;
@@ -94,24 +89,17 @@ public ResponseEntity<org.entur.gbfs.validator.api.model.ValidationResult> valid
9489
ValidatePostRequestAuth apiAuth = validatePostRequest.getAuth();
9590

9691
if (apiAuth != null) {
97-
// The OpenAPI generator for 'oneOf' with discriminator typically creates a common wrapper
98-
// that holds the actual instance. We need to get that instance.
99-
Object actualAuth = apiAuth.getActualInstance(); // This is a common pattern
100-
101-
if (actualAuth instanceof BasicAuth) {
102-
BasicAuth basic = (BasicAuth) actualAuth;
92+
if (apiAuth instanceof BasicAuth basic) {
10393
if (basic.getUsername() != null && basic.getPassword() != null) {
104-
loaderAuth = new LoaderBasicAuth(basic.getUsername(), basic.getPassword());
94+
loaderAuth = new org.entur.gbfs.validator.loader.auth.BasicAuth(basic.getUsername(), basic.getPassword());
10595
}
106-
} else if (actualAuth instanceof BearerTokenAuth) {
107-
BearerTokenAuth bearer = (BearerTokenAuth) actualAuth;
96+
} else if (apiAuth instanceof BearerTokenAuth bearer) {
10897
if (bearer.getToken() != null) {
109-
loaderAuth = new LoaderBearerTokenAuth(bearer.getToken());
98+
loaderAuth = new org.entur.gbfs.validator.loader.auth.BearerTokenAuth(bearer.getToken());
11099
}
111-
} else if (actualAuth instanceof OAuthClientCredentialsGrantAuth) {
112-
OAuthClientCredentialsGrantAuth oauth = (OAuthClientCredentialsGrantAuth) actualAuth;
100+
} else if (apiAuth instanceof OAuthClientCredentialsGrantAuth oauth) {
113101
if (oauth.getClientId() != null && oauth.getClientSecret() != null && oauth.getTokenUrl() != null) {
114-
loaderAuth = new LoaderOAuthClientCredentialsGrantAuth(oauth.getClientId(), oauth.getClientSecret(), oauth.getTokenUrl().toString());
102+
loaderAuth = new org.entur.gbfs.validator.loader.auth.OAuthClientCredentialsGrantAuth(oauth.getClientId(), oauth.getClientSecret(), oauth.getTokenUrl().toString());
115103
}
116104
}
117105
}
@@ -245,10 +233,10 @@ private List<GbfsFile> mapFiles(
245233
apiFile.setName(loadedFile.fileName());
246234
apiFile.setUrl(loadedFile.url());
247235

248-
List<ApiSystemError> combinedApiSystemErrors = new ArrayList<>();
236+
List<SystemError> combinedApiSystemErrors = new ArrayList<>();
249237

250238
// System errors from loader
251-
List<LoaderSystemError> loaderSystemErrors = loadedFile.systemErrors();
239+
List<LoaderError> loaderSystemErrors = loadedFile.loaderErrors();
252240
if (loaderSystemErrors != null && !loaderSystemErrors.isEmpty()) {
253241
combinedApiSystemErrors.addAll(mapLoaderSystemErrorsToApi(loaderSystemErrors));
254242
}
@@ -262,7 +250,7 @@ private List<GbfsFile> mapFiles(
262250
apiFile.setErrors(mapFileValidationErrors(validationResult.errors()));
263251

264252
// Add system errors from validator (parsing errors)
265-
List<ValidatorSystemError> validatorSystemErrors = validationResult.systemErrors();
253+
List<ValidatorError> validatorSystemErrors = validationResult.validatorErrors();
266254
if (validatorSystemErrors != null && !validatorSystemErrors.isEmpty()) {
267255
combinedApiSystemErrors.addAll(mapValidatorSystemErrorsToApi(validatorSystemErrors));
268256
}
@@ -287,24 +275,24 @@ private List<GbfsFile> mapFiles(
287275
return apiGbfsFiles;
288276
}
289277

290-
private List<ApiSystemError> mapLoaderSystemErrorsToApi(List<LoaderSystemError> loaderSystemErrors) {
278+
private List<SystemError> mapLoaderSystemErrorsToApi(List<LoaderError> loaderSystemErrors) {
291279
if (loaderSystemErrors == null) {
292280
return new ArrayList<>();
293281
}
294282
return loaderSystemErrors.stream().map(loaderError -> {
295-
ApiSystemError apiError = new ApiSystemError();
283+
SystemError apiError = new SystemError();
296284
apiError.setError(loaderError.error());
297285
apiError.setMessage(loaderError.message());
298286
return apiError;
299287
}).toList();
300288
}
301289

302-
private List<ApiSystemError> mapValidatorSystemErrorsToApi(List<ValidatorSystemError> validatorSystemErrors) {
290+
private List<SystemError> mapValidatorSystemErrorsToApi(List<ValidatorError> validatorSystemErrors) {
303291
if (validatorSystemErrors == null) {
304292
return new ArrayList<>();
305293
}
306294
return validatorSystemErrors.stream().map(validatorError -> {
307-
ApiSystemError apiError = new ApiSystemError();
295+
SystemError apiError = new SystemError();
308296
apiError.setError(validatorError.error());
309297
apiError.setMessage(validatorError.message());
310298
return apiError;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
*
3+
* *
4+
* *
5+
* * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by
6+
* * * the European Commission - subsequent versions of the EUPL (the "Licence");
7+
* * * You may not use this work except in compliance with the Licence.
8+
* * * You may obtain a copy of the Licence at:
9+
* * *
10+
* * * https://joinup.ec.europa.eu/software/page/eupl
11+
* * *
12+
* * * Unless required by applicable law or agreed to in writing, software
13+
* * * distributed under the Licence is distributed on an "AS IS" basis,
14+
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* * * See the Licence for the specific language governing permissions and
16+
* * * limitations under the Licence.
17+
* *
18+
*
19+
*/
20+
21+
package org.entur.gbfs.validator.api;
22+
23+
import org.springframework.boot.SpringApplication;
24+
import org.springframework.boot.autoconfigure.SpringBootApplication;
25+
26+
@SpringBootApplication
27+
public class TestApplication {
28+
public static void main(String[] args) {
29+
SpringApplication.run(TestApplication.class, args);
30+
}
31+
}

0 commit comments

Comments
 (0)