2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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 package org.onap.aaf.auth.direct.test;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
26 import static org.mockito.MockitoAnnotations.initMocks;
28 import java.util.ArrayList;
29 import java.util.List;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.Mock;
35 import org.mockito.Mockito;
36 import org.mockito.runners.MockitoJUnitRunner;
37 import org.onap.aaf.auth.dao.cass.LocateDAO;
38 import org.onap.aaf.auth.dao.cass.LocateDAO.Data;
39 import org.onap.aaf.auth.direct.DirectAAFLocator;
40 import org.onap.aaf.auth.env.AuthzEnv;
41 import org.onap.aaf.auth.env.AuthzTrans;
42 import org.onap.aaf.auth.layer.Result;
43 import org.onap.aaf.cadi.Access;
44 import org.onap.aaf.cadi.LocatorException;
45 import org.onap.aaf.cadi.PropAccess;
46 import org.onap.aaf.cadi.config.Config;
48 import junit.framework.Assert;
51 @RunWith(MockitoJUnitRunner.class)
52 public class JU_DirectAAFLocator {
67 public void setUp() throws Exception {
72 // public void testConstructorExcpetion() {
73 // Mockito.doReturn(access).when(env).access();
74 // Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
75 // Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
77 // DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao,"test","test");
78 // } catch (LocatorException e) {
79 //// System.out.println(e.getMessage());
80 // assertEquals("Invalid Version String: test", e.getMessage());
84 // NOTE: These mocks to not well represent the DirectAAFLocator Class.
86 public void testConstructorUriExcpetion() {
87 Assert.assertTrue(true);
90 // PropAccess access = Mockito.mock(PropAccess.class);
91 // Mockito.doReturn(access).when(env).access();
92 // Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
93 // Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
95 // DirectAAFLocator aafLocatorObj=new DirectAAFLocator(env, ldao," test","3.2");
96 // } catch (LocatorException e) {
97 //// System.out.println(e.getMessage());
98 // assertTrue(e.getMessage().contains("Illegal character in path at index"));
102 // public void testRefresh() {
104 // DirectAAFLocator aafLocatorObj=null;
105 // PropAccess access = Mockito.mock(PropAccess.class);
106 // Mockito.doReturn(access).when(env).access();
107 // Mockito.doReturn(trans).when(env).newTransNoAvg();
108 // Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
109 // Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
111 // aafLocatorObj = new DirectAAFLocator(env, ldao,"test","30.20.30.30");
112 // } catch (LocatorException e) {
113 // // TODO Auto-generated catch block
114 // e.printStackTrace();
116 // Result<List<Data>> retVal1 = new Result<List<Data>>(null,0,"",new String[0]);
118 // Data data= new Data();
123 // retVal1.value = new ArrayList<Data>();
124 // retVal1.value.add(data);
126 // Mockito.doReturn(retVal1).when(ldao).readByName(trans,"test");
127 // boolean retVal = aafLocatorObj.refresh();
128 //// System.out.println(retVal);
129 // assertTrue(retVal);
133 // public void testRefreshNOK() {
135 // DirectAAFLocator aafLocatorObj=null;
136 // PropAccess access = Mockito.mock(PropAccess.class);
137 // Mockito.doReturn(access).when(env).access();
138 // Mockito.doReturn(trans).when(env).newTransNoAvg();
139 // Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
140 // Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
142 // aafLocatorObj = new DirectAAFLocator(env, ldao,"test","30.20.30.30");
143 // } catch (LocatorException e) {
144 // // TODO Auto-generated catch block
145 // e.printStackTrace();
147 // Result<List<Data>> retVal1 = new Result<List<Data>>(null,1,"",new String[0]);
149 // Mockito.doReturn(retVal1).when(ldao).readByName(trans,"test");
150 // boolean retVal = aafLocatorObj.refresh();
151 //// System.out.println(retVal);
152 // assertFalse(retVal);