summaryrefslogtreecommitdiffstats
path: root/auth/auth-batch/src/test
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-03-22 14:13:22 -0500
committerInstrumental <jonathan.gathman@att.com>2019-03-22 14:14:25 -0500
commitd86e3224e6a5af2bd2b713f93bea5e6677d3ebc2 (patch)
treee348a186ae270463024c1b3d44113a08135ca957 /auth/auth-batch/src/test
parente3163b2d5609753f874e2f52fd5ef67fa063af7a (diff)
Batch, Remove unneeded Classes, refine, etc
Issue-ID: AAF-789 Change-Id: I48b39bb79144b20dfac5ff61e41ea4f0035b8442 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-batch/src/test')
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_ActionDAO.java171
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_CacheTouch.java124
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_CredPrintTest.java67
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Email.java151
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_EmailPrint.java92
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_FuturePrintTest.java61
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_Message.java62
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_RoleCreate.java249
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_RoleDeleteTest.java249
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URAdd.java246
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URDelete.java246
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFutureApproveExec.java264
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFuturePrintTest.java57
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URModify.java281
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URPrintTest.java58
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URPunt.java246
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Approver.java65
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_ExpireRange.java1
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_History.java68
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_InputIterator.java76
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MonthData.java105
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NsAttrib.java51
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Perm.java98
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_Role.java15
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_UserRole.java21
25 files changed, 3 insertions, 3121 deletions
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
deleted file mode 100644
index 39743896..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_ActionDAO.java
+++ /dev/null
@@ -1,171 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.util.Properties;
-
-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.common.Define;
-import org.onap.aaf.auth.dao.hl.Function;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-public class JU_ActionDAO {
-
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- ActionDAO actionObj;
-
- 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 {
- initMocks(this);
- Session sessionObj=Mockito.mock(Session.class);
- PreparedStatement psObj =Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(),Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Define.set(access);
- actionObj = new ActionDAOStub(trans, cluster, true);
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-// 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);
- }
-
- @Test
- public void testGetSession() {
- try {
- Session session = actionObj.getSession(trans);
- assertTrue(session.toString().contains("Mock for Session"));
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testQuestion() {
- Question retVal = actionObj.question();
- assertTrue(retVal.toString().contains("org.onap.aaf.auth.dao.hl.Question"));
- }
-
- @Test
- public void testFunction() {
- Function retVal = actionObj.function();
- assertTrue(retVal.toString().contains("org.onap.aaf.auth.dao.hl.Function"));
- }
-
- @Test
- public void testClose() {
- actionObj.close(trans);
-// assertTrue(session.toString().contains("Mock for Session"));
- }
-
- @Test
- public void testCloseFalse() {
- actionObj = new ActionDAOStub(trans, Mockito.mock(ActionDAO.class));
- actionObj.close(trans);
-// assertTrue(session.toString().contains("Mock for Session"));
- }
-
-}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_CacheTouch.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_CacheTouch.java
deleted file mode 100644
index 99e11a5a..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_CacheTouch.java
+++ /dev/null
@@ -1,124 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.util.Properties;
-
-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.batch.actions.CacheTouch;
-import org.onap.aaf.auth.common.Define;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-public class JU_CacheTouch {
-
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- CacheTouch actionObj;
-
-
- @Before
- public void setUp() throws APIException, IOException {
- initMocks(this);
- Session sessionObj=Mockito.mock(Session.class);
- PreparedStatement psObj =Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(),Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Define.set(access);
- actionObj = new CacheTouch(trans, cluster, true);
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExec() {
- Result<Void> session = actionObj.exec(trans,"test","test");
- assertTrue(session.toString().contains("Success"));
-
- }
- @Test
- public void testExecElse() {
- try {
- actionObj = new CacheTouch(trans, cluster, false);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Result<Void> session = actionObj.exec(trans,"test","test");
- assertTrue(session.toString().contains("No Cache Data named test"));
-
- }
-
- @Test
- public void test2Argonstructor() {
- actionObj = new CacheTouch(trans, Mockito.mock(ActionDAO.class));
-
-
- }
-
-}
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
deleted file mode 100644
index ebb307c2..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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<Void> 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
deleted file mode 100644
index 3a170679..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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
deleted file mode 100644
index 64d02ee3..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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
deleted file mode 100644
index 00542a2f..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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
deleted file mode 100644
index 86bab83e..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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_RoleCreate.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_RoleCreate.java
deleted file mode 100644
index cf563fdf..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_RoleCreate.java
+++ /dev/null
@@ -1,249 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-
-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.batch.actions.RoleCreate;
-import org.onap.aaf.auth.batch.helpers.Role;
-import org.onap.aaf.auth.batch.helpers.UserRole;
-import org.onap.aaf.auth.common.Define;
-import org.onap.aaf.auth.dao.cached.CachedRoleDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.UserRoleDAO.Data;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-public class JU_RoleCreate {
-
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- RoleCreate createObj;
-
-
- @Before
- public void setUp() throws APIException, IOException {
- initMocks(this);
- Session sessionObj=Mockito.mock(Session.class);
- PreparedStatement psObj =Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(),Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Define.set(access);
- createObj = new RoleCreate(trans, cluster, true);
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExec() {
- Result<RoleDAO.Data> retVal = createObj.exec(trans,Mockito.mock(Role.class),"test");
- assertTrue(retVal.toString().contains("Success"));
-
- }
- @Test
- public void testExecElse() {
- Question ques = Mockito.mock(Question.class);
- try {
- Role roleObj = new Role("test","test","test",new HashSet());
-
- CachedRoleDAO roleDaoObj = Mockito.mock(CachedRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(roleDaoObj).create(Mockito.any(), Mockito.any());
-
- createObj = new RoleCreateImpl(trans, cluster, false, ques, roleDaoObj);
- Result<RoleDAO.Data> session = createObj.exec(trans, roleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseDateLess() {
- Question ques = Mockito.mock(Question.class);
- try {
- Role roleObj = new Role("test","test","test",new HashSet());
-
- CachedRoleDAO userRoleDaoObj = Mockito.mock(CachedRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- DateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
- try {
- data.expires = sdf.parse("01/01/2100");
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).create(Mockito.any(), Mockito.any());
-
- createObj = new RoleCreateImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<RoleDAO.Data> session = createObj.exec(trans, roleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseNok() {
- Question ques = Mockito.mock(Question.class);
- try {
- Role roleObj = new Role("test","test","test",new HashSet());
-
- CachedRoleDAO userRoleDaoObj = Mockito.mock(CachedRoleDAO.class);
-
- Result<Void> retVal1 = new Result<Void>(null,1,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).create(Mockito.any(), Mockito.any());
-
- createObj = new RoleCreateImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<RoleDAO.Data> session = createObj.exec(trans, roleObj, "test");
- assertTrue(session.toString().contains("test"));
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void test2Argonstructor() {
- createObj = new RoleCreate(trans, Mockito.mock(ActionDAO.class));
- }
-
- class RoleCreateImpl extends RoleCreate{
-
- public RoleCreateImpl(AuthzTrans trans, Cluster cluster, boolean dryRun, Question ques, CachedRoleDAO userRoleDaoObj) throws APIException, IOException {
- super(trans, cluster, dryRun);
- setQuestion(ques, userRoleDaoObj);
- }
-
- public void setQuestion(Question ques, CachedRoleDAO userRoleDaoObj) {
- Field field, nsDaoField;
- try {
- field = RoleCreateImpl.class.getSuperclass().getSuperclass().getDeclaredField("q");
- nsDaoField = Question.class.getDeclaredField("roleDAO");
-
- field.setAccessible(true);
- nsDaoField.setAccessible(true);
- // remove final modifier from field
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- modifiersField.setInt(nsDaoField, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(this, ques);
- nsDaoField.set(ques, userRoleDaoObj);
- } catch (NoSuchFieldException | SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_RoleDeleteTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_RoleDeleteTest.java
deleted file mode 100644
index 83899fd9..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_RoleDeleteTest.java
+++ /dev/null
@@ -1,249 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-
-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.batch.actions.RoleDelete;
-import org.onap.aaf.auth.batch.helpers.Role;
-import org.onap.aaf.auth.batch.helpers.UserRole;
-import org.onap.aaf.auth.common.Define;
-import org.onap.aaf.auth.dao.cached.CachedRoleDAO;
-import org.onap.aaf.auth.dao.cass.RoleDAO;
-import org.onap.aaf.auth.dao.cass.UserRoleDAO.Data;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-public class JU_RoleDeleteTest {
-
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- RoleDelete createObj;
-
-
- @Before
- public void setUp() throws APIException, IOException {
- initMocks(this);
- Session sessionObj=Mockito.mock(Session.class);
- PreparedStatement psObj =Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(),Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Define.set(access);
- createObj = new RoleDelete(trans, cluster, true);
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExec() {
- Result<Void> retVal = createObj.exec(trans,Mockito.mock(Role.class),"test");
- assertTrue(retVal.toString().contains("Success"));
-
- }
- @Test
- public void testExecElse() {
- Question ques = Mockito.mock(Question.class);
- try {
- Role roleObj = new Role("test","test","test",new HashSet());
-
- CachedRoleDAO roleDaoObj = Mockito.mock(CachedRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(roleDaoObj).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
-
- createObj = new RoleDeleteImpl(trans, cluster, false, ques, roleDaoObj);
- Result<Void> session = createObj.exec(trans, roleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseDateLess() {
- Question ques = Mockito.mock(Question.class);
- try {
- Role roleObj = new Role("test","test","test",new HashSet());
-
- CachedRoleDAO userRoleDaoObj = Mockito.mock(CachedRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- DateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
- try {
- data.expires = sdf.parse("01/01/2100");
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
-
- createObj = new RoleDeleteImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = createObj.exec(trans, roleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseNok() {
- Question ques = Mockito.mock(Question.class);
- try {
- Role roleObj = new Role("test","test","test",new HashSet());
-
- CachedRoleDAO userRoleDaoObj = Mockito.mock(CachedRoleDAO.class);
-
- Result<Void> retVal1 = new Result<Void>(null,1,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).delete(Mockito.any(), Mockito.any(), Mockito.anyBoolean());
-
- createObj = new RoleDeleteImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = createObj.exec(trans, roleObj, "test");
- assertTrue(session.toString().contains("test"));
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void test2Argonstructor() {
- createObj = new RoleDelete(trans, Mockito.mock(ActionDAO.class));
- }
-
- class RoleDeleteImpl extends RoleDelete{
-
- public RoleDeleteImpl(AuthzTrans trans, Cluster cluster, boolean dryRun, Question ques, CachedRoleDAO userRoleDaoObj) throws APIException, IOException {
- super(trans, cluster, dryRun);
- setQuestion(ques, userRoleDaoObj);
- }
-
- public void setQuestion(Question ques, CachedRoleDAO userRoleDaoObj) {
- Field field, nsDaoField;
- try {
- field = RoleDeleteImpl.class.getSuperclass().getSuperclass().getDeclaredField("q");
- nsDaoField = Question.class.getDeclaredField("roleDAO");
-
- field.setAccessible(true);
- nsDaoField.setAccessible(true);
- // remove final modifier from field
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- modifiersField.setInt(nsDaoField, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(this, ques);
- nsDaoField.set(ques, userRoleDaoObj);
- } catch (NoSuchFieldException | SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URAdd.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URAdd.java
deleted file mode 100644
index 50fb962b..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URAdd.java
+++ /dev/null
@@ -1,246 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
-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.batch.actions.URAdd;
-import org.onap.aaf.auth.batch.helpers.UserRole;
-import org.onap.aaf.auth.common.Define;
-import org.onap.aaf.auth.dao.cached.CachedUserRoleDAO;
-import org.onap.aaf.auth.dao.cass.UserRoleDAO.Data;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-public class JU_URAdd {
-
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- URAdd addObj;
-
-
- @Before
- public void setUp() throws APIException, IOException {
- initMocks(this);
- Session sessionObj=Mockito.mock(Session.class);
- PreparedStatement psObj =Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(),Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Define.set(access);
- addObj = new URAdd(trans, cluster, true);
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExec() {
- Result<Data> retVal = addObj.exec(trans,Mockito.mock(UserRole.class),"test");
- assertTrue(retVal.toString().contains("Success"));
-
- }
- @Test
- public void testExecElse() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).create(trans, userRoleObj.urdd());
-
- addObj = new URAddImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Data> session = addObj.exec(trans, userRoleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseDateLess() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- DateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
- try {
- data.expires = sdf.parse("01/01/2100");
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).create(trans, userRoleObj.urdd());
-
- addObj = new URAddImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Data> session = addObj.exec(trans, userRoleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseNok() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- Result<Void> retVal1 = new Result<Void>(null,1,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).create(trans, userRoleObj.urdd());
-
- addObj = new URAddImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Data> session = addObj.exec(trans, userRoleObj, "test");
- assertTrue(session.toString().contains("test"));
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void test2Argonstructor() {
- addObj = new URAdd(trans, Mockito.mock(ActionDAO.class));
- }
-
- class URAddImpl extends URAdd{
-
- public URAddImpl(AuthzTrans trans, Cluster cluster, boolean dryRun, Question ques, CachedUserRoleDAO userRoleDaoObj) throws APIException, IOException {
- super(trans, cluster, dryRun);
- setQuestion(ques, userRoleDaoObj);
-// q =new Question(trans, cluster, CassAccess.KEYSPACE, false);
-// q = ques;
- // TODO Auto-generated constructor stub
- }
-
- public void setQuestion(Question ques, CachedUserRoleDAO userRoleDaoObj) {
- Field field, nsDaoField;
- try {
- field = URAddImpl.class.getSuperclass().getSuperclass().getDeclaredField("q");
- nsDaoField = Question.class.getDeclaredField("userRoleDAO");
-
- field.setAccessible(true);
- nsDaoField.setAccessible(true);
- // remove final modifier from field
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- modifiersField.setInt(nsDaoField, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(this, ques);
- nsDaoField.set(ques, userRoleDaoObj);
- } catch (NoSuchFieldException | SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URDelete.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URDelete.java
deleted file mode 100644
index 6e92591a..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URDelete.java
+++ /dev/null
@@ -1,246 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
-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.batch.actions.URDelete;
-import org.onap.aaf.auth.batch.helpers.UserRole;
-import org.onap.aaf.auth.common.Define;
-import org.onap.aaf.auth.dao.cached.CachedUserRoleDAO;
-import org.onap.aaf.auth.dao.cass.UserRoleDAO.Data;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-public class JU_URDelete {
-
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- URDelete deleteObj;
-
-
- @Before
- public void setUp() throws APIException, IOException {
- initMocks(this);
- Session sessionObj=Mockito.mock(Session.class);
- PreparedStatement psObj =Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(),Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Define.set(access);
- deleteObj = new URDelete(trans, cluster, true);
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExec() {
- Result<Void> retVal = deleteObj.exec(trans,Mockito.mock(UserRole.class),"test");
- assertTrue(retVal.toString().contains("Success"));
-
- }
- @Test
- public void testExecElse() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).delete(trans, userRoleObj.urdd(), true);
-
- deleteObj = new URDeleteImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = deleteObj.exec(trans, userRoleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseDateLess() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- DateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
- try {
- data.expires = sdf.parse("01/01/2100");
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).delete(trans, userRoleObj.urdd(), true);
-
- deleteObj = new URDeleteImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = deleteObj.exec(trans, userRoleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseNok() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- Result<Void> retVal1 = new Result<Void>(null,1,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).delete(trans, userRoleObj.urdd(), true);
-
- deleteObj = new URDeleteImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = deleteObj.exec(trans, userRoleObj, "test");
- assertTrue(session.toString().contains("test"));
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void test2Argonstructor() {
- deleteObj = new URDelete(trans, Mockito.mock(ActionDAO.class));
- }
-
- class URDeleteImpl extends URDelete{
-
- public URDeleteImpl(AuthzTrans trans, Cluster cluster, boolean dryRun, Question ques, CachedUserRoleDAO userRoleDaoObj) throws APIException, IOException {
- super(trans, cluster, dryRun);
- setQuestion(ques, userRoleDaoObj);
-// q =new Question(trans, cluster, CassAccess.KEYSPACE, false);
-// q = ques;
- // TODO Auto-generated constructor stub
- }
-
- public void setQuestion(Question ques, CachedUserRoleDAO userRoleDaoObj) {
- Field field, nsDaoField;
- try {
- field = URDeleteImpl.class.getSuperclass().getSuperclass().getDeclaredField("q");
- nsDaoField = Question.class.getDeclaredField("userRoleDAO");
-
- field.setAccessible(true);
- nsDaoField.setAccessible(true);
- // remove final modifier from field
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- modifiersField.setInt(nsDaoField, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(this, ques);
- nsDaoField.set(ques, userRoleDaoObj);
- } catch (NoSuchFieldException | SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFutureApproveExec.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFutureApproveExec.java
deleted file mode 100644
index 58d52f7d..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URFutureApproveExec.java
+++ /dev/null
@@ -1,264 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
-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.batch.actions.URFutureApproveExec;
-import org.onap.aaf.auth.batch.actions.test.JU_URPunt.URPuntImpl;
-import org.onap.aaf.auth.batch.helpers.Approval;
-import org.onap.aaf.auth.batch.helpers.Future;
-import org.onap.aaf.auth.common.Define;
-import org.onap.aaf.auth.dao.cass.FutureDAO;
-import org.onap.aaf.auth.dao.hl.Function;
-import org.onap.aaf.auth.dao.hl.Function.FUTURE_OP;
-import org.onap.aaf.auth.dao.hl.Function.OP_STATUS;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-import io.netty.util.internal.SystemPropertyUtil;
-
-
-
-public class JU_URFutureApproveExec {
-
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- URFutureApproveExec actionObj;
-
-
- @Before
- public void setUp() throws APIException, IOException {
- initMocks(this);
- Session sessionObj=Mockito.mock(Session.class);
- PreparedStatement psObj =Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(),Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Define.set(access);
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExec() {
- try {
- actionObj = new URFutureApproveExec(trans, cluster, true);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Approval approval = Mockito.mock(Approval.class);
- List<Approval> approvalAL = new ArrayList<>();
- approvalAL.add(approval);
- Result<OP_STATUS> retVal = actionObj.exec(trans,approvalAL,Mockito.mock(Future.class));
- assertTrue(8 == retVal.status);
-
- }
-
- @Test
- public void testExecElseOpStatusD() {
- Result<OP_STATUS> retValD = new Result<OP_STATUS>(OP_STATUS.D, 0, "test", new String[0]);
- try {
- actionObj = new URFutureApproveExecImpl(trans, cluster, false, retValD);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Approval approval = new Approval(null, null, "", "test", "", "", "", "", 0L);
- List<Approval> approvalAL = new ArrayList<>();
-
- Future futureObj = new Future(null, "", "", new Date(), new Date(), null);
-
- approvalAL.add(approval);
- Result<OP_STATUS> retVal = actionObj.exec(trans,approvalAL,futureObj);
- assertTrue(0 == retVal.status && "test".equals(retVal.toString()));
-
- }
-
- @Test
- public void testExecElseOpStatusE() {
- Result<OP_STATUS> retValD = new Result<OP_STATUS>(OP_STATUS.E, 0, "test", new String[0]);
- try {
- actionObj = new URFutureApproveExecImpl(trans, cluster, false, retValD);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Approval approval = new Approval(null, null, "", "test", "", "", "", "", 0L);
- List<Approval> approvalAL = new ArrayList<>();
-
- Future futureObj = new Future(null, "", "", new Date(), new Date(), null);
-
- approvalAL.add(approval);
- Result<OP_STATUS> retVal = actionObj.exec(trans,approvalAL,futureObj);
- assertTrue(0 == retVal.status && "test".equals(retVal.toString()));
-
- }
-
- @Test
- public void testExecElseOpStatusL() {
- Result<OP_STATUS> retValD = new Result<OP_STATUS>(OP_STATUS.L, 0, "test", new String[0]);
- try {
- actionObj = new URFutureApproveExecImpl(trans, cluster, false, retValD);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Approval approval = new Approval(null, null, "", "test", "", "", "", "", 0L);
- List<Approval> approvalAL = new ArrayList<>();
-
- Future futureObj = new Future(null, "", "", new Date(), new Date(), null);
-
- approvalAL.add(approval);
- Result<OP_STATUS> retVal = actionObj.exec(trans,approvalAL,futureObj);
- assertTrue(0 == retVal.status && "test".equals(retVal.toString()));
-
- }
-
- @Test
- public void testExecElseOpStatusP() {
- Result<OP_STATUS> retValD = new Result<OP_STATUS>(OP_STATUS.P, 0, "test", new String[0]);
- try {
- actionObj = new URFutureApproveExecImpl(trans, cluster, false, retValD);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Approval approval = new Approval(null, null, "", "test", "", "", "", "", 0L);
- List<Approval> approvalAL = new ArrayList<>();
-
- Future futureObj = new Future(null, "", "", new Date(), new Date(), null);
-
- approvalAL.add(approval);
- Result<OP_STATUS> retVal = actionObj.exec(trans,approvalAL,futureObj);
- assertTrue(0 == retVal.status && "test".equals(retVal.toString()));
-
- }
-
- @Test
- public void testExecElseNok() {
- Result<OP_STATUS> retValD = new Result<OP_STATUS>(null, 1, "test", new String[0]);
- try {
- actionObj = new URFutureApproveExecImpl(trans, cluster, false, retValD);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Approval approval = new Approval(null, null, "", "test", "", "", "", "", 0L);
- List<Approval> approvalAL = new ArrayList<>();
-
- Future futureObj = new Future(null, "", "", new Date(), new Date(), null);
-
- approvalAL.add(approval);
- Result<OP_STATUS> retVal = actionObj.exec(trans,approvalAL,futureObj);
- System.out.println(retVal);
- assertTrue(1 == retVal.status);
-
- }
-
- @Test
- public void test2Argonstructor() {
- actionObj = new URFutureApproveExec(trans, Mockito.mock(ActionDAO.class));
- }
-
- class URFutureApproveExecImpl extends URFutureApproveExec{
-
- public URFutureApproveExecImpl(AuthzTrans trans, Cluster cluster, boolean dryRun, Result<OP_STATUS> retValD)
- throws APIException, IOException {
- super(trans, cluster, dryRun);
- setFunction(Mockito.mock(Function.class));
- Mockito.doReturn(retValD).when(f).performFutureOp(Mockito.any(), Mockito.any(), Mockito.any(),Mockito.any(),Mockito.any());
- }
-
- public void setFunction(Function f) {
- Field field;
- try {
- field = URFutureApproveExecImpl.class.getSuperclass().getSuperclass().getDeclaredField("f");
-
- field.setAccessible(true);
- // remove final modifier from field
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(this, f);
- } catch (NoSuchFieldException | SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-}
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
deleted file mode 100644
index 9f569d65..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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_URModify.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URModify.java
deleted file mode 100644
index eb9a4bf9..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URModify.java
+++ /dev/null
@@ -1,281 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
-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.batch.actions.URModify;
-import org.onap.aaf.auth.batch.actions.URPunt;
-import org.onap.aaf.auth.batch.actions.URModify.Modify;
-import org.onap.aaf.auth.batch.actions.test.JU_URPunt.URPuntImpl;
-import org.onap.aaf.auth.batch.helpers.UserRole;
-import org.onap.aaf.auth.common.Define;
-import org.onap.aaf.auth.dao.cached.CachedUserRoleDAO;
-import org.onap.aaf.auth.dao.cass.Status;
-import org.onap.aaf.auth.dao.cass.UserRoleDAO.Data;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-public class JU_URModify {
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- URModify modifyObj;
-
- @Before
- public void setUp() throws APIException, IOException {
- initMocks(this);
- Session sessionObj = Mockito.mock(Session.class);
- PreparedStatement psObj = Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(), Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS, "org.osaaf.aaf");
- Define.set(access);
- modifyObj = new URModify(trans, cluster, true);
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testURPrint() {
- UserRole ur = new UserRole("user", "ns", "rname", Calendar.getInstance().getTime());
- Result<Void> retVal = modifyObj.exec(trans, ur, Mockito.mock(Modify.class));
- assertTrue(retVal.toString().contains("Success"));
- }
-
- @Test
- public void testExecElse() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test", "test", "test", new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- data.user="test";
- data.role="test.test";
- dataAL.add(data);
- Result<List<Data>> retVal = new Result<List<Data>>(dataAL, 0, "test", new String[0]);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL, 0, "test", new String[0]);
-
- Mockito.doReturn(retVal).when(userRoleDaoObj).read(trans, userRoleObj.user(), userRoleObj.role());
- Mockito.doReturn(retVal1).when(userRoleDaoObj).update(trans, data);
-
- modifyObj = new URModifyImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = modifyObj.exec(trans, userRoleObj, Mockito.mock(Modify.class));
- assertTrue(Status.ERR_UserRoleNotFound == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseUpdateFail() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test", "test", "test", new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- data.user="test";
- data.role="test.test";
- dataAL.add(data);
- Result<List<Data>> retVal = new Result<List<Data>>(dataAL, 0, "test", new String[0]);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL, 1, "test", new String[0]);
-
- Mockito.doReturn(retVal).when(userRoleDaoObj).read(trans, userRoleObj.user(), userRoleObj.role());
- Mockito.doReturn(retVal1).when(userRoleDaoObj).update(trans, data);
-
- modifyObj = new URModifyImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = modifyObj.exec(trans, userRoleObj, Mockito.mock(Modify.class));
- assertTrue(Status.ERR_UserRoleNotFound == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseUserDiff() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test", "test", "test", new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- dataAL.add(data);
- Result<List<Data>> retVal = new Result<List<Data>>(dataAL, 0, "test", new String[0]);
-
- Mockito.doReturn(retVal).when(userRoleDaoObj).read(trans, userRoleObj.user(), userRoleObj.role());
-
- modifyObj = new URModifyImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = modifyObj.exec(trans, userRoleObj, Mockito.mock(Modify.class));
- assertTrue(Status.ERR_Denied == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseReadNOK() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test", "test", "test", new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- dataAL.add(data);
- Result<List<Data>> retVal = new Result<List<Data>>(dataAL, 1, "test", new String[0]);
-
- Mockito.doReturn(retVal).when(userRoleDaoObj).read(trans, userRoleObj.user(), userRoleObj.role());
-
- modifyObj = new URModifyImpl(trans, cluster, false, ques, userRoleDaoObj);
- Result<Void> session = modifyObj.exec(trans, userRoleObj, Mockito.mock(Modify.class));
- assertTrue(1 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void test2Argonstructor() {
- modifyObj = new URModify(trans, Mockito.mock(ActionDAO.class));
- }
-
- class URModifyImpl extends URModify{
-
- public URModifyImpl(AuthzTrans trans, Cluster cluster, boolean dryRun, Question ques, CachedUserRoleDAO userRoleDaoObj) throws APIException, IOException {
- super(trans, cluster, dryRun);
- setQuestion(ques, userRoleDaoObj);
-// q =new Question(trans, cluster, CassAccess.KEYSPACE, false);
-// q = ques;
- // TODO Auto-generated constructor stub
- }
-
- public void setQuestion(Question ques, CachedUserRoleDAO userRoleDaoObj) {
- Field field, nsDaoField;
- try {
- field = URPuntImpl.class.getSuperclass().getSuperclass().getSuperclass().getDeclaredField("q");
- nsDaoField = Question.class.getDeclaredField("userRoleDAO");
-
- field.setAccessible(true);
- nsDaoField.setAccessible(true);
- // remove final modifier from field
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- modifiersField.setInt(nsDaoField, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(this, ques);
- nsDaoField.set(ques, userRoleDaoObj);
- } catch (NoSuchFieldException | SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-}
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
deleted file mode 100644
index 8a037ece..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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/actions/test/JU_URPunt.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URPunt.java
deleted file mode 100644
index 434ec418..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/actions/test/JU_URPunt.java
+++ /dev/null
@@ -1,246 +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.batch.actions.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
-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.batch.actions.URPunt;
-import org.onap.aaf.auth.batch.helpers.UserRole;
-import org.onap.aaf.auth.common.Define;
-import org.onap.aaf.auth.dao.cached.CachedUserRoleDAO;
-import org.onap.aaf.auth.dao.cass.UserRoleDAO.Data;
-import org.onap.aaf.auth.dao.hl.Question;
-import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-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.APIException;
-import org.onap.aaf.misc.env.LogTarget;
-import org.onap.aaf.misc.env.TimeTaken;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.PreparedId;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Session;
-
-public class JU_URPunt {
-
- @Mock
- AuthzTrans trans;
- @Mock
- Cluster cluster;
- @Mock
- PropAccess access;
-
- @Mock
- URPunt actionObj;
-
-
- @Before
- public void setUp() throws APIException, IOException {
- initMocks(this);
- Session sessionObj=Mockito.mock(Session.class);
- PreparedStatement psObj =Mockito.mock(PreparedStatement.class);
- try {
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error();
- Mockito.doReturn("10").when(trans).getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF);
- Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(Mockito.anyString(),Mockito.anyInt());
- Mockito.doReturn(sessionObj).when(cluster).connect("authz");
- Mockito.doReturn(psObj).when(sessionObj).prepare(Mockito.anyString());
-
- Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(psObj).getVariables();
- Mockito.doReturn(Mockito.mock(PreparedId.class)).when(psObj).getPreparedId();
- Mockito.doReturn(Mockito.mock(Properties.class)).when(access).getProperties();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Define.set(access);
- actionObj = new URPunt(trans, cluster, 10, 10, true);
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExec() {
- Result<Void> retVal = actionObj.exec(trans,Mockito.mock(UserRole.class),"test");
- assertTrue(retVal.toString().contains("Success"));
-
- }
- @Test
- public void testExecElse() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- data.expires = new Date();
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).read(trans, userRoleObj.user(), userRoleObj.role());
-
- actionObj = new URPuntImpl(trans, cluster, false, 10, 10, ques, userRoleDaoObj);
- Result<Void> session = actionObj.exec(trans, userRoleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseDateLess() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- List<Data> dataAL = new ArrayList<Data>();
- Data data = new Data();
- DateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
- try {
- data.expires = sdf.parse("01/01/2100");
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- dataAL.add(data);
- Result<List<Data>> retVal1 = new Result<List<Data>>(dataAL,0,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).read(trans, userRoleObj.user(), userRoleObj.role());
-
- actionObj = new URPuntImpl(trans, cluster, false, 0, 0,ques, userRoleDaoObj);
- Result<Void> session = actionObj.exec(trans, userRoleObj, "test");
- assertTrue(0 == session.status);
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testExecElseNok() {
- Question ques = Mockito.mock(Question.class);
- try {
- UserRole userRoleObj = new UserRole("test","test","test",new Date());
- CachedUserRoleDAO userRoleDaoObj = Mockito.mock(CachedUserRoleDAO.class);
-
- Result<Void> retVal1 = new Result<Void>(null,1,"test",new String[0]);
-
- Mockito.doReturn(retVal1).when(userRoleDaoObj).read(trans, userRoleObj.user(), userRoleObj.role());
-
- actionObj = new URPuntImpl(trans, cluster, false, 10, 10, ques, userRoleDaoObj);
- Result<Void> session = actionObj.exec(trans, userRoleObj, "test");
- assertTrue(session.toString().contains("test"));
- } catch (APIException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void test2Argonstructor() {
- actionObj = new URPunt(trans, Mockito.mock(ActionDAO.class), 10, 10);
- }
-
- class URPuntImpl extends URPunt{
-
- public URPuntImpl(AuthzTrans trans, Cluster cluster, boolean dryRun, int months, int range,Question ques, CachedUserRoleDAO userRoleDaoObj) throws APIException, IOException {
- super(trans, cluster, months, range, dryRun);
- setQuestion(ques, userRoleDaoObj);
-// q =new Question(trans, cluster, CassAccess.KEYSPACE, false);
-// q = ques;
- // TODO Auto-generated constructor stub
- }
-
- public void setQuestion(Question ques, CachedUserRoleDAO userRoleDaoObj) {
- Field field, nsDaoField;
- try {
- field = URPuntImpl.class.getSuperclass().getSuperclass().getSuperclass().getDeclaredField("q");
- nsDaoField = Question.class.getDeclaredField("userRoleDAO");
-
- field.setAccessible(true);
- nsDaoField.setAccessible(true);
- // remove final modifier from field
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- modifiersField.setInt(nsDaoField, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(this, ques);
- nsDaoField.set(ques, userRoleDaoObj);
- } catch (NoSuchFieldException | SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-}
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
deleted file mode 100644
index bd498f58..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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_ExpireRange.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_ExpireRange.java
index f64bdfc0..20d0dcba 100644
--- 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
@@ -54,7 +54,6 @@ public class JU_ExpireRange {
r = expRange.getRange(rs, gc.getTime());
assertNotNull(r);
assertEquals("Delete",r.name());
- assertFalse(r.shouldContact(null));
}
// Test 1 week prior
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
deleted file mode 100644
index beaaad31..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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
deleted file mode 100644
index f30ad3cc..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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_MonthData.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_MonthData.java
deleted file mode 100644
index d9d9d018..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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_NsAttrib.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NsAttrib.java
deleted file mode 100644
index 6df877fe..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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
deleted file mode 100644
index 10cbd359..00000000
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/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.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
index 250c7a10..ad53e0e1 100644
--- 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
@@ -21,24 +21,15 @@
package org.onap.aaf.auth.batch.helpers.test;
-import static org.junit.Assert.*;
-import org.junit.After;
+import java.util.HashSet;
+import java.util.Set;
+
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;
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
index 5b20ce22..ab531e90 100644
--- 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
@@ -21,7 +21,6 @@
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;
@@ -33,11 +32,9 @@ 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.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;
@@ -136,24 +133,6 @@ public class JU_UserRole {
}
@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 testLoad() {
Creator<UserRole> creator = mock(Creator.class);
Trans trans = mock(Trans.class);