diff options
author | gabe.maurer <gabe.maurer@att.com> | 2018-05-09 14:43:40 -0500 |
---|---|---|
committer | gabe.maurer <gabe.maurer@att.com> | 2018-05-09 14:44:25 -0500 |
commit | 851aecff6f8fa7cb546486d6bcc52f068a5c1102 (patch) | |
tree | 15c444aaf983712d4a2abed4ff9e24cda45ddd01 | |
parent | 1474e204f441bf1eabfaa8d458857c76250133bb (diff) |
Increased code coverage auth batch
Issue-ID: AAF-233
Change-Id: I3b44c2c2cef68561addfbe8a185ce9b5da65e749
Signed-off-by: gabe.maurer <gabe.maurer@att.com>
6 files changed, 356 insertions, 1 deletions
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java new file mode 100644 index 00000000..adb91566 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/actions/test/JU_ActionDAO.java @@ -0,0 +1,95 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.actions.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.actions.ActionDAO; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.misc.env.APIException; + +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Configuration; +import com.datastax.driver.core.Cluster.Initializer; +import com.datastax.driver.core.Host.StateListener; + +import static org.mockito.Mockito.*; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.Collection; +import java.util.List; + +import org.junit.Test; + +public class JU_ActionDAO { + + AuthzTrans aTrans; + Cluster cluster; + ActionDAOStub actionDAOStub; + ActionDAOStub actionDAOStub1; + + private class ActionDAOStub extends ActionDAO { + + public ActionDAOStub(AuthzTrans trans, ActionDAO predecessor) { + super(trans, predecessor); + // TODO Auto-generated constructor stub + } + + public ActionDAOStub(AuthzTrans trans, Cluster cluster, boolean dryRun) throws APIException, IOException { + super(trans, cluster, dryRun); + // TODO Auto-generated constructor stub + } + + @Override + public Result exec(AuthzTrans trans, Object data, Object t) { + // TODO Auto-generated method stub + return null; + } + + } + + @Before + public void setUp() throws APIException, IOException { +// Cluster.Initializer cInit = mock(Cluster.Initializer.class); +// Cluster.Builder cBuild = new Cluster.Builder(); +// cBuild.addContactPoint("test"); +// cBuild.build(); +// cluster.buildFrom(cBuild); +// cluster.builder(); +// cluster.init(); +// cluster.builder().getContactPoints(); +// +// +// +// aTrans = mock(AuthzTrans.class); +// cluster = mock(Cluster.class); +// actionDAOStub = new ActionDAOStub(aTrans,cluster,true); +// actionDAOStub1 = new ActionDAOStub(aTrans, actionDAOStub); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java new file mode 100644 index 00000000..37882527 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Approver.java @@ -0,0 +1,65 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.helpers.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.actions.Message; +import org.onap.aaf.auth.helpers.Approver; +import org.onap.aaf.auth.org.Organization; + +import static org.mockito.Mockito.*; +import org.junit.Test; + +public class JU_Approver { + + Approver approver; + Organization org; + Message msg; + + @Before + public void setUp() { + org = mock(Organization.class); + approver = new Approver("approver", org); + msg = new Message(); + } + + @Test + public void testAddRequest() { + approver.addRequest("user"); + approver.addRequest("user"); + } + + @Test + public void testBuild() { + approver.addRequest("user"); + approver.addRequest("user1"); + approver.addRequest("user2"); + approver.addRequest("user3"); + approver.build(msg); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_CacheChange.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_CacheChange.java new file mode 100644 index 00000000..c029be13 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_CacheChange.java @@ -0,0 +1,80 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.helpers.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.helpers.CacheChange; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; + +import java.util.List; + +import org.junit.Test; + +public class JU_CacheChange { + + CacheChange cc; + + + @Before + public void setUp() { + cc = new CacheChange(); + } + + @Test + public void testDelayedDelete() { + cc.delayedDelete(null); + } + + @Test + public void testGetRemoved() { + List list = cc.getRemoved(); + Assert.assertNotNull(list); + } + + @Test + public void testResetLocalData() { + cc.resetLocalData(); + } + + @Test + public void testCacheSize() { + int size; + size = cc.cacheSize(); + Assert.assertEquals(0, size); + } + + @Test + public void testContains() { + boolean containsBools; + containsBools = cc.contains(null); + Assert.assertEquals(false, containsBools); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java index dad723b9..9b2f2db0 100644 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchException.java @@ -48,7 +48,7 @@ public class JU_BatchException { } @Test - public void test() { + public void testBatchException() { bExcept1 = new BatchException(); bExcept2 = new BatchException("test"); bExcept3 = new BatchException(throwable); diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java new file mode 100644 index 00000000..cc30890c --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java @@ -0,0 +1,48 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.BatchPrincipal; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; +import org.junit.Test; + +public class JU_BatchPrincipal { + + BatchPrincipal bPrincipal; + + @Test + public void testBatchPrincipal() { + bPrincipal = new BatchPrincipal("name"); + bPrincipal.getName(); + Assert.assertEquals("Batch", bPrincipal.tag()); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_CassBatch.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_CassBatch.java new file mode 100644 index 00000000..0e7a4244 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_CassBatch.java @@ -0,0 +1,67 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.CassBatch; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.org.OrganizationException; +import org.onap.aaf.misc.env.APIException; + +import static org.mockito.Mockito.*; + +import java.io.IOException; + +import org.junit.Test; + +public class JU_CassBatch { + + AuthzTrans aTrans; + + private class CassBatchStub extends CassBatch { + + protected CassBatchStub(AuthzTrans trans, String log4jName) + throws APIException, IOException, OrganizationException { + super(trans, log4jName); + // TODO Auto-generated constructor stub + } + + @Override + protected void run(AuthzTrans trans) { + // TODO Auto-generated method stub + + } + + } + + @Before + public void setUp() throws APIException, IOException, OrganizationException { + aTrans = mock(AuthzTrans.class); + //CassBatchStub cassBatchStub = new CassBatchStub(aTrans,"log"); //Cannot do until Batch is understood + } + +} |