summaryrefslogtreecommitdiffstats
path: root/auth/auth-batch
diff options
context:
space:
mode:
authorSai Gandham <sg481n@att.com>2018-10-26 09:58:18 -0500
committerSai Gandham <sg481n@att.com>2018-10-26 10:09:15 -0500
commit05ef6f4b159071f52b1d01b6239808dec8441f32 (patch)
tree91f7841537718fa25de4ca514b559502980387c3 /auth/auth-batch
parent696d9dc4dd96a3cea4f65effbc37a9aec4e71b5d (diff)
Add more junits to batch module
fixed test failure Issue-ID: AAF-111 Change-Id: I9161af0391183a0806104608703183ecac6bdf72 Signed-off-by: Sai Gandham <sg481n@att.com>
Diffstat (limited to 'auth/auth-batch')
-rw-r--r--auth/auth-batch/file4
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/JU_NotificationTest.java78
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/creators/RowCreator.java434
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approval.java316
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Future.java218
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NS.java172
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NsAttrib.java42
7 files changed, 999 insertions, 265 deletions
diff --git a/auth/auth-batch/file b/auth/auth-batch/file
new file mode 100644
index 00000000..4055fcda
--- /dev/null
+++ b/auth/auth-batch/file
@@ -0,0 +1,4 @@
+instructions
+instructions
+promptinstructions
+promptinstructions
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/JU_NotificationTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/JU_NotificationTest.java
new file mode 100644
index 00000000..d3a1258d
--- /dev/null
+++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/JU_NotificationTest.java
@@ -0,0 +1,78 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.helpers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.aaf.auth.actions.Message;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.helpers.Notification.TYPE;
+import org.onap.aaf.auth.helpers.creators.RowCreator;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.TimeTaken;
+
+public class JU_NotificationTest {
+
+ @Mock
+ private AuthzTrans trans;
+ @Mock
+ private Creator<Notification> creator;
+ @Mock
+ private TimeTaken tt;
+
+ @Mock
+ private LogTarget logTarget;
+ private Message msg;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+
+ msg = new Message();
+ msg.line("%n", "Message");
+
+ when(trans.info()).thenReturn(logTarget);
+ when(trans.start("Load Notify", Env.REMOTE)).thenReturn(tt);
+ }
+
+ @Test
+ public void test() {
+ Notification notification = Notification.create("user", TYPE.CN);
+ assertEquals(notification.checksum(), 0);
+ notification.set(msg);
+ assertEquals(notification.checksum(), 10);
+ assertNull(Notification.get("user", TYPE.CN));
+ assertTrue(notification.update(trans, null, true));
+ assertTrue(notification.toString().contains("\"user\",\"CN\","));
+
+ Notification.v2_0_18.create(RowCreator.getRow());
+ assertEquals(Notification.v2_0_18.select(), "SELECT user,type,last,checksum FROM authz.notify LIMIT 100000");
+
+ }
+} \ No newline at end of file
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/creators/RowCreator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/creators/RowCreator.java
new file mode 100644
index 00000000..078c383b
--- /dev/null
+++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/creators/RowCreator.java
@@ -0,0 +1,434 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.helpers.creators;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.nio.ByteBuffer;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import com.datastax.driver.core.ColumnDefinitions;
+import com.datastax.driver.core.LocalDate;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Token;
+import com.datastax.driver.core.TupleValue;
+import com.datastax.driver.core.TypeCodec;
+import com.datastax.driver.core.UDTValue;
+import com.google.common.reflect.TypeToken;
+
+public class RowCreator {
+
+ public static Row getRow() {
+ Row row = new Row() {
+
+ @Override
+ public boolean isNull(String name) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public BigInteger getVarint(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public UUID getUUID(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public UDTValue getUDTValue(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public TupleValue getTupleValue(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getTimestamp(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getTime(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getString(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public short getShort(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public <T> Set<T> getSet(String name, TypeToken<T> elementsType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> Set<T> getSet(String name, Class<T> elementsClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <K, V> Map<K, V> getMap(String name, TypeToken<K> keysType, TypeToken<V> valuesType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <K, V> Map<K, V> getMap(String name, Class<K> keysClass, Class<V> valuesClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getLong(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public <T> List<T> getList(String name, TypeToken<T> elementsType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> List<T> getList(String name, Class<T> elementsClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getInt(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public InetAddress getInet(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public float getFloat(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public double getDouble(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public BigDecimal getDecimal(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public LocalDate getDate(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ByteBuffer getBytesUnsafe(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ByteBuffer getBytes(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte getByte(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean getBool(String name) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public <T> T get(String name, TypeCodec<T> codec) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> T get(String name, TypeToken<T> targetType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> T get(String name, Class<T> targetClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isNull(int i) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public BigInteger getVarint(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public UUID getUUID(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public UDTValue getUDTValue(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public TupleValue getTupleValue(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getTimestamp(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getTime(int i) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getString(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public short getShort(int i) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public <T> Set<T> getSet(int i, TypeToken<T> elementsType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> Set<T> getSet(int i, Class<T> elementsClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <K, V> Map<K, V> getMap(int i, TypeToken<K> keysType, TypeToken<V> valuesType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <K, V> Map<K, V> getMap(int i, Class<K> keysClass, Class<V> valuesClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getLong(int i) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public <T> List<T> getList(int i, TypeToken<T> elementsType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> List<T> getList(int i, Class<T> elementsClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getInt(int i) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public InetAddress getInet(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public float getFloat(int i) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public double getDouble(int i) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public BigDecimal getDecimal(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public LocalDate getDate(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ByteBuffer getBytesUnsafe(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ByteBuffer getBytes(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte getByte(int i) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean getBool(int i) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public <T> T get(int i, TypeCodec<T> codec) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> T get(int i, TypeToken<T> targetType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> T get(int i, Class<T> targetClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Token getToken(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Token getToken(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Token getPartitionKeyToken() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ColumnDefinitions getColumnDefinitions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ return row;
+ }
+
+}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approval.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approval.java
index 288e929b..ab86a648 100644
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approval.java
+++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approval.java
@@ -21,137 +21,211 @@
package org.onap.aaf.auth.helpers.test;
-import static org.junit.Assert.*;
-import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
import org.onap.aaf.auth.dao.cass.ApprovalDAO;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.helpers.Approval;
+import org.onap.aaf.auth.helpers.creators.RowCreator;
+import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.misc.env.LogTarget;
import junit.framework.Assert;
-import static org.mockito.Mockito.*;
+public class JU_Approval {
+
+ Approval approval;
+ UUID id;
+ UUID ticket;
+ Date date;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+ @Before
+ public void setUp() {
+ id = new UUID(0, 0);
+ ticket = new UUID(0, 0);
+ date = new Date();
-import org.junit.Test;
+ approval = new Approval(id, ticket, "approver", date, "user", "memo", "operation", "status", "type", 100l);
+ }
-public class JU_Approval {
-
- Approval approval;
- UUID id;
- UUID ticket;
- Date date;
-
- @Before
- public void setUp() {
- id = new UUID(0, 0);
- ticket = new UUID(0, 0);
- date = new Date();
-
- approval = new Approval(id, ticket, "approver", date,
- "user", "memo", "operation", "status", "type", 100l);
- }
-
- @Test
- public void testRoleFromMemo() {
- Assert.assertNull(approval.roleFromMemo(null));
- Assert.assertEquals(".admin", approval.roleFromMemo("Re-Validate as Administrator for AAF Namespace '\'test\'test"));
- Assert.assertEquals(".owner", approval.roleFromMemo("Re-Validate Ownership for AAF Namespace '\'test\'test"));
- Assert.assertEquals("", approval.roleFromMemo("Re-Approval in Role '\'test\'test"));
- }
-
- @Test
- public void testExpunge() {
- approval.expunge();
- }
-
- @Test
- public void testGetLast_notified() {
- Assert.assertTrue(approval.getLast_notified()instanceof Date);
- }
-
- @Test
- public void testSetLastNotified() {
- approval.setLastNotified(date);
- }
-
- @Test
- public void testGetStatus() {
- Assert.assertEquals("status", approval.getStatus());
- }
-
- @Test
- public void testSetStatus() {
- approval.setStatus("status");
- }
-
- @Test
- public void testGetId() {
- Assert.assertTrue(approval.getId() instanceof UUID);
- }
-
- @Test
- public void testGetTicket() {
- Assert.assertTrue(approval.getTicket() instanceof UUID);
- }
-
- @Test
- public void testGetMemo() {
- Assert.assertEquals("memo", approval.getMemo());
- }
-
- @Test
- public void testGetOperation() {
- Assert.assertEquals("operation", approval.getOperation());
- }
-
- @Test
- public void testGetType() {
- Assert.assertEquals("type", approval.getType());
- }
-
- @Test
- public void testLapsed() {
- approval.lapsed();
- }
-
- @Test
- public void testGetRole() {
- Assert.assertNull(approval.getRole());
- }
-
- @Test
- public void testToString() {
- Assert.assertEquals("user memo", approval.toString());
- }
-
- @Test
- public void testResetLocalData() {
- approval.resetLocalData();
- }
-
- @Test
- public void testSizeForDeletion() {
- Assert.assertEquals(0, approval.sizeForDeletion());
- }
-
- @Test
- public void testPendingDelete() {
- Assert.assertFalse(approval.pendingDelete(approval));
- }
-
- @Test
- public void testDelayDelete() {
- AuthzTrans trans = mock(AuthzTrans.class);
- ApprovalDAO dao = mock(ApprovalDAO.class);
- List<Approval> list = null;
- approval.delayDelete(trans, dao, true, list, "text");
- }
+ @Test
+ public void testRoleFromMemo() {
+ Assert.assertNull(approval.roleFromMemo(null));
+ Assert.assertEquals(".admin",
+ approval.roleFromMemo("Re-Validate as Administrator for AAF Namespace '\'test\'test"));
+ Assert.assertEquals(".owner", approval.roleFromMemo("Re-Validate Ownership for AAF Namespace '\'test\'test"));
+ Assert.assertEquals("", approval.roleFromMemo("Re-Approval in Role '\'test\'test"));
+ }
+
+ @Test
+ public void testExpunge() {
+ approval.expunge();
+ }
+
+ @Test
+ public void testGetLast_notified() {
+ Assert.assertTrue(approval.getLast_notified() instanceof Date);
+ }
+
+ @Test
+ public void testSetLastNotified() {
+ approval.setLastNotified(date);
+ }
+
+ @Test
+ public void testGetStatus() {
+ Assert.assertEquals("status", approval.getStatus());
+ }
+
+ @Test
+ public void testSetStatus() {
+ approval.setStatus("status");
+ }
+
+ @Test
+ public void testGetId() {
+ Assert.assertTrue(approval.getId() instanceof UUID);
+ }
+
+ @Test
+ public void testGetTicket() {
+ Assert.assertTrue(approval.getTicket() instanceof UUID);
+ }
+
+ @Test
+ public void testGetMemo() {
+ Assert.assertEquals("memo", approval.getMemo());
+ }
+
+ @Test
+ public void testGetOperation() {
+ Assert.assertEquals("operation", approval.getOperation());
+ }
+
+ @Test
+ public void testGetType() {
+ Assert.assertEquals("type", approval.getType());
+ }
+
+ @Test
+ public void testLapsed() {
+ approval.lapsed();
+ }
+
+ @Test
+ public void testGetRole() {
+ Assert.assertNull(approval.getRole());
+ }
+
+ @Test
+ public void testToString() {
+ Assert.assertEquals("user memo", approval.toString());
+ }
+
+ @Test
+ public void testResetLocalData() {
+ approval.resetLocalData();
+ }
+
+ @Test
+ public void testSizeForDeletion() {
+ approval = new Approval(id, ticket, "approver", date, "user", "memo", "operation", "status", "type", 100l);
+ Assert.assertEquals(0, approval.sizeForDeletion());
+ }
+
+ @Test
+ public void testPendingDelete() {
+ Assert.assertFalse(approval.pendingDelete(approval));
+ }
+
+ @Test
+ public void testUpdateNonDryRun() {
+ approval = new Approval(id, ticket, "approver", date, "user", "memo", "operation", "status", "type", 100l);
+ AuthzTrans trans = mock(AuthzTrans.class);
+ ApprovalDAO dao = mock(ApprovalDAO.class);
+ LogTarget target = mock(LogTarget.class);
+
+ when(trans.info()).thenReturn(target);
+
+ approval.update(trans, dao, false);
+ }
+
+ @Test
+ public void testUpdateDryRun() {
+ approval = new Approval(id, ticket, "approver", date, "user", "memo", "operation", "status", "type", 100l);
+ AuthzTrans trans = mock(AuthzTrans.class);
+ ApprovalDAO dao = mock(ApprovalDAO.class);
+ LogTarget target = mock(LogTarget.class);
+
+ when(trans.info()).thenReturn(target);
+
+ approval.update(trans, dao, true);
+ }
+
+ @Test
+ public void testDelayDeleteDryRun() {
+ approval = new Approval(id, ticket, "approver", date, "user", "memo", "operation", "status", "type", 100l);
+ AuthzTrans trans = mock(AuthzTrans.class);
+ ApprovalDAO dao = mock(ApprovalDAO.class);
+ LogTarget target = mock(LogTarget.class);
+
+ when(trans.info()).thenReturn(target);
+
+ List<Approval> list = new ArrayList<Approval>();
+ list.add(approval);
+ Approval.delayDelete(trans, dao, true, list, "text");
+ }
+
+ @Test
+ public void testDelayDeleteNonDryRun() {
+ approval = new Approval(id, ticket, "approver", date, "user", "memo", "operation", "status", "type", 100l);
+ AuthzTrans trans = mock(AuthzTrans.class);
+ ApprovalDAO dao = mock(ApprovalDAO.class);
+ LogTarget target = mock(LogTarget.class);
+
+ when(trans.info()).thenReturn(target);
+ Result<Void> rv = Result.ok();
+ when(dao.delete(any(AuthzTrans.class), any(ApprovalDAO.Data.class), any(Boolean.class))).thenReturn(rv);
+
+ List<Approval> list = new ArrayList<Approval>();
+ list.add(approval);
+ Approval.delayDelete(trans, dao, false, list, "text");
+ }
+
+ @Test
+ public void testDelayDeleteResultNotOk() {
+ approval = new Approval(id, ticket, "approver", date, "user", "memo", "operation", "status", "type", 100l);
+ AuthzTrans trans = mock(AuthzTrans.class);
+ ApprovalDAO dao = mock(ApprovalDAO.class);
+ LogTarget target = mock(LogTarget.class);
+
+ when(trans.info()).thenReturn(target);
+ Result<Void> rv = Result.err(new Exception());
+ when(dao.delete(any(AuthzTrans.class), any(ApprovalDAO.Data.class), any(Boolean.class))).thenReturn(rv);
+
+ List<Approval> list = new ArrayList<Approval>();
+ list.add(approval);
+ Approval.delayDelete(trans, dao, false, list, "text");
+ }
+
+ @Test
+ public void testv2() {
+ Approval.v2_0_17.create(RowCreator.getRow());
+
+ assertEquals(
+ "select id,ticket,approver,last_notified,user,memo,operation,status,type,WRITETIME(status) from authz.approval",
+ Approval.v2_0_17.select());
+
+ }
}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Future.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Future.java
index a3aef1c9..92debf44 100644
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Future.java
+++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Future.java
@@ -21,88 +21,156 @@
package org.onap.aaf.auth.helpers.test;
-import static org.junit.Assert.*;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.onap.aaf.auth.helpers.Future;
-
-import static org.mockito.Mockito.*;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.nio.ByteBuffer;
+import java.util.ArrayList;
import java.util.Date;
import java.util.UUID;
+import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.onap.aaf.auth.dao.cass.FutureDAO;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.helpers.Creator;
+import org.onap.aaf.auth.helpers.Future;
+import org.onap.aaf.auth.helpers.creators.RowCreator;
+import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.TimeTaken;
+import org.onap.aaf.misc.env.Trans;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.SimpleStatement;
public class JU_Future {
-
- Future future;
- Date start;
- Date expires;
- ByteBuffer bBuff;
-
- @Before
- public void setUp() {
- UUID id = new UUID(0, 0);
- start = new Date();
- expires = new Date();
- future = new Future(id, "Re-Validate Ownership for AAF Namespace '\'test\'test","target",start, expires, bBuff);
- }
-
- @Test
- public void testId() {
- Assert.assertTrue(future.id() instanceof UUID);
- }
-
- @Test
- public void testMemo() {
- Assert.assertEquals("Re-Validate Ownership for AAF Namespace '\'test\'test", future.memo());
- }
-
- @Test
- public void testStart() {
- Assert.assertTrue(future.start() instanceof Date);
- }
-
- @Test
- public void testExpires() {
- Assert.assertTrue(future.expires() instanceof Date);
- }
-
- @Test
- public void testTarget() {
- Assert.assertEquals("target",future.target());
- }
-
- @Test
- public void testExpunge() {
- future.expunge();
- }
-
- @Test
- public void testCompareTo() {
- future.compareTo(null);
- future.compareTo(future);
- }
-
- @Test
- public void testResetLocalData() {
- future.resetLocalData();
- }
-
- @Test
- public void testSizeForDeletion() {
- Assert.assertEquals(0, future.sizeForDeletion());
- }
-
- @Test
- public void testPendingDelete() {
- Assert.assertEquals(false, future.pendingDelete(future));
- }
-
+
+ Future future;
+ Date start;
+ Date expires;
+ ByteBuffer bBuff;
+
+ @Before
+ public void setUp() {
+ UUID id = new UUID(0, 0);
+ start = new Date();
+ expires = new Date();
+ future = new Future(id, "Re-Validate Ownership for AAF Namespace '\'test\'test", "target", start, expires,
+ bBuff);
+ }
+
+ @Test
+ public void testId() {
+ Assert.assertTrue(future.id() instanceof UUID);
+ }
+
+ @Test
+ public void testMemo() {
+ Assert.assertEquals("Re-Validate Ownership for AAF Namespace '\'test\'test", future.memo());
+ }
+
+ @Test
+ public void testStart() {
+ Assert.assertTrue(future.start() instanceof Date);
+ }
+
+ @Test
+ public void testExpires() {
+ Assert.assertTrue(future.expires() instanceof Date);
+ }
+
+ @Test
+ public void testTarget() {
+ Assert.assertEquals("target", future.target());
+ }
+
+ @Test
+ public void testExpunge() {
+ future.expunge();
+ }
+
+ @Test
+ public void testCompareTo() {
+ future.compareTo(null);
+ future.compareTo(future);
+ }
+
+ @Test
+ public void testResetLocalData() {
+ future.resetLocalData();
+ }
+
+ @Test
+ public void testSizeForDeletion() {
+ Assert.assertEquals(0, future.sizeForDeletion());
+ }
+
+ @Test
+ public void testPendingDelete() {
+ Assert.assertEquals(false, future.pendingDelete(future));
+ }
+
+ @Test
+ public void testLoad() {
+ Session session = mock(Session.class);
+ Trans trans = mock(Trans.class);
+ Creator<Future> creator = mock(Creator.class);
+ LogTarget target = mock(LogTarget.class);
+ TimeTaken tt = mock(TimeTaken.class);
+ ResultSet results = mock(ResultSet.class);
+ ArrayList<Row> rows = new ArrayList<Row>();
+ Row row = RowCreator.getRow();
+ rows.add(row);
+
+ when(results.all()).thenReturn(rows);
+ when(trans.info()).thenReturn(target);
+ when(trans.start("Load Futures", Env.REMOTE)).thenReturn(tt);
+ when(trans.start("Process Futures", Env.SUB)).thenReturn(tt);
+ when(session.execute(any(SimpleStatement.class))).thenReturn(results);
+ when(creator.create(row)).thenReturn(future);
+
+ Future.load(trans, session, creator);
+ }
+
+ @Test
+ public void testV2() {
+ Future.v2_0_17.create(RowCreator.getRow());
+ assertEquals(Future.v2_0_17.select(), "select id,memo,target,start,expires from authz.future");
+ }
+
+ @Test
+ public void testWithConstruct() {
+ Future.withConstruct.create(RowCreator.getRow());
+ assertEquals(Future.withConstruct.select(), "select id,memo,target,start,expires,construct from authz.future");
+ }
+
+ @Test
+ public void testDelayedDeleteWithDryRun() {
+ AuthzTrans trans = mock(AuthzTrans.class);
+ LogTarget target = mock(LogTarget.class);
+
+ when(trans.info()).thenReturn(target);
+
+ assertEquals(Result.ok().status, future.delayedDelete(trans, null, true, "text").status);
+ }
+
+ @Test
+ public void testDelayedDeleteNonDryRun() {
+ AuthzTrans trans = mock(AuthzTrans.class);
+ LogTarget target = mock(LogTarget.class);
+ FutureDAO fd = mock(FutureDAO.class);
+
+ when(trans.info()).thenReturn(target);
+ when(fd.delete(any(AuthzTrans.class), any(FutureDAO.Data.class), any(Boolean.class))).thenReturn(Result.ok());
+
+ assertEquals(Result.ok().status, future.delayedDelete(trans, fd, false, "text").status);
+ }
}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NS.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NS.java
index ec158c41..b69f8873 100644
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NS.java
+++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NS.java
@@ -21,59 +21,139 @@
package org.onap.aaf.auth.helpers.test;
-import static org.junit.Assert.*;
-import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
+import org.onap.aaf.auth.helpers.Creator;
import org.onap.aaf.auth.helpers.NS;
import org.onap.aaf.auth.helpers.NS.NSSplit;
+import org.onap.aaf.auth.helpers.creators.RowCreator;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.TimeTaken;
+import org.onap.aaf.misc.env.Trans;
-import junit.framework.Assert;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.SimpleStatement;
-import static org.mockito.Mockito.*;
-import org.junit.Test;
+import junit.framework.Assert;
public class JU_NS {
-
- NS ns;
- NSSplit nSSplit;
-
- @Before
- public void setUp() {
- ns = new NS("name", "description", "parent", 1, 1);
- nSSplit = new NSSplit("string",1);
- }
-
- @Test
- public void testToString() {
- Assert.assertEquals("name", ns.toString());
- }
-
- @Test
- public void testHashCode() {
- Assert.assertEquals(3373707, ns.hashCode());
- }
-
- @Test
- public void testEquals() {
- Assert.assertEquals(true, ns.equals("name"));
- Assert.assertEquals(false, ns.equals("name1"));
- }
-
- @Test
- public void testCompareTo() {
- NS nsValid = new NS("name", "description", "parent", 1, 1);
- Assert.assertEquals(0, ns.compareTo(nsValid));
-
- NS nsInvalid = new NS("name1", "description", "parent", 1, 1);
- Assert.assertEquals(-1, ns.compareTo(nsInvalid));
- }
-
- @Test
- public void testDeriveParent() {
- ns.deriveParent("d.ot.te.d");
- }
+
+ NS ns;
+ NSSplit nSSplit;
+
+ @Before
+ public void setUp() {
+ ns = new NS("name", "description", "parent", 1, 1);
+ nSSplit = new NSSplit("string", 1);
+ }
+
+ @Test
+ public void testToString() {
+ Assert.assertEquals("name", ns.toString());
+ }
+
+ @Test
+ public void testHashCode() {
+ Assert.assertEquals(3373707, ns.hashCode());
+ }
+
+ @Test
+ public void testEquals() {
+ Assert.assertEquals(true, ns.equals("name"));
+ Assert.assertEquals(false, ns.equals("name1"));
+ }
+
+ @Test
+ public void testCompareTo() {
+ NS nsValid = new NS("name", "description", "parent", 1, 1);
+ Assert.assertEquals(0, ns.compareTo(nsValid));
+
+ NS nsInvalid = new NS("name1", "description", "parent", 1, 1);
+ Assert.assertEquals(-1, ns.compareTo(nsInvalid));
+ }
+
+ @Test
+ public void testDeriveParent() {
+ ns.deriveParent("d.ot.te.d");
+ }
+
+ @Test
+ public void testLoadWithoutNS() {
+ Trans trans = mock(Trans.class);
+ Session session = mock(Session.class);
+ Creator<NS> creator = mock(Creator.class);
+ LogTarget target = mock(LogTarget.class);
+ TimeTaken tt = mock(TimeTaken.class);
+ ResultSet results = mock(ResultSet.class);
+ ArrayList<Row> rows = new ArrayList<Row>();
+ Row row = RowCreator.getRow();
+ rows.add(row);
+
+ when(trans.info()).thenReturn(target);
+ when(trans.start("Read Namespaces", Env.REMOTE)).thenReturn(tt);
+ when(trans.start("Load Namespaces", Env.SUB)).thenReturn(tt);
+ when(session.execute(any(SimpleStatement.class))).thenReturn(results);
+ when(results.iterator()).thenReturn(rows.iterator());
+ when(creator.create(row)).thenReturn(ns);
+
+ NS.load(trans, session, creator);
+ }
+
+ @Test
+ public void testLoadOne() {
+ Trans trans = mock(Trans.class);
+ Session session = mock(Session.class);
+ Creator<NS> creator = mock(Creator.class);
+ LogTarget target = mock(LogTarget.class);
+ TimeTaken tt = mock(TimeTaken.class);
+ ResultSet results = mock(ResultSet.class);
+ ArrayList<Row> rows = new ArrayList<Row>();
+ Row row = RowCreator.getRow();
+ rows.add(row);
+
+ when(trans.info()).thenReturn(target);
+ when(trans.start("Read Namespaces", Env.REMOTE)).thenReturn(tt);
+ when(trans.start("Load Namespaces", Env.SUB)).thenReturn(tt);
+ when(session.execute(any(SimpleStatement.class))).thenReturn(results);
+ when(results.iterator()).thenReturn(rows.iterator());
+ when(creator.create(row)).thenReturn(ns);
+
+ NS.loadOne(trans, session, creator, "text");
+ }
+
+ @Test
+ public void testCount() {
+ Trans trans = mock(Trans.class);
+ Session session = mock(Session.class);
+ LogTarget target = mock(LogTarget.class);
+ TimeTaken tt = mock(TimeTaken.class);
+ ResultSet results = mock(ResultSet.class);
+ ArrayList<Row> rows = new ArrayList<Row>();
+ Row row = RowCreator.getRow();
+ rows.add(row);
+
+ when(trans.info()).thenReturn(target);
+ when(trans.start("Count Namespaces", Env.REMOTE)).thenReturn(tt);
+ when(session.execute(any(SimpleStatement.class))).thenReturn(results);
+ when(results.one()).thenReturn(row);
+
+ assertEquals(0, NS.count(trans, session));
+ }
+
+ @Test
+ public void testV2() {
+ NS.v2_0_11.create(RowCreator.getRow());
+ assertEquals(NS.v2_0_11.select(), "SELECT name, description, parent, type, scope FROM authz.ns ");
+ }
}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NsAttrib.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NsAttrib.java
index a566f8d1..acf9b478 100644
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NsAttrib.java
+++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NsAttrib.java
@@ -21,35 +21,31 @@
package org.onap.aaf.auth.helpers.test;
-import static org.junit.Assert.*;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.onap.aaf.auth.helpers.Creator;
import org.onap.aaf.auth.helpers.NsAttrib;
-import org.onap.aaf.misc.env.Trans;
-
-import com.datastax.driver.core.Session;
+import org.onap.aaf.auth.helpers.creators.RowCreator;
import junit.framework.Assert;
-import static org.mockito.Mockito.*;
-import org.junit.Test;
-
public class JU_NsAttrib {
-
- NsAttrib nsAttrib;
-
- @Before
- public void setUp() {
- nsAttrib = new NsAttrib("ns", "key", "value");
- }
-
- @Test
- public void testToString() {
- Assert.assertEquals("\"ns\",\"key\",\"value\"", nsAttrib.toString());
- }
+
+ NsAttrib nsAttrib;
+
+ @Before
+ public void setUp() {
+ nsAttrib = new NsAttrib("ns", "key", "value");
+ }
+
+ @Test
+ public void testToString() {
+ Assert.assertEquals("\"ns\",\"key\",\"value\"", nsAttrib.toString());
+ }
+
+ @Test
+ public void testV2() {
+ NsAttrib.v2_0_11.create(RowCreator.getRow());
+ Assert.assertEquals("select ns,key,value from authz.ns_attrib", NsAttrib.v2_0_11.select());
+ }
}