diff options
Diffstat (limited to 'auth/auth-batch')
8 files changed, 1220 insertions, 241 deletions
diff --git a/auth/auth-batch/pom.xml b/auth/auth-batch/pom.xml index 304a23f7..802538ab 100644 --- a/auth/auth-batch/pom.xml +++ b/auth/auth-batch/pom.xml @@ -20,242 +20,235 @@ * --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>authparent</artifactId> - <version>2.1.15-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>aaf-auth-batch</artifactId> - <name>AAF Auth Batch</name> - <description>Batch Processing for AAF Auth</description> - <packaging>jar</packaging> - - <developers> - <developer> - <name>Jonathan Gathman</name> - <email>jonathan.gathman@att.com</email> - <organization>ATT</organization> - <roles> - <role>Architect</role> - <role>Lead Developer</role> - </roles> - </developer> - <developer> - <name>Gabe Maurer</name> - <email>gabe.maurer@att.com</email> - <organization>ATT</organization> - <roles> - <role>Developer</role> - </roles> - </developer> - <developer> - <name>Ian Howell</name> - <email>ian.howell@att.com</email> - <organization>ATT</organization> - <roles> - <role>Developer</role> - </roles> - </developer> - <developer> - <name>Sai Gandham</name> - <email>sai.gandham@att.com</email> - <organization>ATT</organization> - <roles> - <role>Developer</role> - </roles> - </developer> - </developers> - - <properties> - - - - <maven.test.failure.ignore>false</maven.test.failure.ignore> - <!-- SONAR --> - <!-- <sonar.skip>true</sonar.skip> --> - <jacoco.version>0.7.7.201606060606</jacoco.version> - <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version> - <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> - <!-- Default Sonar configuration --> - <sonar.jacoco.reportPaths>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPaths> - <sonar.jacoco.itReportPaths>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPaths> - <!-- Note: This list should match jacoco-maven-plugin's exclusion list below --> - <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions> - <nexusproxy>https://nexus.onap.org</nexusproxy> - <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath> - <releaseNexusPath>/content/repositories/releases/</releaseNexusPath> - <stagingNexusPath>/content/repositories/staging/</stagingNexusPath> - <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath> - </properties> - - <dependencies> - - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-misc-env</artifactId> - </dependency> - - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-cadi-core</artifactId> - </dependency> - - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-misc-rosetta</artifactId> - </dependency> - - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-cadi-aaf</artifactId> - </dependency> - - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-auth-cass</artifactId> - </dependency> - - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-auth-deforg</artifactId> - </dependency> - - <!--dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency --> - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-deploy-plugin</artifactId> - <configuration> - <skip>false</skip> - </configuration> - </plugin> - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude>**/gen/**</exclude> - <exclude>**/generated-sources/**</exclude> - <exclude>**/yang-gen/**</exclude> - <exclude>**/pax/**</exclude> - </excludes> - </configuration> - <executions> - - <execution> - <id>pre-unit-test</id> - <goals> - <goal>prepare-agent</goal> - </goals> - <configuration> - <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile> - <propertyName>surefireArgLine</propertyName> - </configuration> - </execution> - - - <execution> - <id>post-unit-test</id> - <phase>test</phase> - <goals> - <goal>report</goal> - </goals> - <configuration> - <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile> - <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> - </configuration> - </execution> - <execution> - <id>pre-integration-test</id> - <phase>pre-integration-test</phase> - <goals> - <goal>prepare-agent</goal> - </goals> - <configuration> - <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile> - <propertyName>failsafeArgLine</propertyName> - </configuration> - </execution> - - <execution> - <id>post-integration-test</id> - <phase>post-integration-test</phase> - <goals> - <goal>report</goal> - </goals> - <configuration> - <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile> - <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <classifier>tests</classifier> - <archive> - <manifest> - <mainClass>org.onap.aaf.auth.batch.Batch</mainClass> - </manifest> - <manifestEntries> - <Sealed>true</Sealed> - </manifestEntries> - </archive> - - </configuration> - <executions> - <execution> - <id>full</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <descriptors> - <descriptor>src/assemble/auth-batch.xml</descriptor> - </descriptors> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <distributionManagement> - <repository> - <id>ecomp-releases</id> - <name>AAF Release Repository</name> - <url>${nexusproxy}${releaseNexusPath}</url> - </repository> - <snapshotRepository> - <id>ecomp-snapshots</id> - <name>AAF Snapshot Repository</name> - <url>${nexusproxy}${snapshotNexusPath}</url> - </snapshotRepository> - <site> - <id>ecomp-site</id> - <url>dav:${nexusproxy}${sitePath}</url> - </site> - </distributionManagement> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>authparent</artifactId> + <version>2.1.16-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>aaf-auth-batch</artifactId> + <name>AAF Auth Batch</name> + <description>Batch Processing for AAF Auth</description> + <packaging>jar</packaging> + + <developers> + <developer> + <name>Jonathan Gathman</name> + <email>jonathan.gathman@att.com</email> + <organization>ATT</organization> + <roles> + <role>Architect</role> + <role>Lead Developer</role> + </roles> + </developer> + <developer> + <name>Gabe Maurer</name> + <email>gabe.maurer@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + <developer> + <name>Ian Howell</name> + <email>ian.howell@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + <developer> + <name>Sai Gandham</name> + <email>sai.gandham@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + </developers> + + <properties> + + + + <maven.test.failure.ignore>false</maven.test.failure.ignore> + <!-- SONAR --> + <!-- <sonar.skip>true</sonar.skip> --> + <jacoco.version>0.7.7.201606060606</jacoco.version> + <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version> + <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> + <!-- Default Sonar configuration --> + <sonar.jacoco.reportPaths>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPaths> + <sonar.jacoco.itReportPaths>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPaths> + <!-- Note: This list should match jacoco-maven-plugin's exclusion list below --> + <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions> + <nexusproxy>https://nexus.onap.org</nexusproxy> + <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath> + <releaseNexusPath>/content/repositories/releases/</releaseNexusPath> + <stagingNexusPath>/content/repositories/staging/</stagingNexusPath> + <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath> + </properties> + + <dependencies> + + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-misc-env</artifactId> + </dependency> + + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-cadi-core</artifactId> + </dependency> + + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-misc-rosetta</artifactId> + </dependency> + + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-cadi-aaf</artifactId> + </dependency> + + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-auth-cass</artifactId> + </dependency> + + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-auth-deforg</artifactId> + </dependency> + + <!--dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency --> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude>**/gen/**</exclude> + <exclude>**/generated-sources/**</exclude> + <exclude>**/yang-gen/**</exclude> + <exclude>**/pax/**</exclude> + </excludes> + </configuration> + <executions> + + <execution> + <id>pre-unit-test</id> + <goals> + <goal>prepare-agent</goal> + </goals> + <configuration> + <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile> + <propertyName>surefireArgLine</propertyName> + </configuration> + </execution> + + + <execution> + <id>post-unit-test</id> + <phase>test</phase> + <goals> + <goal>report</goal> + </goals> + <configuration> + <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile> + <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> + </configuration> + </execution> + <execution> + <id>pre-integration-test</id> + <phase>pre-integration-test</phase> + <goals> + <goal>prepare-agent</goal> + </goals> + <configuration> + <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile> + <propertyName>failsafeArgLine</propertyName> + </configuration> + </execution> + + <execution> + <id>post-integration-test</id> + <phase>post-integration-test</phase> + <goals> + <goal>report</goal> + </goals> + <configuration> + <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile> + <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <classifier>tests</classifier> + <archive> + <manifest> + <mainClass>org.onap.aaf.auth.batch.Batch</mainClass> + </manifest> + <manifestEntries> + <Sealed>true</Sealed> + </manifestEntries> + </archive> + + </configuration> + <executions> + <execution> + <id>full</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/assemble/auth-batch.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <distributionManagement> + <repository> + <id>ecomp-releases</id> + <name>AAF Release Repository</name> + <url>${nexusproxy}${releaseNexusPath}</url> + </repository> + <snapshotRepository> + <id>ecomp-snapshots</id> + <name>AAF Snapshot Repository</name> + <url>${nexusproxy}${snapshotNexusPath}</url> + </snapshotRepository> + <site> + <id>ecomp-site</id> + <url>dav:${nexusproxy}${sitePath}</url> + </site> + </distributionManagement> </project> diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java index 7b6e09f5..a943cbc2 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/ApprovedRpt.java @@ -30,13 +30,10 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.UUID; - import org.onap.aaf.auth.batch.Batch; import org.onap.aaf.auth.env.AuthzTrans; import org.onap.aaf.auth.org.OrganizationException; -import org.onap.aaf.cadi.routing.GreatCircle; import org.onap.aaf.cadi.util.CSV; -import org.onap.aaf.cadi.util.CSV.Visitor; import org.onap.aaf.cadi.util.CSV.Writer; import org.onap.aaf.misc.env.APIException; import org.onap.aaf.misc.env.Env; diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_ApprovalSetTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_ApprovalSetTest.java new file mode 100644 index 00000000..fe7bd6c5 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_ApprovalSetTest.java @@ -0,0 +1,150 @@ +/** + * ============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.approvalsets; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.MockitoAnnotations.initMocks; + +import java.io.IOException; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Properties; +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.common.Define; +import org.onap.aaf.auth.dao.cass.ApprovalDAO; +import org.onap.aaf.auth.dao.cass.FutureDAO; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.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.ResultSet; +import com.datastax.driver.core.Session; + +public class JU_ApprovalSetTest { + + @Mock + AuthzTrans trans; + @Mock + Cluster cluster; + @Mock + PropAccess access; + + @Mock + ApprovalSet actionObj; + + @Mock + DataView dv; + + @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); + GregorianCalendar start= new GregorianCalendar(); + actionObj = new ApprovalSet(start, "test", dv); + } catch (CadiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testPuntDate() { + actionObj.write(trans); + ApprovalDAO.Data dataObj = new ApprovalDAO.Data(); + + Result<FutureDAO.Data> rs1 = new Result<FutureDAO.Data>(null,0,"test",new Object[0]); + Mockito.doReturn(rs1).when(dv).insert(Mockito.any(AuthzTrans.class), Mockito.any(FutureDAO.Data.class)); + Mockito.doReturn(rs1).when(dv).insert(Mockito.any(AuthzTrans.class), Mockito.any(ApprovalDAO.Data.class)); + actionObj.ladd.add(dataObj); + Result<Void> retVal = actionObj.write(trans); + + rs1 = new Result<FutureDAO.Data>(null,1,"test",new Object[0]); + Mockito.doReturn(rs1).when(dv).insert(Mockito.any(AuthzTrans.class), Mockito.any(ApprovalDAO.Data.class)); + retVal = actionObj.write(trans); + assertTrue("Security - test".equals(retVal.details)); + + actionObj.ladd.add(dataObj); + retVal = actionObj.write(trans); + assertTrue(retVal.details.contains("Security - test")); + + Mockito.doReturn(rs1).when(dv).insert(Mockito.any(AuthzTrans.class), Mockito.any(FutureDAO.Data.class)); + retVal = actionObj.write(trans); + assertTrue(retVal.details.contains("Security - test")); + + actionObj.setConstruct(null); + actionObj.setExpires(new GregorianCalendar()); + actionObj.setMemo(""); + actionObj.ladd = null; + actionObj.write(trans); + } + + @Test + public void testHasApprovals() { + assertFalse(actionObj.hasApprovals()); + + ApprovalDAO.Data dataObj = new ApprovalDAO.Data(); + actionObj.ladd.add(dataObj); + assertTrue(actionObj.hasApprovals()); + } + + @Test + public void testApprovers() { + Set<String> retVal = actionObj.approvers(); + assertTrue(retVal.size() == 0); + + ApprovalDAO.Data dataObj = new ApprovalDAO.Data(); + actionObj.ladd.add(dataObj); + retVal = actionObj.approvers(); + assertTrue(retVal.size() == 1); + + } +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_Pending.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_Pending.java new file mode 100644 index 00000000..eca5ed7c --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_Pending.java @@ -0,0 +1,133 @@ +/** + * ============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.approvalsets; + +import static org.junit.Assert.assertTrue; +import static org.mockito.MockitoAnnotations.initMocks; + +import java.io.IOException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.cadi.util.CSV.Writer; +import org.onap.aaf.misc.env.APIException; + +import com.datastax.driver.core.Cluster; + +public class JU_Pending { + + @Mock + AuthzTrans trans; + @Mock + Cluster cluster; + @Mock + PropAccess access; + + @Mock + DataView dv; + + @Before + public void setUp() throws APIException, IOException { + initMocks(this); + } + + @Test + public void testRow() { + Writer approveCW = Mockito.mock(Writer.class); + Mockito.doNothing().when(approveCW).row(Mockito.anyString(), + Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), + Mockito.anyInt()); + Pending pendingObj = new Pending(new Date()); + pendingObj.row(approveCW, "key"); + Date date = null; + pendingObj = new Pending(date); + } + + @Test + public void testInc() { + List<String> inpList = new ArrayList<>(); + inpList.add("test"); + inpList.add("test"); + inpList.add("test"); + inpList.add(null); + inpList.add("10"); + try { + Pending pendingObj = new Pending(inpList); + pendingObj.inc(); + assertTrue(11 == pendingObj.qty()); + + Pending tempPending = new Pending(inpList); + pendingObj.inc(tempPending); + assertTrue(21 == pendingObj.qty()); + + tempPending.earliest = new Date(); + pendingObj.earliest = new Date(); + pendingObj.inc(tempPending); + + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, 1); + pendingObj.earliest = calendar.getTime(); + pendingObj.inc(tempPending); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testEarliest() { + List<String> inpList = new ArrayList<>(); + try { + inpList.add("test"); + inpList.add("test"); + inpList.add("test"); + inpList.add("2019-01-01"); + inpList.add("10"); + Pending.create(); + + Pending pendingObj = new Pending(inpList); + pendingObj.earliest(null); + + pendingObj.earliest = null; + pendingObj.earliest(new Date()); + + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, 1); + pendingObj.earliest(calendar.getTime()); + assertTrue(119 == pendingObj.earliest().getYear()); + assertTrue(pendingObj.newApprovals()); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_URApprovalSet.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_URApprovalSet.java new file mode 100644 index 00000000..dd9527a1 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/approvalsets/JU_URApprovalSet.java @@ -0,0 +1,234 @@ +/** + * ============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.approvalsets; + +import static org.junit.Assert.assertTrue; +import static org.mockito.MockitoAnnotations.initMocks; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.dao.cass.NsDAO; +import org.onap.aaf.auth.dao.cass.RoleDAO; +import org.onap.aaf.auth.dao.cass.UserRoleDAO; +import org.onap.aaf.auth.dao.cass.UserRoleDAO.Data; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.auth.org.Organization; +import org.onap.aaf.auth.org.Organization.Identity; +import org.onap.aaf.auth.org.OrganizationException; +import org.onap.aaf.cadi.CadiException; +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.org.DefaultOrgIdentity; + +import com.datastax.driver.core.Cluster; + +public class JU_URApprovalSet { + + @Mock + AuthzTrans trans; + @Mock + Cluster cluster; + @Mock + PropAccess access; + + @Mock + DataView dv; + + URApprovalSet approvalObj; + + @Mock + Loader<UserRoleDAO.Data> lurdd; + + @Before + public void setUp() { + initMocks(this); + } + + @Test + public void testConstructor() { + GregorianCalendar start = new GregorianCalendar(); + UserRoleDAO.Data urdd = new UserRoleDAO.Data(); + urdd.rname = "owner"; + urdd.expires = new Date(); + Organization orgObj = Mockito.mock(Organization.class); + try { + + Mockito.doReturn(urdd).when(lurdd).load(); + Mockito.doReturn(orgObj).when(trans).org(); + Mockito.doReturn(Mockito.mock(GregorianCalendar.class)).when(orgObj) + .expiration(null, Organization.Expiration.UserInRole); + + Result<RoleDAO.Data> rsRoleData = new Result<RoleDAO.Data>(null, 0, + "test", new Object[0]); + Mockito.doReturn(rsRoleData).when(dv).roleByName(trans, urdd.role); + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + } catch (CadiException e) { + assertTrue(e.getMessage().contains("Error - test")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + urdd.rname = "admin"; + RoleDAO.Data dataObj = new RoleDAO.Data(); + Result<RoleDAO.Data> rsRoleData = new Result<RoleDAO.Data>(dataObj, + 0, "test", new Object[0]); + Mockito.doReturn(rsRoleData).when(dv).roleByName(trans, urdd.role); + + Result<NsDAO.Data> rsNsData = new Result<NsDAO.Data>(null, 0, + "test", new Object[0]); + Mockito.doReturn(rsNsData).when(dv).ns(trans, urdd.ns); + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + } catch (CadiException e) { + assertTrue(e.getMessage().contains("Error - test")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + urdd.rname = "rname"; + NsDAO.Data dataObj = new NsDAO.Data(); + + Result<NsDAO.Data> rsNsData = new Result<NsDAO.Data>(dataObj, 0, + "test", new Object[0]); + Mockito.doReturn(rsNsData).when(dv).ns(trans, urdd.ns); + + Result<List<Data>> rsData = new Result<List<Data>>(null, 1, "test", + new Object[0]); + Mockito.doReturn(rsData).when(dv).ursByRole(trans, urdd.role); + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + } catch (CadiException e) { + assertTrue(e.getMessage() + .contains("User 'null' in Role 'null' does not exist")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + + List<Data> dataAL = new ArrayList<>(); + Data data = new Data(); + data.user = "user"; + urdd.user = "test"; + dataAL.add(data); + Result<List<Data>> rsData = new Result<List<Data>>(dataAL, 0, + "test", new Object[0]); + Mockito.doReturn(rsData).when(dv).ursByRole(trans, urdd.role); + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + } catch (CadiException e) { + assertTrue(e.getMessage() + .contains("User 'test' in Role 'null' does not exist")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + + List<Data> dataAL = new ArrayList<>(); + Data data = new Data(); + data.user = "user"; + urdd.user = "user"; + dataAL.add(data); + Result<List<Data>> rsData = new Result<List<Data>>(dataAL, 0, + "test", new Object[0]); + Mockito.doReturn(rsData).when(dv).ursByRole(trans, urdd.role); + + Result<List<UserRoleDAO.Data>> rsURData = new Result<List<UserRoleDAO.Data>>( + null, 1, "test", new Object[0]); + Mockito.doReturn(rsURData).when(dv).ursByRole(trans, + urdd.ns + ".owner"); + + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + + List<UserRoleDAO.Data> urDataAL = new ArrayList<>(); + UserRoleDAO.Data urData = new UserRoleDAO.Data(); + urData.user = "user"; + urDataAL.add(urData); + rsURData = new Result<List<UserRoleDAO.Data>>(urDataAL, 0, "test", + new Object[0]); + Mockito.doReturn(rsURData).when(dv).ursByRole(trans, + urdd.ns + ".owner"); + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + + List<Identity> identityAL = new ArrayList<Identity>(); + Identity idenObj = Mockito.mock(DefaultOrgIdentity.class); + identityAL.add(idenObj); + + try { + Mockito.doReturn(identityAL).when(orgObj).getApprovers(trans, + urdd.user); + } catch (OrganizationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + + urDataAL = new ArrayList<>(); + urData = new UserRoleDAO.Data(); + urData.user = "user1"; + urDataAL.add(urData); + rsURData = new Result<List<UserRoleDAO.Data>>(urDataAL, 0, "test", + new Object[0]); + Mockito.doReturn(rsURData).when(dv).ursByRole(trans, + urdd.ns + ".owner"); + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + } catch (CadiException e) { + assertTrue(e.getMessage() + .contains("User 'null' in Role 'null' does not exist")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + try { + Mockito.doThrow(new OrganizationException()).when(orgObj) + .getApprovers(trans, urdd.user); + } catch (OrganizationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + approvalObj = new URApprovalSet(trans, start, dv, lurdd); + } catch (CadiException e) { + e.printStackTrace(); + assertTrue(e.getMessage() + .contains("User 'null' in Role 'null' does not exist")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_BatchDataViewTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_BatchDataViewTest.java new file mode 100644 index 00000000..b918c31d --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_BatchDataViewTest.java @@ -0,0 +1,174 @@ +/** + * ============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; + +import static org.junit.Assert.assertTrue; +import static org.mockito.MockitoAnnotations.initMocks; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.dao.cass.ApprovalDAO; +import org.onap.aaf.auth.dao.cass.FutureDAO; +import org.onap.aaf.auth.dao.cass.NsDAO; +import org.onap.aaf.auth.dao.cass.RoleDAO; +import org.onap.aaf.auth.dao.cass.UserRoleDAO; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.layer.Result; +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.TimeTaken; + +import com.datastax.driver.core.Session; + +public class JU_BatchDataViewTest { + + @Mock + AuthzTrans trans; + + @Mock + Session session; + + @Mock + PropAccess access; + + BatchDataView batchDataViewObj; + + @Before + public void setUp() throws APIException, IOException { + initMocks(this); + batchDataViewObj = new BatchDataView(trans, session, true); + Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start( + Mockito.anyString(), Mockito.anyInt(), Mockito.anyString()); + } + + @Test + public void testNs() { + Result<NsDAO.Data> retVal = batchDataViewObj.ns(trans, "test"); + assertTrue(retVal.status == 9); + + NS n = new NS("test1", "test2", "test3", 1, 2); + NS.data.put("test", n); + retVal = batchDataViewObj.ns(trans, "test"); + assertTrue(retVal.status == 0); + } + + @Test + public void testRoleByName() { + Result<RoleDAO.Data> retVal = batchDataViewObj.roleByName(trans, + "test"); + assertTrue(retVal.status == 9); + + Role n = new Role("test1"); + n.rdd = new RoleDAO.Data(); + Role.byName.put("test", n); + retVal = batchDataViewObj.roleByName(trans, "test"); + assertTrue(retVal.status == 0); + + n.rdd = null; + Role.byName.put("test", n); + retVal = batchDataViewObj.roleByName(trans, "test"); + assertTrue(retVal.status == 9); + } + @Test + public void testUrsByRole() { + Result<List<UserRoleDAO.Data>> retVal = batchDataViewObj + .ursByRole(trans, "test"); + assertTrue(retVal.status == 9); + + Role n = new Role("test1"); + n.rdd = new RoleDAO.Data(); + UserRole ur = new UserRole("user", "role", "ns", "rname", new Date()); + (new UserRole.DataLoadVisitor()).visit(ur); + retVal = batchDataViewObj.ursByRole(trans, "role"); + assertTrue(retVal.status == 0); + + } + @Test + public void testUrsByUser() { + Result<List<UserRoleDAO.Data>> retVal = batchDataViewObj + .ursByUser(trans, "test"); + assertTrue(retVal.status == 9); + + Role n = new Role("test1"); + n.rdd = new RoleDAO.Data(); + UserRole ur = new UserRole("user", "role", "ns", "rname", new Date()); + (new UserRole.DataLoadVisitor()).visit(ur); + retVal = batchDataViewObj.ursByUser(trans, "user"); + assertTrue(retVal.status == 0); + + } + @Test + public void testDeleteFuture() { + FutureDAO.Data dataObj = new FutureDAO.Data(); + dataObj.id = new UUID(1000L, 1000L); + Result<FutureDAO.Data> retVal = batchDataViewObj.delete(trans, dataObj); + assertTrue(retVal.status == 0); + + } + @Test + public void testDeleteApproval() { + ApprovalDAO.Data dataObj = new ApprovalDAO.Data(); + dataObj.id = new UUID(1000L, 1000L); + Result<ApprovalDAO.Data> retVal = batchDataViewObj.delete(trans, + dataObj); + assertTrue(retVal.status == 0); + + } + + @Test + public void testInsertApproval() { + ApprovalDAO.Data dataObj = new ApprovalDAO.Data(); + dataObj.id = new UUID(1000L, 1000L); + dataObj.memo = "memo"; + dataObj.ticket = new UUID(1000L, 1000L); + Result<ApprovalDAO.Data> retVal = batchDataViewObj.insert(trans, + dataObj); + assertTrue(retVal.status == 0); + + } + @Test + public void testInsertFuture() { + FutureDAO.Data dataObj = new FutureDAO.Data(); + dataObj.id = new UUID(1000L, 1000L); + dataObj.memo = "memo"; + dataObj.construct = ByteBuffer.allocate(1000); + Result<FutureDAO.Data> retVal = batchDataViewObj.insert(trans, dataObj); + assertTrue(retVal.status == 0); + + dataObj.target_key = "memo"; + retVal = batchDataViewObj.insert(trans, dataObj); + assertTrue(retVal.status == 0); + } + @Test + public void testFlush() { + batchDataViewObj.flush(); + + } +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_CQLBatchLoopTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_CQLBatchLoopTest.java new file mode 100644 index 00000000..aef5d22c --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_CQLBatchLoopTest.java @@ -0,0 +1,177 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.auth.batch.helpers; + +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 org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.LogTarget; + +import com.datastax.driver.core.Session; + +public class JU_CQLBatchLoopTest { + + @Mock + AuthzTrans trans; + + @Mock + Session session; + + @Mock + LogTarget lg; + + @Mock + CQLBatch cqlBatchObj; + + CQLBatchLoop cqlBatchLoopObj; + + @Before + public void setUp() throws APIException, IOException { + initMocks(this); + Mockito.doReturn(lg).when(trans).info(); + Mockito.doReturn(new StringBuilder()).when(cqlBatchObj).begin(); + cqlBatchLoopObj = new CQLBatchLoop(cqlBatchObj, 0, false); + } + + @Test + public void testShowProgress() { + CQLBatchLoop tempLoopObj = cqlBatchLoopObj.showProgress(); + Field f; + try { + f = CQLBatchLoop.class.getDeclaredField("showProgress"); + f.setAccessible(true); + assertTrue(cqlBatchLoopObj.total() == 0); + assertTrue(f.getBoolean(tempLoopObj)); + } catch (NoSuchFieldException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (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(); + } + } + + @Test + public void testInc() { + StringBuilder sb = cqlBatchLoopObj.inc(); + sb = cqlBatchLoopObj.inc(); + assertTrue(cqlBatchLoopObj.batches() == 1); + Field f; + try { + f = CQLBatchLoop.class.getDeclaredField("showProgress"); + f.setAccessible(true); + f.set(cqlBatchLoopObj, true); + } catch (NoSuchFieldException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (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(); + } + cqlBatchLoopObj.inc(); + assertTrue(cqlBatchLoopObj.batches() == 2); + System.out.println(sb.toString()); + } + + @Test + public void testFlush() { + Field f, f1; + try { + f1 = CQLBatchLoop.class.getDeclaredField("i"); + f1.setAccessible(true); + + f1.set(cqlBatchLoopObj, -1); + } catch (NoSuchFieldException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (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(); + } + cqlBatchLoopObj.flush(); + try { + f = CQLBatchLoop.class.getDeclaredField("current"); + f1 = CQLBatchLoop.class.getDeclaredField("i"); + f.setAccessible(true); + f1.setAccessible(true); + + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL); + + StringBuilder sb = new StringBuilder("tets"); + for (int i = 1; i < 25600; i++) { + sb = sb.append("test"); + } + f.set(cqlBatchLoopObj, sb); + f1.set(cqlBatchLoopObj, 10); + } catch (NoSuchFieldException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (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(); + } + cqlBatchLoopObj.flush(); + } + + @Test + public void testReset() { + cqlBatchLoopObj.reset(); + assertTrue(cqlBatchLoopObj.batches() == 0); + System.out.println(cqlBatchLoopObj.toString()); + } +} diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_CQLBatchTest.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_CQLBatchTest.java new file mode 100644 index 00000000..a826a983 --- /dev/null +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/JU_CQLBatchTest.java @@ -0,0 +1,121 @@ +/** + * ============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; + +import static org.junit.Assert.assertNull; +import static org.mockito.MockitoAnnotations.initMocks; + +import java.io.IOException; +import java.lang.reflect.Field; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aaf.auth.env.AuthzTrans; +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.ResultSet; +import com.datastax.driver.core.Session; + +public class JU_CQLBatchTest { + + @Mock + AuthzTrans trans; + + @Mock + Session session; + + @Mock + LogTarget lg; + + CQLBatch cqlBatchObj; + + @Before + public void setUp() throws APIException, IOException { + initMocks(this); + Mockito.doReturn(lg).when(trans).info(); + cqlBatchObj = new CQLBatch(lg, session); + Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start( + Mockito.anyString(), Mockito.anyInt(), Mockito.anyString()); + + Mockito.doReturn(Mockito.mock(ResultSet.class)).when(session) + .execute(Mockito.anyString()); + } + + @Test + public void testExecute() { + ResultSet retVal = cqlBatchObj.execute(); + assertNull(retVal); + + Field f; + try { + f = CQLBatch.class.getDeclaredField("sb"); + f.setAccessible(true); + f.set(cqlBatchObj, new StringBuilder("test")); + retVal = cqlBatchObj.execute(); + } catch (NoSuchFieldException | SecurityException + | IllegalArgumentException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + @Test + public void testExecute2() { + ResultSet retVal = cqlBatchObj.execute(false); + assertNull(retVal); + + Field f; + try { + f = CQLBatch.class.getDeclaredField("sb"); + f.setAccessible(true); + f.set(cqlBatchObj, new StringBuilder("test")); + retVal = cqlBatchObj.execute(true); + cqlBatchObj.toString(); + } catch (NoSuchFieldException | SecurityException + | IllegalArgumentException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + @Test + public void testSingleExec() { + ResultSet retVal = cqlBatchObj.singleExec(new StringBuilder("test"), + true); + assertNull(retVal); + + retVal = cqlBatchObj.singleExec(new StringBuilder("test"), false); + } + + @Test + public void testTouch() { + cqlBatchObj.touch("test", 0, 4, true); + + } + +} |