******************************************************************************/\r
package org.onap.aaf.osaaf.defOrg;\r
\r
-import static org.junit.Assert.*;\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertTrue;\r
\r
import java.io.File;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.regex.Matcher;\r
-\r
-import javax.mail.Address;\r
-import javax.mail.internet.InternetAddress;\r
+import java.util.Set;\r
\r
import org.junit.Before;\r
import org.junit.Test;\r
import org.mockito.MockitoAnnotations;\r
import org.onap.aaf.authz.env.AuthzEnv;\r
import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.org.Executor;\r
import org.onap.aaf.authz.org.OrganizationException;\r
-import org.onap.aaf.authz.org.Organization.Identity;\r
-import org.onap.aaf.authz.org.Organization.Policy;\r
-import org.onap.aaf.osaaf.defOrg.DefaultOrg;\r
-import org.onap.aaf.osaaf.defOrg.Identities.Data;\r
import org.powermock.api.mockito.PowerMockito;\r
import org.powermock.modules.junit4.PowerMockRunner;\r
\r
@Mock\r
File fIdentitiesMock;\r
\r
+\r
@Before\r
public void setUp() throws OrganizationException{\r
MockitoAnnotations.initMocks(this);\r
PowerMockito.when(authzEnvMock.getProperty(s=(REALM + ".mailHost"), null)).thenReturn("hello");\r
PowerMockito.when(authzEnvMock.getProperty(s=(REALM + ".supportEmail"), null)).thenReturn("notnull");\r
- PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn("C:/Users/sv8675/Desktop/AAF-Code-Sai/AAF-master/authz/authz-defOrg/src/main/java/test.txt");\r
+ PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn("src\\test\\resources\\test.txt");\r
PowerMockito.when(fIdentitiesMock.exists()).thenReturn(true);\r
//PowerMockito.when((fIdentitiesMock!=null && fIdentitiesMock.exists())).thenReturn(true);\r
defaultOrg = new DefaultOrg(authzEnvMock);\r
public void test() throws OrganizationException{\r
//PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn(" ");\r
//defaultOrg = new DefaultOrg(authzEnvMock);\r
- assertTrue(true);\r
+ assertTrue(defaultOrg != null);\r
+}\r
+\r
+\r
+@Test //(expected=OrganizationException.class)\r
+public void testMultipleCreds() throws OrganizationException{\r
+ String id = "test";\r
+ //PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn(" ");\r
+ //defaultOrg = new DefaultOrg(authzEnvMock);\r
+ boolean canHaveMultipleCreds;\r
+ canHaveMultipleCreds = defaultOrg.canHaveMultipleCreds(id );\r
+ System.out.println("value of canHaveMultipleCreds: " + canHaveMultipleCreds);\r
+ assertTrue(canHaveMultipleCreds);\r
+}\r
+\r
+\r
+@Test \r
+public void testGetIdentityTypes() throws OrganizationException{\r
+ Set<String> identityTypes = defaultOrg.getIdentityTypes();\r
+ System.out.println("value of IdentityTypes: " + identityTypes);\r
+ assertTrue(identityTypes.size() == 4);\r
}\r
\r
+\r
+@Test \r
+public void testGetRealm() throws OrganizationException{\r
+ String realmTest = defaultOrg.getRealm();\r
+ System.out.println("value of realm: " + realmTest);\r
+ assertTrue(realmTest == REALM);\r
+}\r
+\r
+@Test \r
+public void testGetName() throws OrganizationException{\r
+ String testName = defaultOrg.getName();\r
+ System.out.println("value of name: " + testName);\r
+ assertTrue(testName == NAME);\r
+}\r
+\r
+\r
+@Test \r
+public void testGetDomain() throws OrganizationException{\r
+ String testDomain = defaultOrg.getDomain();\r
+ System.out.println("value of domain: " + testDomain);\r
+ assertTrue(testDomain == DOMAIN);\r
+}\r
+\r
+\r
+\r
@Test\r
public void testIsValidID(){ \r
String Result = defaultOrg.isValidID(Matchers.anyString());\r
<project.innoVersion>1.0.0-SNAPSHOT</project.innoVersion>
<project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>
<project.dme2Version>3.1.200</project.dme2Version>
- <sonar.language>java</sonar.language>
- <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
- <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
- <sonar.jacoco.reportPath>${project.build.directory}/coverage-reports/jacoco.exec</sonar.jacoco.reportPath>
- <sonar.jacoco.itReportPath>${project.build.directory}/coverage-reports/jacoco-it.exec</sonar.jacoco.itReportPath>
- <sonar.jacoco.reportMissing.force.zero>true</sonar.jacoco.reportMissing.force.zero>
- <sonar.projectVersion>${project.version}</sonar.projectVersion>
+ <!-- SONAR -->
+ <jacoco.version>0.7.7.201606060606</jacoco.version>
+ <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
+ <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
+ <!-- Default Sonar configuration -->
+ <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->
+ <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
<releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
<exclude>**/JU_CredDAO.java</exclude>
<exclude>**/JU_CacheInfoDAO.java</exclude>
<exclude>**/JU_ApprovalDAO.java</exclude>
- <exclude>**/JU_Define.java</exclude>
+ <!-- <exclude>**/JU_Define.java</exclude> -->
+ <exclude>**/JU_Identities.java</exclude>
<exclude>**/JU_AuthzTransFilter.java</exclude>
<exclude>**/JU_CachingFileAccess.java</exclude>
<!-- <exclude>**/AbsServiceTest.java</exclude> -->
- <exclude>**/JU_DefaultOrg.java</exclude>
+ <!-- <exclude>**/JU_DefaultOrg.java</exclude> -->
<exclude>**/JU_FileServer.java</exclude>
<exclude>**/JU_DirectAAFLur.java</exclude>
<exclude>**/JU_AuthAPI.java</exclude>
</configuration>
</plugin>
<plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>0.7.7.201606060606</version>
- <configuration>
- <dumpOnExit>true</dumpOnExit>
- <includes>
- <include>org.onap.aaf.*</include>
- </includes>
- </configuration>
- <executions>
- <execution>
- <id>pre-unit-test</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
- <!-- <append>true</append> -->
- </configuration>
- </execution>
- <execution>
- <id>pre-integration-test</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
- <!-- <append>true</append> -->
- </configuration>
- </execution>
- <execution>
- <goals>
- <goal>merge</goal>
- </goals>
- <phase>post-integration-test</phase>
- <configuration>
- <fileSets>
- <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
- <directory>${project.build.directory}/coverage-reports</directory>
- <includes>
- <include>*.exec</include>
- </includes>
- </fileSet>
- </fileSets>
- <destFile>${project.build.directory}/jacoco-dev.exec</destFile>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco.version}</version>
+ <configuration>
+ <excludes>
+ <exclude>**/gen/**</exclude>
+ <exclude>**/generated-sources/**</exclude>
+ <exclude>**/yang-gen/**</exclude>
+ <exclude>**/pax/**</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+
+ <execution>
+ <id>pre-unit-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>
+ <propertyName>surefireArgLine</propertyName>
+ </configuration>
+ </execution>
+
+
+ <execution>
+ <id>post-unit-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
+ <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>pre-integration-test</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>
+
+ <propertyName>failsafeArgLine</propertyName>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>post-integration-test</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>
+ <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</pluginManagement>