1 /*******************************************************************************
2 * ============LICENSE_START====================================================
4 * * ===========================================================================
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * * ===========================================================================
7 * * Licensed under the Apache License, Version 2.0 (the "License");
8 * * you may not use this file except in compliance with the License.
9 * * You may obtain a copy of the License at
11 * * http://www.apache.org/licenses/LICENSE-2.0
13 * * Unless required by applicable law or agreed to in writing, software
14 * * distributed under the License is distributed on an "AS IS" BASIS,
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * * See the License for the specific language governing permissions and
17 * * limitations under the License.
18 * * ============LICENSE_END====================================================
21 ******************************************************************************/
22 package org.onap.aaf.org.test;
24 import static org.junit.Assert.*;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.mockito.Matchers;
33 import org.mockito.Mock;
34 import org.mockito.MockitoAnnotations;
35 import org.onap.aaf.auth.env.AuthzEnv;
36 import org.onap.aaf.auth.env.AuthzTrans;
37 import org.onap.aaf.auth.org.OrganizationException;
38 import org.onap.aaf.org.DefaultOrg;
39 import org.powermock.api.mockito.PowerMockito;
40 import org.powermock.modules.junit4.PowerMockRunner;
42 @RunWith(PowerMockRunner.class)
43 public class JU_DefaultOrg {
45 DefaultOrg defaultOrg;
46 //private DefaultOrg defaultOrgMock;
48 AuthzEnv authzEnvMock;
51 AuthzTrans authzTransMock;
56 private static final String PROPERTY_IS_REQUIRED = " property is Required";
57 private static final String DOMAIN = "osaaf.com";
58 private static final String REALM = "com.osaaf";
59 private static final String NAME = "Default Organization";
60 private static final String NO_PASS = NAME + " does not support Passwords. Use AAF";
61 String mailHost,mailFromUserId,supportAddress;
62 private String SUFFIX;
67 public void setUp() throws OrganizationException{
68 MockitoAnnotations.initMocks(this);
69 PowerMockito.when(authzEnvMock.getProperty(s=(REALM + ".mailHost"), null)).thenReturn("hello");
70 PowerMockito.when(authzEnvMock.getProperty(s=(REALM + ".supportEmail"), null)).thenReturn("notnull");
71 PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn("src" + File.separator + "test" + File.separator + "resources" + File.separator + "test.txt");
72 PowerMockito.when(fIdentitiesMock.exists()).thenReturn(true);
73 //PowerMockito.when((fIdentitiesMock!=null && fIdentitiesMock.exists())).thenReturn(true);
74 defaultOrg = new DefaultOrg(authzEnvMock, REALM);
77 //@Test //(expected=OrganizationException.class)
78 public void test() throws OrganizationException{
79 //PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn(" ");
80 //defaultOrg = new DefaultOrg(authzEnvMock);
81 assertTrue(defaultOrg != null);
85 //@Test //(expected=OrganizationException.class)
86 public void testMultipleCreds() throws OrganizationException{
88 //PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn(" ");
89 //defaultOrg = new DefaultOrg(authzEnvMock);
90 boolean canHaveMultipleCreds;
91 canHaveMultipleCreds = defaultOrg.canHaveMultipleCreds(id );
92 System.out.println("value of canHaveMultipleCreds: " + canHaveMultipleCreds);
93 assertTrue(canHaveMultipleCreds);
98 public void testGetIdentityTypes() throws OrganizationException{
99 Set<String> identityTypes = defaultOrg.getIdentityTypes();
100 System.out.println("value of IdentityTypes: " + identityTypes);
101 assertTrue(identityTypes.size() == 4);
106 public void testGetRealm() throws OrganizationException{
107 String realmTest = defaultOrg.getRealm();
108 System.out.println("value of realm: " + realmTest);
109 assertTrue(realmTest == REALM);
113 public void testGetName() throws OrganizationException{
114 String testName = defaultOrg.getName();
115 System.out.println("value of name: " + testName);
116 assertTrue(testName == NAME);
121 public void testGetDomain() throws OrganizationException{
122 String testDomain = defaultOrg.getDomain();
123 System.out.println("value of domain: " + testDomain);
124 assertTrue(testDomain == DOMAIN);
128 // public void testIsValidID(){
129 // String Result = defaultOrg.isValidID(Matchers.anyString());
130 // System.out.println("value of res " +Result);
131 // assertNotNull(Result);
135 public void notYetImplemented() {
136 fail("Tests in this file should not be trusted");