diff options
author | gabe.maurer <gabe.maurer@att.com> | 2018-05-10 13:40:13 -0500 |
---|---|---|
committer | gabe.maurer <gabe.maurer@att.com> | 2018-05-10 13:44:53 -0500 |
commit | dc1338557a1cee4dbc8e171bd4e42e209fd84103 (patch) | |
tree | 17db9817d3b59fbe41fd585d88b6914816ec6e63 /auth/auth-batch | |
parent | 65a908e7f117f7e237589781bd214a8c6c4e0509 (diff) |
Increased auth batch coverage
Issue-ID: AAF-233
Change-Id: I96e646ff26ba6be92ba7dc4dbf8be086f90adb04
Signed-off-by: gabe.maurer <gabe.maurer@att.com>
Diffstat (limited to 'auth/auth-batch')
-rw-r--r-- | auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Creator.java | 72 | ||||
-rw-r--r-- | auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Cred.java | 142 |
2 files changed, 214 insertions, 0 deletions
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Creator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Creator.java new file mode 100644 index 00000000..f07aa820 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Creator.java @@ -0,0 +1,72 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + + +package org.onap.aaf.auth.helpers.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.helpers.Creator; + +import com.datastax.driver.core.Row; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; +import org.junit.Test; + +public class JU_Creator { + + CreatorStub creatorStub; + + private class CreatorStub extends Creator{ + + @Override + public Object create(Row row) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String select() { + // TODO Auto-generated method stub + return "Select"; //Changed from null to Select + } + + } + + @Before + public void setUp() { + creatorStub = new CreatorStub(); + } + + @Test + public void testQuery() { + creatorStub.select(); + Assert.assertEquals("Select WHERE test;", creatorStub.query("test")); + Assert.assertEquals("Select;", creatorStub.query(null)); + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Cred.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Cred.java new file mode 100644 index 00000000..ad7fbe0c --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_Cred.java @@ -0,0 +1,142 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + + +package org.onap.aaf.auth.helpers.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.common.Define; +import org.onap.aaf.auth.helpers.Cred; +import org.onap.aaf.auth.helpers.Cred.CredCount; +import org.onap.aaf.auth.helpers.Cred.Instance; +import org.onap.aaf.cadi.CadiException; +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.misc.env.Trans; + +import com.datastax.driver.core.Session; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Date; + +import org.junit.Test; + +public class JU_Cred { + + private ByteArrayOutputStream outStream; + private ByteArrayOutputStream errStream; + Cred cred; + Instance instance; + Date date; + Integer integer; + PropAccess prop; + Define define = new Define(); + Trans trans; + Session session; + CredCount cc; + + @Before + public void setUp() throws CadiException { + outStream = new ByteArrayOutputStream(); + errStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outStream)); + System.setErr(new PrintStream(errStream)); + date = new Date(); + integer = new Integer(20); + trans = mock(Trans.class); + session = mock(Session.class); + cc = new CredCount(3); + prop = new PropAccess(); + prop.setProperty(Config.AAF_ROOT_NS, "org.onap.aaf"); + prop.setProperty(Config.AAF_ROOT_COMPANY,"test"); + define.set(prop); + + instance = new Instance(12, date, integer, 125642678910L); + cred = new Cred("myid1234@aaf.att.com"); + } + + @Test + public void testLast() { //TODO: set instances + Assert.assertNull(cred.last(null)); + } + + @Test + public void testTypes() { //TODO: set instances + Assert.assertNotNull(cred.types()); + } + + @Test + public void testCount() { //TODO: set instances + Assert.assertNotNull(cred.count(3)); + } + + @Test + public void testToString() { //TODO: set instances + Assert.assertEquals("myid1234@aaf.att.com[]", cred.toString()); + } + + @Test + public void testHashCode() { //TODO: set instances + Assert.assertEquals(-1619358251, cred.hashCode()); + } + + @Test + public void testEquals() { //TODO: set instances + Assert.assertEquals(true, cred.equals("myid1234@aaf.att.com")); + } + + @Test + public void testInc() { + Date begin = new Date(date.getTime() - 10); + Date after = new Date(date.getTime() + 10); + cc.inc(-1, begin, after); + cc.inc(1, begin, after); + cc.inc(2, begin, after); + cc.inc(200, begin, after); + } + + @Test + public void testAuthCount() { //TODO: set instances + Assert.assertEquals(0, cc.authCount(1)); + } + + @Test + public void testX509Count() { //TODO: set instances + Assert.assertEquals(0, cc.x509Count(0)); + } + + @After + public void cleanUp() { + System.setErr(System.err); + System.setOut(System.out); + } + +} |