1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\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
11 * * http://www.apache.org/licenses/LICENSE-2.0
\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
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.cmd;
\r
25 import static org.junit.Assert.assertEquals;
\r
27 import java.io.IOException;
\r
28 import java.security.GeneralSecurityException;
\r
29 import java.util.Date;
\r
30 import java.util.GregorianCalendar;
\r
32 import javax.xml.datatype.DatatypeConfigurationException;
\r
33 import javax.xml.datatype.DatatypeFactory;
\r
34 import javax.xml.datatype.XMLGregorianCalendar;
\r
36 import org.junit.BeforeClass;
\r
37 import org.junit.Test;
\r
38 import org.junit.runner.RunWith;
\r
39 import org.mockito.runners.MockitoJUnitRunner;
\r
40 import org.onap.aaf.cadi.CadiException;
\r
41 import org.onap.aaf.cadi.LocatorException;
\r
42 import org.onap.aaf.cadi.client.Future;
\r
43 import org.onap.aaf.inno.env.APIException;
\r
45 import aaf.v2_0.History;
\r
47 @RunWith(MockitoJUnitRunner.class)
\r
48 public class JU_BaseCmd {
\r
50 private static AAFcli cli;
\r
51 private static BaseCmd bCmd;
\r
54 public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException {
\r
55 cli = JU_AAFCli.getAAfCli();
\r
56 bCmd = new BaseCmd<>(cli, "testString");
\r
60 public void exec() throws CadiException, APIException, LocatorException {
\r
61 assertEquals(bCmd._exec(4, "add", "del", "reset", "extend"), 0);
\r
66 public void exec1() throws CadiException, APIException, LocatorException {
\r
67 assertEquals(bCmd._exec(0, "add", "del", "reset", "extend"), 0);
\r
72 public void error() throws CadiException, APIException, LocatorException {
\r
73 boolean noError = true;
\r
74 Future<String> future = new Future<String>() {
\r
77 public boolean get(int timeout) throws CadiException {
\r
78 // TODO Auto-generated method stub
\r
84 // TODO Auto-generated method stub
\r
89 public String body() {
\r
90 // TODO Auto-generated method stub
\r
95 public String header(String tag) {
\r
96 // TODO Auto-generated method stub
\r
101 bCmd.error(future);
\r
102 } catch (Exception e) {
\r
105 assertEquals(noError, true);
\r
112 public void activity() throws DatatypeConfigurationException {
\r
113 boolean noError = true;
\r
114 History history = new History();
\r
115 History.Item item = new History.Item();
\r
116 item.setTarget("target");
\r
117 item.setUser("user");
\r
118 item.setMemo("memo");
\r
120 GregorianCalendar c = new GregorianCalendar();
\r
121 c.setTime(new Date());
\r
122 XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
\r
123 item.setTimestamp(date);
\r
124 history.getItem().add(item);
\r
126 bCmd.activity(history, "history");
\r
127 } catch (Exception e) {
\r
130 assertEquals(noError, true);
\r
135 public void activity1() throws DatatypeConfigurationException {
\r
136 boolean noError = true;
\r
137 History history = new History();
\r
138 History.Item item = new History.Item();
\r
139 item.setTarget("target");
\r
140 item.setUser("user");
\r
141 item.setMemo("memo");
\r
143 GregorianCalendar c = new GregorianCalendar();
\r
144 c.setTime(new Date());
\r
145 XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
\r
146 item.setTimestamp(date);
\r
147 history.getItem().add(item);
\r
149 bCmd.activity(history, "1[]");
\r
150 } catch (Exception e) {
\r
153 assertEquals(noError, true);
\r
160 public void error1() {
\r
161 boolean noError = true;
\r
162 Future<String> future = new Future<String>() {
\r
165 public boolean get(int timeout) throws CadiException {
\r
166 // TODO Auto-generated method stub
\r
171 public int code() {
\r
172 // TODO Auto-generated method stub
\r
177 public String body() {
\r
178 // TODO Auto-generated method stub
\r
179 return "{<html><code>1</code></html>";
\r
183 public String header(String tag) {
\r
184 // TODO Auto-generated method stub
\r
189 bCmd.error(future);
\r
190 } catch (Exception e) {
\r
193 assertEquals(noError, true);
\r
198 public void error2() {
\r
199 boolean noError = true;
\r
200 Future<String> future = new Future<String>() {
\r
203 public boolean get(int timeout) throws CadiException {
\r
204 // TODO Auto-generated method stub
\r
209 public int code() {
\r
210 // TODO Auto-generated method stub
\r
215 public String body() {
\r
216 // TODO Auto-generated method stub
\r
221 public String header(String tag) {
\r
222 // TODO Auto-generated method stub
\r
227 bCmd.error(future);
\r
228 } catch (Exception e) {
\r
231 assertEquals(noError, true);
\r