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 ******************************************************************************/
23 package org.onap.aaf.auth.cmd.test.ns;
25 import static org.junit.Assert.assertEquals;
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.when;
29 import java.io.Writer;
30 import java.net.HttpURLConnection;
32 import java.net.URISyntaxException;
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.junit.runner.RunWith;
37 import org.mockito.runners.MockitoJUnitRunner;
38 import org.onap.aaf.auth.cmd.AAFcli;
39 import org.onap.aaf.auth.cmd.ns.Create;
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.cadi.http.HRcli;
50 import org.onap.aaf.misc.env.APIException;
52 @RunWith(MockitoJUnitRunner.class)
53 public class JU_Create {
55 private static Create create;//might need to replace import with org.onap.aaf.auth.cmd.perm
64 public void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {
65 prop = new PropAccess();
66 aEnv = new AuthzEnv();
67 wtr = mock(Writer.class);
68 loc = mock(Locator.class);
69 SecuritySetter<HttpURLConnection> secSet = mock(SecuritySetter.class);
70 hman = new HMangr(aEnv, loc);
71 aafcli = new AAFcli(prop, aEnv, wtr, hman, null, secSet);
72 NS ns = new NS(aafcli);
73 create = new Create(ns);
79 public void testExec() throws APIException, LocatorException, CadiException, URISyntaxException {
80 Item value = mock(Item.class);
81 Locator.Item item = new Locator.Item() {
83 when(loc.best()).thenReturn(value);
84 URI uri = new URI("http://www.oracle.com/technetwork/java/index.html");
85 when(loc.get(value)).thenReturn(uri);
86 SecuritySetter<HttpURLConnection> secSet = mock(SecuritySetter.class);
87 HRcli hcli = new HRcli(hman, uri, item, secSet);
88 String[] strArr = {"add","upd","del","add","upd","del"};
89 create._exec(0, strArr);
94 public void detailedHelp() {
95 boolean hasNoError = true;
97 create.detailedHelp(1, new StringBuilder("test"));
98 } catch (Exception e) {
101 assertEquals(hasNoError, true);