ONAP Code Coverage for DMI is not publishing to sonar 05/139705/3
authorsourabh_sourabh <sourabh.sourabh@est.tech>
Tue, 10 Dec 2024 11:32:35 +0000 (11:32 +0000)
committersourabh_sourabh <sourabh.sourabh@est.tech>
Tue, 10 Dec 2024 12:18:14 +0000 (12:18 +0000)
- Added sonar plugin for dmi service.

Issue-ID: CPS-2545
Change-Id: Ic779c81dc5db3071010f5b47cd3f4a75a107c494
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
dmi-service/pom.xml
dmi-service/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java

index 0686f3a..3736b76 100644 (file)
@@ -46,6 +46,7 @@
         <maven.deploy.plugin.version>3.1.2</maven.deploy.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>
+        <sonar.version>4.0.0.4121</sonar.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>
         <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
@@ -55,6 +56,7 @@
         <jacoco.minimum.coverage>0.98</jacoco.minimum.coverage>
         <jacoco.outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</jacoco.outputDirectory>
         <jacoco.version>0.8.11</jacoco.version>
+        <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
 
         <!-- ONAP Nexus Repository Configuration -->
         <onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
                     <excludes>
                         <exclude>org/onap/cps/ncmp/dmi/model/*</exclude>
                         <exclude>org/onap/cps/ncmp/dmi/datajobs/model/*</exclude>
+                        <exclude>**/pom.xml</exclude>
                     </excludes>
                 </configuration>
                 <executions>
                     </execution>
                 </executions>
             </plugin>
+            <!-- Sonar Plugin for Code Quality -->
+            <plugin>
+                <groupId>org.sonarsource.scanner.maven</groupId>
+                <artifactId>sonar-maven-plugin</artifactId>
+                <version>${sonar.version}</version>
+            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-deploy-plugin</artifactId>
index a2a01eb..92165ff 100644 (file)
@@ -51,7 +51,7 @@ public class NcmpRestClient {
         final HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.setBasicAuth(cpsProperties.getAuthUsername(), cpsProperties.getAuthPassword());
         httpHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
-        final HttpEntity httpEntity = new HttpEntity<>(jsonData, httpHeaders);
+        final HttpEntity<String> httpEntity = new HttpEntity<>(jsonData, httpHeaders);
         return restTemplate.exchange(ncmpRegistrationUrl, HttpMethod.POST, httpEntity, String.class);
     }