AT&T 2.0.19 Code drop, stage 3
[aaf/authz.git] / auth / auth-cmd / src / test / java / org / onap / aaf / auth / cmd / test / JU_BaseCmd.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
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
10  * * 
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * * 
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====================================================
19  * *
20  * *
21  ******************************************************************************/
22 package org.onap.aaf.auth.cmd.test;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.fail;
26
27 import java.io.IOException;
28 import java.security.GeneralSecurityException;
29 import java.util.Date;
30 import java.util.GregorianCalendar;
31
32 import javax.xml.datatype.DatatypeConfigurationException;
33 import javax.xml.datatype.DatatypeFactory;
34 import javax.xml.datatype.XMLGregorianCalendar;
35
36 import org.junit.BeforeClass;
37 import org.junit.Test;
38 import org.junit.runner.RunWith;
39 import org.mockito.runners.MockitoJUnitRunner;
40 import org.onap.aaf.auth.cmd.AAFcli;
41 import org.onap.aaf.auth.cmd.BaseCmd;
42 import org.onap.aaf.cadi.CadiException;
43 import org.onap.aaf.cadi.LocatorException;
44 import org.onap.aaf.cadi.client.Future;
45 import org.onap.aaf.misc.env.APIException;
46
47 import aaf.v2_0.History;
48
49 @RunWith(MockitoJUnitRunner.class)
50 public class JU_BaseCmd {
51
52         private static AAFcli cli;
53         private static BaseCmd bCmd;
54
55 //      @BeforeClass
56 //      public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException {
57 //              cli = JU_AAFCli.getAAfCli();
58 //              bCmd = new BaseCmd<>(cli, "testString");
59 //      }
60
61 //      @Test
62 //      public void exec() throws CadiException, APIException, LocatorException {
63 //              assertEquals(bCmd._exec(4, "add", "del", "reset", "extend"), 0);
64 //
65 //      }
66 //      
67 //      @Test
68 //      public void exec1() throws CadiException, APIException, LocatorException {
69 //              assertEquals(bCmd._exec(0, "add", "del", "reset", "extend"), 0);
70 //
71 //      }
72
73 //      @Test
74 //      public void error() throws CadiException, APIException, LocatorException {
75 //              boolean noError = true;
76 //              Future<String> future = new Future<String>() {
77 //
78 //                      @Override
79 //                      public boolean get(int timeout) throws CadiException {
80 //                              // TODO Auto-generated method stub
81 //                              return false;
82 //                      }
83 //
84 //                      @Override
85 //                      public int code() {
86 //                              // TODO Auto-generated method stub
87 //                              return 0;
88 //                      }
89 //
90 //                      @Override
91 //                      public String body() {
92 //                              // TODO Auto-generated method stub
93 //                              return "{%}";
94 //                      }
95 //
96 //                      @Override
97 //                      public String header(String tag) {
98 //                              // TODO Auto-generated method stub
99 //                              return null;
100 //                      }
101 //              };
102 //              try {
103 //                      //TODO: Gabe [JUnit] Not visible for junit
104 //                      bCmd.error(future);
105 //              } catch (Exception e) {
106 //                      noError = false;
107 //              }
108 //              assertEquals(noError, true);
109 //
110 //      }
111 //
112 //
113 //
114 //      @Test
115 //      public void activity() throws DatatypeConfigurationException {
116 //              boolean noError = true;
117 //              History history = new History();
118 //              History.Item item = new History.Item();
119 //              item.setTarget("target");
120 //              item.setUser("user");
121 //              item.setMemo("memo");
122 //
123 //              GregorianCalendar c = new GregorianCalendar();
124 //              c.setTime(new Date());
125 //              XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
126 //              item.setTimestamp(date);
127 //              history.getItem().add(item);
128 //              try {
129 //                      bCmd.activity(history, "history");
130 //              } catch (Exception e) {
131 //                      noError = false;
132 //              }
133 //              assertEquals(noError, true);
134 //
135 //      }
136 //
137 //      @Test
138 //      public void activity1() throws DatatypeConfigurationException {
139 //              boolean noError = true;
140 //              History history = new History();
141 //              History.Item item = new History.Item();
142 //              item.setTarget("target");
143 //              item.setUser("user");
144 //              item.setMemo("memo");
145 //
146 //              GregorianCalendar c = new GregorianCalendar();
147 //              c.setTime(new Date());
148 //              XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
149 //              item.setTimestamp(date);
150 //              history.getItem().add(item);
151 //              try {
152 //                      bCmd.activity(history, "1[]");
153 //              } catch (Exception e) {
154 //                      noError = false;
155 //              }
156 //              assertEquals(noError, true);
157 //
158 //      }
159 //      
160 //
161 //
162 //      @Test
163 //      public void error1() {
164 //              boolean noError = true;
165 //              Future<String> future = new Future<String>() {
166 //
167 //                      @Override
168 //                      public boolean get(int timeout) throws CadiException {
169 //                              // TODO Auto-generated method stub
170 //                              return false;
171 //                      }
172 //
173 //                      @Override
174 //                      public int code() {
175 //                              // TODO Auto-generated method stub
176 //                              return 0;
177 //                      }
178 //
179 //                      @Override
180 //                      public String body() {
181 //                              // TODO Auto-generated method stub
182 //                              return "{<html><code>1</code></html>";
183 //                      }
184 //
185 //                      @Override
186 //                      public String header(String tag) {
187 //                              // TODO Auto-generated method stub
188 //                              return null;
189 //                      }
190 //              };
191 //              try {
192 //                      bCmd.error(future);
193 //              } catch (Exception e) {
194 //                      noError = false;
195 //              }
196 //              assertEquals(noError, true);
197 //
198 //      }
199
200 //      @Test
201 //      public void error2() {
202 //              boolean noError = true;
203 //              Future<String> future = new Future<String>() {
204 //
205 //                      @Override
206 //                      public boolean get(int timeout) throws CadiException {
207 //                              // TODO Auto-generated method stub
208 //                              return false;
209 //                      }
210 //
211 //                      @Override
212 //                      public int code() {
213 //                              // TODO Auto-generated method stub
214 //                              return 0;
215 //                      }
216 //
217 //                      @Override
218 //                      public String body() {
219 //                              // TODO Auto-generated method stub
220 //                              return "other";
221 //                      }
222 //
223 //                      @Override
224 //                      public String header(String tag) {
225 //                              // TODO Auto-generated method stub
226 //                              return null;
227 //                      }
228 //              };
229 //              try {
230 //                      bCmd.error(future);
231 //              } catch (Exception e) {
232 //                      noError = false;
233 //              }
234 //              assertEquals(noError, true);
235 //
236 //      }
237         
238         @Test                                           //TODO: Temporary fix AAF-111
239         public void netYetTested() {
240                 fail("Tests not yet implemented");
241         }
242
243 }