diff options
author | sourabh_sourabh <sourabh.sourabh@est.tech> | 2024-11-12 13:12:02 +0000 |
---|---|---|
committer | sourabh_sourabh <sourabh.sourabh@est.tech> | 2024-11-18 11:34:37 +0000 |
commit | 436a8dc7b4241b685d3f483a5d64b9f4b2000cb5 (patch) | |
tree | c962de7a01fedd24b968bff1c3d78e40a02c08ca /dmi-service | |
parent | 6c877ba9d5e1dfde569593ed88652b93b10ba4a6 (diff) |
Fixed the java code checkstyle configuration and jacoco report
- Removed oParent dependency.
- pulled cps checkstyle and applied for all dmi modules for code style
check and copyright.
- Ignored checkstyle folder for to be commited.
- Fixed java code styles.
- Added missing plugins and configurations for jacoco report.
- Configured deply plugin and related onap properties.
- Temporarily disabled CSIT.
Issue-ID: CPS-2471
Change-Id: I5a26c2a156b93c3e58c5c42814f1dff85831d4df
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Diffstat (limited to 'dmi-service')
4 files changed, 111 insertions, 18 deletions
diff --git a/dmi-service/pom.xml b/dmi-service/pom.xml index 306d6118..6e740e8d 100644 --- a/dmi-service/pom.xml +++ b/dmi-service/pom.xml @@ -20,6 +20,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <parent> <groupId>org.onap.cps</groupId> <artifactId>ncmp-dmi-plugin</artifactId> @@ -29,7 +30,29 @@ <artifactId>dmi-service</artifactId> <properties> + <!-- Application Configuration --> + <app>org.onap.cps.ncmp.dmi.Application</app> + + <image.name>ncmp-dmi-plugin</image.name> + <!-- Encoding Configuration --> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + + <!-- Checkstyle Configuration --> + <checkstyle.config.location>${project.parent.basedir}</checkstyle.config.location> + + <!-- Global properties for version management --> + <bug.pattern.version>1.5.0</bug.pattern.version> + <gmavenplus.plugin.version>4.0.1</gmavenplus.plugin.version> + <maven.surefire.plugin.version>3.3.1</maven.surefire.plugin.version> + <openapi.generator.maven.plugin.version>6.6.0</openapi.generator.maven.plugin.version> + <spring.boot.maven.plugin.version>3.1.2</spring.boot.maven.plugin.version> + <spotbugs.maven.plugin.version>4.4.2</spotbugs.maven.plugin.version> + + <!-- Code Coverage Configuration --> + <jacoco.execFile>${basedir}/target/code-coverage/jacoco-ut.exec</jacoco.execFile> <jacoco.minimum.coverage>0.98</jacoco.minimum.coverage> + <jacoco.outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</jacoco.outputDirectory> + <jacoco.version>0.8.11</jacoco.version> </properties> <dependencyManagement> @@ -237,6 +260,7 @@ <dependency> <groupId>org.onap.cps</groupId> <artifactId>cps-ncmp-events</artifactId> + <version>${cps.version}</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> @@ -289,6 +313,7 @@ <scope>test</scope> </dependency> </dependencies> + <build> <resources> <resource> @@ -313,7 +338,7 @@ <plugin> <groupId>org.openapitools</groupId> <artifactId>openapi-generator-maven-plugin</artifactId> - <version>6.6.0</version> + <version>${openapi.generator.maven.plugin.version}</version> <executions> <execution> <id>dmi-code-gen</id> @@ -396,7 +421,7 @@ <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - <version>3.1.2</version> + <version>${spring.boot.maven.plugin.version}</version> <executions> <execution> <goals> @@ -409,7 +434,7 @@ <plugin> <groupId>org.codehaus.gmavenplus</groupId> <artifactId>gmavenplus-plugin</artifactId> - <version>4.0.1</version> + <version>${gmavenplus.plugin.version}</version> <executions> <execution> <goals> @@ -421,6 +446,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> + <version>${maven.surefire.plugin.version}</version> <configuration> <argLine>${surefireArgLine}</argLine> <includes> @@ -442,7 +468,7 @@ <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> - <version>4.4.2</version> + <version>${spotbugs.maven.plugin.version}</version> <executions> <execution> <id>analyze-compile</id> @@ -465,7 +491,7 @@ <plugin> <groupId>jp.skypencil.findbugs.slf4j</groupId> <artifactId>bug-pattern</artifactId> - <version>1.5.0</version> + <version>${bug.pattern.version}</version> </plugin> </plugins> <effort>Max</effort> @@ -480,7 +506,7 @@ <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> - <version>0.8.10</version> + <version>${jacoco.version}</version> <configuration> <excludes> <exclude>org/onap/cps/ncmp/dmi/model/*</exclude> @@ -493,14 +519,19 @@ <goals> <goal>prepare-agent</goal> </goals> + <configuration> + <destFile>${jacoco.execFile}</destFile> + <propertyName>surefireArgLine</propertyName> + </configuration> </execution> <execution> <id>coverage-check</id> + <phase>test</phase> <goals> <goal>check</goal> </goals> <configuration> - <dataFile>${basedir}/target/code-coverage/jacoco-ut.exec</dataFile> + <dataFile>${jacoco.execFile}</dataFile> <rules> <rule> <element>BUNDLE</element> @@ -516,19 +547,81 @@ </configuration> </execution> <execution> - <id>report</id> - <phase>verify</phase> + <id>post-unit-test</id> + <phase>test</phase> <goals> - <goal>report-aggregate</goal> + <goal>report</goal> </goals> <configuration> - <dataFileIncludes> - <fileInclude>**/code-coverage/jacoco-ut.exec</fileInclude> - </dataFileIncludes> + <outputEncoding>${project.reporting.outputEncoding}</outputEncoding> + <!-- Sets the path to the file which contains the execution data. --> + <dataFile>${jacoco.execFile}</dataFile> + <!-- Sets the output directory for the code coverage report. --> + <outputDirectory>${jacoco.outputDirectory}</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> + <pluginManagement> + <plugins> + <plugin> + <groupId>com.google.cloud.tools</groupId> + <artifactId>jib-maven-plugin</artifactId> + <version>3.3.2</version> + <configuration> + <container> + <mainClass>${app}</mainClass> + <creationTime>USE_CURRENT_TIMESTAMP</creationTime> + </container> + <from> + <image>${base.image}</image> + </from> + <to> + <tags> + <tag>latest</tag> + <tag>${project.version}-latest</tag> + </tags> + <image>${docker.push.registry}/onap/${image.name}:${image.tag}</image> + </to> + </configuration> + <executions> + <execution> + <phase>package</phase> + <id>build</id> + <goals> + <goal>dockerBuild</goal> + </goals> + </execution> + <execution> + <phase>deploy</phase> + <id>buildAndPush</id> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> </build> + <profiles> + <profile> + <id>docker</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <properties> + <image.name>ncmp-dmi-plugin</image.name> + </properties> + <build> + <plugins> + <plugin> + <groupId>com.google.cloud.tools</groupId> + <artifactId>jib-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project>
\ No newline at end of file diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/exception/DmiExceptionHandler.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/exception/DmiExceptionHandler.java index 49db7d8b..4e75f495 100644 --- a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/exception/DmiExceptionHandler.java +++ b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/exception/DmiExceptionHandler.java @@ -58,7 +58,7 @@ public class DmiExceptionHandler { private static ResponseEntity<Object> buildErrorResponse(final HttpStatus httpStatus, final Exception exception) { logForNonDmiException(exception); - final var errorMessage = new ErrorMessage(); + final ErrorMessage errorMessage = new ErrorMessage(); errorMessage.setStatus(httpStatus.toString()); errorMessage.setMessage(exception.getMessage()); errorMessage.setDetails(exception instanceof DmiException ? ((DmiException) exception).getDetails() : diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java index 94783f3b..a2a01ebd 100644 --- a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java +++ b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java @@ -47,11 +47,11 @@ public class NcmpRestClient { * @return the response entity */ public ResponseEntity<String> registerCmHandlesWithNcmp(final String jsonData) { - final var ncmpRegistrationUrl = buildNcmpRegistrationUrl(); - final var httpHeaders = new HttpHeaders(); + final String ncmpRegistrationUrl = buildNcmpRegistrationUrl(); + final HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setBasicAuth(cpsProperties.getAuthUsername(), cpsProperties.getAuthPassword()); httpHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - final var httpEntity = new HttpEntity<>(jsonData, httpHeaders); + final HttpEntity httpEntity = new HttpEntity<>(jsonData, httpHeaders); return restTemplate.exchange(ncmpRegistrationUrl, HttpMethod.POST, httpEntity, String.class); } diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java index fd94e634..1484366f 100644 --- a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java +++ b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java @@ -234,7 +234,7 @@ public class SdncOperations { private List<ModuleSchema> convertToModuleSchemas(final String modulesListAsJson) { try { return JsonPath.using(jsonPathConfiguration).parse(modulesListAsJson).read( - PATH_TO_MODULE_SCHEMAS, new TypeRef<>() { + PATH_TO_MODULE_SCHEMAS, new TypeRef<List<ModuleSchema>>() { }); } catch (final JsonPathException jsonPathException) { throw new SdncException("SDNC Response processing failed", |