Increased code coverage auth batch 91/46891/1
authorgabe.maurer <gabe.maurer@att.com>
Wed, 9 May 2018 19:43:40 +0000 (14:43 -0500)
committergabe.maurer <gabe.maurer@att.com>
Wed, 9 May 2018 19:44:25 +0000 (14:44 -0500)
Issue-ID: AAF-233
Change-Id: I3b44c2c2cef68561addfbe8a185ce9b5da65e749
Signed-off-by: gabe.maurer <gabe.maurer@att.com>
auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java [new file with mode: 0644]
auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java [new file with mode: 0644]
auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_CacheChange.java [new file with mode: 0644]
auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java
auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java [new file with mode: 0644]
auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_CassBatch.java [new file with mode: 0644]

diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java
new file mode 100644 (file)
index 0000000..adb9156
--- /dev/null
@@ -0,0 +1,95 @@
+/**
+ * ============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.actions.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.actions.ActionDAO;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.misc.env.APIException;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Configuration;
+import com.datastax.driver.core.Cluster.Initializer;
+import com.datastax.driver.core.Host.StateListener;
+
+import static org.mockito.Mockito.*;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.Collection;
+import java.util.List;
+
+import org.junit.Test;
+
+public class JU_ActionDAO {
+       
+       AuthzTrans aTrans;
+       Cluster cluster;
+       ActionDAOStub actionDAOStub;
+       ActionDAOStub actionDAOStub1;
+
+       private class ActionDAOStub extends ActionDAO {
+
+               public ActionDAOStub(AuthzTrans trans, ActionDAO predecessor) {
+                       super(trans, predecessor);
+                       // TODO Auto-generated constructor stub
+               }
+
+               public ActionDAOStub(AuthzTrans trans, Cluster cluster, boolean dryRun) throws APIException, IOException {
+                       super(trans, cluster, dryRun);
+                       // TODO Auto-generated constructor stub
+               }
+
+               @Override
+               public Result exec(AuthzTrans trans, Object data, Object t) {
+                       // TODO Auto-generated method stub
+                       return null;
+               }
+               
+       }
+       
+       @Before
+       public void setUp() throws APIException, IOException {
+//             Cluster.Initializer cInit = mock(Cluster.Initializer.class);
+//             Cluster.Builder cBuild = new Cluster.Builder();
+//             cBuild.addContactPoint("test");
+//             cBuild.build();
+//             cluster.buildFrom(cBuild);
+//             cluster.builder();
+//             cluster.init();
+//             cluster.builder().getContactPoints();
+//             
+//
+//             
+//             aTrans = mock(AuthzTrans.class);
+//             cluster = mock(Cluster.class);
+//             actionDAOStub = new ActionDAOStub(aTrans,cluster,true);
+//             actionDAOStub1 = new ActionDAOStub(aTrans, actionDAOStub);
+       }
+
+}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java
new file mode 100644 (file)
index 0000000..3788252
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * ============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.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.actions.Message;
+import org.onap.aaf.auth.helpers.Approver;
+import org.onap.aaf.auth.org.Organization;
+
+import static org.mockito.Mockito.*;
+import org.junit.Test;
+
+public class JU_Approver {
+
+       Approver approver;
+       Organization org;
+       Message msg;
+       
+       @Before
+       public void setUp() {
+               org = mock(Organization.class);
+               approver = new Approver("approver", org);
+               msg = new Message();
+       }
+       
+       @Test
+       public void testAddRequest() {
+               approver.addRequest("user");
+               approver.addRequest("user");
+       }
+       
+       @Test
+       public void testBuild() {
+               approver.addRequest("user");
+               approver.addRequest("user1");
+               approver.addRequest("user2");
+               approver.addRequest("user3");
+               approver.build(msg);
+       }
+
+}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_CacheChange.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_CacheChange.java
new file mode 100644 (file)
index 0000000..c029be1
--- /dev/null
@@ -0,0 +1,80 @@
+/**
+ * ============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.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.CacheChange;
+
+import junit.framework.Assert;
+
+import static org.mockito.Mockito.*;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class JU_CacheChange {
+
+       CacheChange cc;
+       
+       
+       @Before
+       public void setUp() {
+               cc = new CacheChange();
+       }
+       
+       @Test
+       public void testDelayedDelete() {
+               cc.delayedDelete(null);
+       }
+
+       @Test
+       public void testGetRemoved() {
+               List list = cc.getRemoved();
+               Assert.assertNotNull(list);
+       }
+       
+       @Test
+       public void testResetLocalData() {
+               cc.resetLocalData();
+       }
+       
+       @Test
+       public void testCacheSize() {
+               int size;
+               size = cc.cacheSize();
+               Assert.assertEquals(0, size);
+       }
+       
+       @Test
+       public void testContains() {
+               boolean containsBools;
+               containsBools = cc.contains(null);
+               Assert.assertEquals(false, containsBools);
+       }
+
+}
index dad723b..9b2f2db 100644 (file)
@@ -48,7 +48,7 @@ public class JU_BatchException {
        }
        
        @Test
-       public void test() {
+       public void testBatchException() {
                bExcept1 = new BatchException();
                bExcept2 = new BatchException("test");
                bExcept3 = new BatchException(throwable);
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java
new file mode 100644 (file)
index 0000000..cc30890
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * ============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.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.BatchPrincipal;
+
+import junit.framework.Assert;
+
+import static org.mockito.Mockito.*;
+import org.junit.Test;
+
+public class JU_BatchPrincipal {
+
+       BatchPrincipal bPrincipal;
+       
+       @Test
+       public void testBatchPrincipal() {
+               bPrincipal = new BatchPrincipal("name");
+               bPrincipal.getName();
+               Assert.assertEquals("Batch", bPrincipal.tag());
+       }
+
+}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_CassBatch.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_CassBatch.java
new file mode 100644 (file)
index 0000000..0e7a424
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * ============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.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.CassBatch;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.org.OrganizationException;
+import org.onap.aaf.misc.env.APIException;
+
+import static org.mockito.Mockito.*;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class JU_CassBatch {
+       
+       AuthzTrans aTrans;
+       
+       private class CassBatchStub extends CassBatch {
+
+               protected CassBatchStub(AuthzTrans trans, String log4jName)
+                               throws APIException, IOException, OrganizationException {
+                       super(trans, log4jName);
+                       // TODO Auto-generated constructor stub
+               }
+
+               @Override
+               protected void run(AuthzTrans trans) {
+                       // TODO Auto-generated method stub
+                       
+               }
+               
+       }
+       
+       @Before
+       public void setUp() throws APIException, IOException, OrganizationException {
+               aTrans = mock(AuthzTrans.class);
+               //CassBatchStub cassBatchStub = new CassBatchStub(aTrans,"log");                //Cannot do until Batch is understood
+       }
+
+}