From 71340cf50ea2c0fc9cfd0670052c4b4fcabe3db6 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Fri, 30 Nov 2018 14:21:02 -0600 Subject: Change Batch Packaging Issue-ID: AAF-654 Change-Id: Iaa1eab5d43717e7ffe51933511c9b232a5a1d770 Signed-off-by: Instrumental --- .../onap/aaf/auth/actions/test/JU_ActionDAO.java | 95 ----- .../aaf/auth/actions/test/JU_CredPrintTest.java | 67 ---- .../org/onap/aaf/auth/actions/test/JU_Email.java | 151 ------- .../onap/aaf/auth/actions/test/JU_EmailPrint.java | 92 ----- .../aaf/auth/actions/test/JU_FuturePrintTest.java | 61 --- .../org/onap/aaf/auth/actions/test/JU_Message.java | 62 --- .../auth/actions/test/JU_URFuturePrintTest.java | 57 --- .../onap/aaf/auth/actions/test/JU_URPrintTest.java | 58 --- .../aaf/auth/batch/actions/test/JU_ActionDAO.java | 95 +++++ .../auth/batch/actions/test/JU_CredPrintTest.java | 67 ++++ .../onap/aaf/auth/batch/actions/test/JU_Email.java | 151 +++++++ .../aaf/auth/batch/actions/test/JU_EmailPrint.java | 92 +++++ .../batch/actions/test/JU_FuturePrintTest.java | 61 +++ .../aaf/auth/batch/actions/test/JU_Message.java | 62 +++ .../batch/actions/test/JU_URFuturePrintTest.java | 57 +++ .../auth/batch/actions/test/JU_URPrintTest.java | 58 +++ .../auth/batch/helpers/creators/RowCreator.java | 434 +++++++++++++++++++++ .../aaf/auth/batch/helpers/test/JU_Approval.java | 225 +++++++++++ .../aaf/auth/batch/helpers/test/JU_Approver.java | 65 +++ .../auth/batch/helpers/test/JU_CacheChange.java | 80 ++++ .../aaf/auth/batch/helpers/test/JU_Creator.java | 72 ++++ .../onap/aaf/auth/batch/helpers/test/JU_Cred.java | 142 +++++++ .../auth/batch/helpers/test/JU_ExpireRange.java | 71 ++++ .../aaf/auth/batch/helpers/test/JU_Future.java | 177 +++++++++ .../aaf/auth/batch/helpers/test/JU_History.java | 68 ++++ .../auth/batch/helpers/test/JU_InputIterator.java | 76 ++++ .../aaf/auth/batch/helpers/test/JU_MiscID.java | 97 +++++ .../aaf/auth/batch/helpers/test/JU_MonthData.java | 105 +++++ .../onap/aaf/auth/batch/helpers/test/JU_NS.java | 159 ++++++++ .../aaf/auth/batch/helpers/test/JU_NsAttrib.java | 51 +++ .../onap/aaf/auth/batch/helpers/test/JU_Perm.java | 98 +++++ .../onap/aaf/auth/batch/helpers/test/JU_Role.java | 94 +++++ .../aaf/auth/batch/helpers/test/JU_UserRole.java | 186 +++++++++ .../org/onap/aaf/auth/batch/test/JU_Batch.java | 92 +++++ .../aaf/auth/batch/test/JU_BatchException.java | 59 +++ .../aaf/auth/batch/test/JU_BatchPrincipal.java | 48 +++ .../org/onap/aaf/auth/batch/test/JU_CassBatch.java | 67 ++++ .../aaf/auth/batch/test/JU_NotificationTest.java | 80 ++++ .../onap/aaf/auth/helpers/JU_NotificationTest.java | 78 ---- .../onap/aaf/auth/helpers/creators/RowCreator.java | 434 --------------------- .../onap/aaf/auth/helpers/test/JU_Approval.java | 225 ----------- .../onap/aaf/auth/helpers/test/JU_Approver.java | 65 --- .../onap/aaf/auth/helpers/test/JU_CacheChange.java | 80 ---- .../org/onap/aaf/auth/helpers/test/JU_Creator.java | 72 ---- .../org/onap/aaf/auth/helpers/test/JU_Cred.java | 142 ------- .../org/onap/aaf/auth/helpers/test/JU_Future.java | 177 --------- .../org/onap/aaf/auth/helpers/test/JU_History.java | 68 ---- .../aaf/auth/helpers/test/JU_InputIterator.java | 76 ---- .../org/onap/aaf/auth/helpers/test/JU_MiscID.java | 97 ----- .../onap/aaf/auth/helpers/test/JU_MonthData.java | 105 ----- .../java/org/onap/aaf/auth/helpers/test/JU_NS.java | 159 -------- .../onap/aaf/auth/helpers/test/JU_NsAttrib.java | 51 --- .../org/onap/aaf/auth/helpers/test/JU_Perm.java | 98 ----- .../org/onap/aaf/auth/helpers/test/JU_Role.java | 94 ----- .../onap/aaf/auth/helpers/test/JU_UserRole.java | 186 --------- .../test/java/org/onap/aaf/auth/test/JU_Batch.java | 92 ----- .../org/onap/aaf/auth/test/JU_BatchException.java | 59 --- .../org/onap/aaf/auth/test/JU_BatchPrincipal.java | 48 --- .../java/org/onap/aaf/auth/test/JU_CassBatch.java | 67 ---- 59 files changed, 3189 insertions(+), 3116 deletions(-) delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_CredPrintTest.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Email.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_EmailPrint.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_FuturePrintTest.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Message.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_URFuturePrintTest.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_URPrintTest.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_ActionDAO.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_CredPrintTest.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Email.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_EmailPrint.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_FuturePrintTest.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Message.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFuturePrintTest.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URPrintTest.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/creators/RowCreator.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Approval.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Approver.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_CacheChange.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Creator.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Cred.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_ExpireRange.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Future.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_History.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_InputIterator.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MiscID.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MonthData.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NS.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NsAttrib.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Perm.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Role.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_UserRole.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_Batch.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_BatchException.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_BatchPrincipal.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_CassBatch.java create mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_NotificationTest.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/JU_NotificationTest.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/creators/RowCreator.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approval.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_CacheChange.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Creator.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Cred.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Future.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_History.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_InputIterator.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MiscID.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NS.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NsAttrib.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Perm.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Role.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_UserRole.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_Batch.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java delete mode 100644 auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_CassBatch.java (limited to 'auth/auth-batch/src/test/java/org') 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 deleted file mode 100644 index 254a6adf..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * ============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/actions/test/JU_CredPrintTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_CredPrintTest.java deleted file mode 100644 index 2e6ad09c..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_CredPrintTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * ============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.assertEquals; -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.CredPrint; -import org.onap.aaf.auth.dao.cass.CredDAO; -import org.onap.aaf.auth.dao.cass.CredDAO.Data; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.layer.Result; -import org.onap.aaf.misc.env.LogTarget; - -public class JU_CredPrintTest { - - @Mock - private AuthzTrans trans; - private Data cred; - @Mock - LogTarget target; - - @Before - public void setUp() throws Exception { - initMocks(this); - when(trans.info()).thenReturn(target); - cred = new CredDAO.Data(); - cred.type = CredDAO.BASIC_AUTH; - } - - @Test - public void testCred() { - CredPrint print = new CredPrint("text"); - - Result result = print.exec(trans, cred, "text"); - - assertEquals(result.status, result.ok().status); - assertEquals(CredPrint.type(CredDAO.BASIC_AUTH), "OLD"); - assertEquals(CredPrint.type(CredDAO.BASIC_AUTH_SHA256), "U/P"); - assertEquals(CredPrint.type(CredDAO.CERT_SHA256_RSA), "Cert"); - assertEquals(CredPrint.type(0), "Unknown"); - } - -} 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 deleted file mode 100644 index d3d4719e..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Email.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * ============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.ByteArrayOutputStream; -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 { - - private ByteArrayOutputStream outStream; - private ByteArrayOutputStream errStream; - Email email; - Identity usersI; - Message msg; - PrintStream ps; - - @Before - public void setUp() throws FileNotFoundException { - outStream = new ByteArrayOutputStream(); - errStream = new ByteArrayOutputStream(); - ps = new PrintStream(errStream); - System.setOut(new PrintStream(outStream)); - System.setErr(ps); - - 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 { - email.addTo("email"); - email.addCC("email"); - email.log(ps, "email"); - email.addTo("emails"); - email.addCC("emails"); - email.log(ps, "emails"); - } - - @After - public void cleanUp() { - System.setErr(System.err); - System.setOut(System.out); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_EmailPrint.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_EmailPrint.java deleted file mode 100644 index fe87219b..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_EmailPrint.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * ============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.EmailPrint; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.org.Organization; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; - -import static org.mockito.Mockito.*; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.junit.Test; - -public class JU_EmailPrint { - - private ByteArrayOutputStream outStream; - private ByteArrayOutputStream errStream; - EmailPrint ePrint; - AuthzTrans trans; - Organization org; - StringBuilder strBuilder; - - @Before - public void setUp() { - outStream = new ByteArrayOutputStream(); - errStream = new ByteArrayOutputStream(); - System.setOut(new PrintStream(outStream)); - System.setErr(new PrintStream(errStream)); - ePrint = new EmailPrint(); - trans = mock(AuthzTrans.class); - org = mock(Organization.class); - strBuilder = new StringBuilder(); - strBuilder.append("test\nte\nst"); - ePrint.addTo("test"); - ePrint.addTo("test1"); - ePrint.addTo("test2"); - ePrint.addCC("test"); - ePrint.addCC("test1"); - ePrint.addCC("test2"); - - } - - @Test - public void testExec() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - Class c = ePrint.getClass(); - Class[] cArg = new Class[3]; - cArg[0] = AuthzTrans.class; - cArg[1] = Organization.class; - cArg[2] = StringBuilder.class;//Steps to test a protected method - Method execMethod = c.getDeclaredMethod("exec", cArg); - execMethod.setAccessible(true); - execMethod.invoke(ePrint, trans, org, strBuilder); - } - - @After - public void cleanUp() { - System.setErr(System.err); - System.setOut(System.out); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_FuturePrintTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_FuturePrintTest.java deleted file mode 100644 index 121bf48f..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_FuturePrintTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * ============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.assertEquals; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import java.util.Calendar; -import java.util.UUID; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.onap.aaf.auth.actions.FuturePrint; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.helpers.Future; -import org.onap.aaf.auth.layer.Result; -import org.onap.aaf.misc.env.LogTarget; - -public class JU_FuturePrintTest { - @Mock - private AuthzTrans trans; - @Mock - LogTarget target; - private Future future; - - @Before - public void setUp() throws Exception { - initMocks(this); - future = new Future(new UUID(1l, 1l), "memo", "target", Calendar.getInstance().getTime(), - Calendar.getInstance().getTime(), null); - when(trans.info()).thenReturn(target); - } - - @Test - public void testURFuturePrint() { - FuturePrint print = new FuturePrint("Info Text"); - assertEquals(Result.ok().status, print.exec(trans, future, "text").status); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Message.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Message.java deleted file mode 100644 index ada1dbae..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_Message.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * ============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.Message; - -import static org.mockito.Mockito.*; -import org.junit.Test; - -public class JU_Message { - - Message msg; - - @Before - public void setUp() { - msg = new Message(); - } - - @Test - public void testLine() { - msg.line("test"); - } - - @Test - public void testClear() { - msg.clear(); - } - - @Test - public void testMsg() { - StringBuilder sb = new StringBuilder(); - msg.line("test"); - msg.line("test1"); - msg.msg(sb, "indent"); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_URFuturePrintTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_URFuturePrintTest.java deleted file mode 100644 index 95406425..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_URFuturePrintTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * ============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.assertEquals; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import java.util.Calendar; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.onap.aaf.auth.actions.URFuturePrint; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.helpers.UserRole; -import org.onap.aaf.auth.layer.Result; -import org.onap.aaf.misc.env.LogTarget; - -public class JU_URFuturePrintTest { - @Mock - private AuthzTrans trans; - @Mock - LogTarget target; - - @Before - public void setUp() throws Exception { - initMocks(this); - when(trans.info()).thenReturn(target); - } - - @Test - public void testURFuturePrint() { - URFuturePrint print = new URFuturePrint("Info Text"); - UserRole ur = new UserRole("user", "ns", "rname", Calendar.getInstance().getTime()); - assertEquals(Result.ok().status, print.exec(trans, ur, "text").status); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_URPrintTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_URPrintTest.java deleted file mode 100644 index 1e99ec66..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_URPrintTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * ============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.assertEquals; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import java.util.Calendar; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.onap.aaf.auth.actions.URPrint; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.helpers.UserRole; -import org.onap.aaf.auth.layer.Result; -import org.onap.aaf.misc.env.LogTarget; - -public class JU_URPrintTest { - @Mock - private AuthzTrans trans; - @Mock - LogTarget target; - - @Before - public void setUp() throws Exception { - initMocks(this); - when(trans.info()).thenReturn(target); - } - - @Test - public void testURPrint() { - URPrint print = new URPrint("Info Text"); - UserRole ur = new UserRole("user", "ns", "rname", Calendar.getInstance().getTime()); - assertEquals(Result.ok().status, print.exec(trans, ur, "text").status); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_ActionDAO.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_ActionDAO.java new file mode 100644 index 00000000..9376da4b --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_ActionDAO.java @@ -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.batch.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.batch.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/batch/actions/test/JU_CredPrintTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_CredPrintTest.java new file mode 100644 index 00000000..ebb307c2 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_CredPrintTest.java @@ -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.batch.actions.test; + +import static org.junit.Assert.assertEquals; +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.batch.actions.CredPrint; +import org.onap.aaf.auth.dao.cass.CredDAO; +import org.onap.aaf.auth.dao.cass.CredDAO.Data; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.misc.env.LogTarget; + +public class JU_CredPrintTest { + + @Mock + private AuthzTrans trans; + private Data cred; + @Mock + LogTarget target; + + @Before + public void setUp() throws Exception { + initMocks(this); + when(trans.info()).thenReturn(target); + cred = new CredDAO.Data(); + cred.type = CredDAO.BASIC_AUTH; + } + + @Test + public void testCred() { + CredPrint print = new CredPrint("text"); + + Result result = print.exec(trans, cred, "text"); + + assertEquals(result.status, result.ok().status); + assertEquals(CredPrint.type(CredDAO.BASIC_AUTH), "OLD"); + assertEquals(CredPrint.type(CredDAO.BASIC_AUTH_SHA256), "U/P"); + assertEquals(CredPrint.type(CredDAO.CERT_SHA256_RSA), "Cert"); + assertEquals(CredPrint.type(0), "Unknown"); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Email.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Email.java new file mode 100644 index 00000000..3a170679 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Email.java @@ -0,0 +1,151 @@ +/** + * ============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.batch.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.batch.actions.Email; +import org.onap.aaf.auth.batch.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.ByteArrayOutputStream; +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 { + + private ByteArrayOutputStream outStream; + private ByteArrayOutputStream errStream; + Email email; + Identity usersI; + Message msg; + PrintStream ps; + + @Before + public void setUp() throws FileNotFoundException { + outStream = new ByteArrayOutputStream(); + errStream = new ByteArrayOutputStream(); + ps = new PrintStream(errStream); + System.setOut(new PrintStream(outStream)); + System.setErr(ps); + + 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 { + email.addTo("email"); + email.addCC("email"); + email.log(ps, "email"); + email.addTo("emails"); + email.addCC("emails"); + email.log(ps, "emails"); + } + + @After + public void cleanUp() { + System.setErr(System.err); + System.setOut(System.out); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_EmailPrint.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_EmailPrint.java new file mode 100644 index 00000000..64d02ee3 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_EmailPrint.java @@ -0,0 +1,92 @@ +/** + * ============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.batch.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.batch.actions.EmailPrint; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.org.Organization; +import org.onap.aaf.cadi.client.Future; +import org.onap.aaf.cadi.client.Rcli; + +import static org.mockito.Mockito.*; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.Test; + +public class JU_EmailPrint { + + private ByteArrayOutputStream outStream; + private ByteArrayOutputStream errStream; + EmailPrint ePrint; + AuthzTrans trans; + Organization org; + StringBuilder strBuilder; + + @Before + public void setUp() { + outStream = new ByteArrayOutputStream(); + errStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outStream)); + System.setErr(new PrintStream(errStream)); + ePrint = new EmailPrint(); + trans = mock(AuthzTrans.class); + org = mock(Organization.class); + strBuilder = new StringBuilder(); + strBuilder.append("test\nte\nst"); + ePrint.addTo("test"); + ePrint.addTo("test1"); + ePrint.addTo("test2"); + ePrint.addCC("test"); + ePrint.addCC("test1"); + ePrint.addCC("test2"); + + } + + @Test + public void testExec() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + Class c = ePrint.getClass(); + Class[] cArg = new Class[3]; + cArg[0] = AuthzTrans.class; + cArg[1] = Organization.class; + cArg[2] = StringBuilder.class;//Steps to test a protected method + Method execMethod = c.getDeclaredMethod("exec", cArg); + execMethod.setAccessible(true); + execMethod.invoke(ePrint, trans, org, strBuilder); + } + + @After + public void cleanUp() { + System.setErr(System.err); + System.setOut(System.out); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_FuturePrintTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_FuturePrintTest.java new file mode 100644 index 00000000..00542a2f --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_FuturePrintTest.java @@ -0,0 +1,61 @@ +/** + * ============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.batch.actions.test; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +import java.util.Calendar; +import java.util.UUID; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.onap.aaf.auth.batch.actions.FuturePrint; +import org.onap.aaf.auth.batch.helpers.Future; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.misc.env.LogTarget; + +public class JU_FuturePrintTest { + @Mock + private AuthzTrans trans; + @Mock + LogTarget target; + private Future future; + + @Before + public void setUp() throws Exception { + initMocks(this); + future = new Future(new UUID(1l, 1l), "memo", "target", Calendar.getInstance().getTime(), + Calendar.getInstance().getTime(), null); + when(trans.info()).thenReturn(target); + } + + @Test + public void testURFuturePrint() { + FuturePrint print = new FuturePrint("Info Text"); + assertEquals(Result.ok().status, print.exec(trans, future, "text").status); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Message.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Message.java new file mode 100644 index 00000000..86bab83e --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Message.java @@ -0,0 +1,62 @@ +/** + * ============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.batch.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.batch.actions.Message; + +import static org.mockito.Mockito.*; +import org.junit.Test; + +public class JU_Message { + + Message msg; + + @Before + public void setUp() { + msg = new Message(); + } + + @Test + public void testLine() { + msg.line("test"); + } + + @Test + public void testClear() { + msg.clear(); + } + + @Test + public void testMsg() { + StringBuilder sb = new StringBuilder(); + msg.line("test"); + msg.line("test1"); + msg.msg(sb, "indent"); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFuturePrintTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFuturePrintTest.java new file mode 100644 index 00000000..9f569d65 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFuturePrintTest.java @@ -0,0 +1,57 @@ +/** + * ============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.batch.actions.test; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +import java.util.Calendar; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.onap.aaf.auth.batch.actions.URFuturePrint; +import org.onap.aaf.auth.batch.helpers.UserRole; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.misc.env.LogTarget; + +public class JU_URFuturePrintTest { + @Mock + private AuthzTrans trans; + @Mock + LogTarget target; + + @Before + public void setUp() throws Exception { + initMocks(this); + when(trans.info()).thenReturn(target); + } + + @Test + public void testURFuturePrint() { + URFuturePrint print = new URFuturePrint("Info Text"); + UserRole ur = new UserRole("user", "ns", "rname", Calendar.getInstance().getTime()); + assertEquals(Result.ok().status, print.exec(trans, ur, "text").status); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URPrintTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URPrintTest.java new file mode 100644 index 00000000..8a037ece --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URPrintTest.java @@ -0,0 +1,58 @@ +/** + * ============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.batch.actions.test; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +import java.util.Calendar; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.onap.aaf.auth.batch.actions.URPrint; +import org.onap.aaf.auth.batch.helpers.UserRole; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.misc.env.LogTarget; + +public class JU_URPrintTest { + @Mock + private AuthzTrans trans; + @Mock + LogTarget target; + + @Before + public void setUp() throws Exception { + initMocks(this); + when(trans.info()).thenReturn(target); + } + + @Test + public void testURPrint() { + URPrint print = new URPrint("Info Text"); + UserRole ur = new UserRole("user", "ns", "rname", Calendar.getInstance().getTime()); + assertEquals(Result.ok().status, print.exec(trans, ur, "text").status); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/creators/RowCreator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/creators/RowCreator.java new file mode 100644 index 00000000..661105d3 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.batch.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 Set getSet(String name, TypeToken elementsType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Set getSet(String name, Class elementsClass) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getMap(String name, TypeToken keysType, TypeToken valuesType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getMap(String name, Class keysClass, Class valuesClass) { + // TODO Auto-generated method stub + return null; + } + + @Override + public long getLong(String name) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public List getList(String name, TypeToken elementsType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getList(String name, Class 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 get(String name, TypeCodec codec) { + // TODO Auto-generated method stub + return null; + } + + @Override + public T get(String name, TypeToken targetType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public T get(String name, Class 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 Set getSet(int i, TypeToken elementsType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Set getSet(int i, Class elementsClass) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getObject(int i) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getMap(int i, TypeToken keysType, TypeToken valuesType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getMap(int i, Class keysClass, Class valuesClass) { + // TODO Auto-generated method stub + return null; + } + + @Override + public long getLong(int i) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public List getList(int i, TypeToken elementsType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getList(int i, Class 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 get(int i, TypeCodec codec) { + // TODO Auto-generated method stub + return null; + } + + @Override + public T get(int i, TypeToken targetType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public T get(int i, Class 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/batch/helpers/test/JU_Approval.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Approval.java new file mode 100644 index 00000000..44c72763 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Approval.java @@ -0,0 +1,225 @@ +/** + * ============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.batch.helpers.test; + +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.onap.aaf.auth.batch.helpers.Approval; +import org.onap.aaf.auth.batch.helpers.creators.RowCreator; +import org.onap.aaf.auth.dao.cass.ApprovalDAO; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.misc.env.LogTarget; + +import junit.framework.Assert; + +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 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 list = new ArrayList(); + 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 rv = Result.ok(); + when(dao.delete(any(AuthzTrans.class), any(ApprovalDAO.Data.class), any(Boolean.class))).thenReturn(rv); + + List list = new ArrayList(); + 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 rv = Result.err(new Exception()); + when(dao.delete(any(AuthzTrans.class), any(ApprovalDAO.Data.class), any(Boolean.class))).thenReturn(rv); + + List list = new ArrayList(); + 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/batch/helpers/test/JU_Approver.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Approver.java new file mode 100644 index 00000000..bd498f58 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Approver.java @@ -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.batch.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.batch.actions.Message; +import org.onap.aaf.auth.batch.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/batch/helpers/test/JU_CacheChange.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_CacheChange.java new file mode 100644 index 00000000..27d2d3cc --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_CacheChange.java @@ -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.batch.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.batch.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); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Creator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Creator.java new file mode 100644 index 00000000..2a266f54 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Creator.java @@ -0,0 +1,72 @@ +/** + * ============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.batch.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.batch.helpers.Creator; + +import com.datastax.driver.core.Row; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; +import org.junit.Test; + +public class JU_Creator { + + CreatorStub creatorStub; + + private class CreatorStub extends Creator{ + + @Override + public Object create(Row row) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String select() { + // TODO Auto-generated method stub + return "Select"; //Changed from null to Select + } + + } + + @Before + public void setUp() { + creatorStub = new CreatorStub(); + } + + @Test + public void testQuery() { + creatorStub.select(); + Assert.assertEquals("Select WHERE test;", creatorStub.query("test")); + Assert.assertEquals("Select;", creatorStub.query(null)); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Cred.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Cred.java new file mode 100644 index 00000000..20831c66 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Cred.java @@ -0,0 +1,142 @@ +/** + * ============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.batch.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.batch.helpers.Cred; +import org.onap.aaf.auth.batch.helpers.Cred.CredCount; +import org.onap.aaf.auth.batch.helpers.Cred.Instance; +import org.onap.aaf.auth.common.Define; +import org.onap.aaf.cadi.CadiException; +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.misc.env.Trans; + +import com.datastax.driver.core.Session; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Date; + +import org.junit.Test; + +public class JU_Cred { + + private ByteArrayOutputStream outStream; + private ByteArrayOutputStream errStream; + Cred cred; + Instance instance; + Date date; + Integer integer; + PropAccess prop; + Define define = new Define(); + Trans trans; + Session session; + CredCount cc; + + @Before + public void setUp() throws CadiException { + outStream = new ByteArrayOutputStream(); + errStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outStream)); + System.setErr(new PrintStream(errStream)); + date = new Date(); + integer = new Integer(20); + trans = mock(Trans.class); + session = mock(Session.class); + cc = new CredCount(3); + prop = new PropAccess(); + prop.setProperty(Config.AAF_ROOT_NS, "org.onap.aaf"); + prop.setProperty(Config.AAF_ROOT_COMPANY,"test"); + define.set(prop); + + instance = new Instance(12, date, integer, 125642678910L); + cred = new Cred("myid1234@aaf.att.com"); + } + + @Test + public void testLast() { //TODO: set instances + Assert.assertNull(cred.last(null)); + } + + @Test + public void testTypes() { //TODO: set instances + Assert.assertNotNull(cred.types()); + } + + @Test + public void testCount() { //TODO: set instances + Assert.assertNotNull(cred.count(3)); + } + + @Test + public void testToString() { //TODO: set instances + Assert.assertEquals("myid1234@aaf.att.com[]", cred.toString()); + } + + @Test + public void testHashCode() { //TODO: set instances + Assert.assertEquals(-1619358251, cred.hashCode()); + } + + @Test + public void testEquals() { //TODO: set instances + Assert.assertEquals(true, cred.equals("myid1234@aaf.att.com")); + } + + @Test + public void testInc() { + Date begin = new Date(date.getTime() - 10); + Date after = new Date(date.getTime() + 10); + cc.inc(-1, begin, after); + cc.inc(1, begin, after); + cc.inc(2, begin, after); + cc.inc(200, begin, after); + } + + @Test + public void testAuthCount() { //TODO: set instances + Assert.assertEquals(0, cc.authCount(1)); + } + + @Test + public void testX509Count() { //TODO: set instances + Assert.assertEquals(0, cc.x509Count(0)); + } + + @After + public void cleanUp() { + System.setErr(System.err); + System.setOut(System.out); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_ExpireRange.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_ExpireRange.java new file mode 100644 index 00000000..4ed167e9 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_ExpireRange.java @@ -0,0 +1,71 @@ +/** + * ============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.batch.helpers.test; + +import static org.junit.Assert.*; + +import java.util.GregorianCalendar; +import java.util.Set; + +import org.junit.Test; +import org.onap.aaf.auth.batch.helpers.ExpireRange; +import org.onap.aaf.cadi.PropAccess; + +public class JU_ExpireRange { + @Test + public void test() { + ExpireRange expRange = new ExpireRange(new PropAccess()); + + Set names=expRange.names(); + assertTrue(names.contains("OneMonth")); + assertTrue(names.contains("CredOneWeek")); + assertTrue(names.contains("Delete")); + assertFalse(names.contains(null)); + assertFalse(names.contains("bogus")); + + ExpireRange.Range r; + GregorianCalendar gc = new GregorianCalendar(); + String[] all = new String[] {"ur","cred"}; + + // Test 3 weeks prior + gc.setTime(expRange.now); + gc.add(GregorianCalendar.WEEK_OF_MONTH,-3); + for(String rs : all) { + r = expRange.getRange(rs, gc.getTime()); + assertNotNull(r); + assertEquals("Delete",r.name()); + assertFalse(r.shouldContact(null)); + } + + // Test 1 week prior + gc.setTime(expRange.now); + gc.add(GregorianCalendar.WEEK_OF_MONTH,-1); + for(String rs : all) { + r = expRange.getRange(rs, gc.getTime()); + assertNull(r); + } + + // Test Today + r = expRange.getRange("cred", expRange.now); + assertNotNull(r); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Future.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Future.java new file mode 100644 index 00000000..91950c66 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Future.java @@ -0,0 +1,177 @@ +/** + * ============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.batch.helpers.test; + +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.batch.helpers.Creator; +import org.onap.aaf.auth.batch.helpers.Future; +import org.onap.aaf.auth.batch.helpers.creators.RowCreator; +import org.onap.aaf.auth.dao.cass.FutureDAO; +import org.onap.aaf.auth.env.AuthzTrans; +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)); + } + + @Test + public void testLoad() { + Session session = mock(Session.class); + Trans trans = mock(Trans.class); + @SuppressWarnings("unchecked") + Creator creator = (Creator)mock(Creator.class); + LogTarget target = mock(LogTarget.class); + TimeTaken tt = mock(TimeTaken.class); + ResultSet results = mock(ResultSet.class); + ArrayList rows = new ArrayList(); + 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/batch/helpers/test/JU_History.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_History.java new file mode 100644 index 00000000..beaaad31 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.batch.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.batch.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/batch/helpers/test/JU_InputIterator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_InputIterator.java new file mode 100644 index 00000000..f30ad3cc --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_InputIterator.java @@ -0,0 +1,76 @@ +/** + * ============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.batch.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.batch.helpers.InputIterator; + +import static org.mockito.Mockito.*; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintStream; +import java.io.Reader; + +import org.junit.Test; + +public class JU_InputIterator { + + InputIterator inputIterator; + File f; + BufferedReader bReader; + PrintStream pStream; + + @Before + public void setUp() throws IOException { + f = new File("file"); + f.createNewFile(); + bReader = new BufferedReader(new FileReader(f)); + pStream = new PrintStream(f); + inputIterator = new InputIterator(bReader, pStream, "prompt", "instructions"); + } + + @Test + public void test() { + inputIterator.iterator(); + inputIterator.iterator().hasNext(); + inputIterator.iterator().next(); + inputIterator.iterator().remove(); + } + + @After + public void cleanUp() { + if (f.exists()) { + f.delete(); + } + } +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MiscID.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MiscID.java new file mode 100644 index 00000000..d8a2682c --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MiscID.java @@ -0,0 +1,97 @@ +/** + * ============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.batch.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.batch.BatchException; +import org.onap.aaf.auth.batch.helpers.MiscID; + +import com.datastax.driver.core.Row; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; +import org.junit.Test; + +public class JU_MiscID { + + MiscID miscId; + + @Before + public void setUp() { + miscId = new MiscID(); + } + + @Test + public void testRowSet() { + Row row = mock(Row.class); + miscId.set(row); + } + + @Test + public void testStringSet() throws BatchException { + String[] strArr = {"id", "sponsor", "created", "renewal"}; + miscId.set(strArr); + } + + @Test + public void testHashcode() throws BatchException { + String[] strArr = {"id", "sponsor", "created", "renewal"}; + miscId.set(strArr); + Assert.assertEquals(3355, miscId.hashCode()); + } + + @Test + public void testEquals() throws BatchException { + String[] strArr = {"id", "sponsor", "created", "renewal"}; + miscId.set(strArr); + Assert.assertFalse(miscId.equals("id")); + Assert.assertTrue(miscId.equals(miscId)); + } + + @Test + public void testInsertStmt() throws IllegalArgumentException, IllegalAccessException { + String expected = "INSERT INTO authz.miscid (id,created,sponsor,renewal) VALUES ('null','null','null','null')"; + String result = miscId.insertStmt().toString(); + Assert.assertEquals(expected, result); + } + + @Test + public void testUpdateStmt() throws IllegalArgumentException, IllegalAccessException, BatchException { + String expected = "UPDATE authz.miscid SET sponser='sponsor1',created='created1',renewal='renewal1' WHERE id='id'"; + String[] strArr = {"id", "sponsor", "created", "renewal"}; + miscId.set(strArr); + MiscID miscId1 = new MiscID(); + String[] strArr1 = {"id", "sponsor1", "created1", "renewal1"}; + miscId1.set(strArr1); + StringBuilder result = miscId.updateStmt(miscId1); + + Assert.assertEquals(expected, result.toString()); + } + + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MonthData.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MonthData.java new file mode 100644 index 00000000..d9d9d018 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MonthData.java @@ -0,0 +1,105 @@ +/** + * ============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.batch.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.batch.helpers.MonthData; +import org.onap.aaf.auth.batch.helpers.MonthData.Row; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import org.junit.Test; + +public class JU_MonthData { + + File f; + MonthData mData; + Row row; + BufferedWriter bw = null; + FileWriter fw = null; + + @Before + public void setUp() throws IOException { + mData = new MonthData("env"); + row = new Row("target", 10,2,1); + f = new File("Monthlyenv.dat"); + f.createNewFile(); + bw = new BufferedWriter(new FileWriter(f)); + bw.write("#test"+ "\n"); + bw.write("long,tester"+ "\n"); + bw.write("1,2,3,4,5"+ "\n"); + bw.close(); + + mData = new MonthData("env"); + } + + @Test + public void testAdd() { + mData.add(2, "target", 10, 1, 1); + } + + @Test + public void testNotExists() { + mData.notExists(2); + } + + @Test + public void testWrite() throws IOException { + mData.write(); + } + + @Test + public void testCompareTo() { + Row testrow = new Row("testtar",1,1,1); + Assert.assertEquals(-4, row.compareTo(testrow)); + Assert.assertEquals(0, row.compareTo(row)); + } + + @Test + public void testToString() { + Assert.assertEquals("target|10|1|2", row.toString()); + } + + @After + public void cleanUp() { + File g = new File("Monthlyenv.dat.bak"); + if (f.exists()) { + f.delete(); + } + if (g.exists()) { + g.delete(); + } + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NS.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NS.java new file mode 100644 index 00000000..1208ba92 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NS.java @@ -0,0 +1,159 @@ +/** + * ============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.batch.helpers.test; + +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.onap.aaf.auth.batch.helpers.Creator; +import org.onap.aaf.auth.batch.helpers.NS; +import org.onap.aaf.auth.batch.helpers.NS.NSSplit; +import org.onap.aaf.auth.batch.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 com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.Row; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.SimpleStatement; + +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"); + } + + @Test + public void testLoadWithoutNS() { + Trans trans = mock(Trans.class); + Session session = mock(Session.class); + Creator creator = mock(Creator.class); + LogTarget target = mock(LogTarget.class); + TimeTaken tt = mock(TimeTaken.class); + ResultSet results = mock(ResultSet.class); + ArrayList rows = new ArrayList(); + 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 creator = mock(Creator.class); + LogTarget target = mock(LogTarget.class); + TimeTaken tt = mock(TimeTaken.class); + ResultSet results = mock(ResultSet.class); + ArrayList rows = new ArrayList(); + 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 rows = new ArrayList(); + 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/batch/helpers/test/JU_NsAttrib.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NsAttrib.java new file mode 100644 index 00000000..6df877fe --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NsAttrib.java @@ -0,0 +1,51 @@ +/** + * ============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.batch.helpers.test; + +import org.junit.Before; +import org.junit.Test; +import org.onap.aaf.auth.batch.helpers.NsAttrib; +import org.onap.aaf.auth.batch.helpers.creators.RowCreator; + +import junit.framework.Assert; + +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()); + } + + @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()); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Perm.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Perm.java new file mode 100644 index 00000000..10cbd359 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Perm.java @@ -0,0 +1,98 @@ +/** + * ============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.batch.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.batch.helpers.Perm; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.Test; + +public class JU_Perm { + + Perm perm; + Set set; + + @Before + public void setUp() { + set = new HashSet(); + perm = new Perm("ns","type", "instance", "action","description", set); + } + + @Test + public void testFullType() { + Assert.assertEquals("ns.type", perm.fullType()); + } + + @Test + public void testFullPerm() { + Assert.assertEquals("ns.type|instance|action", perm.fullPerm()); + } + + @Test + public void testEncode() { + Assert.assertEquals("ns|type|instance|action", perm.encode()); + } + + @Test + public void testHashCode() { + Assert.assertEquals(850667666, perm.hashCode()); + } + + @Test + public void testToString() { + Assert.assertEquals("ns|type|instance|action", perm.toString()); + } + + @Test + public void testEquals() { + Perm perm1 = new Perm("ns","type", "instance", "action","description", set); + Assert.assertEquals(false, perm.equals(perm1)); + } + + @Test + public void testCompareTo() { + Perm perm1 = new Perm("ns","type", "instance", "action","description", set); + Perm perm2 = new Perm("ns1","type", "instance", "action","description", set); + + Assert.assertEquals(0, perm.compareTo(perm1)); + Assert.assertEquals(75, perm.compareTo(perm2)); + } + + @Test + public void testStageRemove() { + Perm perm1 = new Perm("ns","type", "instance", "action","description", set); + perm.stageRemove(perm1); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Role.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Role.java new file mode 100644 index 00000000..250c7a10 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Role.java @@ -0,0 +1,94 @@ +/** + * ============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.batch.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.batch.helpers.Perm; +import org.onap.aaf.auth.batch.helpers.Role; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.Test; + +public class JU_Role { + + Role shortRole; + Role longRole; + Set set; + + @Before + public void setUp() { + set = new HashSet(); + shortRole = new Role("full"); + longRole = new Role("ns", "name", "description", set); + } + + @Test + public void testEncode() { + Assert.assertEquals("ns|name", longRole.encode()); + } + + @Test + public void testFullName() { + Assert.assertEquals("ns.name", longRole.fullName()); + Assert.assertEquals("full", shortRole.fullName()); + + longRole.fullName("test"); + } + + @Test + public void testToString() { + Assert.assertEquals("ns|name", longRole.toString()); + } + + @Test + public void testHashCode() { + Assert.assertEquals(-2043567518, longRole.hashCode()); + } + + @Test + public void testEquals() { + Assert.assertEquals(false, longRole.equals(longRole)); + } + + @Test + public void testCompareTo() { + Assert.assertEquals(-14, longRole.compareTo(shortRole)); + Assert.assertEquals(14, shortRole.compareTo(longRole)); + } + + @Test + public void testStageRemove() { + longRole.stageRemove(shortRole); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_UserRole.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_UserRole.java new file mode 100644 index 00000000..6b7011c6 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_UserRole.java @@ -0,0 +1,186 @@ +/** + * ============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.batch.helpers.test; + +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.io.PrintStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.onap.aaf.auth.batch.actions.URDelete; +import org.onap.aaf.auth.batch.helpers.Creator; +import org.onap.aaf.auth.batch.helpers.UserRole; +import org.onap.aaf.auth.batch.helpers.creators.RowCreator; +import org.onap.aaf.auth.dao.cass.UserRoleDAO; +import org.onap.aaf.auth.env.AuthzTrans; +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; + +import junit.framework.Assert; + +public class JU_UserRole { + + UserRole userRole; + UserRole userRole1; + Date date; + PrintStream ds; + + @Before + public void setUp() { + date = new Date(); + userRole = new UserRole("user", "ns", "rname", date); + userRole = new UserRole("user", "role", "ns", "rname", date); + } + + @Test + public void testTotalLoaded() { + Assert.assertEquals(0, userRole.totalLoaded()); + } + + @Test + public void testDeleted() { + Assert.assertEquals(0, userRole.deleted()); + } + + @Test + public void testExpunge() { + userRole.expunge(); + } + + @Test + public void testSetDeleteStream() { + userRole.setDeleteStream(ds); + } + + @Test + public void testSetRecoverStream() { + userRole.setRecoverStream(ds); + } + + @Test + public void testUrdd() { + Assert.assertTrue(userRole.urdd() instanceof UserRoleDAO.Data); + } + + @Test + public void testUser() { + Assert.assertEquals("user", userRole.user()); + } + + @Test + public void testRole() { + Assert.assertEquals("role", userRole.role()); + } + + @Test + public void testNs() { + Assert.assertEquals("ns", userRole.ns()); + } + + @Test + public void testRName() { + Assert.assertEquals("rname", userRole.rname()); + } + + @Test + public void testExpires() { + Assert.assertEquals(date, userRole.expires()); + userRole.expires(date); + } + + @Test + public void testToString() { + Assert.assertTrue(userRole.toString() instanceof String); + } + + @Test + public void testGet() { + userRole.get("u", "r"); + } + + @Test + public void testResetLocalData() { + userRole.resetLocalData(); + } + + @Test + public void testSizeForDeletion() { + Assert.assertEquals(0, userRole.sizeForDeletion()); + } + + @Test + public void testPendingDelete() { + Assert.assertFalse(userRole.pendingDelete(userRole)); + } + + @Test + public void testActuateDeletionNow() { + AuthzTrans trans = mock(AuthzTrans.class); + URDelete urd = mock(URDelete.class); + userRole.actuateDeletionNow(trans, urd); + } + + @Test + public void testV2() { + UserRole.v2_0_11.create(RowCreator.getRow()); + assertEquals("select user,role,ns,rname,expires from authz.user_role", UserRole.v2_0_11.select()); + } + + @Test + public void testLoad() { + Creator creator = mock(Creator.class); + 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); + + List rows = new ArrayList(); + + when(trans.info()).thenReturn(target); + when(trans.start("Read UserRoles", Env.REMOTE)).thenReturn(tt); + when(trans.start("Load UserRole", Env.SUB)).thenReturn(tt); + when(session.execute(any(SimpleStatement.class))).thenReturn(results); + when(results.iterator()).thenReturn(rows.iterator()); + + List list = new ArrayList(); + list.add(RowCreator.getRow()); + list.add(RowCreator.getRow()); + + UserRole.load(trans, session, creator, new UserRole.DataLoadVisitor()); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_Batch.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_Batch.java new file mode 100644 index 00000000..1ef6f3b8 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_Batch.java @@ -0,0 +1,92 @@ +/** + * ============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.batch.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.batch.Batch; +import org.onap.aaf.auth.env.AuthzEnv; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.org.Organization; +import org.onap.aaf.auth.org.OrganizationException; +import org.onap.aaf.auth.org.OrganizationFactory; +import org.onap.aaf.cadi.client.Future; +import org.onap.aaf.cadi.client.Rcli; +import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.misc.env.APIException; + +import static org.mockito.Mockito.*; + +import java.io.IOException; + +import org.junit.Test; + +public class JU_Batch { + + AuthzEnv env; + Batch batch; + + private class BatchStub extends Batch { + + protected BatchStub(AuthzEnv env) throws APIException, IOException, OrganizationException { + super(env); + // TODO Auto-generated constructor stub + } + + @Override + protected void run(AuthzTrans trans) { + // TODO Auto-generated method stub + + } + + @Override + protected void _close(AuthzTrans trans) { + // TODO Auto-generated method stub + + } + + } + + @Before + public void setUp() throws OrganizationException { + env = new AuthzEnv(); + env.access().setProperty(Config.CADI_LATITUDE, "38.550674"); + env.access().setProperty(Config.CADI_LONGITUDE, "-90.146942"); + env.setProperty("DRY_RUN", "test"); + env.setProperty("Organization.@aaf.com", "test"); + //env.setProperty("Organization.com.@aaf", "java.lang.Integer"); + env.setProperty("Organization.com.@aaf", "org.onap.aaf.auth.org.Organization"); + env.setProperty("CASS_ENV", "test"); + env.setProperty("test.VERSION", "test.VERSION"); + } + + @Test + public void testIsSpecial() throws APIException, IOException, OrganizationException { + //BatchStub bStub = new BatchStub(env); + //bStub.isSpecial("user"); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_BatchException.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_BatchException.java new file mode 100644 index 00000000..47a7c278 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_BatchException.java @@ -0,0 +1,59 @@ +/** + * ============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.batch.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.batch.BatchException; + +import static org.mockito.Mockito.*; +import org.junit.Test; + +public class JU_BatchException { + + BatchException bExcept1; + BatchException bExcept2; + BatchException bExcept3; + BatchException bExcept4; + BatchException bExcept5; + Throwable throwable; + + @Before + public void setUp() { + throwable = new Throwable(); + } + + @Test + public void testBatchException() { + bExcept1 = new BatchException(); + bExcept2 = new BatchException("test"); + bExcept3 = new BatchException(throwable); + bExcept4 = new BatchException("test", throwable); + bExcept5 = new BatchException("test", throwable,true,true); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_BatchPrincipal.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_BatchPrincipal.java new file mode 100644 index 00000000..4e5ad675 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_BatchPrincipal.java @@ -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.batch.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.batch.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"); + Assert.assertEquals("batch:name", bPrincipal.getName()); + Assert.assertEquals("Btch", bPrincipal.tag()); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_CassBatch.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_CassBatch.java new file mode 100644 index 00000000..dfb30819 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_CassBatch.java @@ -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.batch.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.batch.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 + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_NotificationTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_NotificationTest.java new file mode 100644 index 00000000..79e4168e --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/test/JU_NotificationTest.java @@ -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.batch.test; + +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.batch.actions.Message; +import org.onap.aaf.auth.batch.helpers.Creator; +import org.onap.aaf.auth.batch.helpers.Notification; +import org.onap.aaf.auth.batch.helpers.Notification.TYPE; +import org.onap.aaf.auth.batch.helpers.creators.RowCreator; +import org.onap.aaf.auth.env.AuthzTrans; +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 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/JU_NotificationTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/JU_NotificationTest.java deleted file mode 100644 index d3a1258d..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/JU_NotificationTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * ============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 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 deleted file mode 100644 index 078c383b..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/creators/RowCreator.java +++ /dev/null @@ -1,434 +0,0 @@ -/** - * ============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 Set getSet(String name, TypeToken elementsType) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set getSet(String name, Class elementsClass) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object getObject(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getMap(String name, TypeToken keysType, TypeToken valuesType) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getMap(String name, Class keysClass, Class valuesClass) { - // TODO Auto-generated method stub - return null; - } - - @Override - public long getLong(String name) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public List getList(String name, TypeToken elementsType) { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getList(String name, Class 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 get(String name, TypeCodec codec) { - // TODO Auto-generated method stub - return null; - } - - @Override - public T get(String name, TypeToken targetType) { - // TODO Auto-generated method stub - return null; - } - - @Override - public T get(String name, Class 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 Set getSet(int i, TypeToken elementsType) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set getSet(int i, Class elementsClass) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object getObject(int i) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getMap(int i, TypeToken keysType, TypeToken valuesType) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getMap(int i, Class keysClass, Class valuesClass) { - // TODO Auto-generated method stub - return null; - } - - @Override - public long getLong(int i) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public List getList(int i, TypeToken elementsType) { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getList(int i, Class 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 get(int i, TypeCodec codec) { - // TODO Auto-generated method stub - return null; - } - - @Override - public T get(int i, TypeToken targetType) { - // TODO Auto-generated method stub - return null; - } - - @Override - public T get(int i, Class 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 deleted file mode 100644 index 6020dcc0..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approval.java +++ /dev/null @@ -1,225 +0,0 @@ -/** - * ============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.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.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; - -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 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 list = new ArrayList(); - 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 rv = Result.ok(); - when(dao.delete(any(AuthzTrans.class), any(ApprovalDAO.Data.class), any(Boolean.class))).thenReturn(rv); - - List list = new ArrayList(); - 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 rv = Result.err(new Exception()); - when(dao.delete(any(AuthzTrans.class), any(ApprovalDAO.Data.class), any(Boolean.class))).thenReturn(rv); - - List list = new ArrayList(); - 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_Approver.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java deleted file mode 100644 index b4ae1213..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * ============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 deleted file mode 100644 index fc934e6c..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_CacheChange.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * ============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); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Creator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Creator.java deleted file mode 100644 index ad4d2022..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Creator.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * ============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.Creator; - -import com.datastax.driver.core.Row; - -import junit.framework.Assert; - -import static org.mockito.Mockito.*; -import org.junit.Test; - -public class JU_Creator { - - CreatorStub creatorStub; - - private class CreatorStub extends Creator{ - - @Override - public Object create(Row row) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String select() { - // TODO Auto-generated method stub - return "Select"; //Changed from null to Select - } - - } - - @Before - public void setUp() { - creatorStub = new CreatorStub(); - } - - @Test - public void testQuery() { - creatorStub.select(); - Assert.assertEquals("Select WHERE test;", creatorStub.query("test")); - Assert.assertEquals("Select;", creatorStub.query(null)); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Cred.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Cred.java deleted file mode 100644 index 35a63059..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Cred.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * ============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.common.Define; -import org.onap.aaf.auth.helpers.Cred; -import org.onap.aaf.auth.helpers.Cred.CredCount; -import org.onap.aaf.auth.helpers.Cred.Instance; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.misc.env.Trans; - -import com.datastax.driver.core.Session; - -import junit.framework.Assert; - -import static org.mockito.Mockito.*; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.Date; - -import org.junit.Test; - -public class JU_Cred { - - private ByteArrayOutputStream outStream; - private ByteArrayOutputStream errStream; - Cred cred; - Instance instance; - Date date; - Integer integer; - PropAccess prop; - Define define = new Define(); - Trans trans; - Session session; - CredCount cc; - - @Before - public void setUp() throws CadiException { - outStream = new ByteArrayOutputStream(); - errStream = new ByteArrayOutputStream(); - System.setOut(new PrintStream(outStream)); - System.setErr(new PrintStream(errStream)); - date = new Date(); - integer = new Integer(20); - trans = mock(Trans.class); - session = mock(Session.class); - cc = new CredCount(3); - prop = new PropAccess(); - prop.setProperty(Config.AAF_ROOT_NS, "org.onap.aaf"); - prop.setProperty(Config.AAF_ROOT_COMPANY,"test"); - define.set(prop); - - instance = new Instance(12, date, integer, 125642678910L); - cred = new Cred("myid1234@aaf.att.com"); - } - - @Test - public void testLast() { //TODO: set instances - Assert.assertNull(cred.last(null)); - } - - @Test - public void testTypes() { //TODO: set instances - Assert.assertNotNull(cred.types()); - } - - @Test - public void testCount() { //TODO: set instances - Assert.assertNotNull(cred.count(3)); - } - - @Test - public void testToString() { //TODO: set instances - Assert.assertEquals("myid1234@aaf.att.com[]", cred.toString()); - } - - @Test - public void testHashCode() { //TODO: set instances - Assert.assertEquals(-1619358251, cred.hashCode()); - } - - @Test - public void testEquals() { //TODO: set instances - Assert.assertEquals(true, cred.equals("myid1234@aaf.att.com")); - } - - @Test - public void testInc() { - Date begin = new Date(date.getTime() - 10); - Date after = new Date(date.getTime() + 10); - cc.inc(-1, begin, after); - cc.inc(1, begin, after); - cc.inc(2, begin, after); - cc.inc(200, begin, after); - } - - @Test - public void testAuthCount() { //TODO: set instances - Assert.assertEquals(0, cc.authCount(1)); - } - - @Test - public void testX509Count() { //TODO: set instances - Assert.assertEquals(0, cc.x509Count(0)); - } - - @After - public void cleanUp() { - System.setErr(System.err); - System.setOut(System.out); - } - -} 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 deleted file mode 100644 index fe3d5d95..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Future.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * ============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.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)); - } - - @Test - public void testLoad() { - Session session = mock(Session.class); - Trans trans = mock(Trans.class); - @SuppressWarnings("unchecked") - Creator creator = (Creator)mock(Creator.class); - LogTarget target = mock(LogTarget.class); - TimeTaken tt = mock(TimeTaken.class); - ResultSet results = mock(ResultSet.class); - ArrayList rows = new ArrayList(); - 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_History.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_History.java deleted file mode 100644 index 3346f229..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_History.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * ============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_InputIterator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_InputIterator.java deleted file mode 100644 index 07fd65f0..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_InputIterator.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * ============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.InputIterator; - -import static org.mockito.Mockito.*; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintStream; -import java.io.Reader; - -import org.junit.Test; - -public class JU_InputIterator { - - InputIterator inputIterator; - File f; - BufferedReader bReader; - PrintStream pStream; - - @Before - public void setUp() throws IOException { - f = new File("file"); - f.createNewFile(); - bReader = new BufferedReader(new FileReader(f)); - pStream = new PrintStream(f); - inputIterator = new InputIterator(bReader, pStream, "prompt", "instructions"); - } - - @Test - public void test() { - inputIterator.iterator(); - inputIterator.iterator().hasNext(); - inputIterator.iterator().next(); - inputIterator.iterator().remove(); - } - - @After - public void cleanUp() { - if (f.exists()) { - f.delete(); - } - } -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MiscID.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MiscID.java deleted file mode 100644 index 6f44b391..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MiscID.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * ============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.BatchException; -import org.onap.aaf.auth.helpers.MiscID; - -import com.datastax.driver.core.Row; - -import junit.framework.Assert; - -import static org.mockito.Mockito.*; -import org.junit.Test; - -public class JU_MiscID { - - MiscID miscId; - - @Before - public void setUp() { - miscId = new MiscID(); - } - - @Test - public void testRowSet() { - Row row = mock(Row.class); - miscId.set(row); - } - - @Test - public void testStringSet() throws BatchException { - String[] strArr = {"id", "sponsor", "created", "renewal"}; - miscId.set(strArr); - } - - @Test - public void testHashcode() throws BatchException { - String[] strArr = {"id", "sponsor", "created", "renewal"}; - miscId.set(strArr); - Assert.assertEquals(3355, miscId.hashCode()); - } - - @Test - public void testEquals() throws BatchException { - String[] strArr = {"id", "sponsor", "created", "renewal"}; - miscId.set(strArr); - Assert.assertFalse(miscId.equals("id")); - Assert.assertTrue(miscId.equals(miscId)); - } - - @Test - public void testInsertStmt() throws IllegalArgumentException, IllegalAccessException { - String expected = "INSERT INTO authz.miscid (id,created,sponsor,renewal) VALUES ('null','null','null','null')"; - String result = miscId.insertStmt().toString(); - Assert.assertEquals(expected, result); - } - - @Test - public void testUpdateStmt() throws IllegalArgumentException, IllegalAccessException, BatchException { - String expected = "UPDATE authz.miscid SET sponser='sponsor1',created='created1',renewal='renewal1' WHERE id='id'"; - String[] strArr = {"id", "sponsor", "created", "renewal"}; - miscId.set(strArr); - MiscID miscId1 = new MiscID(); - String[] strArr1 = {"id", "sponsor1", "created1", "renewal1"}; - miscId1.set(strArr1); - StringBuilder result = miscId.updateStmt(miscId1); - - Assert.assertEquals(expected, result.toString()); - } - - -} 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 deleted file mode 100644 index 97b6c56b..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * ============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.MonthData; -import org.onap.aaf.auth.helpers.MonthData.Row; - -import junit.framework.Assert; - -import static org.mockito.Mockito.*; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import org.junit.Test; - -public class JU_MonthData { - - File f; - MonthData mData; - Row row; - BufferedWriter bw = null; - FileWriter fw = null; - - @Before - public void setUp() throws IOException { - mData = new MonthData("env"); - row = new Row("target", 10,2,1); - f = new File("Monthlyenv.dat"); - f.createNewFile(); - bw = new BufferedWriter(new FileWriter(f)); - bw.write("#test"+ "\n"); - bw.write("long,tester"+ "\n"); - bw.write("1,2,3,4,5"+ "\n"); - bw.close(); - - mData = new MonthData("env"); - } - - @Test - public void testAdd() { - mData.add(2, "target", 10, 1, 1); - } - - @Test - public void testNotExists() { - mData.notExists(2); - } - - @Test - public void testWrite() throws IOException { - mData.write(); - } - - @Test - public void testCompareTo() { - Row testrow = new Row("testtar",1,1,1); - Assert.assertEquals(-4, row.compareTo(testrow)); - Assert.assertEquals(0, row.compareTo(row)); - } - - @Test - public void testToString() { - Assert.assertEquals("target|10|1|2", row.toString()); - } - - @After - public void cleanUp() { - File g = new File("Monthlyenv.dat.bak"); - if (f.exists()) { - f.delete(); - } - if (g.exists()) { - g.delete(); - } - } - -} 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 deleted file mode 100644 index b69f8873..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NS.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * ============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.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.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 com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.SimpleStatement; - -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"); - } - - @Test - public void testLoadWithoutNS() { - Trans trans = mock(Trans.class); - Session session = mock(Session.class); - Creator creator = mock(Creator.class); - LogTarget target = mock(LogTarget.class); - TimeTaken tt = mock(TimeTaken.class); - ResultSet results = mock(ResultSet.class); - ArrayList rows = new ArrayList(); - 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 creator = mock(Creator.class); - LogTarget target = mock(LogTarget.class); - TimeTaken tt = mock(TimeTaken.class); - ResultSet results = mock(ResultSet.class); - ArrayList rows = new ArrayList(); - 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 rows = new ArrayList(); - 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 deleted file mode 100644 index acf9b478..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_NsAttrib.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * ============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 org.junit.Before; -import org.junit.Test; -import org.onap.aaf.auth.helpers.NsAttrib; -import org.onap.aaf.auth.helpers.creators.RowCreator; - -import junit.framework.Assert; - -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()); - } - - @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()); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Perm.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Perm.java deleted file mode 100644 index 0ccc77a2..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Perm.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * ============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.Perm; - -import junit.framework.Assert; - -import static org.mockito.Mockito.*; - -import java.util.HashSet; -import java.util.Set; - -import org.junit.Test; - -public class JU_Perm { - - Perm perm; - Set set; - - @Before - public void setUp() { - set = new HashSet(); - perm = new Perm("ns","type", "instance", "action","description", set); - } - - @Test - public void testFullType() { - Assert.assertEquals("ns.type", perm.fullType()); - } - - @Test - public void testFullPerm() { - Assert.assertEquals("ns.type|instance|action", perm.fullPerm()); - } - - @Test - public void testEncode() { - Assert.assertEquals("ns|type|instance|action", perm.encode()); - } - - @Test - public void testHashCode() { - Assert.assertEquals(850667666, perm.hashCode()); - } - - @Test - public void testToString() { - Assert.assertEquals("ns|type|instance|action", perm.toString()); - } - - @Test - public void testEquals() { - Perm perm1 = new Perm("ns","type", "instance", "action","description", set); - Assert.assertEquals(false, perm.equals(perm1)); - } - - @Test - public void testCompareTo() { - Perm perm1 = new Perm("ns","type", "instance", "action","description", set); - Perm perm2 = new Perm("ns1","type", "instance", "action","description", set); - - Assert.assertEquals(0, perm.compareTo(perm1)); - Assert.assertEquals(75, perm.compareTo(perm2)); - } - - @Test - public void testStageRemove() { - Perm perm1 = new Perm("ns","type", "instance", "action","description", set); - perm.stageRemove(perm1); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Role.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Role.java deleted file mode 100644 index 3fd9f870..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Role.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * ============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.Perm; -import org.onap.aaf.auth.helpers.Role; - -import junit.framework.Assert; - -import static org.mockito.Mockito.*; - -import java.util.HashSet; -import java.util.Set; - -import org.junit.Test; - -public class JU_Role { - - Role shortRole; - Role longRole; - Set set; - - @Before - public void setUp() { - set = new HashSet(); - shortRole = new Role("full"); - longRole = new Role("ns", "name", "description", set); - } - - @Test - public void testEncode() { - Assert.assertEquals("ns|name", longRole.encode()); - } - - @Test - public void testFullName() { - Assert.assertEquals("ns.name", longRole.fullName()); - Assert.assertEquals("full", shortRole.fullName()); - - longRole.fullName("test"); - } - - @Test - public void testToString() { - Assert.assertEquals("ns|name", longRole.toString()); - } - - @Test - public void testHashCode() { - Assert.assertEquals(-2043567518, longRole.hashCode()); - } - - @Test - public void testEquals() { - Assert.assertEquals(false, longRole.equals(longRole)); - } - - @Test - public void testCompareTo() { - Assert.assertEquals(-14, longRole.compareTo(shortRole)); - Assert.assertEquals(14, shortRole.compareTo(longRole)); - } - - @Test - public void testStageRemove() { - longRole.stageRemove(shortRole); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_UserRole.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_UserRole.java deleted file mode 100644 index b20f9ded..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_UserRole.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * ============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.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.onap.aaf.auth.actions.URDelete; -import org.onap.aaf.auth.dao.cass.UserRoleDAO; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.helpers.Creator; -import org.onap.aaf.auth.helpers.UserRole; -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 com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.SimpleStatement; - -import junit.framework.Assert; - -public class JU_UserRole { - - UserRole userRole; - UserRole userRole1; - Date date; - PrintStream ds; - - @Before - public void setUp() { - date = new Date(); - userRole = new UserRole("user", "ns", "rname", date); - userRole = new UserRole("user", "role", "ns", "rname", date); - } - - @Test - public void testTotalLoaded() { - Assert.assertEquals(0, userRole.totalLoaded()); - } - - @Test - public void testDeleted() { - Assert.assertEquals(0, userRole.deleted()); - } - - @Test - public void testExpunge() { - userRole.expunge(); - } - - @Test - public void testSetDeleteStream() { - userRole.setDeleteStream(ds); - } - - @Test - public void testSetRecoverStream() { - userRole.setRecoverStream(ds); - } - - @Test - public void testUrdd() { - Assert.assertTrue(userRole.urdd() instanceof UserRoleDAO.Data); - } - - @Test - public void testUser() { - Assert.assertEquals("user", userRole.user()); - } - - @Test - public void testRole() { - Assert.assertEquals("role", userRole.role()); - } - - @Test - public void testNs() { - Assert.assertEquals("ns", userRole.ns()); - } - - @Test - public void testRName() { - Assert.assertEquals("rname", userRole.rname()); - } - - @Test - public void testExpires() { - Assert.assertEquals(date, userRole.expires()); - userRole.expires(date); - } - - @Test - public void testToString() { - Assert.assertTrue(userRole.toString() instanceof String); - } - - @Test - public void testGet() { - userRole.get("u", "r"); - } - - @Test - public void testResetLocalData() { - userRole.resetLocalData(); - } - - @Test - public void testSizeForDeletion() { - Assert.assertEquals(0, userRole.sizeForDeletion()); - } - - @Test - public void testPendingDelete() { - Assert.assertFalse(userRole.pendingDelete(userRole)); - } - - @Test - public void testActuateDeletionNow() { - AuthzTrans trans = mock(AuthzTrans.class); - URDelete urd = mock(URDelete.class); - userRole.actuateDeletionNow(trans, urd); - } - - @Test - public void testV2() { - UserRole.v2_0_11.create(RowCreator.getRow()); - assertEquals("select user,role,ns,rname,expires from authz.user_role", UserRole.v2_0_11.select()); - } - - @Test - public void testLoad() { - Creator creator = mock(Creator.class); - 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); - - List rows = new ArrayList(); - - when(trans.info()).thenReturn(target); - when(trans.start("Read UserRoles", Env.REMOTE)).thenReturn(tt); - when(trans.start("Load UserRole", Env.SUB)).thenReturn(tt); - when(session.execute(any(SimpleStatement.class))).thenReturn(results); - when(results.iterator()).thenReturn(rows.iterator()); - - List list = new ArrayList(); - list.add(RowCreator.getRow()); - list.add(RowCreator.getRow()); - - UserRole.load(trans, session, creator, new UserRole.DataLoadVisitor()); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_Batch.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_Batch.java deleted file mode 100644 index 5394c323..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_Batch.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * ============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.Batch; -import org.onap.aaf.auth.env.AuthzEnv; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.org.Organization; -import org.onap.aaf.auth.org.OrganizationException; -import org.onap.aaf.auth.org.OrganizationFactory; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.misc.env.APIException; - -import static org.mockito.Mockito.*; - -import java.io.IOException; - -import org.junit.Test; - -public class JU_Batch { - - AuthzEnv env; - Batch batch; - - private class BatchStub extends Batch { - - protected BatchStub(AuthzEnv env) throws APIException, IOException, OrganizationException { - super(env); - // TODO Auto-generated constructor stub - } - - @Override - protected void run(AuthzTrans trans) { - // TODO Auto-generated method stub - - } - - @Override - protected void _close(AuthzTrans trans) { - // TODO Auto-generated method stub - - } - - } - - @Before - public void setUp() throws OrganizationException { - env = new AuthzEnv(); - env.access().setProperty(Config.CADI_LATITUDE, "38.550674"); - env.access().setProperty(Config.CADI_LONGITUDE, "-90.146942"); - env.setProperty("DRY_RUN", "test"); - env.setProperty("Organization.@aaf.com", "test"); - //env.setProperty("Organization.com.@aaf", "java.lang.Integer"); - env.setProperty("Organization.com.@aaf", "org.onap.aaf.auth.org.Organization"); - env.setProperty("CASS_ENV", "test"); - env.setProperty("test.VERSION", "test.VERSION"); - } - - @Test - public void testIsSpecial() throws APIException, IOException, OrganizationException { - //BatchStub bStub = new BatchStub(env); - //bStub.isSpecial("user"); - } - -} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java deleted file mode 100644 index c56a76c8..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * ============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.BatchException; - -import static org.mockito.Mockito.*; -import org.junit.Test; - -public class JU_BatchException { - - BatchException bExcept1; - BatchException bExcept2; - BatchException bExcept3; - BatchException bExcept4; - BatchException bExcept5; - Throwable throwable; - - @Before - public void setUp() { - throwable = new Throwable(); - } - - @Test - public void testBatchException() { - bExcept1 = new BatchException(); - bExcept2 = new BatchException("test"); - bExcept3 = new BatchException(throwable); - bExcept4 = new BatchException("test", throwable); - bExcept5 = new BatchException("test", throwable,true,true); - } - -} 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 deleted file mode 100644 index 6186df95..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * ============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"); - Assert.assertEquals("batch:name", bPrincipal.getName()); - Assert.assertEquals("Btch", 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 deleted file mode 100644 index d1934a42..00000000 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_CassBatch.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * ============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 - } - -} -- cgit 1.2.3-korg