Increased auth batch coverage 97/48097/1
authorgabe.maurer <gabe.maurer@att.com>
Thu, 17 May 2018 20:20:00 +0000 (15:20 -0500)
committergabe.maurer <gabe.maurer@att.com>
Thu, 17 May 2018 20:21:09 +0000 (15:21 -0500)
Issue-ID: AAF-233
Change-Id: Iaa87085d7dfd8e18efe99bed5264c0529421e66a
Signed-off-by: gabe.maurer <gabe.maurer@att.com>
auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java
auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Email.java [new file with mode: 0644]
auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Future.java
auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_History.java [new file with mode: 0644]
auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java

index adb9156..80ce0ca 100644 (file)
@@ -83,9 +83,9 @@ public class JU_ActionDAO {
 //             cluster.builder();
 //             cluster.init();
 //             cluster.builder().getContactPoints();
-//             
-//
-//             
+               
+
+               
 //             aTrans = mock(AuthzTrans.class);
 //             cluster = mock(Cluster.class);
 //             actionDAOStub = new ActionDAOStub(aTrans,cluster,true);
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Email.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Email.java
new file mode 100644 (file)
index 0000000..0779a33
--- /dev/null
@@ -0,0 +1,136 @@
+/**
+ * ============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.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.aaf.auth.actions.Email;
+import org.onap.aaf.auth.actions.Message;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.org.Organization.Identity;
+import org.onap.aaf.auth.org.Organization;
+import org.onap.aaf.auth.org.OrganizationException;
+
+import static org.mockito.Mockito.*;
+
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Set;
+
+import org.junit.Test;
+
+public class JU_Email {
+       
+       Email email;
+       Identity usersI;
+       Message msg;
+       
+       @Before
+       public void setUp() {
+               usersI = mock(Identity.class);
+               msg = new Message();
+               email = new Email();
+       }
+
+       @Test
+       public void testClear() {
+               Assert.assertNotNull(email.clear());
+       }
+       
+       @Test
+       public void testIndent() {
+               email.indent("indent");
+       }
+       
+       @Test
+       public void testPreamble() {
+               email.preamble("format");
+       }
+       
+       @Test
+       public void testAddTo() {
+               email.addTo(usersI);
+               
+//             Collection col = mock(Collection.class);
+//             col.add("test");
+//             email.addTo(col);
+               
+               email.addTo("email");
+       }
+       
+       @Test
+       public void testAddCC() {
+               email.addCC(usersI);
+               email.addCC("email");
+       }
+       
+//     @Test
+//     public void testAdd() throws OrganizationException {
+//             email.add(usersI, true);
+//     }
+       
+       @Test
+       public void testSubject() {
+               email.subject("format");
+               email.subject("for%smat","format");
+       }
+       
+       @Test
+       public void testSignature() {
+               email.signature("format","arg");
+       }
+       
+       @Test
+       public void testMsg() {
+               email.msg(msg);
+       }
+       
+       @Test
+       public void testExec() {
+               AuthzTrans trans = mock(AuthzTrans.class);
+               Organization org = mock(Organization.class);
+               email.preamble("format");
+               email.msg(msg);
+               email.signature("format","arg");
+               
+               email.exec(trans, org, "text");
+       }
+       
+       @Test
+       public void testLog() throws FileNotFoundException {
+               PrintStream ps = new PrintStream("test");
+               email.addTo("email");
+               email.addCC("email");
+               email.log(ps, "email");
+               email.addTo("emails");
+               email.addCC("emails");
+               email.log(ps, "emails");
+       }
+
+}
index 7332c16..9d47c13 100644 (file)
@@ -96,12 +96,12 @@ public class JU_Future {
        
        @Test
        public void testSizeForDeletion() {
-               System.out.println(future.sizeForDeletion());
+               Assert.assertEquals(0, future.sizeForDeletion());
        }
        
        @Test
        public void testPendingDelete() {
-               System.out.println(future.pendingDelete(future));
+               Assert.assertEquals(false, future.pendingDelete(future));
        }
        
 
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_History.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_History.java
new file mode 100644 (file)
index 0000000..f617af9
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * ============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.History;
+
+import junit.framework.Assert;
+
+import static org.mockito.Mockito.*;
+
+import java.util.UUID;
+
+import org.junit.Test;
+
+public class JU_History {
+       
+       History history;
+       History history1;
+       
+       @Before
+       public void setUp() {
+               UUID id = new UUID(0, 0);
+               history = new History(id, "action", "memo", "subject", "target", "user", 5);
+               history1 = new History(id, "action", "memo", "reconstruct", "subject", "target", "user", 5);
+       }
+
+       @Test
+       public void testToString() {
+               String result = "00000000-0000-0000-0000-000000000000 5 user, target, action, subject, memo";
+               Assert.assertEquals(result, history.toString());
+       }
+       
+       @Test
+       public void testHashCode() {
+               Assert.assertEquals(0, history.hashCode());
+       }
+       
+       @Test
+       public void testEquals() {
+               Assert.assertFalse(history.equals(history1));
+       }
+       
+}
index e858d40..1fb9b24 100644 (file)
@@ -93,9 +93,13 @@ public class JU_MonthData {
        
        @After
        public void cleanUp() {
+               File g = new File("Monthlyenv.dat.bak");
                if(f.exists()) {
                        f.delete();
                }
+               if(g.exists()) {
+                       g.delete();
+               }
        }
 
 }