X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-cmd%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fcmd%2Ftest%2FJU_Cmd.java;h=b31f104889eb2c84a835651327bb25582982454b;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=e87df80bc7fd3108f88635e0a7406a2e120d4d06;hpb=ebdf1d62d6bc4bb87860a3ff5491bde6d96f8974;p=aaf%2Fauthz.git diff --git a/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/JU_Cmd.java b/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/JU_Cmd.java index e87df80b..b31f1048 100644 --- a/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/JU_Cmd.java +++ b/auth/auth-cmd/src/test/java/org/onap/aaf/auth/cmd/test/JU_Cmd.java @@ -7,9 +7,9 @@ * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at - * * + * * * * http://www.apache.org/licenses/LICENSE-2.0 - * * + * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,6 +19,7 @@ * * * * ******************************************************************************/ + package org.onap.aaf.auth.cmd.test; import static org.junit.Assert.*; @@ -28,6 +29,7 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; +import static org.mockito.Mockito.*; import org.onap.aaf.auth.cmd.AAFcli; import org.onap.aaf.auth.cmd.Cmd; import org.onap.aaf.auth.cmd.Param; @@ -49,8 +51,6 @@ import org.onap.aaf.misc.env.impl.BasicEnv; import aaf.v2_0.History; import aaf.v2_0.History.Item; -import static org.mockito.Mockito.*; - import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -63,124 +63,130 @@ import org.junit.Test; public class JU_Cmd { - CmdStub cmd; - CmdStub cmd1; - CmdStub cmd2; - AAFcli cli; - - private class CmdStub extends Cmd { - - - public CmdStub(AAFcli aafcli, String name, Param[] params) { - super(aafcli, name, params); - // TODO Auto-generated constructor stub - } - - public CmdStub(Cmd parent, String name, Param[] params) { - super(parent, name, params); - // TODO Auto-generated constructor stub - } - - @Override - protected int _exec(int idx, String... args) throws CadiException, APIException, LocatorException { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void error(Future future) { - super.error(future); - } - - } - - @Before - public void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException { - cli = JU_AAFCli.getAAfCli(); - Param[] param = new Param[] {new Param("name",true)}; - - cmd = new CmdStub(cli,"test", param); - cmd1 = new CmdStub(cmd,"test", param); - cmd2 = new CmdStub(cmd,"test", param); - } - - @Test - public void testReportColHead() { - String[] args = new String[] {new String("test")}; - cmd.reportColHead("format", args); - } - - @Test - public void testBuilder() { - StringBuilder detail = new StringBuilder(); - StringBuilder sb = new StringBuilder("test 123"); - - cmd.build(sb, detail); - detail.append("test"); - cmd.build(sb, detail); - } - - @Test - public void testApi() throws APIException, CadiException { - StringBuilder sb = new StringBuilder("test 123"); - Define def = new Define(); - PropAccess prop = new PropAccess(); - def.set(prop); - Mgmt mgmt = new Mgmt(cli); - Cache cache = new Cache(mgmt); - Clear clr = new Clear(cache); - clr.detailedHelp(0, sb); - } - - @Test - public void testToString() { - cmd.toString(); - } - - @Test - public void testFullID() { - cmd.fullID("test"); - cmd.fullID("t@st"); - cmd.fullID(null); - } - - @Test - public void testError() { - Future future = mock(Future.class); - cmd.error(future); - when(future.code()).thenReturn(401); - cmd.error(future); - when(future.code()).thenReturn(403); - cmd.error(future); - when(future.code()).thenReturn(404); - cmd.error(future); - when(future.body()).thenReturn("NotNull"); - cmd.error(future); - when(future.body()).thenReturn("{NotNull"); - cmd.error(future); - when(future.body()).thenReturn("NotNull"); - cmd.error(future); - } - - @Test - public void testActivity() { - History hist = new History(); - cmd.activity(hist, "test"); - cmd.activity(hist, "te[st"); - } - - @Test - public void testWhichOption() throws CadiException { - String[] strArr = {"a", "b", "c"}; - cmd.whichOption(strArr, "b"); - } - - @Test - public void testOneOf() throws APIException, CadiException, LocatorException { - Retryable retryable = mock(Retryable.class); - //cmd.oneOf(retryable, "host"); //TODO: AAF-111 need input for hMan - } - - + CmdStub cmd; + CmdStub cmd1; + CmdStub cmd2; + AAFcli cli; + + private class CmdStub extends Cmd { + + + public CmdStub(AAFcli aafcli, String name, Param[] params) { + super(aafcli, name, params); + // TODO Auto-generated constructor stub + } + + public CmdStub(Cmd parent, String name, Param[] params) { + super(parent, name, params); + // TODO Auto-generated constructor stub + } + + @Override + protected int _exec(int idx, String... args) throws CadiException, APIException, LocatorException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void error(Future future) { + super.error(future); + } + + } + + @Before + public void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException, CadiException { + cli = JU_AAFCli.getAAfCli(); + Param[] param = new Param[] {new Param("name",true)}; + + cmd = new CmdStub(cli,"test", param); + cmd1 = new CmdStub(cmd,"test", param); + cmd2 = new CmdStub(cmd,"test", param); + } + + @Test + public void testReportColHead() { + String[] args = new String[] {new String("test")}; + cmd.reportColHead("format", args); + } + + @Test + public void testBuilder() { + StringBuilder detail = new StringBuilder(); + StringBuilder sb = new StringBuilder("test 123"); + + cmd.build(sb, detail); + detail.append("test"); + cmd.build(sb, detail); + } + + @Test + public void testApi() throws APIException, CadiException { + StringBuilder sb = new StringBuilder("test 123"); + Define def = new Define(); + PropAccess prop = new PropAccess(); + def.set(prop); + Mgmt mgmt = new Mgmt(cli); + Cache cache = new Cache(mgmt); + Clear clr = new Clear(cache); + clr.detailedHelp(0, sb); + } + + @Test + public void testToString() { + cmd.toString(); + } + + @Test + public void testFullID() { + cmd.fullID("test"); + cmd.fullID("t@st"); + cmd.fullID(null); + } + + @Test + public void testError() { + Future future = mock(Future.class); + cmd.error(future); + when(future.code()).thenReturn(401); + cmd.error(future); + when(future.code()).thenReturn(403); + cmd.error(future); + when(future.code()).thenReturn(404); + cmd.error(future); + when(future.body()).thenReturn("NotNull"); + cmd.error(future); + when(future.body()).thenReturn("{NotNull"); + cmd.error(future); + when(future.body()).thenReturn("NotNull"); + cmd.error(future); + } + + @Test + public void testActivity() { + History hist = new History(); + cmd.activity(hist, "test"); + cmd.activity(hist, "te[st"); + } + + @Test + public void testWhichOption() throws CadiException { + String[] strArr = {"a", "b", "c"}; + cmd.whichOption(strArr, "b"); + } + + @Test + public void testOneOf() throws APIException, CadiException, LocatorException { + Retryable retryable = mock(Retryable.class); + //cmd.oneOf(retryable, "host"); //TODO: AAF-111 need input for hMan + } + + @Test + public void testExec() throws CadiException, APIException, LocatorException { + String[] strArr = {"a", "b", "c"}; + cmd.exec(1, strArr); + } + + }