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.helpers.test;
24 import static org.junit.Assert.assertEquals;
25 import static org.mockito.Matchers.any;
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.when;
29 import java.nio.ByteBuffer;
30 import java.util.ArrayList;
31 import java.util.Date;
32 import java.util.UUID;
34 import org.junit.Assert;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.onap.aaf.auth.batch.helpers.Creator;
38 import org.onap.aaf.auth.batch.helpers.Future;
39 import org.onap.aaf.auth.dao.cass.FutureDAO;
40 import org.onap.aaf.auth.env.AuthzTrans;
41 import org.onap.aaf.auth.layer.Result;
42 import org.onap.aaf.misc.env.Env;
43 import org.onap.aaf.misc.env.LogTarget;
44 import org.onap.aaf.misc.env.TimeTaken;
45 import org.onap.aaf.misc.env.Trans;
47 import com.datastax.driver.core.ResultSet;
48 import com.datastax.driver.core.Row;
49 import com.datastax.driver.core.Session;
50 import com.datastax.driver.core.SimpleStatement;
52 public class JU_Future {
61 UUID id = new UUID(0, 0);
64 future = new Future(id, "Re-Validate Ownership for AAF Namespace '\'test\'test", "target", start, expires,
69 public void testId() {
70 Assert.assertTrue(future.id() instanceof UUID);
74 public void testMemo() {
75 Assert.assertEquals("Re-Validate Ownership for AAF Namespace '\'test\'test", future.memo());
79 public void testStart() {
80 Assert.assertTrue(future.start() instanceof Date);
84 public void testExpires() {
85 Assert.assertTrue(future.expires() instanceof Date);
89 public void testTarget() {
90 Assert.assertEquals("target", future.target());
94 public void testExpunge() {
99 public void testCompareTo() {
100 future.compareTo(null);
101 future.compareTo(future);
105 public void testResetLocalData() {
106 Future.resetLocalData();
107 Assert.assertEquals(0, Future.sizeForDeletion());
108 Assert.assertEquals(false, Future.pendingDelete(future));
113 public void testDelayedDeleteWithDryRun() {
114 AuthzTrans trans = mock(AuthzTrans.class);
115 LogTarget target = mock(LogTarget.class);
117 when(trans.info()).thenReturn(target);
119 assertEquals(Result.ok().status, future.delayedDelete(trans, null, true, "text").status);
123 public void testDelayedDeleteNonDryRun() {
124 AuthzTrans trans = mock(AuthzTrans.class);
125 LogTarget target = mock(LogTarget.class);
126 FutureDAO fd = mock(FutureDAO.class);
128 when(trans.info()).thenReturn(target);
129 when(fd.delete(any(AuthzTrans.class), any(FutureDAO.Data.class), any(Boolean.class))).thenReturn(Result.ok());
131 assertEquals(Result.ok().status, future.delayedDelete(trans, fd, false, "text").status);