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.role;
24 import static org.junit.Assert.assertEquals;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.when;
28 import java.io.Writer;
29 import java.net.HttpURLConnection;
31 import java.net.URISyntaxException;
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.role.Describe;
39 import org.onap.aaf.auth.cmd.role.Role;
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.misc.env.APIException;
50 @RunWith(MockitoJUnitRunner.class)
51 public class JU_Describe {
53 private static Describe desc;
62 public void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {
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 Role role = new Role(aafcli);
71 desc = new Describe(role);
75 public void testExec() throws APIException, LocatorException, CadiException, URISyntaxException {
76 Item value = mock(Item.class);
77 Locator.Item item = new Locator.Item() {
79 when(loc.best()).thenReturn(value);
80 URI uri = new URI("http://www.oracle.com/technetwork/java/index.html");
81 when(loc.get(value)).thenReturn(uri);
82 SecuritySetter<HttpURLConnection> secSet = mock(SecuritySetter.class);
83 // HRcli hcli = new HRcli(hman, uri, item, secSet);
84 // String[] strArr = {"add","upd","del","add","upd","del"};
85 // desc._exec(0, strArr);
90 public void detailedHelp() {
91 boolean hasNoError = true;
93 desc.detailedHelp(1, new StringBuilder("test"));
94 } catch (Exception e) {
97 assertEquals(hasNoError, true);