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