diff options
author | gabe.maurer <gabe.maurer@att.com> | 2018-05-11 13:58:36 -0500 |
---|---|---|
committer | gabe.maurer <gabe.maurer@att.com> | 2018-05-11 13:59:10 -0500 |
commit | 970e2dd7dc756531b3efce31d4956231b148f831 (patch) | |
tree | 8358442042e333201964100a4bb83894fcf4325e /auth/auth-batch/src | |
parent | c486733c0160bfb16bb75a008abe4e6a2616cb44 (diff) |
Increased auth batch coverage
Issue-ID: AAF-233
Change-Id: I0d3c1210d0ca318334d6e619de231ca780045e4b
Signed-off-by: gabe.maurer <gabe.maurer@att.com>
Diffstat (limited to 'auth/auth-batch/src')
3 files changed, 252 insertions, 0 deletions
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_InputIterator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_InputIterator.java new file mode 100644 index 00000000..fbb0d23a --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_InputIterator.java @@ -0,0 +1,76 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.helpers.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.helpers.InputIterator; + +import static org.mockito.Mockito.*; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintStream; +import java.io.Reader; + +import org.junit.Test; + +public class JU_InputIterator { + + InputIterator inputIterator; + File f; + BufferedReader bReader; + PrintStream pStream; + + @Before + public void setUp() throws IOException { + f = new File("file"); + f.createNewFile(); + bReader = new BufferedReader(new FileReader(f)); + pStream = new PrintStream(f); + inputIterator = new InputIterator(bReader, pStream, "prompt", "instructions"); + } + + @Test + public void test() { + inputIterator.iterator(); + inputIterator.iterator().hasNext(); + inputIterator.iterator().next(); + inputIterator.iterator().remove(); + } + + @After + public void cleanUp() { + if(f.exists()) { + f.delete(); + } + } +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MiscID.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MiscID.java new file mode 100644 index 00000000..816cda80 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MiscID.java @@ -0,0 +1,97 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.helpers.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.BatchException; +import org.onap.aaf.auth.helpers.MiscID; + +import com.datastax.driver.core.Row; + +import junit.framework.Assert; + +import static org.mockito.Mockito.*; +import org.junit.Test; + +public class JU_MiscID { + + MiscID miscId; + + @Before + public void setUp() { + miscId = new MiscID(); + } + + @Test + public void testRowSet() { + Row row = mock(Row.class); + miscId.set(row); + } + + @Test + public void testStringSet() throws BatchException { + String[] strArr = {"id", "sponsor", "created", "renewal"}; + miscId.set(strArr); + } + + @Test + public void testHashcode() throws BatchException { + String[] strArr = {"id", "sponsor", "created", "renewal"}; + miscId.set(strArr); + Assert.assertEquals(3355, miscId.hashCode()); + } + + @Test + public void testEquals() throws BatchException { + String[] strArr = {"id", "sponsor", "created", "renewal"}; + miscId.set(strArr); + Assert.assertFalse(miscId.equals("id")); + Assert.assertTrue(miscId.equals(miscId)); + } + + @Test + public void testInsertStmt() throws IllegalArgumentException, IllegalAccessException { + String expected = "INSERT INTO authz.miscid (id,created,sponsor,renewal) VALUES ('null','null','null','null')"; + String result = miscId.insertStmt().toString(); + Assert.assertEquals(expected, result); + } + + @Test + public void testUpdateStmt() throws IllegalArgumentException, IllegalAccessException, BatchException { + String expected = "UPDATE authz.miscid SET sponser='sponsor1',created='created1',renewal='renewal1' WHERE id='id'"; + String[] strArr = {"id", "sponsor", "created", "renewal"}; + miscId.set(strArr); + MiscID miscId1 = new MiscID(); + String[] strArr1 = {"id", "sponsor1", "created1", "renewal1"}; + miscId1.set(strArr1); + StringBuilder result = miscId.updateStmt(miscId1); + + Assert.assertEquals(expected, result.toString()); + } + + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java new file mode 100644 index 00000000..21ead4f2 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/helpers/test/JU_MonthData.java @@ -0,0 +1,79 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.helpers.test; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.helpers.MonthData; + +import 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; + BufferedWriter bw = null; + FileWriter fw = null; + + @Before + public void setUp() throws IOException { + mData = new MonthData("env"); + 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); + } + + @After + public void cleanUp() { + if(f.exists()) { + f.delete(); + } + } + +} |