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.Test;
36 import org.mockito.Mock;
37 import org.mockito.Mockito;
38 import org.onap.aaf.auth.env.AuthzTrans;
39 import org.onap.aaf.cadi.PropAccess;
40 import org.onap.aaf.cadi.util.CSV.Writer;
41 import org.onap.aaf.misc.env.APIException;
43 import com.datastax.driver.core.Cluster;
45 public class JU_Pending {
58 public void setUp() throws APIException, IOException {
63 public void testRow() {
64 Writer approveCW = Mockito.mock(Writer.class);
65 Mockito.doNothing().when(approveCW).row(Mockito.anyString(),
66 Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
68 Pending pendingObj = new Pending(new Date());
69 pendingObj.row(approveCW, "key");
71 pendingObj = new Pending(date);
75 public void testInc() {
76 List<String> inpList = new ArrayList<>();
83 Pending pendingObj = new Pending(inpList);
85 assertTrue(11 == pendingObj.qty());
87 Pending tempPending = new Pending(inpList);
88 pendingObj.inc(tempPending);
89 assertTrue(21 == pendingObj.qty());
91 tempPending.earliest = new Date();
92 pendingObj.earliest = new Date();
93 pendingObj.inc(tempPending);
95 Calendar calendar = Calendar.getInstance();
96 calendar.add(Calendar.DAY_OF_YEAR, 1);
97 pendingObj.earliest = calendar.getTime();
98 pendingObj.inc(tempPending);
99 } catch (ParseException e) {
100 // TODO Auto-generated catch block
106 public void testEarliest() {
107 List<String> inpList = new ArrayList<>();
112 inpList.add("2019-01-01");
116 Pending pendingObj = new Pending(inpList);
117 pendingObj.earliest(null);
119 pendingObj.earliest = null;
120 pendingObj.earliest(new Date());
122 Calendar calendar = Calendar.getInstance();
123 calendar.add(Calendar.DAY_OF_YEAR, 1);
124 pendingObj.earliest(calendar.getTime());
125 assertTrue(119 == pendingObj.earliest().getYear());
126 assertTrue(pendingObj.newApprovals());
127 } catch (ParseException e) {
128 // TODO Auto-generated catch block