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.user;
24 import org.junit.Assert;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.when;
30 import java.io.FileNotFoundException;
31 import java.io.PrintWriter;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.Mockito;
37 import org.mockito.runners.MockitoJUnitRunner;
38 import org.onap.aaf.auth.cmd.AAFcli;
39 import org.onap.aaf.auth.cmd.Cmd;
40 import org.onap.aaf.auth.cmd.user.Cred;
41 import org.onap.aaf.auth.cmd.user.User;
42 import org.onap.aaf.auth.env.AuthzEnv;
43 import org.onap.aaf.cadi.CadiException;
44 import org.onap.aaf.cadi.LocatorException;
45 import org.onap.aaf.misc.env.APIException;
47 @RunWith(MockitoJUnitRunner.class)
48 public class JU_Cred {
50 private static Cred testCred;
51 private static User testUser;
52 private static AuthzEnv env;
56 public static void setUp() throws FileNotFoundException, APIException {
58 testCred = mock(Cred.class);
59 testUser = mock(User.class);
60 env = mock(AuthzEnv.class);
61 Mockito.when(env.getProperty(Cmd.STARTDATE,null)).thenReturn(null);
62 Mockito.when(env.getProperty(Cmd.ENDDATE,null)).thenReturn(null);
67 public void exec() throws CadiException, APIException, LocatorException, FileNotFoundException {
68 boolean isNullpointer=false;
69 AAFcli aaFcli= new AAFcli(env, new PrintWriter("temp"), null, null, null);
70 User user= new User(aaFcli);
71 Cred testCred= new Cred(user);
73 testCred._exec(0, "add", "del", "reset", "extend");
74 } catch (Exception e) {
77 assertEquals(isNullpointer, true);
82 public void exec_add() {
84 assertNotNull(testCred._exec(0, "zeroed","add","del","reset","extend"));
85 } catch (CadiException | APIException | LocatorException e) {
86 // TODO Auto-generated catch block
93 public void exec_del() {
95 assertNotNull(testCred._exec(1, "zeroed","add","del","reset","extend"));
96 } catch (CadiException | APIException | LocatorException e) {
97 // TODO Auto-generated catch block
104 public void exec_reset() {
106 assertNotNull(testCred._exec(2, "zeroed","add","del","reset","extend"));
107 } catch (CadiException | APIException | LocatorException e) {
108 // TODO Auto-generated catch block
115 public void exec_extend() {
117 assertNotNull(testCred._exec(3, "zeroed","add","del","reset","extend"));
118 } catch (CadiException | APIException | LocatorException e) {
119 // TODO Auto-generated catch block