2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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====================================================
22 package org.onap.aaf.auth.batch.approvalsets;
24 import static org.junit.Assert.assertTrue;
25 import static org.mockito.MockitoAnnotations.initMocks;
27 import java.io.IOException;
28 import java.text.ParseException;
29 import java.util.ArrayList;
30 import java.util.Calendar;
31 import java.util.Date;
32 import java.util.List;
34 import org.junit.Before;
35 import org.junit.Ignore;
36 import org.junit.Test;
37 import org.mockito.Mock;
38 import org.mockito.Mockito;
39 import org.onap.aaf.auth.env.AuthzTrans;
40 import org.onap.aaf.cadi.PropAccess;
41 import org.onap.aaf.cadi.util.CSV.Writer;
42 import org.onap.aaf.misc.env.APIException;
44 import com.datastax.driver.core.Cluster;
46 public class JU_Pending {
59 public void setUp() throws APIException, IOException {
64 public void testRow() {
65 Writer approveCW = Mockito.mock(Writer.class);
66 Mockito.doNothing().when(approveCW).row(Mockito.anyString(),
67 Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
69 Pending pendingObj = new Pending(new Date());
70 pendingObj.row(approveCW, "key");
72 pendingObj = new Pending(date);
76 public void testInc() {
77 List<String> inpList = new ArrayList<>();
84 Pending pendingObj = new Pending(inpList);
86 assertTrue(11 == pendingObj.qty());
88 Pending tempPending = new Pending(inpList);
89 pendingObj.inc(tempPending);
90 assertTrue(21 == pendingObj.qty());
92 tempPending.earliest = new Date();
93 pendingObj.earliest = new Date();
94 pendingObj.inc(tempPending);
96 Calendar calendar = Calendar.getInstance();
97 calendar.add(Calendar.DAY_OF_YEAR, 1);
98 pendingObj.earliest = calendar.getTime();
99 pendingObj.inc(tempPending);
100 } catch (ParseException e) {
101 // TODO Auto-generated catch block
108 public void testEarliest() {
109 List<String> inpList = new ArrayList<>();
114 inpList.add("2019-01-01");
118 Pending pendingObj = new Pending(inpList);
119 pendingObj.earliest(null);
121 pendingObj.earliest = null;
122 pendingObj.earliest(new Date());
124 Calendar calendar = Calendar.getInstance();
125 calendar.add(Calendar.DAY_OF_YEAR, 1);
126 pendingObj.earliest(calendar.getTime());
127 assertTrue(119 == pendingObj.earliest().getYear());
128 assertTrue(pendingObj.newApprovals());
129 } catch (ParseException e) {
130 // TODO Auto-generated catch block