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;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
26 import static org.junit.Assert.fail;
28 import java.io.IOException;
29 import java.security.GeneralSecurityException;
30 import java.util.Date;
31 import java.util.GregorianCalendar;
33 import javax.xml.datatype.DatatypeConfigurationException;
34 import javax.xml.datatype.DatatypeFactory;
35 import javax.xml.datatype.XMLGregorianCalendar;
37 import org.junit.BeforeClass;
38 import org.junit.Test;
39 import org.junit.runner.RunWith;
40 import org.mockito.runners.MockitoJUnitRunner;
41 import org.onap.aaf.auth.cmd.AAFcli;
42 import org.onap.aaf.auth.cmd.BaseCmd;
43 import org.onap.aaf.cadi.CadiException;
44 import org.onap.aaf.cadi.LocatorException;
45 import org.onap.aaf.cadi.client.Future;
46 import org.onap.aaf.misc.env.APIException;
48 import aaf.v2_0.History;
50 @RunWith(MockitoJUnitRunner.class)
51 public class JU_BaseCmd {
53 private static AAFcli cli;
54 private static BaseCmd bCmd;
57 public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException, CadiException {
58 cli = JU_AAFCli.getAAfCli();
59 bCmd = new BaseCmd<>(cli, "testString");
63 public void exec() throws CadiException, APIException, LocatorException {
64 assertEquals(bCmd._exec(4, "add", "del", "reset", "extend"), 0);
69 public void exec1() throws CadiException, APIException, LocatorException {
70 assertEquals(bCmd._exec(0, "add", "del", "reset", "extend"), 0);
75 public void activity() throws DatatypeConfigurationException {
76 boolean noError = true;
77 History history = new History();
78 History.Item item = new History.Item();
79 item.setTarget("target");
83 GregorianCalendar c = new GregorianCalendar();
84 c.setTime(new Date());
85 XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
86 item.setTimestamp(date);
87 history.getItem().add(item);
89 bCmd.activity(history, "history");
90 } catch (Exception e) {
93 assertEquals(noError, true);
98 public void activity1() throws DatatypeConfigurationException {
99 boolean noError = true;
100 History history = new History();
101 History.Item item = new History.Item();
102 item.setTarget("target");
103 item.setUser("user");
104 item.setMemo("memo");
106 GregorianCalendar c = new GregorianCalendar();
107 c.setTime(new Date());
108 XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
109 item.setTimestamp(date);
110 history.getItem().add(item);
112 bCmd.activity(history, "1[]");
113 } catch (Exception e) {
116 assertEquals(noError, true);