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 static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.when;
29 import java.io.FileNotFoundException;
30 import java.io.PrintWriter;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
35 import org.mockito.Mockito;
36 import org.mockito.runners.MockitoJUnitRunner;
37 import org.onap.aaf.auth.cmd.AAFcli;
38 import org.onap.aaf.auth.cmd.Cmd;
39 import org.onap.aaf.auth.cmd.user.Cred;
40 import org.onap.aaf.auth.cmd.user.User;
41 import org.onap.aaf.auth.env.AuthzEnv;
42 import org.onap.aaf.cadi.CadiException;
43 import org.onap.aaf.cadi.LocatorException;
44 import org.onap.aaf.misc.env.APIException;
46 @RunWith(MockitoJUnitRunner.class)
47 public class JU_Cred {
49 private static Cred testCred;
50 private static User testUser;
51 private static AuthzEnv env;
55 public static void setUp() throws FileNotFoundException, APIException {
57 testCred = mock(Cred.class);
58 testUser = mock(User.class);
59 env = mock(AuthzEnv.class);
60 Mockito.when(env.getProperty(Cmd.STARTDATE,null)).thenReturn(null);
61 Mockito.when(env.getProperty(Cmd.ENDDATE,null)).thenReturn(null);
66 public void exec() throws CadiException, APIException, LocatorException, FileNotFoundException {
67 boolean isNullpointer=false;
68 AAFcli aaFcli= new AAFcli(env, new PrintWriter("temp"), null, null, null);
69 User user= new User(aaFcli);
70 Cred testCred= new Cred(user);
72 testCred._exec(0, "add", "del", "reset", "extend");
73 } catch (Exception e) {
76 assertEquals(isNullpointer, true);
81 public void exec_add() {
83 assertNotNull(testCred._exec(0, "zeroed","add","del","reset","extend"));
84 } catch (CadiException | APIException | LocatorException e) {
85 // TODO Auto-generated catch block
92 public void exec_del() {
94 assertNotNull(testCred._exec(1, "zeroed","add","del","reset","extend"));
95 } catch (CadiException | APIException | LocatorException e) {
96 // TODO Auto-generated catch block
103 public void exec_reset() {
105 assertNotNull(testCred._exec(2, "zeroed","add","del","reset","extend"));
106 } catch (CadiException | APIException | LocatorException e) {
107 // TODO Auto-generated catch block
114 public void exec_extend() {
116 assertNotNull(testCred._exec(3, "zeroed","add","del","reset","extend"));
117 } catch (CadiException | APIException | LocatorException e) {
118 // TODO Auto-generated catch block