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 ******************************************************************************/
23 package org.onap.aaf.auth.cmd.test;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assert.fail;
29 import java.io.IOException;
30 import java.security.GeneralSecurityException;
31 import java.util.Date;
32 import java.util.GregorianCalendar;
34 import javax.xml.datatype.DatatypeConfigurationException;
35 import javax.xml.datatype.DatatypeFactory;
36 import javax.xml.datatype.XMLGregorianCalendar;
38 import org.junit.BeforeClass;
39 import org.junit.Test;
40 import org.junit.runner.RunWith;
41 import org.mockito.runners.MockitoJUnitRunner;
42 import org.onap.aaf.auth.cmd.AAFcli;
43 import org.onap.aaf.auth.cmd.BaseCmd;
44 import org.onap.aaf.cadi.CadiException;
45 import org.onap.aaf.cadi.LocatorException;
46 import org.onap.aaf.cadi.client.Future;
47 import org.onap.aaf.misc.env.APIException;
49 import aaf.v2_0.History;
51 @RunWith(MockitoJUnitRunner.class)
52 public class JU_BaseCmd {
54 private static AAFcli cli;
55 private static BaseCmd bCmd;
58 public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException, CadiException {
59 cli = JU_AAFCli.getAAfCli();
60 bCmd = new BaseCmd<>(cli, "testString");
64 public void exec() throws CadiException, APIException, LocatorException {
65 assertEquals(bCmd._exec(4, "add", "del", "reset", "extend"), 0);
70 public void exec1() throws CadiException, APIException, LocatorException {
71 assertEquals(bCmd._exec(0, "add", "del", "reset", "extend"), 0);
76 public void activity() throws DatatypeConfigurationException {
77 boolean noError = true;
78 History history = new History();
79 History.Item item = new History.Item();
80 item.setTarget("target");
84 GregorianCalendar c = new GregorianCalendar();
85 c.setTime(new Date());
86 XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
87 item.setTimestamp(date);
88 history.getItem().add(item);
90 bCmd.activity(history, "history");
91 } catch (Exception e) {
94 assertEquals(noError, true);
99 public void activity1() throws DatatypeConfigurationException {
100 boolean noError = true;
101 History history = new History();
102 History.Item item = new History.Item();
103 item.setTarget("target");
104 item.setUser("user");
105 item.setMemo("memo");
107 GregorianCalendar c = new GregorianCalendar();
108 c.setTime(new Date());
109 XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
110 item.setTimestamp(date);
111 history.getItem().add(item);
113 bCmd.activity(history, "1[]");
114 } catch (Exception e) {
117 assertEquals(noError, true);