36d071fd4abb680d07e341ab6d5d9725b1398210
[aaf/authz.git] / auth / auth-core / src / test / java / org / onap / aaf / auth / org / test / JU_OrganizationFactory.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
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
10  * *
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * *
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====================================================
19  * *
20  * *
21  ******************************************************************************/
22
23 package org.onap.aaf.auth.org.test;
24
25 import static org.mockito.Mockito.mock;
26
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.Mock;
31 import org.onap.aaf.auth.env.AuthzEnv;
32 import org.onap.aaf.auth.env.AuthzTrans;
33 import org.onap.aaf.auth.org.OrganizationException;
34 import org.onap.aaf.auth.org.OrganizationFactory;
35 import org.onap.aaf.misc.env.impl.BasicEnv;
36 import org.powermock.api.mockito.PowerMockito;
37 import org.powermock.modules.junit4.PowerMockRunner;
38
39 import junit.framework.Assert;
40
41 @RunWith(PowerMockRunner.class)
42 public class JU_OrganizationFactory {
43     private static final String ORG_SLOT = null;
44     OrganizationFactory organizationFactory;
45     BasicEnv bEnv;
46     @Mock
47     AuthzEnv authzEnvMock;
48     String orgClass="orgclass";
49     String orgNS="orgns";
50     @Before
51     public void setUp(){
52         organizationFactory = new OrganizationFactory();
53         bEnv = new BasicEnv();
54     }
55
56     @SuppressWarnings("static-access")
57     @Test
58     public void testInit() {
59         try { 
60                 organizationFactory.init(bEnv);
61                 Assert.fail("Expect an exception");
62         } catch (OrganizationException e) {
63                 Assert.assertEquals("At least one Organization must be defined", e.getMessage());
64         }
65     }
66
67     @SuppressWarnings("static-access")                //TODO:Fix this once real input is available AAF-111
68     @Test
69     public void testObtain() throws OrganizationException{
70         PowerMockito.when(authzEnvMock.getProperty("Organization."+orgNS)).thenReturn("notnull");
71         //organizationFactory.obtain(authzEnvMock, orgNS);
72     }
73
74     @Test
75     public void testGet() throws OrganizationException {  //TODO: Fix with when then return on fail
76         AuthzTrans trans = mock(AuthzTrans.class);
77         //organizationFactory.get(trans);
78     }
79 }