Update project structure to org.onap.aaf
[aaf/authz.git] / authz-cmd / src / test / java / org / onap / aaf / cmd / user / JU_Cred.java
1 /*******************************************************************************\r
2  * ============LICENSE_START====================================================\r
3  * * org.onap.aaf\r
4  * * ===========================================================================\r
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * * ===========================================================================\r
7  * * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * * you may not use this file except in compliance with the License.\r
9  * * You may obtain a copy of the License at\r
10  * * \r
11  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * * \r
13  *  * Unless required by applicable law or agreed to in writing, software\r
14  * * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * * See the License for the specific language governing permissions and\r
17  * * limitations under the License.\r
18  * * ============LICENSE_END====================================================\r
19  * *\r
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
21  * *\r
22  ******************************************************************************/\r
23 package org.onap.aaf.cmd.user;\r
24 \r
25 import static org.junit.Assert.assertEquals;\r
26 import static org.junit.Assert.assertNotNull;\r
27 import static org.mockito.Mockito.mock;\r
28 import static org.mockito.Mockito.when;\r
29 \r
30 import org.junit.BeforeClass;\r
31 import org.junit.Test;\r
32 import org.junit.runner.RunWith;\r
33 import org.mockito.runners.MockitoJUnitRunner;\r
34 import org.onap.aaf.cmd.user.Cred;\r
35 import org.onap.aaf.cmd.user.User;\r
36 \r
37 import org.onap.aaf.cadi.CadiException;\r
38 import org.onap.aaf.cadi.LocatorException;\r
39 import org.onap.aaf.inno.env.APIException;\r
40 \r
41 @RunWith(MockitoJUnitRunner.class)\r
42 public class JU_Cred {\r
43 \r
44         private static Cred testCred;\r
45         private static User testUser;\r
46 \r
47 \r
48         @BeforeClass\r
49         public static void setUp() {\r
50                 testCred = mock(Cred.class);\r
51                 testUser = mock(User.class);\r
52                 try {\r
53                         when(testCred._exec(4, "String1","String2","String3","String4")).thenReturn(10);\r
54                 } catch (CadiException e) {\r
55                         // TODO Auto-generated catch block\r
56                         e.printStackTrace();\r
57                 } catch (APIException e) {\r
58                         // TODO Auto-generated catch block\r
59                         e.printStackTrace();\r
60                 } catch (LocatorException e) {\r
61                         // TODO Auto-generated catch block\r
62                         e.printStackTrace();\r
63                 }\r
64         }\r
65 \r
66         @Test\r
67         public void exec() throws CadiException, APIException, LocatorException {\r
68                 assertEquals(testCred._exec(4, "String1","String2","String3","String4"), 10);\r
69         }\r
70 \r
71 \r
72         @Test\r
73         public void exec_add() {                \r
74                 try {\r
75                         assertNotNull(testCred._exec(0, "zeroed","add","del","reset","extend"));\r
76                 } catch (CadiException | APIException | LocatorException e) {\r
77                         // TODO Auto-generated catch block\r
78                         e.printStackTrace();\r
79                 }\r
80 \r
81         }\r
82 \r
83         @Test\r
84         public void exec_del() {                \r
85                 try {\r
86                         assertNotNull(testCred._exec(1, "zeroed","add","del","reset","extend"));\r
87                 } catch (CadiException | APIException | LocatorException e) {\r
88                         // TODO Auto-generated catch block\r
89                         e.printStackTrace();\r
90                 }\r
91 \r
92         }\r
93 \r
94         @Test\r
95         public void exec_reset() {              \r
96                 try {\r
97                         assertNotNull(testCred._exec(2, "zeroed","add","del","reset","extend"));\r
98                 } catch (CadiException | APIException | LocatorException e) {\r
99                         // TODO Auto-generated catch block\r
100                         e.printStackTrace();\r
101                 }\r
102 \r
103         }\r
104 \r
105         @Test\r
106         public void exec_extend() {             \r
107                 try {\r
108                         assertNotNull(testCred._exec(3, "zeroed","add","del","reset","extend"));\r
109                 } catch (CadiException | APIException | LocatorException e) {\r
110                         // TODO Auto-generated catch block\r
111                         e.printStackTrace();\r
112                 }\r
113 \r
114         }\r
115 \r
116 }\r