Sonar Cloud migration changes 24/103524/1
authorsu622b <su622b@att.com>
Wed, 11 Mar 2020 15:03:27 +0000 (11:03 -0400)
committersu622b <su622b@att.com>
Wed, 11 Mar 2020 15:03:42 +0000 (11:03 -0400)
Issue-ID: DMAAP-1407
Change-Id: I8da1faa13512b16c19862412e76712a30c522a16
Signed-off-by: su622b <su622b@att.com>
pom.xml
src/main/java/org/onap/dmaap/commonauth/kafka/base/authorization/Cadi3AAFProvider.java
src/test/java/org/onap/dmaap/commonauth/kafka/base/authorization/Cadi3AAFProviderTest.java

diff --git a/pom.xml b/pom.xml
index 30cd824..b322d68 100644 (file)
--- a/pom.xml
+++ b/pom.xml
 
                </resources> 
                <plugins>
+                   <plugin>
+                    <groupId>org.jacoco</groupId>
+                    <artifactId>jacoco-maven-plugin</artifactId>
+                    <executions>
+                        <execution>
+                            <id>prepare-agent</id>
+                            <goals>
+                                <goal>prepare-agent</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>report</id>
+                            <goals>
+                                <goal>report</goal>
+                            </goals>
+                            <configuration>
+                                <dataFile>${project.build.directory}/code-coverage/jacoco.exec</dataFile>
+                                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-surefire-plugin</artifactId>
                                        <!-- <skipTests>true</skipTests> -->
                                </configuration>
                        </plugin>
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>cobertura-maven-plugin</artifactId>
-                               <version>2.7</version>
-                               <configuration>
-                                       <formats>
-                                               <format>html</format>
-                                               <format>xml</format>
-                                       </formats>
-                               </configuration>
-                       </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-site-plugin</artifactId>
                <nexusproxy>https://nexus.onap.org</nexusproxy>
                <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
                <onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
+               <sonar.language>java</sonar.language>
+        <sonar.skip>false</sonar.skip>
+        <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
+        <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
+        <sonar.projectVersion>${project.version}</sonar.projectVersion>
        </properties>
 
        <!-- Distribution management -->
index 56fd1bb..b5193cc 100644 (file)
@@ -54,10 +54,16 @@ public class Cadi3AAFProvider implements AuthorizationProvider {
        private static final Logger logger = LoggerFactory.getLogger(Cadi3AAFProvider.class);
 
        static {
-
+               if (System.getProperty("enableCadi") != null) {
+                       if (System.getProperty("enableCadi").equals("true")) {
+                               enableCadi = true;
+                       }
+               }
+         else{
                if (System.getenv("enableCadi") != null && System.getenv("enableCadi").equals("true")) {
                        enableCadi = true;
                }
+         }
                Configuration config = Configuration.getConfiguration();
                try {
                        if (config == null) {
@@ -181,7 +187,6 @@ public class Cadi3AAFProvider implements AuthorizationProvider {
 
                logger.info("^Event received  with   username " + userId);
 
-               boolean enableCadi = System.getenv("enableCadi") == null ? true : false;
                if (!enableCadi) {
                        return null;
                } else {
index 743917d..8bd8486 100644 (file)
@@ -61,6 +61,7 @@ public class Cadi3AAFProviderTest {
        @Before
        public void setUp() throws Exception {
                MockitoAnnotations.initMocks(this);
+               System.setProperty("enableCadi", "true");
                System.setProperty("CADI_PROPERTIES", "src/test/resources/cadi.properties");
                cadi3AAFProvider = new Cadi3AAFProvider();
        }
@@ -77,6 +78,7 @@ public class Cadi3AAFProviderTest {
        
        @Test(expected = NullPointerException.class)
        public void tesAuthenticate() throws Exception {
+               System.setProperty("enableCadi", "true");
                when(aafAuthn.validate("userId", "password")).thenReturn("valid");
                assertEquals(cadi3AAFProvider.authenticate("userId", "password"), "valid");
        }