From: gabe.maurer Date: Thu, 17 May 2018 20:20:00 +0000 (-0500) Subject: Increased auth batch coverage X-Git-Tag: Beijing-2.1.1~38 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aaf%2Fauthz.git;a=commitdiff_plain;h=553ee960cb107e838f83953b37aa6f75d67ae5e6 Increased auth batch coverage Issue-ID: AAF-233 Change-Id: Iaa87085d7dfd8e18efe99bed5264c0529421e66a Signed-off-by: gabe.maurer --- 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 index adb91566..80ce0ca4 100644 --- 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 @@ -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 index 00000000..0779a33d --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Email.java @@ -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"); + } + +} 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 7332c166..9d47c138 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 @@ -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 index 00000000..f617af9a --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_History.java @@ -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)); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java index e858d408..1fb9b248 100644 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java @@ -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(); + } } }