Mass removal of all Tabs (Style Warnings)
[aaf/authz.git] / auth / auth-cmd / src / test / java / org / onap / aaf / auth / cmd / test / ns / JU_Create.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 package org.onap.aaf.auth.cmd.test.ns;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.when;
27
28 import java.io.Writer;
29 import java.net.HttpURLConnection;
30 import java.net.URI;
31 import java.net.URISyntaxException;
32
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.runners.MockitoJUnitRunner;
37 import org.onap.aaf.auth.cmd.AAFcli;
38 import org.onap.aaf.auth.cmd.ns.Create;
39 import org.onap.aaf.auth.cmd.ns.NS;
40 import org.onap.aaf.auth.env.AuthzEnv;
41 import org.onap.aaf.cadi.CadiException;
42 import org.onap.aaf.cadi.Locator;
43 import org.onap.aaf.cadi.Locator.Item;
44 import org.onap.aaf.cadi.LocatorException;
45 import org.onap.aaf.cadi.PropAccess;
46 import org.onap.aaf.cadi.SecuritySetter;
47 import org.onap.aaf.cadi.http.HMangr;
48 import org.onap.aaf.cadi.http.HRcli;
49 import org.onap.aaf.misc.env.APIException;
50
51 @RunWith(MockitoJUnitRunner.class)
52 public class JU_Create {
53
54     private static Create create;//might need to replace import with org.onap.aaf.auth.cmd.perm
55     PropAccess prop;
56     AuthzEnv aEnv;
57     Writer wtr;
58     Locator<URI> loc;
59     HMangr hman;    
60     AAFcli aafcli;
61     
62     @Before
63     public void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {
64         prop = new PropAccess();
65         aEnv = new AuthzEnv();
66         wtr = mock(Writer.class);
67         loc = mock(Locator.class);
68         SecuritySetter<HttpURLConnection> secSet = mock(SecuritySetter.class);
69         hman = new HMangr(aEnv, loc);    
70         aafcli = new AAFcli(prop, aEnv, wtr, hman, null, secSet);
71         NS ns = new NS(aafcli);
72         create = new Create(ns);
73     }
74     
75     
76
77     @Test
78     public void testExec() throws APIException, LocatorException, CadiException, URISyntaxException {
79         Item value = mock(Item.class);
80         Locator.Item item = new Locator.Item() {
81         };
82         when(loc.best()).thenReturn(value);
83         URI uri = new URI("http://www.oracle.com/technetwork/java/index.html");
84         when(loc.get(value)).thenReturn(uri);
85         SecuritySetter<HttpURLConnection> secSet = mock(SecuritySetter.class);
86         HRcli hcli = new HRcli(hman, uri, item, secSet);
87         String[] strArr = {"add","upd","del","add","upd","del"};
88         create._exec(0, strArr);
89         
90     }
91
92     @Test
93     public void detailedHelp() {
94         boolean hasNoError = true;
95         try {
96             create.detailedHelp(1, new StringBuilder("test"));
97         } catch (Exception e) {
98             hasNoError = false;
99         }
100         assertEquals(hasNoError, true);
101     }
102 }