1 /*******************************************************************************
2 * ============LICENSE_START====================================================
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
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 ******************************************************************************/
22 package org.onap.aaf.auth.cmd.test.ns;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
27 import java.io.Writer;
28 import java.net.HttpURLConnection;
30 import java.net.URISyntaxException;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
35 import org.mockito.runners.MockitoJUnitRunner;
36 import org.onap.aaf.auth.cmd.AAFcli;
37 import org.onap.aaf.auth.cmd.ns.Describe;
38 import org.onap.aaf.auth.cmd.ns.NS;
39 import org.onap.aaf.auth.env.AuthzEnv;
40 import org.onap.aaf.cadi.CadiException;
41 import org.onap.aaf.cadi.Locator;
42 import org.onap.aaf.cadi.Locator.Item;
43 import org.onap.aaf.cadi.LocatorException;
44 import org.onap.aaf.cadi.PropAccess;
45 import org.onap.aaf.cadi.SecuritySetter;
46 import org.onap.aaf.cadi.http.HMangr;
47 import org.onap.aaf.misc.env.APIException;
49 @RunWith(MockitoJUnitRunner.class)
50 public class JU_Describe {
52 private static Describe desc;
61 public void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {
62 prop = new PropAccess();
63 aEnv = new AuthzEnv();
64 wtr = mock(Writer.class);
65 loc = mock(Locator.class);
66 SecuritySetter<HttpURLConnection> secSet = mock(SecuritySetter.class);
67 hman = new HMangr(aEnv, loc);
68 aafcli = new AAFcli(prop, aEnv, wtr, hman, null, secSet);
69 NS ns = new NS(aafcli);
70 desc = new Describe(ns);
74 public void testExec() throws APIException, LocatorException, CadiException, URISyntaxException {
75 Item value = mock(Item.class);
76 Locator.Item item = new Locator.Item() {
78 when(loc.best()).thenReturn(value);
79 URI uri = new URI("http://www.oracle.com/technetwork/java/index.html");
80 when(loc.get(value)).thenReturn(uri);
81 SecuritySetter<HttpURLConnection> secSet = mock(SecuritySetter.class);
82 // HRcli hcli = new HRcli(hman, uri, item, secSet);
83 // String[] strArr = {"add","upd","del","add","upd","del"};
84 // desc._exec(0, strArr);
89 public void testDetailedHelp() {
90 StringBuilder sb = new StringBuilder();
91 desc.detailedHelp(0, sb );