Remove Tabs, per Jococo
[aaf/authz.git] / auth / auth-cass / src / test / java / org / onap / aaf / auth / direct / test / JU_DirectLocatorCreator.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
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
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 package org.onap.aaf.auth.direct.test;
22
23 import static org.mockito.MockitoAnnotations.initMocks;
24
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.mockito.runners.MockitoJUnitRunner;
31 import org.onap.aaf.auth.dao.cass.LocateDAO;
32 import org.onap.aaf.auth.direct.DirectLocatorCreator;
33 import org.onap.aaf.auth.env.AuthzEnv;
34 import org.onap.aaf.cadi.LocatorException;
35 import org.onap.aaf.cadi.PropAccess;
36 import org.onap.aaf.cadi.config.Config;
37
38 @RunWith(MockitoJUnitRunner.class) 
39 public class JU_DirectLocatorCreator {
40
41     @Mock
42     AuthzEnv env;
43     
44     @Mock
45     LocateDAO locateDAO;
46     
47     @Mock
48     PropAccess access;
49     
50     @Before
51     public void setUp() throws Exception {
52         initMocks(this);
53     }
54     
55     @Test
56     public void testCreate() {
57         Mockito.doReturn(access).when(env).access();
58         Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
59         Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
60         Mockito.doReturn("").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
61         Mockito.doReturn("").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER_NS,"");
62         Mockito.doReturn("http://aafurl.com").when(access).getProperty(Config.AAF_URL,null);
63         DirectLocatorCreator directLocObj = new DirectLocatorCreator(env, locateDAO);
64         try {
65             directLocObj.create("test", "30.20.30.20");
66         } catch (LocatorException e) {
67             // TODO Auto-generated catch block
68             e.printStackTrace();
69         }
70         directLocObj.setSelf("30.20.30.10", 8080);
71         try {
72             directLocObj.create("test", "30.20.30.20");
73         } catch (LocatorException e) {
74             // TODO Auto-generated catch block
75             e.printStackTrace();
76         }
77     }
78
79     @Test
80     public void testSetSelf() {
81         Mockito.doReturn(access).when(env).access();
82         Mockito.doReturn("20").when(access).getProperty(Config.CADI_LATITUDE,null);
83         Mockito.doReturn("20").when(access).getProperty(Config.CADI_LONGITUDE,null);
84         Mockito.doReturn("20").when(access).getProperty(Config.AAF_LOCATOR_CONTAINER,"");
85         Mockito.doReturn("http://aafurl.com").when(access).getProperty(Config.AAF_URL,null);
86         DirectLocatorCreator directLocObj = new DirectLocatorCreator(env, locateDAO);
87         directLocObj.setSelf("30.20.30.10", 8080);
88     }
89 }