diff options
170 files changed, 20168 insertions, 3807 deletions
@@ -8,4 +8,4 @@ ecomp-sdk/*/null*.csv ecomp-sdk/*/null* ecomp-sdk/*/jacoco.exec ecomp-sdk/*/target -test.txt +test*.txt diff --git a/ecomp-sdk/epsdk-aaf/pom.xml b/ecomp-sdk/epsdk-aaf/pom.xml index cccfc833..f3d22f61 100644 --- a/ecomp-sdk/epsdk-aaf/pom.xml +++ b/ecomp-sdk/epsdk-aaf/pom.xml @@ -1,16 +1,18 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<?xml version="1.0"?> +<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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-aaf</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> <packaging>jar</packaging> <name>ONAP Portal SDK AAF Authorization</name> @@ -49,6 +51,25 @@ <artifactId>eelf-core</artifactId> <version>1.0.0</version> </dependency> + <!-- Jacoco for offline instrumentation --> + <dependency> + <groupId>org.jacoco</groupId> + <artifactId>org.jacoco.agent</artifactId> + <version>${jacoco.version}</version> + <classifier>runtime</classifier> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> @@ -117,12 +138,6 @@ <artifactId>jackson-databind</artifactId> <version>2.6.3</version> </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <scope>test</scope> - </dependency> </dependencies> <profiles> <!-- disable doclint, a new feature in Java 8, when generating javadoc --> @@ -154,7 +169,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> + <version>3.7.0</version> <configuration> <source>1.8</source> <target>1.8</target> diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java index 80956e64..a598a4c4 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPerms.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.domain; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java index fab7d2c0..47c613b0 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetail.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.domain; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java index a14a4b5f..8c191181 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.domain; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java index f38b2f9f..95b4f0c4 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.domain; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java index 3ca88991..aafd9c1b 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUser.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.domain; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java index 5106f387..929bd351 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.domain; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java index 33e21f2c..67d83ff6 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRole.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.domain; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java index d09db15d..68effb0c 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.domain; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java index 8d15b44c..785bbf95 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/exception/UserNotFoundException.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.exception; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java index 8f387f98..0ad02460 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthService.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.service; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java index d2ccfc2e..173e9e7d 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImpl.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.service; @@ -59,6 +59,7 @@ import org.onap.portalsdk.core.web.support.AppUtils; import org.onap.portalsdk.core.web.support.UserUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service("loginExternalAuthService") public class LoginExternalAuthServiceImpl implements LoginExternalAuthService { @@ -79,6 +80,7 @@ public class LoginExternalAuthServiceImpl implements LoginExternalAuthService { @Override @SuppressWarnings("rawtypes") + @Transactional public LoginBean findUser(LoginBean bean, String menuPropertiesFilename, Map additionalParams, boolean matchPassword, HttpServletRequest request) throws Exception { diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java index 6eb312b6..14aeaf5e 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiService.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.service; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java index 8425f7da..fb320c17 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.service; @@ -207,28 +207,30 @@ public class UserApiServiceImpl implements UserApiService { role.setPriority(Integer.valueOf(roleDesc.getPriority())); } } - for (ExternalAccessPerms extPerm : roleDesc.getPermissions()) { - RoleFunction roleFunction = new RoleFunction(); - roleFunction.setCode(extPerm.getInstance()); - roleFunction.setAction(extPerm.getAction()); - if (extPerm.getDescription() != null - && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) { - roleFunction.setName(extPerm.getDescription()); - } else if (extPerm.getDescription() == null - && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) { - roleFunction.setName(extPerm.getType().substring(namespace.length() + 1) + "|" - + extPerm.getInstance() + "|" + extPerm.getAction()); - } else if (extPerm.getDescription() == null - && !EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) { - roleFunction.setName( - extPerm.getType() + "|" + extPerm.getInstance() + "|" + extPerm.getAction()); + if (roleDesc.getPermissions() != null) { + for (ExternalAccessPerms extPerm : roleDesc.getPermissions()) { + RoleFunction roleFunction = new RoleFunction(); + roleFunction.setCode(extPerm.getInstance()); + roleFunction.setAction(extPerm.getAction()); + if (extPerm.getDescription() != null + && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) { + roleFunction.setName(extPerm.getDescription()); + } else if (extPerm.getDescription() == null + && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) { + roleFunction.setName(extPerm.getType().substring(namespace.length() + 1) + "|" + + extPerm.getInstance() + "|" + extPerm.getAction()); + } else if (extPerm.getDescription() == null + && !EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) { + roleFunction.setName( + extPerm.getType() + "|" + extPerm.getInstance() + "|" + extPerm.getAction()); + } + if (EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) { + roleFunction.setType(extPerm.getType().substring(namespace.length() + 1)); + } else { + roleFunction.setType(extPerm.getType()); + } + roleFunctions.add(roleFunction); } - if (EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) { - roleFunction.setType(extPerm.getType().substring(namespace.length() + 1)); - } else { - roleFunction.setType(extPerm.getType()); - } - roleFunctions.add(roleFunction); } } role.setRoleFunctions(roleFunctions); diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java index a680a672..87d4c1fd 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthProperties.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.util; diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java index 56b1527e..6f4ff29a 100644 --- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java +++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtils.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalsdk.external.authorization.util; @@ -44,7 +44,6 @@ import javax.xml.bind.DatatypeConverter; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.onap.portalsdk.core.util.SystemProperties; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -53,9 +52,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class EcompExternalAuthUtils { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EcompExternalAuthUtils.class); - - @Autowired - CipherUtil cipherUtil; public static final String EXT_EMPTY_JSON_STRING = "{}"; public static final String EXT_ROLE_FIELD = "role"; diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetailTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetailTest.java new file mode 100644 index 00000000..43dcc827 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsDetailTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.domain; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class ExternalAccessPermsDetailTest { + + public ExternalAccessPermsDetail mockExternalAccessPermsDetailTest() { + List<String> roles = new ArrayList<>(); + roles.add("test_role"); + roles.add("test_role2"); + ExternalAccessPermsDetail mockExtPermsDetailTest = new ExternalAccessPermsDetail(); + mockExtPermsDetailTest.setAction("*"); + mockExtPermsDetailTest.setDescription("test_name"); + mockExtPermsDetailTest.setType("test_type"); + mockExtPermsDetailTest.setInstance("test_instance"); + mockExtPermsDetailTest.setRoles(roles); + return mockExtPermsDetailTest; + } + + @Test + public void externalAccessPermsDetailTest() { + List<String> roles = new ArrayList<>(); + roles.add("test_role"); + roles.add("test_role2"); + ExternalAccessPermsDetail extPermsDetailTest = new ExternalAccessPermsDetail(); + ExternalAccessPermsDetail extPermsDetailTest2 = new ExternalAccessPermsDetail("test_type", "test_instance", "*", + "test_name"); + ExternalAccessPermsDetail extPermsDetailTest3 = new ExternalAccessPermsDetail("test_type", "test_instance", "*", + roles, "test_name"); + extPermsDetailTest.setAction("*"); + extPermsDetailTest.setDescription("test_name"); + extPermsDetailTest.setType("test_type"); + extPermsDetailTest.setInstance("test_instance"); + extPermsDetailTest.setRoles(roles); + assertEquals(extPermsDetailTest.getAction(), mockExternalAccessPermsDetailTest().getAction()); + assertEquals(extPermsDetailTest.getType(), mockExternalAccessPermsDetailTest().getType()); + assertEquals(extPermsDetailTest.getInstance(), mockExternalAccessPermsDetailTest().getInstance()); + assertEquals(extPermsDetailTest.getDescription(), mockExternalAccessPermsDetailTest().getDescription()); + assertEquals(extPermsDetailTest.getRoles(), mockExternalAccessPermsDetailTest().getRoles()); + assertEquals(extPermsDetailTest2.getAction(), mockExternalAccessPermsDetailTest().getAction()); + assertEquals(extPermsDetailTest2.getType(), mockExternalAccessPermsDetailTest().getType()); + assertEquals(extPermsDetailTest2.getInstance(), mockExternalAccessPermsDetailTest().getInstance()); + assertEquals(extPermsDetailTest2.getDescription(), mockExternalAccessPermsDetailTest().getDescription()); + assertEquals(extPermsDetailTest2.getRoles(), null); + assertEquals(extPermsDetailTest3.getAction(), mockExternalAccessPermsDetailTest().getAction()); + assertEquals(extPermsDetailTest3.getType(), mockExternalAccessPermsDetailTest().getType()); + assertEquals(extPermsDetailTest3.getInstance(), mockExternalAccessPermsDetailTest().getInstance()); + assertEquals(extPermsDetailTest3.getDescription(), mockExternalAccessPermsDetailTest().getDescription()); + assertEquals(extPermsDetailTest3.getRoles(), mockExternalAccessPermsDetailTest().getRoles()); + } + +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java new file mode 100644 index 00000000..0f3a65a5 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.domain; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class ExternalAccessPermsTest { + + public ExternalAccessPerms mockExternalAccessPermsTest() { + ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms(); + mockExtPermsTest.setAction("*"); + mockExtPermsTest.setDescription("test_name"); + mockExtPermsTest.setType("test_type"); + mockExtPermsTest.setInstance("test_instance"); + return mockExtPermsTest; + } + + @Test + public void externalAccessPermsTest() { + List<String> roles = new ArrayList<>(); + roles.add("test_role"); + roles.add("test_role2"); + ExternalAccessPerms extPermsDetailTest = new ExternalAccessPerms(); + ExternalAccessPerms extPermsDetailTest2 = new ExternalAccessPerms("test_type", "test_instance", "*"); + ExternalAccessPerms extPermsDetailTest3 = new ExternalAccessPerms("test_type", "test_instance", "*", + "test_name"); + extPermsDetailTest.setAction("*"); + extPermsDetailTest.setDescription("test_name"); + extPermsDetailTest.setType("test_type"); + extPermsDetailTest.setInstance("test_instance"); + assertEquals(extPermsDetailTest.getAction(), mockExternalAccessPermsTest().getAction()); + assertEquals(extPermsDetailTest.getType(), mockExternalAccessPermsTest().getType()); + assertEquals(extPermsDetailTest.getInstance(), mockExternalAccessPermsTest().getInstance()); + assertEquals(extPermsDetailTest.getDescription(), mockExternalAccessPermsTest().getDescription()); + assertEquals(extPermsDetailTest2.getAction(), mockExternalAccessPermsTest().getAction()); + assertEquals(extPermsDetailTest2.getType(), mockExternalAccessPermsTest().getType()); + assertEquals(extPermsDetailTest2.getInstance(), mockExternalAccessPermsTest().getInstance()); + assertEquals(null, extPermsDetailTest2.getDescription()); + assertEquals(extPermsDetailTest3.getAction(), mockExternalAccessPermsTest().getAction()); + assertEquals(extPermsDetailTest3.getType(), mockExternalAccessPermsTest().getType()); + assertEquals(extPermsDetailTest3.getInstance(), mockExternalAccessPermsTest().getInstance()); + assertEquals(extPermsDetailTest3.getDescription(), mockExternalAccessPermsTest().getDescription()); + assertEquals(true, new ExternalAccessPerms("test_type", "test_instance", "*", "test_name") + .equals(new ExternalAccessPerms("test_type", "test_instance", "*", "test_name"))); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java new file mode 100644 index 00000000..acb14c65 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.domain; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class ExternalAccessRolePermsTest { + + public ExternalAccessRolePerms mockExternalAccessRolePermsTest() { + ExternalAccessPerms mockPerm = new ExternalAccessPerms(); + mockPerm.setAction("*"); + mockPerm.setDescription("test_name"); + mockPerm.setType("test_type"); + mockPerm.setInstance("test_instance"); + ExternalAccessRolePerms mockExtRolePermsTest = new ExternalAccessRolePerms(mockPerm, "test_role"); + return mockExtRolePermsTest; + } + + @Test + public void externalAccessRolePermsTest() { + ExternalAccessPerms perm = new ExternalAccessPerms(); + perm.setAction("*"); + perm.setDescription("test_name"); + perm.setType("test_type"); + perm.setInstance("test_instance"); + ExternalAccessRolePerms mockExtRolePermsTest = new ExternalAccessRolePerms(perm, "test_role"); + assertEquals(mockExtRolePermsTest.getRole(), mockExternalAccessRolePermsTest().getRole()); + assertEquals(mockExtRolePermsTest.getPerm(), mockExternalAccessRolePermsTest().getPerm()); + } + +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java new file mode 100644 index 00000000..aa498aa0 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.domain; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class ExternalAccessRoleTest { + + public ExternalAccessRole mockExternalAccessRoleTest() { + ExternalAccessRole mockRole = new ExternalAccessRole(); + mockRole.setName("test_role"); + mockRole.setDescription("test_role_description"); + return mockRole; + } + + @Test + public void externalAccessRolePermsTest() { + ExternalAccessRole role = new ExternalAccessRole("test_role", "test_role_description"); + assertEquals(role.getName(), mockExternalAccessRoleTest().getName()); + assertEquals(role.getDescription(), mockExternalAccessRoleTest().getDescription()); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java new file mode 100644 index 00000000..5e750543 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.domain; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class ExternalAccessUserRoleDetailTest { + + public ExternalAccessUserRoleDetail mockExternalAccessUserRoleDetailTest() { + List<ExternalAccessPerms> mockPerms = new ArrayList<>(); + ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms(); + mockExtPermsTest.setAction("*"); + mockExtPermsTest.setDescription("test_name"); + mockExtPermsTest.setType("test_type"); + mockExtPermsTest.setInstance("test_instance"); + mockPerms.add(mockExtPermsTest); + ExternalRoleDescription mockRoleDesc = new ExternalRoleDescription(); + mockRoleDesc.setActive("true"); + mockRoleDesc.setAppId("1"); + mockRoleDesc.setAppRoleId("1"); + mockRoleDesc.setId("1"); + mockRoleDesc.setPriority("1"); + mockRoleDesc.setName("test"); + mockRoleDesc.setPermissions(mockPerms); + ExternalAccessUserRoleDetail mockExtUserRoleDetailTest = new ExternalAccessUserRoleDetail(); + mockExtUserRoleDetailTest.setName("test"); + mockExtUserRoleDetailTest.setDescription(mockRoleDesc); + return mockExtUserRoleDetailTest; + } + + @Test + public void externalAccessPermsTest() { + List<ExternalAccessPerms> perms = new ArrayList<>(); + ExternalAccessPerms extPermsTest = new ExternalAccessPerms(); + extPermsTest.setAction("*"); + extPermsTest.setDescription("test_name"); + extPermsTest.setType("test_type"); + extPermsTest.setInstance("test_instance"); + perms.add(extPermsTest); + ExternalRoleDescription roleDesc = new ExternalRoleDescription(); + roleDesc.setActive("true"); + roleDesc.setAppId("1"); + roleDesc.setAppRoleId("1"); + roleDesc.setId("1"); + roleDesc.setPriority("1"); + roleDesc.setName("test"); + roleDesc.setPermissions(perms); + ExternalAccessUserRoleDetail extUserRoleDetailTest = new ExternalAccessUserRoleDetail(); + extUserRoleDetailTest.setName("test"); + extUserRoleDetailTest.setDescription(roleDesc); + ExternalAccessUserRoleDetail extUserRoleDetailTest2 = new ExternalAccessUserRoleDetail("test", roleDesc); + assertEquals(extUserRoleDetailTest.getName(), mockExternalAccessUserRoleDetailTest().getName()); + assertEquals(extUserRoleDetailTest.getDescription(), mockExternalAccessUserRoleDetailTest().getDescription()); + assertEquals(extUserRoleDetailTest2.getName(), mockExternalAccessUserRoleDetailTest().getName()); + assertEquals(extUserRoleDetailTest2.getDescription(), mockExternalAccessUserRoleDetailTest().getDescription()); + assertEquals(true, new ExternalAccessUserRoleDetail("test",roleDesc) + .equals(new ExternalAccessUserRoleDetail("test",roleDesc))); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserTest.java new file mode 100644 index 00000000..18909b74 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.domain; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class ExternalAccessUserTest { + + public ExternalAccessUser mockExternalAccessUserTest() { + return new ExternalAccessUser("test", "test123"); + } + + @Test + public void externalAccessUserTest() { + ExternalAccessUser extUserTest = new ExternalAccessUser("test", "test123"); + assertEquals(extUserTest.getUser(), mockExternalAccessUserTest().getUser()); + assertEquals(extUserTest.getRole(), mockExternalAccessUserTest().getRole()); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRoleTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRoleTest.java new file mode 100644 index 00000000..c295a537 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAuthUserRoleTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.domain; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class ExternalAuthUserRoleTest { + + public ExternalAuthUserRole mockExternalAccessUserTest() { + ExternalAuthUserRole mockExtAuthUserRole = new ExternalAuthUserRole(); + mockExtAuthUserRole.setUser("test123"); + mockExtAuthUserRole.setRole("test"); + mockExtAuthUserRole.setExpiryDate("1/1/1111"); + return mockExtAuthUserRole; + } + + @Test + public void externalAuthUserRoleTest() { + ExternalAuthUserRole extAuthUserRole = new ExternalAuthUserRole(); + extAuthUserRole.setUser("test123"); + extAuthUserRole.setRole("test"); + extAuthUserRole.setExpiryDate("1/1/1111"); + assertEquals(extAuthUserRole.getRole(), mockExternalAccessUserTest().getRole()); + assertEquals(extAuthUserRole.getUser(), mockExternalAccessUserTest().getUser()); + assertEquals(extAuthUserRole.getExpiryDate(), mockExternalAccessUserTest().getExpiryDate()); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java new file mode 100644 index 00000000..251f8303 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.domain; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class ExternalRoleDescriptionTest { + + public ExternalRoleDescription mockExternalRoleDescriptionTest() { + List<ExternalAccessPerms> mockPerms = new ArrayList<>(); + ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms(); + mockExtPermsTest.setAction("*"); + mockExtPermsTest.setDescription("test_name"); + mockExtPermsTest.setType("test_type"); + mockExtPermsTest.setInstance("test_instance"); + mockPerms.add(mockExtPermsTest); + ExternalRoleDescription mockExtRoleDesc = new ExternalRoleDescription(); + mockExtRoleDesc.setActive("true"); + mockExtRoleDesc.setAppRoleId("1"); + mockExtRoleDesc.setAppId("1"); + mockExtRoleDesc.setId("1"); + mockExtRoleDesc.setName("test"); + mockExtRoleDesc.setPermissions(mockPerms); + mockExtRoleDesc.setPriority("1"); + return mockExtRoleDesc; + } + + @Test + public void externalRoleDescriptionTest() { + List<ExternalAccessPerms> perms = new ArrayList<>(); + ExternalAccessPerms extPermsTest = new ExternalAccessPerms(); + extPermsTest.setAction("*"); + extPermsTest.setDescription("test_name"); + extPermsTest.setType("test_type"); + extPermsTest.setInstance("test_instance"); + perms.add(extPermsTest); + ExternalRoleDescription extRoleDesc = new ExternalRoleDescription(); + extRoleDesc.setActive("true"); + extRoleDesc.setAppRoleId("1"); + extRoleDesc.setAppId("1"); + extRoleDesc.setId("1"); + extRoleDesc.setName("test"); + extRoleDesc.setPermissions(perms); + extRoleDesc.setPriority("1"); + assertEquals(extRoleDesc.getActive(), mockExternalRoleDescriptionTest().getActive()); + assertEquals(extRoleDesc.getAppId(), mockExternalRoleDescriptionTest().getAppId()); + assertEquals(extRoleDesc.getAppRoleId(), mockExternalRoleDescriptionTest().getAppRoleId()); + assertEquals(extRoleDesc.getId(), mockExternalRoleDescriptionTest().getId()); + assertEquals(extRoleDesc.getName(), mockExternalRoleDescriptionTest().getName()); + assertEquals(extRoleDesc.getPriority(), mockExternalRoleDescriptionTest().getPriority()); + assertEquals(extRoleDesc.getPermissions(), mockExternalRoleDescriptionTest().getPermissions()); + assertEquals(true, extRoleDesc.equals(mockExternalRoleDescriptionTest())); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java new file mode 100644 index 00000000..ae6eb975 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java @@ -0,0 +1,185 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.service; + +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.portalsdk.core.command.LoginBean; +import org.onap.portalsdk.core.domain.App; +import org.onap.portalsdk.core.domain.Role; +import org.onap.portalsdk.core.domain.RoleFunction; +import org.onap.portalsdk.core.domain.User; +import org.onap.portalsdk.core.domain.UserApp; +import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.portalsdk.core.web.support.AppUtils; +import org.onap.portalsdk.core.web.support.UserUtils; +import org.onap.portalsdk.external.framework.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@SuppressWarnings({ "unchecked", "rawtypes" }) +@RunWith(PowerMockRunner.class) +@PrepareForTest({AppUtils.class, UserUtils.class, SystemProperties.class}) +public class LoginExternalAuthServiceImplTest { + + @InjectMocks + private LoginExternalAuthServiceImpl loginExternalAuthServiceImpl; + + @Mock + private DataAccessService dataAccessService; + + @Mock + private UserApiService userApiService; + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + @Before + public void setup() { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(UserUtils.class); + PowerMockito.mockStatic(SystemProperties.class); + } + + private User userObj() { + User user = new User(); + user.setEmail("test@mail.com"); + user.setFirstName("Test_firstname"); + user.setHrid("test_hrid"); + user.setJobTitle("test_jobtitle"); + user.setLastName("test_lastname"); + user.setLoginId("test123"); + user.setOrgManagerUserId("test456"); + user.setMiddleInitial("test_middlename"); + user.setOrgCode("testcode"); + user.setOrgId(1l); + user.setOrgUserId("test123"); + user.setActive(true); + user.setLastLoginDate(new Date()); + RoleFunction roleFunction = new RoleFunction(); + roleFunction.setId(12L); + roleFunction.setName("Role Function"); + + Set roleFunctions = new TreeSet(); + roleFunctions.add(roleFunction); + + Role role = new Role(); + role.setName("Role"); + role.setActive(true); + role.setRoleFunctions(roleFunctions); + Set userApps = new TreeSet(); + UserApp userApp = new UserApp(); + userApp.setUserId(1L); + userApp.setApp(getApp()); + userApp.setRole(role); + userApps.add(userApp); + user.setUserApps(userApps); + return user; + } + + public App getApp() { + App app = new App(); + app.setId(new Long(1)); + app.setName("Default"); + return app; + } + + @Test + public void findUserTest() throws Exception { + LoginBean bean = new LoginBean(); + bean.setUserid("test123"); + Map additionalParams = new HashMap<>(); + User user = userObj(); + user.setId(1l); + List usersId = new ArrayList<>(); + usersId.add(user.getId()); + List users = new ArrayList<>(); + users.add(user); + Mockito.when(userApiService.getUser(bean.getUserid(), mockedRequest)).thenReturn(user); + Map<String, String> params = new HashMap<>(); + params.put("orgUserId", "test123"); + Mockito.when(dataAccessService.executeNamedQuery("getUserIdByorgUserId", params, null)).thenReturn(usersId); + Map<String, String> params2 = new HashMap<>(); + params.put("org_user_id", "test123"); + Mockito.when(dataAccessService.executeNamedQuery("getUserByOrgUserId", params2, new HashMap())).thenReturn(users); + LoginBean expected = loginExternalAuthServiceImpl.findUser(bean, "menu", additionalParams, mockedRequest); + assertNotNull(expected); + } + + @Test + public void findUserForNewUserTest() throws Exception { + LoginBean bean = new LoginBean(); + bean.setUserid("test123"); + Map additionalParams = new HashMap<>(); + User user = userObj(); + List usersId = new ArrayList<>(); + usersId.add(user.getId()); + List users = new ArrayList<>(); + users.add(user); + Mockito.when(userApiService.getUser(bean.getUserid(), mockedRequest)).thenReturn(user); + Map<String, String> params = new HashMap<>(); + params.put("orgUserId", "test123"); + Mockito.when(dataAccessService.executeNamedQuery("getUserIdByorgUserId", params, null)).thenReturn(usersId); + Map<String, String> params2 = new HashMap<>(); + params.put("org_user_id", "test123"); + Mockito.when(dataAccessService.executeNamedQuery("getUserByOrgUserId", params2, new HashMap())).thenReturn(null); + LoginBean expected = loginExternalAuthServiceImpl.findUser(bean, "menu", additionalParams, mockedRequest); + assertNotNull(expected); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImplTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImplTest.java new file mode 100644 index 00000000..d93b03c1 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImplTest.java @@ -0,0 +1,313 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.service; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.json.JSONObject; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.core.command.PostSearchBean; +import org.onap.portalsdk.core.command.support.SearchResult; +import org.onap.portalsdk.core.domain.App; +import org.onap.portalsdk.core.domain.Role; +import org.onap.portalsdk.core.domain.RoleFunction; +import org.onap.portalsdk.core.domain.User; +import org.onap.portalsdk.core.domain.UserApp; +import org.onap.portalsdk.core.service.AppService; +import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.service.LdapService; +import org.onap.portalsdk.core.service.PostSearchService; +import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.portalsdk.external.authorization.util.EcompExternalAuthProperties; +import org.onap.portalsdk.external.authorization.util.EcompExternalAuthUtils; +import org.onap.portalsdk.external.framework.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@SuppressWarnings({ "rawtypes", "unchecked" }) +@RunWith(PowerMockRunner.class) +@PrepareForTest({ EcompExternalAuthProperties.class, EcompExternalAuthUtils.class }) +public class UserApiServiceImplTest { + + private static final String APP_ID = "appId"; + + private static final String PRIORITY = "priority"; + + private static final String ACTIVE = "active"; + + private static final String ROLE_NAME = "name"; + + private static final String APP_ROLE_ID = "appRoleId"; + + private static final String ID = "id"; + + @InjectMocks + private UserApiServiceImpl UserApiServiceImpl; + + @Mock + private DataAccessService dataAccessService; + + @Mock + private LoginExternalAuthService loginAAFService; + + @Mock + private LdapService ldapService; + + @Mock + private PostSearchService postSearchService; + + @Mock + private AppService appService; + + @Mock + RestTemplate template = new RestTemplate(); + + @Before + public void setup() throws Exception { + PowerMockito.mockStatic(EcompExternalAuthProperties.class); + PowerMockito.mockStatic(EcompExternalAuthUtils.class); + PowerMockito.mockStatic(SystemProperties.class); + Mockito.when(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_NAMESPACE)) + .thenReturn("com.test.app2"); + Mockito.when(EcompExternalAuthUtils.base64encodeKeyForAAFBasicAuth()).thenReturn(new HttpHeaders()); + Mockito.when(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_USER_DOMAIN)) + .thenReturn("@test.com"); + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + private User userObj() { + User user = new User(); + user.setEmail("test@mail.com"); + user.setFirstName("Test_firstname"); + user.setHrid("test_hrid"); + user.setJobTitle("test_jobtitle"); + user.setLastName("test_lastname"); + user.setLoginId("test123"); + user.setOrgManagerUserId("test456"); + user.setMiddleInitial("test_middlename"); + user.setOrgCode("testcode"); + user.setOrgId(1l); + user.setOrgUserId("test123"); + user.setActive(true); + user.setLastLoginDate(new Date()); + RoleFunction roleFunction = new RoleFunction(); + roleFunction.setId(12L); + roleFunction.setName("Role Function"); + + Set roleFunctions = new TreeSet(); + roleFunctions.add(roleFunction); + + Role role = new Role(); + role.setName("Role"); + role.setActive(true); + role.setRoleFunctions(roleFunctions); + Set userApps = new TreeSet(); + UserApp userApp = new UserApp(); + userApp.setUserId(1L); + userApp.setApp(getApp()); + userApp.setRole(role); + userApps.add(userApp); + user.setUserApps(userApps); + return user; + } + + public App getApp() { + App app = new App(); + app.setId(new Long(1)); + app.setName("Default"); + return app; + } + + @Test + public void getUserTest() throws Exception { + ObjectMapper mapper = new ObjectMapper(); + Map<String, String> roleDesc = new LinkedHashMap<>(); + roleDesc.put(ID, "1"); + roleDesc.put(ROLE_NAME, "test_role"); + roleDesc.put(ACTIVE, String.valueOf(true)); + roleDesc.put(PRIORITY, String.valueOf(1)); + roleDesc.put(APP_ID, String.valueOf(1)); + roleDesc.put(APP_ROLE_ID, String.valueOf(1l)); + String addDesc = mapper.writeValueAsString(roleDesc); + JSONObject mockJsonObjectRole = new JSONObject(); + JSONObject mockJsonObjectRole2 = new JSONObject(); + JSONObject mockJsonObjectRole3 = new JSONObject(); + JSONObject mockJsonObjectRole4 = new JSONObject(); + JSONObject mockJsonObjectRole5 = new JSONObject(); + JSONObject mockJsonObjectPerm1 = new JSONObject(); + JSONObject mockJsonObjectPerm2 = new JSONObject(); + mockJsonObjectPerm1.put("type", "com.test.app2.test_type"); + mockJsonObjectPerm1.put("instance", "test_instance"); + mockJsonObjectPerm1.put("action", "*"); + mockJsonObjectPerm2.put("type", "com.test.app.test_type2"); + mockJsonObjectPerm2.put("instance", "test_instance2"); + mockJsonObjectPerm2.put("action", "*"); + List<JSONObject> permsList = new ArrayList<>(); + permsList.add(mockJsonObjectPerm1); + permsList.add(mockJsonObjectPerm2); + mockJsonObjectRole.put("name", "com.test.app2.test_role"); + mockJsonObjectRole2.put("name", "com.test.app2.test_role2"); + mockJsonObjectRole2.put("perms", permsList); + mockJsonObjectRole2.put("description", addDesc); + mockJsonObjectRole3.put("name", "com.test.app2.Account_Administrator"); + mockJsonObjectRole4.put("name", "com.test.app2.admin"); + mockJsonObjectRole5.put("name", "com.test.app2.owner"); + List<JSONObject> userRolesList = new ArrayList<>(); + JSONObject mockJsonObjectFinalUserRole = new JSONObject(); + userRolesList.add(mockJsonObjectRole); + userRolesList.add(mockJsonObjectRole2); + userRolesList.add(mockJsonObjectRole3); + userRolesList.add(mockJsonObjectRole4); + userRolesList.add(mockJsonObjectRole5); + mockJsonObjectFinalUserRole.put("role", userRolesList); + Mockito.when(EcompExternalAuthUtils.isJSONValid(addDesc)).thenReturn(true); + ResponseEntity<String> response = new ResponseEntity<>(mockJsonObjectFinalUserRole.toString(), HttpStatus.OK); + Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), + Matchers.<HttpEntity<String>>any(), Matchers.eq(String.class))).thenReturn(response); + Mockito.when(EcompExternalAuthUtils.checkNameSpaceMatching(Matchers.anyString(), Matchers.anyString())) + .thenReturn(true); + Mockito.when(loginAAFService.findUserWithoutPwd("test123")).thenReturn(userObj()); + Mockito.when(appService.getApp(1l)).thenReturn(getApp()); + User actual = UserApiServiceImpl.getUser("test123", mockedRequest); + assertNotNull(actual); + } + + @Test + public void getNewUserNullExceptionTest() throws Exception { + JSONObject mockJsonObjectRole = new JSONObject(); + JSONObject mockJsonObjectRole2 = new JSONObject(); + JSONObject mockJsonObjectRole3 = new JSONObject(); + JSONObject mockJsonObjectPerm1 = new JSONObject(); + JSONObject mockJsonObjectPerm2 = new JSONObject(); + mockJsonObjectPerm1.put("type", "com.test.app2.test_type"); + mockJsonObjectPerm1.put("instance", "test_instance"); + mockJsonObjectPerm1.put("action", "*"); + mockJsonObjectPerm2.put("type", "com.test.app.test_type2"); + mockJsonObjectPerm2.put("instance", "test_instance2"); + mockJsonObjectPerm2.put("action", "*"); + List<JSONObject> permsList = new ArrayList<>(); + permsList.add(mockJsonObjectPerm1); + permsList.add(mockJsonObjectPerm2); + mockJsonObjectRole.put("name", "com.test.app2.test_role"); + mockJsonObjectRole2.put("name", "com.test.app2.test_role2"); + mockJsonObjectRole2.put("perms", permsList); + mockJsonObjectRole3.put("name", "com.test.app2.Account_Administrator"); + List<JSONObject> userRolesList = new ArrayList<>(); + JSONObject mockJsonObjectFinalUserRole = new JSONObject(); + userRolesList.add(mockJsonObjectRole); + userRolesList.add(mockJsonObjectRole2); + userRolesList.add(mockJsonObjectRole3); + mockJsonObjectFinalUserRole.put("role", userRolesList); + ResponseEntity<String> response = new ResponseEntity<>(mockJsonObjectFinalUserRole.toString(), HttpStatus.OK); + Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), + Matchers.<HttpEntity<String>>any(), Matchers.eq(String.class))).thenReturn(response); + Mockito.when(EcompExternalAuthUtils.checkNameSpaceMatching(Matchers.anyString(), Matchers.anyString())) + .thenReturn(true); + Mockito.when(loginAAFService.findUserWithoutPwd("test123")).thenReturn(null); + Mockito.when(appService.getApp(1l)).thenReturn(getApp()); + PostSearchBean postSearchBean = new PostSearchBean(); + postSearchBean.setOrgUserId("test123"); + SearchResult result = new SearchResult(); + result.add(userObj()); + Mockito.when(ldapService.searchPost(postSearchBean.getUser(), postSearchBean.getSortBy1(), + postSearchBean.getSortBy2(), postSearchBean.getSortBy3(), postSearchBean.getPageNo(), + postSearchBean.getNewDataSize(), 1)).thenReturn(result); + User user = UserApiServiceImpl.getUser("test123", mockedRequest); + assertNull(user); + } + + @Test + public void getRoleFunctionsTest() throws Exception { + JSONObject mockJsonObjectPerms = new JSONObject(); + JSONObject mockJsonObjectPerm1 = new JSONObject(); + JSONObject mockJsonObjectPerm2 = new JSONObject(); + JSONObject mockJsonObjectPerm3 = new JSONObject(); + mockJsonObjectPerm1.put("type", "com.test.app2.test_type"); + mockJsonObjectPerm1.put("instance", "test_instance"); + mockJsonObjectPerm1.put("action", "*"); + mockJsonObjectPerm2.put("type", "com.test.app2.test_type2"); + mockJsonObjectPerm2.put("instance", "test_instance2"); + mockJsonObjectPerm2.put("action", "*"); + mockJsonObjectPerm2.put("description", "test_name"); + mockJsonObjectPerm3.put("type", "com.test.app3.test_type3"); + mockJsonObjectPerm3.put("instance", "test_instance3"); + mockJsonObjectPerm3.put("action", "*"); + List<JSONObject> permsList = new ArrayList<>(); + permsList.add(mockJsonObjectPerm1); + permsList.add(mockJsonObjectPerm2); + mockJsonObjectPerms.put("perm", permsList); + ResponseEntity<String> response = new ResponseEntity<>(mockJsonObjectPerms.toString(), HttpStatus.OK); + Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), + Matchers.<HttpEntity<String>>any(), Matchers.eq(String.class))).thenReturn(response); + List<RoleFunction> actual = UserApiServiceImpl.getRoleFunctions("test123"); + assertNotNull(actual); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthPropertiesTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthPropertiesTest.java new file mode 100644 index 00000000..24c19622 --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthPropertiesTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.util; + +import static org.junit.Assert.assertNull; + +import java.util.Properties; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ Properties.class }) +public class EcompExternalAuthPropertiesTest { + + @Test + public void getPropertyTest() { + String actual = EcompExternalAuthProperties.getProperty("test"); + assertNull(actual); + } + +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtilsTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtilsTest.java new file mode 100644 index 00000000..b35a1cda --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/util/EcompExternalAuthUtilsTest.java @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.authorization.util; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.util.SystemProperties; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.http.HttpHeaders; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ EcompExternalAuthProperties.class, CipherUtil.class }) +public class EcompExternalAuthUtilsTest { + + public static final String EXT_EMPTY_JSON_STRING = "{}"; + public static final String EXT_ROLE_FIELD = "role"; + public static final String EXT_PERM_FIELD = "perm"; + public static final String EXT_PERM_FIELD_TYPE = "type"; + public static final String EXT_PERM_ACCESS = ".access"; + public static final String EXT_ROLE_FIELD_NAME = "name"; + public static final String EXT_NULL_VALUE = "null"; + public static final String EXT_FIELD_DESCRIPTION = "description"; + public static final String EXT_FIELD_PERMS = "perms"; + public static final String EXT_ROLE_FIELD_OWNER = ".owner"; + public static final String EXT_ROLE_FIELD_ADMIN = ".admin"; + + @Before + public void setup() { + PowerMockito.mockStatic(EcompExternalAuthProperties.class); + PowerMockito.mockStatic(CipherUtil.class); + Mockito.when(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_USER_NAME)) + .thenReturn("test_username"); + Mockito.when(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_PASSWORD)) + .thenReturn("test_password"); + MockitoAnnotations.initMocks(this); + } + + @Test + public void base64encodeKeyForAAFBasicAuthTest() throws Exception { + Mockito.when( + CipherUtil.decryptPKC("test_password", SystemProperties.getProperty(SystemProperties.Decryption_Key))) + .thenReturn("test_decrypted_password"); + HttpHeaders actual = EcompExternalAuthUtils.base64encodeKeyForAAFBasicAuth(); + assertNotNull(actual); + } + + @Test(expected = NullPointerException.class) + public void base64encodeKeyForAAFBasicAuthDecryptPassExceptionTest() throws Exception { + Mockito.when( + CipherUtil.decryptPKC("test_password", SystemProperties.getProperty(SystemProperties.Decryption_Key))) + .thenThrow(new NullPointerException()); + EcompExternalAuthUtils.base64encodeKeyForAAFBasicAuth(); + } + + @Test + public void checkNameSpaceMatchingTest() throws Exception { + EcompExternalAuthUtils.checkNameSpaceMatching("com.test.app.role.name", "com.test.app.role"); + } + + @Test + public void checkNameSpaceNotMatchingTest() throws Exception { + PowerMockito.mockStatic(EcompExternalAuthProperties.class); + EcompExternalAuthUtils.checkNameSpaceMatching("com.test.app2.role.name", "com.test.app.role"); + } + + @Test + public void checkNameSpaceMatchingLengthTest() throws Exception { + EcompExternalAuthUtils.checkNameSpaceMatching("com.test.app2.role", "com.test.app2.role.test"); + } + + @Test + public void isJsonValidTest() { + boolean actual = EcompExternalAuthUtils.isJSONValid("{\"test\":\"test\"}"); + assertTrue(actual); + } + + @Test + public void isJsonValidFailTest() { + boolean actual = EcompExternalAuthUtils.isJSONValid("{\"test\":\"test\""); + assertFalse(actual); + } +} diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/framework/MockitoTestSuite.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/framework/MockitoTestSuite.java new file mode 100644 index 00000000..adc1b27a --- /dev/null +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/framework/MockitoTestSuite.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.external.framework; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class MockitoTestSuite { + + + public MockHttpServletRequestWrapper mockedRequest = new MockHttpServletRequestWrapper( + Mockito.mock(HttpServletRequest.class)); + public HttpServletResponse mockedResponse = Mockito.mock(HttpServletResponse.class); + + public MockHttpServletRequestWrapper getMockedRequest() { + return mockedRequest; + } + + public HttpServletResponse getMockedResponse() { + return mockedResponse; + } + + public class MockHttpServletRequestWrapper extends HttpServletRequestWrapper { + + HttpSession session = Mockito.mock(HttpSession.class); + + public MockHttpServletRequestWrapper(HttpServletRequest request) { + super(request); + + } + + @Override + public HttpSession getSession() { + + return session; + } + + @Override + public HttpSession getSession(boolean create) { + + return session; + } + + } + + @Test + public void test() + { + assert(true); + } +} diff --git a/ecomp-sdk/epsdk-analytics/pom.xml b/ecomp-sdk/epsdk-analytics/pom.xml index bcf202d5..3a2fd1a2 100644 --- a/ecomp-sdk/epsdk-analytics/pom.xml +++ b/ecomp-sdk/epsdk-analytics/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineInfo.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineInfo.java index d8fa23e3..26f33a35 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineInfo.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineInfo.java @@ -72,12 +72,12 @@ public class LineInfo { public LineInfo clone() { LineInfo lineInfo = new LineInfo(nodeID1, nodeID2); + lineInfo.setLineID(lineID); lineInfo.geoCoordinate1.longitude = geoCoordinate1.longitude; lineInfo.geoCoordinate1.latitude = geoCoordinate1.latitude; lineInfo.geoCoordinate2.longitude = geoCoordinate2.longitude; lineInfo.geoCoordinate2.latitude = geoCoordinate2.latitude; lineInfo.setDescription(lineDescription); - lineInfo.setLineID(lineID); lineInfo.setLineType(lineType); lineInfo.setMoveable(moveable); lineInfo.setDeleteable(deleteable); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java index 86f85be2..5c3f938a 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal SDK * =================================================================== - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java index 378c6a87..66d6e965 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java @@ -583,7 +583,7 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject { String query = Globals.getLoadQuickLinks(); query = query.replace("[userID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),userID)); - query = query.replace("[roleList.toString()]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),roleList.toString())); + query = query.replace("[roleList.toString()]", roleList.toString()); query = query.replace("[nvls(menuId)]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),nvls(menuId))); DataSet ds = DbUtils diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java index 44a05512..72eb64b8 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java @@ -1422,6 +1422,153 @@ public class ReportDefinition extends ReportWrapper implements Serializable { resetCache(false); } // parseReportSQL + public void parseReportSQL(String sql, boolean storeInSession) throws RaptorException { + StringBuffer parsedSQL = new StringBuffer(); + + Vector updatedReportCols = new Vector(); + + curSQLParsePos = 0; + int lastParsePos = curSQLParsePos; + String lastToken = null; + String nextToken = getNextSQLParseToken(sql, true); + + String dbInfo = getDBInfo(); + boolean isCYMBALScript = false; + if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { + try { + org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); + String dbType = remDbInfo.getDBType(dbInfo); + if (dbType.equals("DAYTONA") && !(nextToken.toUpperCase().equals("SELECT"))) { + isCYMBALScript = true; + } + } catch (Exception ex) { + throw new RaptorException(ex); + } + } + if ( isCYMBALScript == false ) { + while (nextToken.length() > 0) { + if (parsedSQL.length() == 0) { + if (nextToken.toUpperCase().equals("SELECT")) + parsedSQL.append("SELECT "); + else + throw new org.onap.portalsdk.analytics.error.ValidationException( + "The SQL must start with the SELECT keyword."); + } else if (nextToken.toUpperCase().equals("DISTINCT") + && parsedSQL.toString().equals("SELECT ")) { + parsedSQL.append("DISTINCT "); + } else if (nextToken.equals("*") + && (parsedSQL.toString().equals("SELECT ") || parsedSQL.toString().equals( + "SELECT DISTINCT "))) { + throw new org.onap.portalsdk.analytics.error.ValidationException( + "You cannot use \"SELECT *\". Please specify select columns/expressions."); + } else if (nextToken.toUpperCase().equals("FROM")) { + if (lastToken != null) { + updatedReportCols.add(getParseSQLDataColumn(lastToken, null, parsedSQL, + updatedReportCols, false)); + lastToken = null; + } + + parsedSQL.append(" \n"); + while (lastParsePos < sql.length() + && Character.isWhitespace(sql.charAt(lastParsePos))) + lastParsePos++; + parsedSQL.append(sql.substring(lastParsePos)); + break; + } else { + if (nextToken.charAt(nextToken.length() - 1) == ',') { + // The token ends with , + nextToken = nextToken.substring(0, nextToken.length() - 1); + + if (nextToken.length() == 0) { + if (lastToken != null) { + updatedReportCols.add(getParseSQLDataColumn(lastToken, null, + parsedSQL, updatedReportCols, false)); + lastToken = null; + } // else just comma => ignore it + } else { + if (lastToken != null) { + updatedReportCols.add(getParseSQLDataColumn(lastToken, nextToken, + parsedSQL, updatedReportCols, false)); + lastToken = null; + } else + updatedReportCols.add(getParseSQLDataColumn(nextToken, null, + parsedSQL, updatedReportCols, false)); + } + } else { + // The token doesn't end with , + if (lastToken == null) + lastToken = nextToken; + else { + String token = getNextSQLParseToken(sql, false); + if (!token.toUpperCase().equals("FROM")) + throw new org.onap.portalsdk.analytics.error.ValidationException( + "|FROM keyword or a comma expected after [" + nextToken + + "]."); + + updatedReportCols.add(getParseSQLDataColumn(lastToken, nextToken, + parsedSQL, updatedReportCols, false)); + lastToken = null; + } // else + } // else + } // else + + lastParsePos = curSQLParsePos; + nextToken = getNextSQLParseToken(sql, true); + } // while + } else { // if CYMBAL Script + curSQLParsePos = 0; + Pattern re = null; + Matcher matcher = null; + String extracted = null; + nextToken = getNextCYMBALSQLParseToken(sql,true); + while (nextToken.length() > 0) { + if (lastToken == null) lastToken = nextToken; + + if( lastToken.toUpperCase().startsWith("DO DISPLAY")) { + re = Pattern.compile("each(.*)\\[.(.*?)\\]"); //\\[(.*?)\\] + matcher = re.matcher(nextToken); + if (matcher.find()) { + extracted = matcher.group(); + re = Pattern.compile("\\[(.*?)\\]"); + matcher = re.matcher(nextToken); + if(matcher.find()) { + extracted = matcher.group(); + extracted = extracted.substring(1,extracted.length()-1); + StringTokenizer sToken = new StringTokenizer(extracted, ","); + while(sToken.hasMoreTokens()) { + String str1 = sToken.nextToken().trim().substring(1); + updatedReportCols.add(getParseSQLDataColumn("", str1, + new StringBuffer(""), updatedReportCols, true)); + } + } + + } + + } + lastToken = nextToken; + nextToken = getNextCYMBALSQLParseToken(sql, true); + } + + } + if (updatedReportCols.size() == 0) + throw new org.onap.portalsdk.analytics.error.ValidationException( + "The SQL statement must have at least one column in the SELECT clause."); + if (getDataSourceList().getDataSource().size() == 0) + addDataSourceType(new ObjectFactory(), "du0", "DUAL", "", "DUAL", null, null, null); + DataSourceType dst = (DataSourceType) getDataSourceList().getDataSource().get(0); + dst.getDataColumnList().getDataColumn().clear(); + + for (int i = 0; i < updatedReportCols.size(); i++) { + DataColumnType dct = (DataColumnType) updatedReportCols.get(i); + dct.setTableId(dst.getTableId()); + dct.setOrderSeq(i + 1); + dst.getDataColumnList().getDataColumn().add(dct); + } // for + if(storeInSession) + setReportSQL(parsedSQL.toString()); + resetCache(false); + } // parseReportSQL + private String getNextCYMBALSQLParseToken(String sql, boolean updateParsePos) { int braketCount = 0; boolean isInsideQuote = false; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSON.java index e5fc94ae..3281eee7 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSON.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSON.java @@ -48,6 +48,14 @@ public class ColumnEditJSON implements WizardJSON { private String displayHeaderAlignment; private boolean sortable; private boolean visible; + private Integer displayWidth; + private Integer displayWidthInPixel; + private String colType; + private Integer groupByPos; + private Integer level; + private String dataType; + private String noWrap; + private Integer indentation; private String drilldownURL; private String drilldownParams; @@ -55,6 +63,13 @@ public class ColumnEditJSON implements WizardJSON { private String errorMessage; private String errorStackTrace; + private String depeondsOnForField; + private String subTotalCustomText; + private boolean hideRepeatedKey; + private Integer colspan; + private String displayName; + private String displayTotal; + public String getTabId() { return tabId; } @@ -133,5 +148,93 @@ public class ColumnEditJSON implements WizardJSON { public void setDrilldownType(String drilldownType) { this.drilldownType = drilldownType; } + + public Integer getDisplayWidth() { + return displayWidth; + } + public void setDisplayWidth(Integer displayWidth) { + this.displayWidth = displayWidth; + } + public Integer getDisplayWidthInPixel() { + return displayWidthInPixel; + } + public void setDisplayWidthInPixel(Integer displayWidthInPixel) { + this.displayWidthInPixel = displayWidthInPixel; + } + public Integer getGroupByPos() { + return groupByPos; + } + public void setGroupByPos(Integer groupByPos) { + this.groupByPos = groupByPos; + } + public Integer getLevel() { + return level; + } + public void setLevel(Integer level) { + this.level = level; + } + public String getDataType() { + return dataType; + } + public void setDataType(String dataType) { + this.dataType = dataType; + } + public String getNoWrap() { + return noWrap; + } + public void setNoWrap(String noWrap) { + this.noWrap = noWrap; + } + public Integer getIndentation() { + return indentation; + } + public void setIndentation(Integer indentation) { + this.indentation = indentation; + } + public String getColType() { + return colType; + } + public void setColType(String colType) { + this.colType = colType; + } + public String getDepeondsOnForField() { + return depeondsOnForField; + } + public void setDepeondsOnForField(String depeondsOnForField) { + this.depeondsOnForField = depeondsOnForField; + } + public String getSubTotalCustomText() { + return subTotalCustomText; + } + public void setSubTotalCustomText(String subTotalCustomText) { + this.subTotalCustomText = subTotalCustomText; + } + public boolean isHideRepeatedKey() { + return hideRepeatedKey; + } + public void setHideRepeatedKey(boolean hideRepeatedKey) { + this.hideRepeatedKey = hideRepeatedKey; + } + public Integer getColspan() { + return colspan; + } + public void setColspan(Integer colspan) { + this.colspan = colspan; + } + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + public String getDisplayTotal() { + return displayTotal; + } + public void setDisplayTotal(String displayTotal) { + this.displayTotal = displayTotal; + } + + + } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/DefinitionJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/DefinitionJSON.java index 73ac97d8..47b1ef9e 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/DefinitionJSON.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/DefinitionJSON.java @@ -64,7 +64,15 @@ public class DefinitionJSON implements WizardJSON { private Integer numFormCols; private String reportTitle; private String reportSubTitle; - + private String oneTimeRec; + private String hourlyRec; + private String dailyRec; + private String dailyMFRec; + private String weeklyRec; + private String monthlyRec; + private String allowScheduler; + private String sizedByContent; + private String repDefType; @Override public String getTabName() { return tabName; @@ -246,7 +254,78 @@ public class DefinitionJSON implements WizardJSON { public void setReportSubTitle(String reportSubTitle) { this.reportSubTitle = reportSubTitle; } + + public String getOneTimeRec() { + return oneTimeRec; + } + + public void setOneTimeRec(String oneTimeRec) { + this.oneTimeRec = oneTimeRec; + } + + public String getHourlyRec() { + return hourlyRec; + } + + public void setHourlyRec(String hourlyRec) { + this.hourlyRec = hourlyRec; + } + + public String getDailyRec() { + return dailyRec; + } + + public void setDailyRec(String dailyRec) { + this.dailyRec = dailyRec; + } + + public String getDailyMFRec() { + return dailyMFRec; + } + + public void setDailyMFRec(String dailyMFRec) { + this.dailyMFRec = dailyMFRec; + } + + public String getWeeklyRec() { + return weeklyRec; + } + + public void setWeeklyRec(String weeklyRec) { + this.weeklyRec = weeklyRec; + } + + public String getMonthlyRec() { + return monthlyRec; + } + + public void setMonthlyRec(String monthlyRec) { + this.monthlyRec = monthlyRec; + } + + public String getAllowScheduler() { + return allowScheduler; + } + + public void setAllowScheduler(String allowScheduler) { + this.allowScheduler = allowScheduler; + } + + public String getSizedByContent() { + return sizedByContent; + } + + public void setSizedByContent(String sizedByContent) { + this.sizedByContent = sizedByContent; + } + + public String getRepDefType() { + return repDefType; + } + + public void setRepDefType(String repDefType) { + this.repDefType = repDefType; + } - } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSON.java index bc39006f..e8238534 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSON.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSON.java @@ -48,6 +48,7 @@ public class FormEditJSON implements WizardJSON { private String fieldName; private String fieldType; private boolean visible; + private boolean groupFormField; private String defaultValue; private String fieldDefaultSQL; private String fieldSQL; @@ -56,7 +57,7 @@ public class FormEditJSON implements WizardJSON { private String message; private String errorMessage; private String errorStackTrace; - + private Integer orderSeq; public String getMessage() { return message; @@ -145,5 +146,19 @@ public class FormEditJSON implements WizardJSON { public void setFieldSQL(String fieldSQL) { this.fieldSQL = fieldSQL; } + public boolean isGroupFormField() { + return groupFormField; + } + public void setGroupFormField(boolean groupFormField) { + this.groupFormField = groupFormField; + } + public Integer getOrderSeq() { + return orderSeq; + } + public void setOrderSeq(Integer orderSeq) { + this.orderSeq = orderSeq; + } + + } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/SearchFieldJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/SearchFieldJSON.java index b3cfe243..f80ba993 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/SearchFieldJSON.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/SearchFieldJSON.java @@ -41,6 +41,7 @@ public class SearchFieldJSON implements ElementJSON { private String id; private String name; + private Integer orderSeq; public String getId() { return id; } @@ -53,6 +54,12 @@ public class SearchFieldJSON implements ElementJSON { public void setName(String name) { this.name = name; } + public Integer getOrderSeq() { + return orderSeq; + } + public void setOrderSeq(Integer orderSeq) { + this.orderSeq = orderSeq; + } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java index cfae1ab3..5ed8f9f6 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java @@ -75,20 +75,6 @@ class PageEvent extends PdfPageEventHelper { public PageEvent(PdfBean pb) { this.pb = pb; } - - private int getWidthEntries(int howManyLogos){ - int widthEntries = 0; - - if(howManyLogos == 2) - widthEntries = 3; - else - if(howManyLogos == 1) - widthEntries = 2; - else - widthEntries = 0; - - return widthEntries; - } private int getHowManyLogos(){ int howManyLogos = 0; @@ -220,13 +206,6 @@ class PageEvent extends PdfPageEventHelper { table.addCell(new Paragraph(pb.getLeftFooter(), font)); } - private void addHeaderDummy(PdfPTable table, Font font) { - Font font1 = new Font(font); - font1.setSize(Globals.getPDFFooterFontSize()); - - table.addCell(new Paragraph("Header row", font1)); - } - private void addLogo(PdfPTable table, Font font, String imgSrc, int alignment, int absoluteSize) { Image img = null; @@ -243,7 +222,6 @@ class PageEvent extends PdfPageEventHelper { //log that the input file couldnt be loaded - } else{ - //img.scaleAbsolute(absoluteSize, absoluteSize); img.scalePercent(absoluteSize, absoluteSize); PdfPCell cell = new PdfPCell(img); cell.setBorderColor(Color.WHITE); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java index 80860912..ec83ffbf 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java @@ -47,6 +47,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; +import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -54,6 +55,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.SortedSet; +import java.util.TimeZone; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -68,6 +70,7 @@ import org.onap.portalsdk.analytics.model.ReportHandler; import org.onap.portalsdk.analytics.model.base.ChartSeqComparator; import org.onap.portalsdk.analytics.system.AppUtils; import org.onap.portalsdk.analytics.system.ConnectionUtils; +import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.DataSet; import org.onap.portalsdk.analytics.util.HtmlStripper; @@ -1804,6 +1807,9 @@ public class ChartD3Helper { } wholeScript.append(" .tickFormat(function(d) { \n"); + wholeScript.append(" var local_dt = new Date(); \n var utc = d + (local_dt.getTimezoneOffset() * 60000);\n"); + wholeScript.append(" var nd = new Date(utc + (3600000*"+getCurrentTimezoneOffset()+")); "); + if(formatFlag==DAYFLAG) wholeScript.append(" return d3.time.format('%m/%d/%Y')(new Date(d)) }); \n"); else if(formatFlag==HOURFLAG) @@ -3569,6 +3575,11 @@ public class ChartD3Helper { return title; } + public java.util.Date timezoneConversion(SimpleDateFormat sdf, String dateStr) { + // sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + return sdf.parse(dateStr, new ParsePosition(0)); + } + public java.util.Date getDateFromDateStr(String dateStr) { SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat EEEMMDDYYYYFormat = new SimpleDateFormat("EEE, MM/dd/yyyy"); //2012-11-01 00:00:00 @@ -3619,117 +3630,142 @@ public class ChartD3Helper { int flagDate = 10; */ - date = MMDDYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); + //date = MMDDYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMDDYYYYHHMMSSFormat, dateStr); if(date!=null) formatFlag = SECFLAG; if(date==null) { - date = EEEMMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); + //date = EEEMMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(EEEMMDDYYYYFormat, dateStr); if(date!=null) formatFlag = DAYOFTHEWEEKFLAG; } if(date==null) { - date = MMDDYYYYHHMMFormat.parse(dateStr, new ParsePosition(0)); + //date = MMDDYYYYHHMMFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMDDYYYYHHMMFormat, dateStr); if(date!=null) formatFlag = MINFLAG; } if(date==null) { //MMDDYYYYHHFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - date = MMDDYYYYHHFormat.parse(dateStr, new ParsePosition(0)); + //date = MMDDYYYYHHFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMDDYYYYHHFormat, dateStr); if(date!=null) formatFlag = HOURFLAG; } if(date==null) { - date = MMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); + //date = MMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMDDYYYYFormat, dateStr); if(date!=null) formatFlag = DAYFLAG; } if(date==null) { - date = YYYYMMDDFormat.parse(dateStr, new ParsePosition(0)); + //date = YYYYMMDDFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(YYYYMMDDFormat, dateStr); if(date!=null) formatFlag = DAYFLAG; } if(date==null) { - date = timestampFormat.parse(dateStr, new ParsePosition(0)); + //date = timestampFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(timestampFormat, dateStr); if(date!=null) formatFlag = SECFLAG; } if(date==null) { - date = timestampHrFormat.parse(dateStr, new ParsePosition(0)); + //date = timestampHrFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(timestampHrFormat, dateStr); if(date!=null) formatFlag = HOURFLAG; } if(date==null) { - date = timestampDayFormat.parse(dateStr, new ParsePosition(0)); + //date = timestampDayFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(timestampDayFormat, dateStr); if(date!=null) formatFlag = DAYFLAG; } if(date==null) { - date = MONYYYYFormat.parse(dateStr, new ParsePosition(0)); + //date = MONYYYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MONYYYYFormat, dateStr); if(date!=null) formatFlag = MONTHFLAG; } if(date==null) { - date = MMYYYYFormat.parse(dateStr, new ParsePosition(0)); + //date = MMYYYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMYYYYFormat, dateStr); if(date!=null) formatFlag = MONTHFLAG; } if(date==null) { - date = MMMMMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); + //date = MMMMMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMMMMDDYYYYFormat, dateStr); if(date!=null) formatFlag = DAYFLAG; } if(date==null) { - date = MONTHYYYYFormat.parse(dateStr, new ParsePosition(0)); + //date = MONTHYYYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MONTHYYYYFormat, dateStr); if(date!=null) formatFlag = MONTHFLAG; } if(date==null) { - date = YYYYMMDDHHMMSSFormat.parse(dateStr, new ParsePosition(0)); + //date = YYYYMMDDHHMMSSFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(YYYYMMDDHHMMSSFormat, dateStr); if(date!=null) formatFlag = SECFLAG; } if(date==null) { - date = YYYYMMDDHHMMFormat.parse(dateStr, new ParsePosition(0)); + //date = YYYYMMDDHHMMFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(YYYYMMDDHHMMFormat, dateStr); if(date!=null) formatFlag = MINFLAG; } if(date==null) { - date = DDMONYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); + //date = DDMONYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(DDMONYYYYHHMMSSFormat, dateStr); if(date!=null) formatFlag = SECFLAG; } if(date==null) { - date = DDMONYYYYHHMMFormat.parse(dateStr, new ParsePosition(0)); + //date = DDMONYYYYHHMMFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(DDMONYYYYHHMMFormat, dateStr); if(date!=null) formatFlag = MINFLAG; } if(date==null) { - date = DDMONYYYYFormat.parse(dateStr, new ParsePosition(0)); + //date = DDMONYYYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(DDMONYYYYFormat, dateStr); if(date!=null) formatFlag = DAYFLAG; } if(date==null) { - date = MMDDYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); + //date = MMDDYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMDDYYHHMMSSFormat, dateStr); if(date!=null) formatFlag = SECFLAG; } if(date==null) { - date = MMDDYYHHMMFormat.parse(dateStr, new ParsePosition(0)); + //date = MMDDYYHHMMFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMDDYYHHMMFormat, dateStr); if(date!=null) formatFlag = MINFLAG; } if(date==null) { - date = MMDDYYFormat.parse(dateStr, new ParsePosition(0)); + //date = MMDDYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMDDYYFormat, dateStr); if(date!=null) formatFlag = DAYFLAG; } if(date==null) { - date = timestampFormat1.parse(dateStr, new ParsePosition(0)); + //date = timestampFormat1.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(timestampFormat1, dateStr); if(date!=null) formatFlag = SECFLAG; } if(date==null) { - date = MMDDYYYYHHMMZFormat.parse(dateStr, new ParsePosition(0)); + //date = MMDDYYYYHHMMZFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(MMDDYYYYHHMMZFormat, dateStr); if(date!=null) formatFlag = MINFLAG; } if(date==null) { - date = YYYYFormat.parse(dateStr, new ParsePosition(0)); + //date = YYYYFormat.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(YYYYFormat, dateStr); /* Some random numbers should not satisfy this year format. */ if(dateStr.length()>4) date = null; if(date!=null) formatFlag = YEARFLAG; } if(date==null) { - date = timestamp_W_dash.parse(dateStr, new ParsePosition(0)); + //date = timestamp_W_dash.parse(dateStr, new ParsePosition(0)); + date = timezoneConversion(timestamp_W_dash, dateStr); if(date!=null) formatFlag = SECFLAG; } if(date==null) @@ -4085,6 +4121,23 @@ public class ChartD3Helper { return valuesMap; - } + } + + public static int getCurrentTimezoneOffset() { + + TimeZone tz = TimeZone.getDefault(); + java.util.Calendar cal = GregorianCalendar.getInstance(tz); + int offsetInMillis = tz.getOffset(cal.getTimeInMillis()); + int hourOffset = Math.abs(offsetInMillis / 3600000) * 60; + boolean isDST = tz.inDaylightTime(new java.util.Date()); + if(isDST){ + hourOffset += 60; + } + int offset = hourOffset + Math.abs((offsetInMillis / 60000) % 60); + if (offsetInMillis > 0) + offset *= -1; + + return Globals.getTimezoneOffset(); + } } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java index 529790e9..bb99318f 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java @@ -2895,6 +2895,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep reportJSONRuntime.setReportID(getReportID()); reportJSONRuntime.setReportName(getReportName()); reportJSONRuntime.setReportSubTitle(getReportSubTitle()); + reportJSONRuntime.setAllowEdit(isAllowEdit(request)); reportJSONRuntime.setNumFormCols(getNumFormColsAsInt()); ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>(); ArrayList<FormFieldJSON> formFieldJSONList = new ArrayList<FormFieldJSON>(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java index f0991e94..a1196808 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java @@ -1530,6 +1530,13 @@ public class Globals extends org.onap.portalsdk.analytics.RaptorObject { } } + public static int getTimezoneOffset() { + try { + return Integer.parseInt(nvls(raptorProperties.getProperty("time_zone_offset"), new Integer(0).toString()).trim()); + } catch (Exception ex) { return 0;} + } + + //new method added to get the help message for schedule tab public static String getScheduleHelpMessage() { return nvls(raptorProperties.getProperty("schedule_help_text"),"").trim(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java index b2ce1b7d..e06a1765 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java @@ -66,9 +66,13 @@ import org.onap.portalsdk.analytics.error.RaptorRuntimeException; import org.onap.portalsdk.analytics.error.ReportSQLException; import org.onap.portalsdk.analytics.model.DataCache; import org.onap.portalsdk.analytics.model.ReportHandler; +import org.onap.portalsdk.analytics.model.ReportLoader; +import org.onap.portalsdk.analytics.model.base.IdNameList; import org.onap.portalsdk.analytics.model.base.IdNameValue; import org.onap.portalsdk.analytics.model.base.ReportUserRole; +import org.onap.portalsdk.analytics.model.definition.DrillDownParamDef; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; +import org.onap.portalsdk.analytics.model.definition.ReportLogEntry; import org.onap.portalsdk.analytics.model.definition.SecurityEntry; import org.onap.portalsdk.analytics.model.definition.wizard.ColumnEditJSON; import org.onap.portalsdk.analytics.model.definition.wizard.ColumnJSON; @@ -296,6 +300,20 @@ public class RaptorControllerAsync extends RestrictedBaseController { } } + @RequestMapping(value = "/report/wizard/drill_down_param/{parameter}", method = RequestMethod.GET, produces = "application/json") + public @ResponseBody List<DrillDownParamDef> getDrillDownParamDef (@PathVariable("parameter") String parameter, HttpServletRequest request, HttpServletResponse response) + throws IOException, RaptorException { + List<DrillDownParamDef> list = new ArrayList<>(); + String[] tmepArray = null; + if(parameter!=null){ + tmepArray = parameter.split("&"); + } + for(String str:tmepArray){ + list.add(new DrillDownParamDef(str)); + } + return list; + } + @RequestMapping(value = "/report/wizard/list_columns", method = RequestMethod.GET, produces = "application/json") public @ResponseBody ArrayList<ColumnJSON> listColumns(HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException { @@ -307,7 +325,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { for (DataColumnType reportColumnType : reportColumnList) { columnJSON = new ColumnJSON(); columnJSON.setId(reportColumnType.getColId()); - columnJSON.setName(reportColumnType.getColName()); + columnJSON.setName(reportColumnType.getDisplayName()); listJSON.add(columnJSON); } return listJSON; @@ -375,6 +393,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { String fieldDisplay = fft.getFieldName(); fieldJSON.setId(fieldId); fieldJSON.setName(fieldDisplay); + fieldJSON.setOrderSeq(fft.getOrderBySeq()); listJSON.add(fieldJSON); } } @@ -501,20 +520,15 @@ public class RaptorControllerAsync extends RestrictedBaseController { fft.setFieldDefaultSQL(formEditJSON.getFieldDefaultSQL()); fft.setFieldSQL(formEditJSON.getFieldSQL()); fft.setValidationType(formEditJSON.getValidationType()); - + fft.setGroupFormField(formEditJSON.isGroupFormField()); + fft.setOrderBySeq(formEditJSON.getOrderSeq()); // clear predefined value - if (fft.getPredefinedValueList() != null) { - for (Iterator<String> iter = fft.getPredefinedValueList().getPredefinedValue() - .iterator(); iter.hasNext();) - iter.remove(); - } - + PredefinedValueList predefinedValueList = new ObjectFactory().createPredefinedValueList(); + fft.setPredefinedValueList(predefinedValueList); + List<IdNameBooleanJSON> predefList = formEditJSON.getPredefinedValueList(); if (predefList != null && predefList.size() > 0) { for (IdNameBooleanJSON item : predefList) { - PredefinedValueList predefinedValueList = new ObjectFactory() - .createPredefinedValueList(); - fft.setPredefinedValueList(predefinedValueList); fft.getPredefinedValueList().getPredefinedValue().add(item.getId()); } } @@ -540,6 +554,52 @@ public class RaptorControllerAsync extends RestrictedBaseController { return messageJSON; } + + @RequestMapping(value = "report/wizard/add_formfield_tab_data", method = RequestMethod.POST) + public @ResponseBody MessageJSON addFFTabWiseData(@RequestBody FormEditJSON formEditJSON, + HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException { + ReportDefinition rdef = null; + rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); + + MessageJSON messageJSON = new MessageJSON(); + try { + if (rdef != null) { + FormEditJSON wizardJSON = new FormEditJSON(); + wizardJSON.setTabId("FormEdit"); + wizardJSON.setTabName("Form Edit"); + String fieldId =""; + if(rdef.getFormFieldList()==null || rdef.getFormFieldList().getFormField()==null || rdef.getFormFieldList().getFormField().size()==0) + fieldId = "ff1"; + else + fieldId = "ff"+(rdef.getFormFieldList().getFormField().size()+1); + FormFieldType currField = rdef.addFormFieldType(new ObjectFactory(), "", "", "", "", "", "", "", "", null, null, "",""); + currField.setFieldId(fieldId); + currField.setFieldName(formEditJSON.getFieldName()); + currField.setFieldType(formEditJSON.getFieldType()==null?null:formEditJSON.getFieldType()); + currField.setVisible(formEditJSON.isVisible()?"Y":"N"); + currField.setDefaultValue(formEditJSON.getDefaultValue()); + currField.setFieldDefaultSQL(formEditJSON.getFieldDefaultSQL()); + currField.setFieldSQL(formEditJSON.getFieldSQL()); + currField.setValidationType(formEditJSON.getValidationType()); + currField.setGroupFormField(formEditJSON.isGroupFormField()); + persistReportDefinition(request, rdef); + + messageJSON.setMessage("Success formfield Details of given report is saved in session."); + messageJSON.setAnyStacktrace(rdef.getReportID() + " is added to session and DB."); + + } else { + messageJSON.setMessage("Report Definition is not in session"); + messageJSON.setAnyStacktrace("Report Definition is not in session"); + + } + } catch (Exception ex) { + messageJSON.setMessage("Error occured while formfield details Tab"); + messageJSON.setAnyStacktrace(getStackTrace(ex)); + return messageJSON; + } + + return messageJSON; + } @RequestMapping(value = "report/wizard/save_col_tab_data", method = RequestMethod.POST) public @ResponseBody MessageJSON saveColTabWiseData(@RequestBody ColumnEditJSON columnEditJSON, @@ -558,6 +618,18 @@ public class RaptorControllerAsync extends RestrictedBaseController { // columnJSON = new ColumnJSON(); if (reportColumnType.getColId().equals(colId)) { reportColumnType.setColName(columnEditJSON.getColName()); + reportColumnType.setDependsOnFormField(columnEditJSON.getDepeondsOnForField()==null?"":columnEditJSON.getDepeondsOnForField()); + reportColumnType.setColType(columnEditJSON.getDataType()==null?"":columnEditJSON.getDataType()); + reportColumnType.setDbColName(columnEditJSON.getDataType()==null?"":columnEditJSON.getDataType()); + reportColumnType.setGroupByPos(columnEditJSON.getGroupByPos()); + reportColumnType.setSubTotalCustomText(columnEditJSON.getSubTotalCustomText()); + reportColumnType.setHideRepeatedKey(columnEditJSON.isHideRepeatedKey()); + reportColumnType.setLevel(columnEditJSON.getLevel()); + reportColumnType.setColspan(columnEditJSON.getColspan()); + reportColumnType.setDisplayName(columnEditJSON.getDisplayName()); + reportColumnType.setDisplayWidthInPxls(columnEditJSON.getDisplayWidthInPixel()==null?null:String.valueOf(columnEditJSON.getDisplayWidthInPixel())); + reportColumnType.setNowrap(columnEditJSON.getNoWrap()); + reportColumnType.setIndentation(columnEditJSON.getIndentation()); reportColumnType.setDisplayAlignment(columnEditJSON.getDisplayAlignment()); reportColumnType.setDisplayHeaderAlignment(columnEditJSON.getDisplayHeaderAlignment()); reportColumnType.setIsSortable(columnEditJSON.isSortable()); @@ -565,7 +637,9 @@ public class RaptorControllerAsync extends RestrictedBaseController { reportColumnType.setDrillDownURL(columnEditJSON.getDrilldownURL()); reportColumnType.setDrillDownParams(columnEditJSON.getDrilldownParams()); reportColumnType.setDrillDownType(columnEditJSON.getDrilldownType()); - + if(columnEditJSON.getDisplayTotal()!=null) + reportColumnType.setDisplayTotal(columnEditJSON.getDisplayTotal()); + } } @@ -650,22 +724,28 @@ public class RaptorControllerAsync extends RestrictedBaseController { rdef.setFormHelpText(formHelpText); Integer pageSize = definitionJSON.getPageSize(); - rdef.setPageSize(pageSize); + if(pageSize!=null) + rdef.setPageSize(pageSize); List<IdNameBooleanJSON> menuIds = definitionJSON.getDisplayArea(); - for (IdNameBooleanJSON menuId : menuIds) { - if (menuId.isSelected()) { - rdef.setMenuID(menuId.getName()); - } + if(menuIds!=null){ + for (IdNameBooleanJSON menuId : menuIds) { + if (menuId.isSelected()) { + rdef.setMenuID(menuId.getName()); + } + } } + Boolean hideFormFieldsAfterRun = definitionJSON.getHideFormFieldsAfterRun(); - rdef.setHideFormFieldAfterRun(hideFormFieldsAfterRun); + rdef.setHideFormFieldAfterRun(hideFormFieldsAfterRun==null?false:hideFormFieldsAfterRun); Integer maxRowsInExcelCSVDownload = definitionJSON.getMaxRowsInExcelCSVDownload(); - rdef.setMaxRowsInExcelDownload(maxRowsInExcelCSVDownload); + if(maxRowsInExcelCSVDownload!=null) + rdef.setMaxRowsInExcelDownload(maxRowsInExcelCSVDownload); Integer frozenColumns = definitionJSON.getFrozenColumns(); - rdef.setFrozenColumns(frozenColumns); + if(frozenColumns!=null) + rdef.setFrozenColumns(frozenColumns); String dataGridAlign = definitionJSON.getDataGridAlign(); rdef.setDataGridAlign(dataGridAlign); String emptyMessage = definitionJSON.getEmptyMessage(); @@ -674,10 +754,11 @@ public class RaptorControllerAsync extends RestrictedBaseController { rdef.setDataContainerHeight(dataContainerHeight); String dataContainerWidth = definitionJSON.getDataContainerWidth(); rdef.setDataContainerWidth(dataContainerWidth); - boolean runtimeColSortDisabled = definitionJSON.getRuntimeColSortDisabled(); - rdef.setRuntimeColSortDisabled(runtimeColSortDisabled); + Boolean runtimeColSortDisabled = definitionJSON.getRuntimeColSortDisabled(); + rdef.setRuntimeColSortDisabled(runtimeColSortDisabled==null?false:runtimeColSortDisabled); Integer numFormCols = definitionJSON.getNumFormCols(); - rdef.setNumFormCols(Integer.toString(numFormCols)); + if(numFormCols!=null) + rdef.setNumFormCols(Integer.toString(numFormCols)); String reportTitle = definitionJSON.getReportTitle(); rdef.setReportTitle(reportTitle); String reportSubTitle = definitionJSON.getReportSubTitle(); @@ -685,24 +766,45 @@ public class RaptorControllerAsync extends RestrictedBaseController { List<NameBooleanJSON> displayOptions = definitionJSON.getDisplayOptions(); StringBuffer displayOptionStr = new StringBuffer("NNNNNNN"); - for (NameBooleanJSON displayOption : displayOptions) { - if (displayOption.isSelected()) { - if (displayOption.getName().equals("HideFormFields")) { - displayOptionStr.setCharAt(0, 'Y'); - } else if (displayOption.getName().equals("HideChart")) { - displayOptionStr.setCharAt(1, 'Y'); - } else if (displayOption.getName().equals("HideReportData")) { - displayOptionStr.setCharAt(2, 'Y'); - } else if (displayOption.getName().equals("HideExcel")) { - displayOptionStr.setCharAt(5, 'Y'); - } else if (displayOption.getName().equals("HidePdf")) { - displayOptionStr.setCharAt(6, 'Y'); + if(displayOptions!=null){ + for (NameBooleanJSON displayOption : displayOptions) { + if (displayOption.isSelected()) { + if (displayOption.getName().equals("HideFormFields")) { + displayOptionStr.setCharAt(0, 'Y'); + } else if (displayOption.getName().equals("HideChart")) { + displayOptionStr.setCharAt(1, 'Y'); + } else if (displayOption.getName().equals("HideReportData")) { + displayOptionStr.setCharAt(2, 'Y'); + } else if (displayOption.getName().equals("HideExcel")) { + displayOptionStr.setCharAt(5, 'Y'); + } else if (displayOption.getName().equals("HidePdf")) { + displayOptionStr.setCharAt(6, 'Y'); + } } - } + } } - - rdef.setDisplayOptions(displayOptionStr.toString()); + + if(displayOptionStr!=null) + rdef.setDisplayOptions(displayOptionStr.toString()); + + if(definitionJSON.getAllowScheduler()!=null) + rdef.setAllowSchedule(definitionJSON.getAllowScheduler().equals("true")?"Y":"N"); + if(definitionJSON.getSizedByContent()!=null) + rdef.setSizedByContent(definitionJSON.getSizedByContent().equals("true")?"Y":"N"); + if(definitionJSON.getOneTimeRec()!=null) + rdef.setIsOneTimeScheduleAllowed(definitionJSON.getOneTimeRec().equals("true")?"Y":"N"); + if(definitionJSON.getHourlyRec()!=null) + rdef.setIsHourlyScheduleAllowed(definitionJSON.getHourlyRec().equals("true")?"Y":"N"); + if(definitionJSON.getDailyRec()!=null) + rdef.setIsDailyScheduleAllowed(definitionJSON.getDailyRec().equals("true")?"Y":"N"); + if(definitionJSON.getDailyMFRec()!=null) + rdef.setIsDailyMFScheduleAllowed(definitionJSON.getDailyMFRec().equals("true")?"Y":"N"); + if(definitionJSON.getWeeklyRec()!=null) + rdef.setIsWeeklyScheduleAllowed(definitionJSON.getWeeklyRec().equals("true")?"Y":"N"); + if(definitionJSON.getMonthlyRec()!=null) + rdef.setIsMonthlyScheduleAllowed(definitionJSON.getMonthlyRec().equals("true")?"Y":"N"); + } if (id.equals("Create")) { rdef.persistReport(request); @@ -779,7 +881,8 @@ public class RaptorControllerAsync extends RestrictedBaseController { wizardJSON.setFieldDefaultSQL(fft.getFieldDefaultSQL()); wizardJSON.setFieldSQL(fft.getFieldSQL()); wizardJSON.setValidationType(fft.getValidationType()); - + wizardJSON.setGroupFormField(fft.isGroupFormField()); + wizardJSON.setOrderSeq(fft.getOrderBySeq()); PredefinedValueList preDefined = fft.getPredefinedValueList(); if (preDefined != null) { @@ -847,7 +950,20 @@ public class RaptorControllerAsync extends RestrictedBaseController { reportColumnType.getDrillDownParams() == null ? "" : reportColumnType.getDrillDownParams()); wizardJSON.setDrilldownType( reportColumnType.getDrillDownType() == null ? "" : reportColumnType.getDrillDownType()); - + wizardJSON.setDataType(reportColumnType.getDbColType() == null ? "" :reportColumnType.getDbColType()); + wizardJSON.setGroupByPos(reportColumnType.getGroupByPos()); + wizardJSON.setLevel(reportColumnType.getLevel()); + wizardJSON.setDisplayWidth(reportColumnType.getDisplayWidth()); + wizardJSON.setNoWrap(reportColumnType.getNowrap() == null ? "" : reportColumnType.getNowrap()); + wizardJSON.setIndentation(reportColumnType.getIndentation()); + + wizardJSON.setDepeondsOnForField(reportColumnType.getDependsOnFormField() ==null?"":reportColumnType.getDependsOnFormField()); + wizardJSON.setSubTotalCustomText(reportColumnType.getSubTotalCustomText()==null?"":reportColumnType.getSubTotalCustomText()); + + wizardJSON.setHideRepeatedKey(reportColumnType.isHideRepeatedKey()==null?false:reportColumnType.isHideRepeatedKey()); + wizardJSON.setColspan(reportColumnType.getColspan()==null?null:reportColumnType.getColspan()); + wizardJSON.setDisplayName(reportColumnType.getDisplayName()); + wizardJSON.setDisplayTotal(reportColumnType.getDisplayTotal()); } } } else { @@ -905,6 +1021,17 @@ public class RaptorControllerAsync extends RestrictedBaseController { return wizardJSON; } + @RequestMapping(value = { "/report/wizard/retrieveTotalForTheColList" }, method = RequestMethod.GET) + public @ResponseBody List<IdNameValue> getTotalForTheCol(HttpServletRequest request) + throws IOException, RaptorException { + IdNameList idNameList = AppConstants.TOTAL_FUNCTIONS; + List<IdNameValue> list = new ArrayList<>(); + for(int i=0; i<idNameList.getCount(); i++) + list.add(idNameList.getValue(i)); + + return list; + } + @RequestMapping(value = { "/report/wizard/security/retrieveReportUserList" }, method = RequestMethod.GET) public @ResponseBody List<SecurityEntry> getReportUserList(HttpServletRequest request) throws IOException, RaptorException { @@ -1339,7 +1466,17 @@ public class RaptorControllerAsync extends RestrictedBaseController { wizardJSON.setNumFormCols((rdef != null) ? rdef.getNumFormColsAsInt() : 1); wizardJSON.setReportTitle((rdef != null) ? rdef.getReportTitle() : ""); wizardJSON.setReportSubTitle((rdef != null) ? rdef.getReportSubTitle() : ""); - + + /*Robert add*/ + wizardJSON.setOneTimeRec((rdef != null) ? rdef.getIsOneTimeScheduleAllowed() : "false"); + wizardJSON.setHourlyRec((rdef != null) ? rdef.getIsHourlyScheduleAllowed() : "false"); + wizardJSON.setDailyRec((rdef != null) ? rdef.getIsDailyScheduleAllowed() : "false"); + wizardJSON.setDailyMFRec((rdef != null) ? rdef.getIsDailyMFScheduleAllowed() : "false"); + wizardJSON.setWeeklyRec((rdef != null) ? rdef.getIsWeeklyScheduleAllowed() : "false"); + wizardJSON.setMonthlyRec((rdef != null) ? rdef.getIsMonthlyScheduleAllowed() : "false"); + wizardJSON.setAllowScheduler((rdef != null) ? rdef.getAllowSchedule() : "false"); + wizardJSON.setSizedByContent((rdef != null) ? rdef.getSizedByContentOption() : "false"); + wizardJSON.setRepDefType(rdef.getReportDefType()); } ObjectMapper mapper = new ObjectMapper(); @@ -1357,7 +1494,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { RaptorResponse raptorResponse = new RaptorResponse(); String sql = queryJSON.getQuery(); String jsonInString = ""; - + ServletContext servletContext = request.getSession().getServletContext(); if (!Globals.isSystemInitialized()) { Globals.initializeSystem(servletContext); @@ -1440,7 +1577,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { QueryResultJSON queryResultJSON = new QueryResultJSON(); queryResultJSON.setQuery(queryJSON.getQuery()); String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery()); - rdef.parseReportSQL(query); + rdef.parseReportSQL(query,validate); queryResultJSON.setQuery(query); int numColumns = ds.getColumnCount(); @@ -1548,6 +1685,23 @@ public class RaptorControllerAsync extends RestrictedBaseController { return raptorResponse; } + + + @RequestMapping(value = "/report/wizard/get_report_log/{reportID}", method = RequestMethod.GET) + public @ResponseBody ArrayList<ReportLogEntry> getLogs(@PathVariable("reportID") String reportId, HttpServletRequest request, + HttpServletResponse ReportLogEntry) throws IOException { + ArrayList<ReportLogEntry> arrayList = new ArrayList<>(); + try { + Vector<ReportLogEntry> v = ReportLoader.loadReportLogEntries(reportId); + for(ReportLogEntry r:v ){ + arrayList.add(r); + } + } catch (RaptorException e) { + logger.error(EELFLoggerDelegate.errorLogger, + "RaptorControllerAsync getLogs.", e); + } + return arrayList; + } @RequestMapping(value = "save_chart", method = RequestMethod.POST) public void reportChartReceive(@RequestBody ChartJSON chartJSON, HttpServletRequest request, @@ -1627,7 +1781,12 @@ public class RaptorControllerAsync extends RestrictedBaseController { dct.setChartSeq(-1); // if we set it to -1, means this range axis will not be included else dct.setChartSeq(++r); - dct.setColOnChart("0"); + + if (!dct.getColId().equals(domainAxis)) { + dct.setColOnChart("0"); + }else{ + dct.setChartSeq(-1); + } dct.setYAxis(rangeYAxis); // +"|"+dct.getColId()); dct.setChartGroup(rangeChartGroup); // +"|"+dct.getColId()); dct.setChartColor(rangeColor); @@ -1646,7 +1805,6 @@ public class RaptorControllerAsync extends RestrictedBaseController { } } - reportRuntime.setChartLeftAxisLabel(chartJSON.getPrimaryAxisLabel()); reportRuntime.setChartRightAxisLabel(chartJSON.getSecondaryAxisLabel()); diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/AbstractDummyController.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/AbstractDummyController.java new file mode 100644 index 00000000..9381f41c --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/AbstractDummyController.java @@ -0,0 +1,43 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +public abstract class AbstractDummyController { + +} + diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionHandlerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionHandlerTest.java new file mode 100644 index 00000000..71d3a1b5 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionHandlerTest.java @@ -0,0 +1,1259 @@ +package org.onap.portalsdk.analytics.controller; +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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============================================ + * + * + */ + + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.whenNew; + +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Vector; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.io.FilenameUtils; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.model.DataCache; +import org.onap.portalsdk.analytics.model.ReportHandler; +import org.onap.portalsdk.analytics.model.ReportLoader; +import org.onap.portalsdk.analytics.model.SearchHandler; +import org.onap.portalsdk.analytics.model.base.IdNameColLookup; +import org.onap.portalsdk.analytics.model.base.IdNameList; +import org.onap.portalsdk.analytics.model.base.ReportWrapper; +import org.onap.portalsdk.analytics.model.definition.ReportDefinition; +import org.onap.portalsdk.analytics.model.definition.ReportSchedule; +import org.onap.portalsdk.analytics.model.runtime.ChartWebRuntime; +import org.onap.portalsdk.analytics.model.runtime.FormField; +import org.onap.portalsdk.analytics.model.runtime.ReportFormFields; +import org.onap.portalsdk.analytics.model.runtime.ReportJSONRuntime; +import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; +import org.onap.portalsdk.analytics.model.runtime.VisualManager; +import org.onap.portalsdk.analytics.model.search.ReportSearchResultJSON; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.ConnectionUtils; +import org.onap.portalsdk.analytics.system.DbUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.system.IAppUtils; +import org.onap.portalsdk.analytics.system.fusion.domain.QuickLink; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.Utils; +import org.onap.portalsdk.analytics.view.ReportData; +import org.onap.portalsdk.analytics.xmlobj.ChartAdditionalOptions; +import org.onap.portalsdk.analytics.xmlobj.CustomReportType; +import org.onap.portalsdk.analytics.xmlobj.DashboardReports; +import org.onap.portalsdk.analytics.xmlobj.DataColumnList; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; +import org.onap.portalsdk.analytics.xmlobj.DataSourceList; +import org.onap.portalsdk.analytics.xmlobj.DataSourceType; +import org.onap.portalsdk.analytics.xmlobj.FormFieldList; +import org.onap.portalsdk.analytics.xmlobj.FormFieldType; +import org.onap.portalsdk.analytics.xmlobj.FormatList; +import org.onap.portalsdk.analytics.xmlobj.FormatType; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.onap.portalsdk.analytics.xmlobj.Reports; +import org.onap.portalsdk.analytics.xmlobj.SemaphoreType; +import org.onap.portalsdk.core.logging.format.AlarmSeverityEnum; +import org.onap.portalsdk.core.util.SecurityCodecUtil; +import org.onap.portalsdk.core.web.support.UserUtils; +import org.owasp.esapi.ESAPI; +import org.owasp.esapi.Encoder; +import org.owasp.esapi.codecs.Codec; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ AppUtils.class, UserUtils.class, ESAPI.class, AppConstants.class, AlarmSeverityEnum.class, ReportWrapper.class, + ReportDefinition.class, SecurityCodecUtil.class, Globals.class, DbUtils.class, ReportLoader.class, ConnectionUtils.class, FilenameUtils.class, Utils.class, ReportRuntime.class, DataCache.class, ActionHandler.class}) +public class ActionHandlerTest { + + @InjectMocks + ActionHandler actionHandler = new ActionHandler(); + + @Mock + Connection connection; + @Mock + PreparedStatement stmt; + @Mock + ResultSet rs; + @Mock + java.sql.Clob clob; + @Mock + InputStream in; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + + @SuppressWarnings("unchecked") + @Test + public void reportRunTest_WhenReportTypeIsNotEqualToDashboard() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.mockStatic(ReportWrapper.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mock(AppConstants.class); + PowerMockito.mockStatic(ReportDefinition.class); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(mockedRequest.getParameter("action")).thenReturn("test"); + when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); + when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("testxyz"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("FirstDashReport")).thenReturn(rr); + when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("report.download"); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + when(Globals.getDownloadAllEmailSent()).thenReturn("test"); + DataSet set = Mockito.mock(DataSet.class); + when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); + when(DbUtils.getConnection()).thenReturn(connection); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn(null); + when(rr.getReportID()).thenReturn("test"); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_SHOW_BACK_BTN)).thenReturn(true); + when(Globals.getLoadCustomReportXml()).thenReturn("java.lang.String"); + String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CustomReportType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"><reportName>name</reportName><reportDescr>desc</reportDescr><chartType>type</chartType><showChartTitle>false</showChartTitle><public>false</public><createId>id</createId><pageNav>false</pageNav></CustomReportType>"; + when(connection.prepareStatement("1")).thenReturn(stmt); + when(stmt.executeQuery()).thenReturn(rs); + when(Globals.isWeblogicServer()).thenReturn(true); + when(rs.getClob(1)).thenReturn(clob); + when(rs.next()).thenReturn(true); + when(clob.getAsciiStream()).thenReturn(in); + when(in.read(Matchers.any())).thenReturn(1); + when(AppUtils.nvl(rr.getLegendLabelAngle())).thenReturn("standard"); + when(AppUtils.nvl("Y")).thenReturn("Y"); + when(AppUtils.nvl("bottom")).thenReturn("Y"); + when(AppUtils.nvl("test")).thenReturn("test|"); + when(AppUtils.getRequestValue(mockedRequest, "c_dashboard")).thenReturn("1"); + when(ReportLoader.isDashboardType("-1")).thenReturn(false); + ReportDefinition rdf = PowerMockito.mock(ReportDefinition.class); + whenNew(ReportDefinition.class) + .withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class)) + .thenReturn(rdf); + when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject())).thenReturn(rdf); + CustomReportType crType = Mockito.mock(CustomReportType.class); + when(ReportWrapper.unmarshalCR(Matchers.anyString())).thenReturn(crType); + when(Globals.getReportWrapperFormat()).thenReturn("[Globals.getTimeFormat()]"); + when(Globals.getTimeFormat()).thenReturn("[reportID]"); + when(Globals.getReportUserAccess()).thenReturn("[reportID]"); + when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set); + when(set.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + when(set.getString(Matchers.anyInt(), Matchers.any(String.class))).thenReturn("test"); + when(ReportLoader.loadCustomReportXML("test2")).thenReturn(str); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + List formFieldTypeList = new ArrayList<>(); + formFieldTypeList.add(formFieldType); + FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class); + when(formFieldList.getFormField()).thenReturn(formFieldTypeList); + Mockito.when(crType.getFormFieldList()).thenReturn(formFieldList); + when(Globals.getRequestParams()).thenReturn("test,case"); + when( Globals.getSessionParams()).thenReturn("test,abc"); + when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + + DataSourceList dataSourceList = new DataSourceList(); + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + //dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + //dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + List predefinedValues = new ArrayList<>(); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", FormField.FFT_COMBO_BOX, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", FormField.FFT_LIST_MULTI, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", FormField.FFT_BLANK, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + rr.setReportFormFields(null); + rr.setReportFormFields(reportFormFields); + when(rr.getReportFormFields()).thenReturn(reportFormFields); + when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("test"); + Enumeration<String> enums; + Vector<String> attrs = new Vector<String>(); + attrs.add("ff_test"); + enums = attrs.elements(); + when(rr.getParamKeys()).thenReturn(enums); + + DashboardReports daashBoard = Mockito.mock(DashboardReports.class); + when(rdf.getDashBoardReports()).thenReturn(daashBoard); + when(daashBoard.getReportsList()).thenReturn(new ArrayList<Reports>()); + String testHTML = "<table border=1><tr><td>[Report#123]</td><td>[Report#124]</td></tr><tr><td>[Report#125]</td><td>[Report#126]</td></tr></table>"; + when(rr.getDashboardLayoutHTML()).thenReturn(testHTML); + when(rr.getReportType()).thenReturn("test"); + when(mockedRequest.getParameter("refresh")).thenReturn("N"); + when(rr.getDisplayContent()).thenReturn(true); + + when(AppUtils.getRequestNvlValue(mockedRequest,AppConstants.RI_VISUAL_ACTION)).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest,AppConstants.RI_DETAIL_ID)).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest,AppConstants.RI_DETAIL_ID)).thenReturn("test"); + when(rr.isDisplayOptionHideMap()).thenReturn(true); + when(mockedRequest.getSession().getAttribute("isEmbedded")).thenReturn(true); + when(rr.isDrillDownURLInPopupPresent()).thenReturn(true); + ArrayList aL = new ArrayList<>(); + ReportRuntime rr1 = PowerMockito.mock(ReportRuntime.class); + when(rr1.getReportID()).thenReturn("test1"); + when(rr1.getReportType()).thenReturn("test"); + aL.add(rr1); + when(mockedRequest.getSession().getAttribute(AppConstants.DRILLDOWN_REPORTS_LIST)).thenReturn(aL); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_RESET_PARAMS)).thenReturn(true); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_RESET_ACTION)).thenReturn(false); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_GO_BACK)).thenReturn(true); + + assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); + } + + @Test + public void reportRunExceptionTest() { + when(mockedRequest.getParameter("action")).thenReturn("test"); + PowerMockito.mockStatic(AppUtils.class); + when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(true); + assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); + } + + @SuppressWarnings("unchecked") + @Test + public void reportRunTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.mockStatic(ReportWrapper.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mock(AppConstants.class); + PowerMockito.mockStatic(ReportDefinition.class); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(mockedRequest.getParameter("action")).thenReturn("test"); + when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); + when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("testxyz"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("FirstDashReport")).thenReturn(rr); + when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("report.download"); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + when(Globals.getDownloadAllEmailSent()).thenReturn("test"); + DataSet set = Mockito.mock(DataSet.class); + when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); + when(DbUtils.getConnection()).thenReturn(connection); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn(AppConstants.RT_DASHBOARD); + when(rr.getReportID()).thenReturn(AppConstants.RT_DASHBOARD); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_SHOW_BACK_BTN)).thenReturn(true); + when(Globals.getLoadCustomReportXml()).thenReturn("java.lang.String"); + String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CustomReportType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"><reportName>name</reportName><reportDescr>desc</reportDescr><chartType>type</chartType><showChartTitle>false</showChartTitle><public>false</public><createId>id</createId><pageNav>false</pageNav></CustomReportType>"; + when(connection.prepareStatement("1")).thenReturn(stmt); + when(stmt.executeQuery()).thenReturn(rs); + when(Globals.isWeblogicServer()).thenReturn(true); + when(rs.getClob(1)).thenReturn(clob); + when(rs.next()).thenReturn(true); + when(clob.getAsciiStream()).thenReturn(in); + when(in.read(Matchers.any())).thenReturn(1); + when(AppUtils.nvl(rr.getLegendLabelAngle())).thenReturn("standard"); + when(AppUtils.nvl("Y")).thenReturn("Y"); + when(AppUtils.nvl("bottom")).thenReturn("Y"); + when(AppUtils.nvl("test")).thenReturn("test|"); + when(AppUtils.getRequestValue(mockedRequest, "c_dashboard")).thenReturn("1"); + when(ReportLoader.isDashboardType("-1")).thenReturn(false); + ReportDefinition rdf = PowerMockito.mock(ReportDefinition.class); + whenNew(ReportDefinition.class) + .withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class)) + .thenReturn(rdf); + when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject())).thenReturn(rdf); + CustomReportType crType = Mockito.mock(CustomReportType.class); + when(ReportWrapper.unmarshalCR(Matchers.anyString())).thenReturn(crType); + when(Globals.getReportWrapperFormat()).thenReturn("[Globals.getTimeFormat()]"); + when(Globals.getTimeFormat()).thenReturn("[reportID]"); + when(Globals.getReportUserAccess()).thenReturn("[reportID]"); + when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set); + when(set.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + when(ReportLoader.loadCustomReportXML("test2")).thenReturn(str); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + List formFieldTypeList = new ArrayList<>(); + formFieldTypeList.add(formFieldType); + FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class); + when(formFieldList.getFormField()).thenReturn(formFieldTypeList); + Mockito.when(crType.getFormFieldList()).thenReturn(formFieldList); + when(Globals.getRequestParams()).thenReturn("test,case"); + when( Globals.getSessionParams()).thenReturn("test,abc"); + when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + + DataSourceList dataSourceList = new DataSourceList(); + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + //dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + //dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + List predefinedValues = new ArrayList<>(); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", FormField.FFT_COMBO_BOX, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", FormField.FFT_LIST_MULTI, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", FormField.FFT_BLANK, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + rr.setReportFormFields(null); + rr.setReportFormFields(reportFormFields); + when(rr.getReportFormFields()).thenReturn(reportFormFields); + when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("test"); + Enumeration<String> enums; + Vector<String> attrs = new Vector<String>(); + attrs.add("ff_test"); + enums = attrs.elements(); + when(rr.getParamKeys()).thenReturn(enums); + + DashboardReports daashBoard = Mockito.mock(DashboardReports.class); + when(rdf.getDashBoardReports()).thenReturn(daashBoard); + when(daashBoard.getReportsList()).thenReturn(new ArrayList<Reports>()); + String testHTML = "<table border=1><tr><td>[Report#123]</td><td>[Report#124]</td></tr><tr><td>[Report#125]</td><td>[Report#126]</td></tr></table>"; + when(rr.getDashboardLayoutHTML()).thenReturn(testHTML); + when(rr.getReportType()).thenReturn(AppConstants.RT_DASHBOARD); + when(mockedRequest.getParameter("refresh")).thenReturn("N"); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_DISPLAY_CONTENT)).thenReturn(true); + assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); + } + + + + @SuppressWarnings("unchecked") + @Test + public void reportRunRaptorReportExceptionTest() throws Exception { + try { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.mockStatic(ReportWrapper.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mock(AppConstants.class); + PowerMockito.mockStatic(ReportDefinition.class); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(mockedRequest.getParameter("action")).thenReturn("test"); + when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); + when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("testxyz"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("FirstDashReport")).thenReturn(rr); + when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("report.download"); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + when(Globals.getDownloadAllEmailSent()).thenReturn("test"); + DataSet set = Mockito.mock(DataSet.class); + when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); + when(DbUtils.getConnection()).thenReturn(connection); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("test2"); + when(rr.getReportID()).thenReturn("test"); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_SHOW_BACK_BTN)).thenReturn(true); + when(Globals.getLoadCustomReportXml()).thenReturn("java.lang.String"); + String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CustomReportType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"><reportName>name</reportName><reportDescr>desc</reportDescr><chartType>type</chartType><showChartTitle>false</showChartTitle><public>false</public><createId>id</createId><pageNav>false</pageNav></CustomReportType>"; + when(connection.prepareStatement("1")).thenReturn(stmt); + when(stmt.executeQuery()).thenReturn(rs); + when(Globals.isWeblogicServer()).thenReturn(true); + when(rs.getClob(1)).thenReturn(clob); + when(rs.next()).thenReturn(true); + when(clob.getAsciiStream()).thenReturn(in); + when(in.read(Matchers.any())).thenReturn(1); + when(AppUtils.nvl(rr.getLegendLabelAngle())).thenReturn("standard"); + when(AppUtils.nvl("Y")).thenReturn("Y"); + when(AppUtils.nvl("bottom")).thenReturn("Y"); + when(AppUtils.nvl("test")).thenReturn("test|"); + when(AppUtils.getRequestValue(mockedRequest, "c_dashboard")).thenReturn("1"); + when(ReportLoader.isDashboardType("-1")).thenReturn(false); + ReportDefinition rdf = PowerMockito.mock(ReportDefinition.class); + whenNew(ReportDefinition.class) + .withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class)) + .thenReturn(rdf); + when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject())).thenReturn(rdf); + CustomReportType crType = Mockito.mock(CustomReportType.class); + when(ReportWrapper.unmarshalCR(Matchers.anyString())).thenReturn(crType); + when(Globals.getReportWrapperFormat()).thenReturn("[Globals.getTimeFormat()]"); + when(Globals.getTimeFormat()).thenReturn("[reportID]"); + when(Globals.getReportUserAccess()).thenReturn("[reportID]"); + when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set); + when(set.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + when(ReportLoader.loadCustomReportXML("test2")).thenReturn(str); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + List formFieldTypeList = new ArrayList<>(); + formFieldTypeList.add(formFieldType); + FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class); + when(formFieldList.getFormField()).thenReturn(formFieldTypeList); + Mockito.when(crType.getFormFieldList()).thenReturn(formFieldList); + when(Globals.getRequestParams()).thenReturn("test,case"); + when( Globals.getSessionParams()).thenReturn("test,abc"); + when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + + DataSourceList dataSourceList = new DataSourceList(); + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + //dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + //dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + when(rr.getReportType()).thenReturn(AppConstants.RT_DASHBOARD); + + List predefinedValues = new ArrayList<>(); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", FormField.FFT_COMBO_BOX, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", FormField.FFT_LIST_MULTI, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", FormField.FFT_BLANK, "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + rr.setReportFormFields(null); + rr.setReportFormFields(reportFormFields); + when(rr.getReportFormFields()).thenReturn(reportFormFields); + when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("test"); + Enumeration<String> enums; + Vector<String> attrs = new Vector<String>(); + attrs.add("ff_test"); + enums = attrs.elements(); + when(rr.getParamKeys()).thenReturn(enums); + assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); + }catch(Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void reportRunForCSVDownloadTest() throws Exception { + when(mockedRequest.getParameter("action")).thenReturn("test"); + when(mockedRequest.getParameter("r_action")).thenReturn("report.csv.download"); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); + when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn(""); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + when(AppUtils.getRequestFlag(mockedRequest, "fromReportLog")).thenReturn(true); + when(rr.getReportType()).thenReturn(AppConstants.RT_LINEAR); + when(rr.getReportDataSQL(Matchers.anyString(), Matchers.anyInt(), Matchers.any())).thenReturn("test"); + PowerMockito.mockStatic(ESAPI.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + when(Globals.getDownloadAllEmailSent()).thenReturn("test"); + DataSet set = new DataSet(); + when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); + assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); + } + + @Test + public void reportRunForExcelDownloadTest() throws Exception { + when(mockedRequest.getParameter("action")).thenReturn("test"); + when(mockedRequest.getParameter("r_action")).thenReturn("report.download.excel2007"); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); + when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn(""); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_REFRESH)).thenReturn(true); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + when(AppUtils.getRequestFlag(mockedRequest, "fromReportLog")).thenReturn(false); + when(rr.getReportType()).thenReturn(AppConstants.RT_LINEAR); + when(rr.getReportDataSQL(Matchers.anyString(), Matchers.anyInt(), Matchers.any())).thenReturn("test"); + PowerMockito.mockStatic(ESAPI.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + when(Globals.getDownloadAllEmailSent()).thenReturn("test"); + DataSet set = new DataSet(); + when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); + Enumeration<String> enum1 = Mockito.mock(Enumeration.class); + HttpSession session = mockedRequest.getSession(); + when(session.getAttributeNames()).thenReturn(enum1); + assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); + } + + + public ReportRuntime mockReportRunTime1() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + when(Globals.getReportUserAccess()).thenReturn("test"); + ResultSet rs = PowerMockito.mock(ResultSet.class); + ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); + when(rsmd.getColumnCount()).thenReturn(1); + when(rs.getMetaData()).thenReturn(rsmd); + DataSet datset = PowerMockito.mock(DataSet.class); + // datset = new DataSet(rs); + when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + when(Globals.getNewScheduleData()).thenReturn("test"); + CustomReportType customReportType = new CustomReportType(); + DataSourceList dataSourceList = new DataSourceList(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnTypeList.add(dataColumnType); + customReportType.setReportType("test"); + customReportType.setReportTitle("test"); + customReportType.setDataSourceList(dataSourceList); + ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions(); + chartAdditionalOptions.setLabelAngle("test"); + chartAdditionalOptions.setTimeSeriesRender("test"); + chartAdditionalOptions.setMultiSeries(false); + customReportType.setChartAdditionalOptions(chartAdditionalOptions); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + PowerMockito.mockStatic(UserUtils.class); + when(Globals.getRequestParams()).thenReturn("test"); + when(Globals.getSessionParams()).thenReturn("test"); + when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + PowerMockito.mockStatic(AppUtils.class); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test12"); + ReportRuntime rr = new ReportRuntime(reportWrapper, mockedRequest); + rr.setLegendLabelAngle("test"); + rr.setMultiSeries(false); + rr.setChartType("test"); + return rr; + } + + + @Test + public void reportRunTestCase1() throws Exception { + when(mockedRequest.getParameter("action")).thenReturn("test"); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); + when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + + PowerMockito.mockStatic(ESAPI.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + when(Globals.getDownloadAllEmailSent()).thenReturn("test"); + DataSet set = PowerMockito.mock(DataSet.class); + when(set.isEmpty()).thenReturn(false); + when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn(null); + PowerMockito.mockStatic(ReportLoader.class); + when(ReportLoader.loadCustomReportXML(Matchers.anyString())).thenReturn("test"); + assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); + } + + + @Test + public void reportDeleteTest() throws Exception { + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + PowerMockito.mockStatic(AlarmSeverityEnum.class); + DataSet set = Mockito.mock(DataSet.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + ReportDefinition rd = PowerMockito.mock(ReportDefinition.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("1"); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("1"); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + when(Globals.getReportSecurity()).thenReturn("[rw.getReportID()]"); + when(Globals.getReportUserAccess()).thenReturn("[reportID]"); + when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set); + when(Globals.getDeleteOnlyByOwner()).thenReturn(true); + when(Globals.getLogVariablesInSession()).thenReturn("test"); + HttpSession session = Mockito.mock(HttpSession.class); + when(session.getAttribute(Matchers.anyString())).thenReturn(rr); + when(session.getAttribute(Matchers.anyString())).thenReturn(rd); + assertEquals(actionHandler.reportDelete(mockedRequest, "10").getClass(), String.class); + } + + + @Test + public void reportSearchTest() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + when(AppUtils.getImgFolderURL()).thenReturn("test"); + SearchHandler sh = Mockito.mock(SearchHandler.class); + whenNew(SearchHandler.class).withNoArguments().thenReturn(sh); + ReportSearchResultJSON rsrj = Mockito.mock(ReportSearchResultJSON.class); + when(sh.loadReportSearchResult(mockedRequest)).thenReturn(rsrj); + when(rsrj.getJSONString()).thenReturn("test"); + Enumeration<String> enum1 = Mockito.mock(Enumeration.class); + HttpSession session = mockedRequest.getSession(); + when(session.getAttributeNames()).thenReturn(enum1); + actionHandler.reportSearch(mockedRequest, "10"); + } + + + @Test + public void reportChartRunTest() throws Exception { + ChartWebRuntime cwr = PowerMockito.mock(ChartWebRuntime.class); + whenNew(ChartWebRuntime.class).withNoArguments().thenReturn(cwr); + when(cwr.generateChart(mockedRequest,false)).thenReturn("testReport"); + assertEquals("testReport", actionHandler.reportChartRun(mockedRequest, "10")); + } + + @Test + public void reportSearchUserTest() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + when(AppUtils.getImgFolderURL()).thenReturn("test"); + SearchHandler sh = Mockito.mock(SearchHandler.class); + whenNew(SearchHandler.class).withNoArguments().thenReturn(sh); + ReportSearchResultJSON rsrj = Mockito.mock(ReportSearchResultJSON.class); + when(sh.loadReportSearchResult(mockedRequest)).thenReturn(rsrj); + when(rsrj.getJSONString()).thenReturn("test"); + Enumeration<String> enum1 = Mockito.mock(Enumeration.class); + HttpSession session = mockedRequest.getSession(); + when(session.getAttributeNames()).thenReturn(enum1); + assertEquals("test", actionHandler.reportSearchUser(mockedRequest, "10")); + } + + @Test + public void reportSearchPublicTest() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + when(AppUtils.getImgFolderURL()).thenReturn("test"); + SearchHandler sh = Mockito.mock(SearchHandler.class); + whenNew(SearchHandler.class).withNoArguments().thenReturn(sh); + ReportSearchResultJSON rsrj = Mockito.mock(ReportSearchResultJSON.class); + when(sh.loadReportSearchResult(mockedRequest)).thenReturn(rsrj); + when(rsrj.getJSONString()).thenReturn("test"); + Enumeration<String> enum1 = Mockito.mock(Enumeration.class); + HttpSession session = mockedRequest.getSession(); + when(session.getAttributeNames()).thenReturn(enum1); + assertEquals("test", actionHandler.reportSearchPublic(mockedRequest, "10")); + } + + @Test + public void reportSearchFavoritesTest() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + when(AppUtils.getImgFolderURL()).thenReturn("test"); + SearchHandler sh = Mockito.mock(SearchHandler.class); + whenNew(SearchHandler.class).withNoArguments().thenReturn(sh); + ReportSearchResultJSON rsrj = Mockito.mock(ReportSearchResultJSON.class); + when(sh.loadReportSearchResult(mockedRequest)).thenReturn(rsrj); + when(rsrj.getJSONString()).thenReturn("test"); + Enumeration<String> enum1 = Mockito.mock(Enumeration.class); + HttpSession session = mockedRequest.getSession(); + when(session.getAttributeNames()).thenReturn(enum1); + assertEquals("test", actionHandler.reportSearchFavorites(mockedRequest, "10")); + } + + @Test + public void reportChartDataRunTest() throws Exception { + ChartWebRuntime cwr = Mockito.mock(ChartWebRuntime.class); + whenNew(ChartWebRuntime.class).withNoArguments().thenReturn(cwr); + when(cwr.generateChart(mockedRequest)).thenReturn("testReport"); + assertEquals("testReport", actionHandler.reportChartDataRun(mockedRequest, "10")); + } + + + @Test + public void processScheduleDeleteTest() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(DbUtils.class); + PowerMockito.mockStatic(Globals.class); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_SCHEDULE_ID)).thenReturn("test"); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("test2"); + ReportHandler rh = Mockito.mock(ReportHandler.class); + ReportDefinition rdef = Mockito.mock(ReportDefinition.class); + whenNew(ReportHandler.class).withNoArguments().thenReturn(rh); + when(rh.loadReportDefinition(mockedRequest, "test2")).thenReturn(rdef); + when(AppUtils.getRequestNvlValue(mockedRequest, "myScheduleRepId")).thenReturn("test3"); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportSchedule rs = Mockito.mock(ReportSchedule.class); + whenNew(ReportSchedule.class).withArguments(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class)).thenReturn(rs); + Connection con = Mockito.mock(Connection.class); + when(DbUtils.startTransaction()).thenReturn(con); + PowerMockito.doNothing().when(rs).deleteScheduleData(con); + PowerMockito.doNothing().when(DbUtils.class, "commitTransaction", new Object[]{con}); + PowerMockito.doNothing().when(DbUtils.class, "clearConnection", new Object[]{con}); + when(mockedRequest.getParameter("action")).thenReturn("report.download.excel2007"); + + when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_REFRESH)).thenReturn(true); + when(AppUtils.getRequestFlag(mockedRequest, "fromReportLog")).thenReturn(false); + when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + + PowerMockito.mockStatic(ESAPI.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + when(Globals.getDownloadAllEmailSent()).thenReturn("test"); + DataSet set = PowerMockito.mock(DataSet.class); + when(set.isEmpty()).thenReturn(false); + when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn(null); + PowerMockito.mockStatic(ReportLoader.class); + when(ReportLoader.loadCustomReportXML(Matchers.anyString())).thenReturn("test"); + PowerMockito.doNothing().when(rr).logReportExecutionTime(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class)); + assertEquals(String.class, actionHandler.processScheduleDelete(mockedRequest, "10").getClass()); + } + + @Test + public void testFormFieldRun() { + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportJSONRuntime rjr = Mockito.mock(ReportJSONRuntime.class); + when(rr.createFormFieldJSONRuntime(mockedRequest)).thenReturn(rjr); + assertEquals(String.class, actionHandler.formFieldRun(mockedRequest, "10").getClass()); + } + + @Test + public void testGetReportData() throws RaptorException { + PowerMockito.mockStatic(ConnectionUtils.class); + PowerMockito.mockStatic(AppUtils.class); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + ReportFormFields rff = PowerMockito.mock(ReportFormFields.class); + FormField ff = PowerMockito.mock(FormField.class); + SemaphoreType st = PowerMockito.mock(SemaphoreType.class); + FormatList fl = PowerMockito.mock(FormatList.class); + FormatType ft = PowerMockito.mock(FormatType.class); + VisualManager visualManager = PowerMockito.mock(VisualManager.class); + List<FormatType> ftList = new ArrayList<>(); + ftList.add(ft); + List<DataColumnType> dctList= new ArrayList<>(); + DataColumnType dct = new DataColumnType(); + dct.setColId("1"); + dct.setDisplayName("testData"); + dct.setColType("DATE"); + dct.setDependsOnFormField("[testFieldDisplayName]"); + dct.setSemaphoreId("testSemaphoreId"); + dct.setColFormat("testColFormat"); + dct.setDrillDownURL("testDrillDownUrl"); + dct.setVisible(true); + dct.setDisplayWidthInPxls("testDisplayWidthInPxls"); + dct.setDisplayHeaderAlignment("testDisplayHeaderAlignment"); + dctList.add(dct); + when(rr.getAllColumns()).thenReturn(dctList); + when(rr.getReportFormFields()).thenReturn(rff); + when(rr.getDBInfo()).thenReturn("testDB"); + when(rr.getReportDefType()).thenReturn(AppConstants.RD_SQL_BASED); + when(rr.getSemaphoreById(Mockito.any())).thenReturn(st); + when(rr.getChildReportFormFields(Mockito.any(HttpServletRequest.class), Mockito.any(String.class))).thenReturn(rff); + when(rr.getVisualManager()).thenReturn(visualManager); + DataSet ds = PowerMockito.mock(DataSet.class); + when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + when(ds.getRowCount()).thenReturn(1); + when(ds.getString(Mockito.any(Integer.class),Mockito.any(Integer.class))).thenReturn("testDataValue"); + when(rff.size()).thenReturn(1); + when(rff.getFormField(Mockito.any(Integer.class))).thenReturn(ff); + when(ff.getFieldDisplayName()).thenReturn("testFieldDisplayName"); + when(ff.getFieldName()).thenReturn("testFieldName"); + when(mockedRequest.getParameter("testFieldName")).thenReturn("testFieldValue"); + when(st.getFormatList()).thenReturn(fl); + when(st.getSemaphoreType()).thenReturn(AppConstants.ST_ROW); + when(fl.getFormat()).thenReturn(ftList); + when(ft.getLessThanValue()).thenReturn("10"); + when(visualManager.isColumnVisible(Mockito.any(String.class))).thenReturn(true); + when(visualManager.getSortByColId()).thenReturn("1"); + assertEquals(ReportData.class, actionHandler.getReportData(rr, mockedRequest, "test", 10).getClass()); + } + + @Test(expected = IOException.class) + public void testDownloadAll() throws InterruptedException, IOException, Exception { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + PowerMockito.mockStatic(FilenameUtils.class); + PowerMockito.mockStatic(Utils.class); + PowerMockito.mockStatic(ReportRuntime.class); + when(AppUtils.getRequestValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); + when(AppUtils.getUserEmail(mockedRequest)).thenReturn("test@mail.com"); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + when(AppUtils.getRequestValue(mockedRequest, "log_id")).thenReturn("testLogID"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(Globals.getDownloadAllEmailSent()).thenReturn("testEmailSentQuery"); + when(Globals.getDownloadAllGenKey()).thenReturn("testGenerateKeyQuery"); + when(Globals.getShellScriptDir()).thenReturn("./"); + DataSet ds = PowerMockito.mock(DataSet.class); + when(DbUtils.executeQuery(Mockito.any(String.class), Mockito.eq(1))).thenReturn(ds); + when(DbUtils.executeQuery(Mockito.any(String.class))).thenReturn(ds); + when(ds.isEmpty()).thenReturn(false); + when(ds.getString(0,"user_id")).thenReturn("testUserID"); + when(ds.getString(0,"rep_id")).thenReturn("testReportID"); + when(ds.getRowCount()).thenReturn(1); + when(ds.getString(0,0)).thenReturn("testScheduleId"); + when(FilenameUtils.normalize(Mockito.any(String.class))).thenReturn("testFile.txt"); + when(Utils.isDownloadFileExists(Mockito.any(String.class))).thenReturn(true); + when(Utils.getLatestDownloadableFile(Mockito.any(String.class))).thenReturn("testLastDownloadedFile.txt"); + List<DataColumnType> dctList= new ArrayList<>(); + DataColumnType dct = new DataColumnType(); + dct.setDisplayName("testData"); + dctList.add(dct); + when(rr.getAllColumns()).thenReturn(dctList); + when(mockedRequest.getParameter("refresh")).thenReturn("N"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(rr.getReportID()).thenReturn("testReportID"); + actionHandler.downloadAll(mockedRequest, "10"); + } + + @Test + public void testRunSQLPopup() throws ReportSQLException { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(Utils.class); + PowerMockito.mockStatic(ConnectionUtils.class); + when(AppUtils.getRequestNvlValue(mockedRequest, AppConstants.RI_FORMATTED_SQL)).thenReturn("SELECT * FROM TEST"); + when(AppUtils.getRequestNvlValue(mockedRequest,AppConstants.RI_CHK_FIELD_SQL)).thenReturn("N"); + ReportDefinition rdef = PowerMockito.mock(ReportDefinition.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class); + formFieldList.getFormField().add(formFieldType); + when(rdef.getFormFieldList()).thenReturn(formFieldList); + when(rdef.getFormFieldDisplayName(formFieldType)).thenReturn("testField"); + when(mockedRequest.getParameter("remoteDbPrefix")).thenReturn("testDB"); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + when(Utils.replaceInString(Mockito.any(String.class),Mockito.any(String.class),Mockito.any(String.class))).thenReturn("testString"); + when(Globals.getRequestParams()).thenReturn("test"); + when(Globals.getSessionParams()).thenReturn("test"); + DataSet ds = PowerMockito.mock(DataSet.class); + when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class), Mockito.eq(true))).thenReturn(ds); + when(ds.getRowCount()).thenReturn(1); + when(ds.getString(Mockito.any(Integer.class),Mockito.any(Integer.class))).thenReturn("testDataValue"); + PowerMockito.mockStatic(ESAPI.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + actionHandler.testRunSQLPopup(mockedRequest, "10"); + } + + @Test + public void testSchedCondPopup() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + ReportDefinition rdef = PowerMockito.mock(ReportDefinition.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + when(AppUtils.getRequestNvlValue(mockedRequest, AppConstants.RI_FORMATTED_SQL)).thenReturn("testSQL"); + when(Globals.getTestSchedCondPopup()).thenReturn("testQuery"); + when(mockedRequest.getParameter("remoteDbPrefix")).thenReturn("testDB"); + DataSet ds = PowerMockito.mock(DataSet.class); + when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + when(ds.getRowCount()).thenReturn(1); + actionHandler.testSchedCondPopup(mockedRequest, "10"); + } + + @Test + public void testReportShowSQLPopup() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + ReportDefinition rdef = PowerMockito.mock(ReportDefinition.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + when(rdef.generateSQL(Mockito.any(String.class),Mockito.any(HttpServletRequest.class))).thenReturn("testReportSQL"); + actionHandler.reportShowSQLPopup(mockedRequest, "10"); + } + + + @Test + public void testReportFilterDataPopup() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + ReportDefinition rdef = PowerMockito.mock(ReportDefinition.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + when(AppUtils.getRequestNvlValue(mockedRequest, AppConstants.RI_COLUMN_ID)).thenReturn("testColID"); + when(rdef.getDBInfo()).thenReturn(null); + when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("testDB"); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_RESET_PARAMS)).thenReturn(false); + IdNameColLookup lookUp = Mockito.mock(IdNameColLookup.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_COLUMN_LOOKUP)).thenReturn(lookUp); + when(lookUp.getColId()).thenReturn("testColID"); + when(AppUtils.getRequestNvlValue(mockedRequest, AppConstants.RI_SEARCH_STRING)).thenReturn("testSearchStr"); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_CONTAIN_FLAG)).thenReturn(true); + actionHandler.reportFilterDataPopup(mockedRequest, "10"); + } + + @Test + public void testReportImportSave() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CustomReportType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"><reportName>name</reportName><reportDescr>desc</reportDescr><chartType>type</chartType><showChartTitle>false</showChartTitle><public>false</public><createId>id</createId><pageNav>false</pageNav></CustomReportType>"; + when(AppUtils.getRequestValue(mockedRequest, "reportXML")).thenReturn(str); + ReportHandler rh = Mockito.mock(ReportHandler.class); + ReportDefinition rdef = Mockito.mock(ReportDefinition.class); + whenNew(ReportHandler.class).withNoArguments().thenReturn(rh); + when(rh.createReportDefinition(mockedRequest, "-1", str)).thenReturn(rdef); + PowerMockito.doNothing().when(rdef).updateReportDefType(); + PowerMockito.doNothing().when(rdef).generateWizardSequence(mockedRequest); + when(rdef.getReportName()).thenReturn("test"); + PowerMockito.doNothing().when(rdef).setReportName("Import: test"); + PowerMockito.doNothing().when(rdef).clearAllDrillDowns(); + actionHandler.reportImportSave(mockedRequest, "10"); + } + + @Test + public void testProcessSchedule() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.mockStatic(DbUtils.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_SCHEDULE)).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, AppConstants.RI_ACTION)).thenReturn("test"); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_SCHEDULE_ID)).thenReturn(""); + ReportSchedule rs = Mockito.mock(ReportSchedule.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_SCHEDULE)).thenReturn(rs); + when(rs.getScheduleID()).thenReturn("testSchecduleID"); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("testReportID"); + when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); + when(ReportLoader.doesUserCanScheduleReport(Mockito.any(HttpServletRequest.class), Mockito.any(String.class))).thenReturn(true); + when(rs.getFormFields()).thenReturn("testField"); + when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + Connection con = Mockito.mock(Connection.class); + when(DbUtils.startTransaction()).thenReturn(con); + actionHandler.processSchedule(mockedRequest, "10"); + } + + @Test(expected=RuntimeException.class) + public void testProcessSchedule_WhenReportScheduleIsNull() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_SCHEDULE)).thenReturn(null); + when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn(""); + ReportDefinition rdef = PowerMockito.mock(ReportDefinition.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + actionHandler.processSchedule(mockedRequest, "10"); + } + + @Test + public void testReportValuesMapDefPopup() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + ReportDefinition rdef = PowerMockito.mock(ReportDefinition.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + when(AppUtils.getRequestNvlValue(mockedRequest, "colName")).thenReturn("testCol"); + when(AppUtils.getRequestNvlValue(mockedRequest, "displayName")).thenReturn("testDisplayName"); + when(AppUtils.getRequestNvlValue(mockedRequest, "displayFormat")).thenReturn("testDisplayFormat"); + when(AppUtils.getRequestNvlValue(mockedRequest, "tableId")).thenReturn("testTableId"); + when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("testDB"); + when(Globals.getReportValuesMapDefA()).thenReturn("testA"); + when(Globals.getReportValuesMapDefB()).thenReturn("testB"); + when(Globals.getReportValuesMapDefC()).thenReturn("testC"); + when(Globals.getReportValuesMapDefD()).thenReturn("testD"); + when(Globals.getDefaultPageSize()).thenReturn(10); + DataSourceType ds = Mockito.mock(DataSourceType.class); + when(ds.getTableName()).thenReturn("testTable"); + when(rdef.getTableById(Mockito.any(String.class))).thenReturn(ds); + DataSet data = Mockito.mock(DataSet.class); + when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(data); + actionHandler.reportValuesMapDefPopup(mockedRequest, "10"); + } + + @Test + public void testReportFormFieldPopup() { + PowerMockito.mockStatic(AppUtils.class); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + FormField formField = new FormField("test", "fieldDisplayName", FormField.FFT_COMBO_BOX, "validationType", false, + "defaultValue", "helpText", new ArrayList<>(), false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + when(rr.getFormField(Mockito.any(String.class))).thenReturn(formField); + ReportFormFields rff = PowerMockito.mock(ReportFormFields.class); + when(rr.getReportFormFields()).thenReturn(rff); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + IdNameList lookup = Mockito.mock(IdNameList.class); + when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_TEXTFIELD_POP)).thenReturn(true); + actionHandler.reportFormFieldPopup(mockedRequest, "10"); + } + + @Test + public void testReportCreate() throws Exception { + PowerMockito.mockStatic(ReportDefinition.class); + PowerMockito.mockStatic(DataCache.class); + Enumeration<String> enum1 = Mockito.mock(Enumeration.class); + HttpSession session = mockedRequest.getSession(); + when(session.getAttributeNames()).thenReturn(enum1); + ReportDefinition rdef = PowerMockito.mock(ReportDefinition.class); + when(ReportDefinition.createBlank(mockedRequest)).thenReturn(rdef); + PowerMockito.doNothing().when(DataCache.class, "refreshReportTableSources", new Object[]{}); + actionHandler.reportCreate(mockedRequest, "10"); + } + + @Test + public void testRefreshCache() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DataCache.class); + Enumeration<String> enum1 = Mockito.mock(Enumeration.class); + HttpSession session = mockedRequest.getSession(); + when(session.getAttributeNames()).thenReturn(enum1); + PowerMockito.doNothing().when(DataCache.class, "refreshAll", new Object[]{}); + IAppUtils iau = Mockito.mock(IAppUtils.class); + when(Globals.getAppUtils()).thenReturn(iau); + PowerMockito.doNothing().when(iau).resetUserCache(); + actionHandler.refreshCache(mockedRequest, "10"); + } + + @Test + public void testProcessScheduleReportListd() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(ReportLoader.class); + when(AppUtils.getRequestNvlValue(mockedRequest, "schedule_reports")).thenReturn("reportID"); + when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); + when(ReportLoader.doesUserCanScheduleReport(mockedRequest, null)).thenReturn(true); + ReportDefinition rdef = PowerMockito.mock(ReportDefinition.class); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + when(rdef.getReportID()).thenReturn("reportID"); + actionHandler.processScheduleReportList(mockedRequest, "10"); + } + + + @Test + public void testGetQuickLinksJSON() throws Exception { + PowerMockito.mockStatic(SecurityCodecUtil.class); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(ReportLoader.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + when(SecurityCodecUtil.getCodec()).thenReturn(codec); + when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + ArrayList<QuickLink> qList = new ArrayList<QuickLink>(); + qList.add(new QuickLink()); + when(ReportLoader.getQuickLinksJSON(Mockito.any(HttpServletRequest.class), Mockito.any(String.class), Mockito.eq(true))).thenReturn(qList); + actionHandler.getQuickLinksJSON(mockedRequest, "10"); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionMappingTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionMappingTest.java new file mode 100644 index 00000000..ce883537 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionMappingTest.java @@ -0,0 +1,70 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class ActionMappingTest { + + ActionMapping actionMapping; + Action action; + private String ACTION = "testAction"; + private String CONTROLLER_CLASS = "testController"; + private String CONTROLLER_METHOD = "test"; + private String JSP_NAME = "testJsp"; + + @Before + public void init() { + actionMapping = new ActionMapping(); + action = new Action(ACTION, CONTROLLER_CLASS, CONTROLLER_METHOD, JSP_NAME); + actionMapping.addAction(action); + } + + @Test + public void testGetAction() { + Action localAction = (Action)actionMapping.get(ACTION); + assertEquals(ACTION, localAction.getAction()); + assertEquals(CONTROLLER_CLASS, localAction.getControllerClass()); + assertEquals(CONTROLLER_METHOD, localAction.getControllerMethod()); + assertEquals(JSP_NAME, localAction.getJspName()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionTest.java new file mode 100644 index 00000000..06fa42fe --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionTest.java @@ -0,0 +1,89 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.onap.portalsdk.analytics.controller.Action; + + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class ActionTest { + + Action action; + private String ACTION = "testAction"; + private String CONTROLLER_CLASS = "testController"; + private String CONTROLLER_METHOD = "test"; + private String JSP_NAME = "testJsp"; + + @Before + public void init() { + action = new Action(ACTION, CONTROLLER_CLASS, CONTROLLER_METHOD, JSP_NAME); + } + + @Test + public void testNotNull() { + assertNotNull(action); + } + + @Test + public void testActionAttributes() { + assertEquals(ACTION, action.getAction()); + assertEquals(CONTROLLER_CLASS, action.getControllerClass()); + assertEquals(CONTROLLER_METHOD, action.getControllerMethod()); + assertEquals(JSP_NAME, action.getJspName()); + } + + @Test + public void testParse() { + String configFileEntry = "testAction testController test testJsp"; + Action localAction = action.parse(configFileEntry); + assertEquals(ACTION, localAction.getAction()); + assertEquals(CONTROLLER_CLASS, localAction.getControllerClass()); + assertEquals(CONTROLLER_METHOD, localAction.getControllerMethod()); + assertEquals(JSP_NAME, localAction.getJspName()); + } +}
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ControllerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ControllerTest.java new file mode 100644 index 00000000..0bcf8637 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ControllerTest.java @@ -0,0 +1,262 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class, AppUtils.class}) +public class ControllerTest { + Controller controller; + String ACTION_KEY = "testAction"; + Action action; + ActionMapping actionMapping; + private String ACTION = "testAction"; + private String CONTROLLER_CLASS = "org.onap.portalsdk.analytics.controller.DummyController"; + private String PRIVATE_CONTROLLER_CLASS = "org.onap.portalsdk.analytics.controller.PrivateDummyController"; + private String ABSTRACT_CONTROLLER_CLASS = "org.onap.portalsdk.analytics.controller.AbstractDummyController"; + private String CONTROLLER_METHOD = "view"; + private String JSP_NAME = "testJsp"; + private String ERROR_PAGE = "errorPage"; + private String ERROR_MESSAGE = "testErrorMessage"; + private String TEST_ID = "testID"; + private String REPORT_NAME = "testReport"; + private String REPORT_SQL = "testReportSQL"; + private String LOG_VAR_IN_SESSION = "test"; + + @Before + public void setup() { + controller = new Controller(); + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockResponse = mockitoTestSuite.getMockedResponse(); + + @Test + public void processRequestTest_WhenClassNotFoundException() throws Exception { + actionMapping = new ActionMapping(); + action = new Action(ACTION, "AdminController", CONTROLLER_METHOD, JSP_NAME); + actionMapping.addAction(action); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(ERROR_PAGE); + assertEquals(ERROR_PAGE, controller.processRequest(ACTION_KEY, mockedRequest)); + } + + @Test + public void processRequestTest_WhenActionIsNull() throws Exception { + actionMapping = new ActionMapping(); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(ERROR_PAGE); + assertEquals(ERROR_PAGE, controller.processRequest(ACTION_KEY, mockedRequest)); + } + + @Test + public void processRequestTest() throws Exception { + actionMapping = new ActionMapping(); + action = new Action("report.run", CONTROLLER_CLASS, CONTROLLER_METHOD, JSP_NAME); + actionMapping.addAction(action); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(ERROR_PAGE); + assertEquals(JSP_NAME, controller.processRequest(mockedRequest)); + } + + + @Test + public void processRequestTest_WithNoSuchMethodException() throws Exception { + actionMapping = new ActionMapping(); + action = new Action(ACTION, CONTROLLER_CLASS, "viewHome", JSP_NAME); + actionMapping.addAction(action); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(ERROR_PAGE); + assertEquals(ERROR_PAGE, controller.processRequest(ACTION_KEY, mockedRequest)); + } + + + @Test + public void handleRequestTest() throws Exception { + actionMapping = new ActionMapping(); + action = new Action("report.run", CONTROLLER_CLASS, CONTROLLER_METHOD, JSP_NAME); + actionMapping.addAction(action); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(ERROR_PAGE); + ServletContext sc= Mockito.mock(ServletContext.class); + RequestDispatcher mockedRequestDispatcher = Mockito.mock(RequestDispatcher.class); + when(sc.getRequestDispatcher(Mockito.any(String.class))).thenReturn(mockedRequestDispatcher); + Mockito.doNothing().when(mockedRequestDispatcher).forward(Mockito.any(HttpServletRequest.class), Mockito.any(HttpServletResponse.class)); + controller.handleRequest(mockedRequest, mockResponse,sc); + } + + @Test + public void processRequestTest_WithIllegalAccess() throws Exception { + actionMapping = new ActionMapping(); + action = new Action(ACTION, PRIVATE_CONTROLLER_CLASS, "", JSP_NAME); + actionMapping.addAction(action); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(ERROR_PAGE); + assertEquals(ERROR_PAGE, controller.processRequest(ACTION_KEY, mockedRequest)); + } + + + @Test + public void processRequestTest_WithInvocationTargetException() throws Exception { + actionMapping = new ActionMapping(); + action = new Action(ACTION, CONTROLLER_CLASS, "throwInvocationTarget", JSP_NAME); + actionMapping.addAction(action); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(ERROR_PAGE); + assertEquals(ERROR_PAGE, controller.processRequest(ACTION_KEY, mockedRequest)); + } + + + @Test + public void processRequestTest_WithInstantiationException() throws Exception { + actionMapping = new ActionMapping(); + action = new Action(ACTION, ABSTRACT_CONTROLLER_CLASS, "throwInstantiation", JSP_NAME); + actionMapping.addAction(action); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(ERROR_PAGE); + assertEquals(ERROR_PAGE, controller.processRequest(ACTION_KEY, mockedRequest)); + } + + + + +}
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/DummyController.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/DummyController.java new file mode 100644 index 00000000..94ec5dc9 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/DummyController.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import java.lang.reflect.InvocationTargetException; + +import javax.servlet.http.HttpServletRequest; + +class DummyController{ + public String view(HttpServletRequest request, String jspName) { + return jspName; + } + public void throwInvocationTarget(HttpServletRequest request, String jspName) throws InvocationTargetException { + throw new InvocationTargetException(null, ""); + } +}
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ErrorHandlerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ErrorHandlerTest.java new file mode 100644 index 00000000..6c84ce12 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ErrorHandlerTest.java @@ -0,0 +1,191 @@ +package org.onap.portalsdk.analytics.controller; +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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============================================ + * + * + */ + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.model.definition.ReportDefinition; +import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class, AppUtils.class}) +public class ErrorHandlerTest { + + ErrorHandler errorHandler; + private String ERROR_MESSAGE = "testErrorMessage"; + private String TEST_PAGE = "testPage"; + private String TEST_ID = "testID"; + private String REPORT_NAME = "testReport"; + private String REPORT_SQL = "testReportSQL"; + private String LOG_VAR_IN_SESSION = "test"; + + @Before + public void setup() { + errorHandler = new ErrorHandler(); + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + + @Test + public void processErrorTest() { + when(mockedRequest.getAttribute(AppConstants.RI_ERROR_LIST)).thenReturn(null); + errorHandler.processError(mockedRequest, ERROR_MESSAGE); + } + + @Test + public void processErrorRaptorExceptionTest() { + when(mockedRequest.getAttribute(AppConstants.RI_ERROR_LIST)).thenReturn(null); + RaptorException re = new RaptorException(ERROR_MESSAGE); + errorHandler.processError(mockedRequest, re); + } + + @Test + public void processFatalErrorTest_WhenReportWrapperIsNotNull() throws Exception{ + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(TEST_PAGE); + assertEquals(TEST_PAGE, errorHandler.processFatalError(mockedRequest, rse)); + } + + @Test + public void processFatalErrorTest_WhenReportDefinitionIsNotNull() throws Exception{ + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportDefinition rd = PowerMockito.mock(ReportDefinition.class); + when(rd.getReportID()).thenReturn(TEST_ID); + when(rd.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rd); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPage()).thenReturn(TEST_PAGE); + assertEquals(TEST_PAGE, errorHandler.processFatalError(mockedRequest, rse)); + } + + @Test + public void processFatalErrorJSONTest_WhenReportWrapperIsNotNull() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + String jsonString = errorHandler.processFatalErrorJSON(mockedRequest, rse); + assertTrue(jsonString.contains(ERROR_MESSAGE)); + } + + @Test + public void processFatalErrorJSONTest_WhenReportDefinitionIsNotNull() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + HttpSession session = mockedRequest.getSession(); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportDefinition rd = PowerMockito.mock(ReportDefinition.class); + when(rd.getReportID()).thenReturn(TEST_ID); + when(rd.getReportName()).thenReturn(REPORT_NAME); + when(session.getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rd); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + String jsonString = errorHandler.processFatalErrorJSON(mockedRequest, rse); + assertTrue(jsonString.contains(ERROR_MESSAGE)); + } + + @Test + public void processFatalErrorWMenuTest_WhenReportWrapperIsNotNull() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + when(rr.getReportID()).thenReturn(TEST_ID); + when(rr.getReportName()).thenReturn(REPORT_NAME); + HttpSession session = mockedRequest.getSession(); + when(session.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPageWMenu()).thenReturn(TEST_PAGE); + assertEquals(TEST_PAGE, errorHandler.processFatalErrorWMenu(mockedRequest, rse)); + } + + @Test + public void processFatalErrorWMenuTest_WhenReportDefinitionIsNotNull() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + when(Globals.getLogVariablesInSession()).thenReturn(LOG_VAR_IN_SESSION); + ReportDefinition rd = PowerMockito.mock(ReportDefinition.class); + when(rd.getReportID()).thenReturn(TEST_ID); + when(rd.getReportName()).thenReturn(REPORT_NAME); + HttpSession session = mockedRequest.getSession(); + when(session.getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rd); + ReportSQLException rse = new ReportSQLException(ERROR_MESSAGE,REPORT_SQL); + PowerMockito.doNothing().when(AppUtils.class, "processErrorNotification", new Object[]{mockedRequest, rse}); + when(AppUtils.getErrorPageWMenu()).thenReturn(TEST_PAGE); + assertEquals(TEST_PAGE, errorHandler.processFatalErrorWMenu(mockedRequest, rse)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/PrivateDummyController.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/PrivateDummyController.java new file mode 100644 index 00000000..25e0b3d9 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/PrivateDummyController.java @@ -0,0 +1,42 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +public class PrivateDummyController { + private PrivateDummyController() {} +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceCrossTabTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceCrossTabTest.java new file mode 100644 index 00000000..8b836554 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceCrossTabTest.java @@ -0,0 +1,87 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class WizardSequenceCrossTabTest { + + WizardSequenceCrossTab wizardSequenceCrossTab; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getEnableReportLog()).thenReturn(true); + wizardSequenceCrossTab = new WizardSequenceCrossTab(true); + } + + @Test + public void testNotNull() { + assertNotNull(wizardSequenceCrossTab); + } + + @Test + public void testIndexValues() { + assertEquals(AppConstants.WS_DEFINITION,wizardSequenceCrossTab.get(0)); + assertEquals(AppConstants.WS_TABLES,wizardSequenceCrossTab.get(1)); + assertEquals(AppConstants.WS_COLUMNS, wizardSequenceCrossTab.get(2)); + assertEquals(AppConstants.WS_FORM_FIELDS, wizardSequenceCrossTab.get(3)); + assertEquals(AppConstants.WS_FILTERS, wizardSequenceCrossTab.get(4)); + assertEquals(AppConstants.WS_JAVASCRIPT, wizardSequenceCrossTab.get(5)); + assertEquals(AppConstants.WS_USER_ACCESS, wizardSequenceCrossTab.get(6)); + assertEquals(AppConstants.WS_REPORT_LOG, wizardSequenceCrossTab.get(7)); + assertEquals(AppConstants.WS_RUN, wizardSequenceCrossTab.get(8)); + } + + @Test + public void testSize() { + assertEquals(9,wizardSequenceCrossTab.size()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceDashboardTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceDashboardTest.java new file mode 100644 index 00000000..f733c154 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceDashboardTest.java @@ -0,0 +1,82 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class WizardSequenceDashboardTest { + + WizardSequenceDashboard wizardSequenceDashboard; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getEnableReportLog()).thenReturn(true); + wizardSequenceDashboard = new WizardSequenceDashboard(true); + } + + @Test + public void testNotNull() { + assertNotNull(wizardSequenceDashboard); + } + + @Test + public void testIndexValues() { + assertEquals(AppConstants.WS_DEFINITION, wizardSequenceDashboard.get(0)); + assertEquals(AppConstants.WS_USER_ACCESS, wizardSequenceDashboard.get(1)); + assertEquals(AppConstants.WS_REPORT_LOG, wizardSequenceDashboard.get(2)); + assertEquals(AppConstants.WS_RUN, wizardSequenceDashboard.get(3)); + } + + @Test + public void testSize() { + assertEquals(4, wizardSequenceDashboard.size()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceLinearTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceLinearTest.java new file mode 100644 index 00000000..b5ae1488 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceLinearTest.java @@ -0,0 +1,87 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class WizardSequenceLinearTest { + + WizardSequenceLinear wizardSequenceLinear; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getEnableReportLog()).thenReturn(true); + wizardSequenceLinear = new WizardSequenceLinear(true); + } + + @Test + public void testNotNull() { + assertNotNull(wizardSequenceLinear); + } + + @Test + public void testIndexValues() { + assertEquals(AppConstants.WS_DEFINITION,wizardSequenceLinear.get(0)); + assertEquals(AppConstants.WS_TABLES,wizardSequenceLinear.get(1)); + assertEquals(AppConstants.WS_COLUMNS, wizardSequenceLinear.get(2)); + assertEquals(AppConstants.WS_FORM_FIELDS, wizardSequenceLinear.get(3)); + assertEquals(AppConstants.WS_FILTERS, wizardSequenceLinear.get(4)); + assertEquals(AppConstants.WS_SORTING, wizardSequenceLinear.get(5)); + assertEquals(AppConstants.WS_USER_ACCESS, wizardSequenceLinear.get(6)); + assertEquals(AppConstants.WS_REPORT_LOG, wizardSequenceLinear.get(7)); + assertEquals(AppConstants.WS_RUN, wizardSequenceLinear.get(8)); + } + + @Test + public void testSize() { + assertEquals(9,wizardSequenceLinear.size()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedCrossTabTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedCrossTabTest.java new file mode 100644 index 00000000..d4ceaff1 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedCrossTabTest.java @@ -0,0 +1,86 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class WizardSequenceSQLBasedCrossTabTest { + + WizardSequenceSQLBasedCrossTab wizardSequenceSQLBasedCrossTab; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getEnableReportLog()).thenReturn(true); + wizardSequenceSQLBasedCrossTab = new WizardSequenceSQLBasedCrossTab(true); + } + + @Test + public void testNotNull() { + assertNotNull(wizardSequenceSQLBasedCrossTab); + } + + @Test + public void testIndexValues() { + assertEquals(AppConstants.WS_DEFINITION,wizardSequenceSQLBasedCrossTab.get(0)); + assertEquals(AppConstants.WS_SQL,wizardSequenceSQLBasedCrossTab.get(1)); + assertEquals(AppConstants.WS_COLUMNS, wizardSequenceSQLBasedCrossTab.get(2)); + assertEquals(AppConstants.WS_FORM_FIELDS, wizardSequenceSQLBasedCrossTab.get(3)); + assertEquals(AppConstants.WS_JAVASCRIPT, wizardSequenceSQLBasedCrossTab.get(4)); + assertEquals(AppConstants.WS_USER_ACCESS, wizardSequenceSQLBasedCrossTab.get(5)); + assertEquals(AppConstants.WS_REPORT_LOG, wizardSequenceSQLBasedCrossTab.get(6)); + assertEquals(AppConstants.WS_RUN, wizardSequenceSQLBasedCrossTab.get(7)); + } + + @Test + public void testSize() { + assertEquals(8,wizardSequenceSQLBasedCrossTab.size()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedHiveTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedHiveTest.java new file mode 100644 index 00000000..d64738a2 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedHiveTest.java @@ -0,0 +1,87 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class WizardSequenceSQLBasedHiveTest { + + WizardSequenceSQLBasedHive wizardSequenceSQLBasedHive; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getEnableReportLog()).thenReturn(true); + wizardSequenceSQLBasedHive = new WizardSequenceSQLBasedHive(true); + } + + @Test + public void testNotNull() { + assertNotNull(wizardSequenceSQLBasedHive); + } + + @Test + public void testIndexValues() { + assertEquals(AppConstants.WS_DEFINITION, wizardSequenceSQLBasedHive.get(0)); + assertEquals(AppConstants.WS_SQL, wizardSequenceSQLBasedHive.get(1)); + assertEquals(AppConstants.WS_COLUMNS, wizardSequenceSQLBasedHive.get(2)); + assertEquals(AppConstants.WS_FORM_FIELDS, wizardSequenceSQLBasedHive.get(3)); + assertEquals(AppConstants.WS_JAVASCRIPT, wizardSequenceSQLBasedHive.get(4)); + assertEquals(AppConstants.WS_CHART, wizardSequenceSQLBasedHive.get(5)); + assertEquals(AppConstants.WS_USER_ACCESS, wizardSequenceSQLBasedHive.get(6)); + assertEquals(AppConstants.WS_REPORT_LOG, wizardSequenceSQLBasedHive.get(7)); + assertEquals(AppConstants.WS_RUN, wizardSequenceSQLBasedHive.get(8)); + } + + @Test + public void testSize() { + assertEquals(9, wizardSequenceSQLBasedHive.size()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedLinearDataminingTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedLinearDataminingTest.java new file mode 100644 index 00000000..19c3e7e0 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedLinearDataminingTest.java @@ -0,0 +1,88 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class WizardSequenceSQLBasedLinearDataminingTest { + + WizardSequenceSQLBasedLinearDatamining wizardSequenceSQLBasedLinearDatamining; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getEnableReportLog()).thenReturn(true); + wizardSequenceSQLBasedLinearDatamining = new WizardSequenceSQLBasedLinearDatamining(true); + } + + @Test + public void testNotNull() { + assertNotNull(wizardSequenceSQLBasedLinearDatamining); + } + + @Test + public void testIndexValues() { + assertEquals(AppConstants.WS_DEFINITION, wizardSequenceSQLBasedLinearDatamining.get(0)); + assertEquals(AppConstants.WS_SQL, wizardSequenceSQLBasedLinearDatamining.get(1)); + assertEquals(AppConstants.WS_COLUMNS, wizardSequenceSQLBasedLinearDatamining.get(2)); + assertEquals(AppConstants.WS_FORM_FIELDS, wizardSequenceSQLBasedLinearDatamining.get(3)); + assertEquals(AppConstants.WS_DATA_FORECASTING, wizardSequenceSQLBasedLinearDatamining.get(4)); + assertEquals(AppConstants.WS_JAVASCRIPT, wizardSequenceSQLBasedLinearDatamining.get(5)); + assertEquals(AppConstants.WS_CHART, wizardSequenceSQLBasedLinearDatamining.get(6)); + assertEquals(AppConstants.WS_USER_ACCESS, wizardSequenceSQLBasedLinearDatamining.get(7)); + assertEquals(AppConstants.WS_REPORT_LOG, wizardSequenceSQLBasedLinearDatamining.get(8)); + assertEquals(AppConstants.WS_RUN, wizardSequenceSQLBasedLinearDatamining.get(9)); + } + + @Test + public void testSize() { + assertEquals(10, wizardSequenceSQLBasedLinearDatamining.size()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedLinearTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedLinearTest.java new file mode 100644 index 00000000..94d8e6b9 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceSQLBasedLinearTest.java @@ -0,0 +1,85 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class WizardSequenceSQLBasedLinearTest { + + WizardSequenceSQLBasedLinear wizardSequenceSQLBasedLinear; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getEnableReportLog()).thenReturn(true); + wizardSequenceSQLBasedLinear = new WizardSequenceSQLBasedLinear(true); + } + + @Test + public void testNotNull() { + assertNotNull(wizardSequenceSQLBasedLinear); + } + + @Test + public void testIndexValues() { + assertEquals(AppConstants.WS_DEFINITION,wizardSequenceSQLBasedLinear.get(0)); + assertEquals(AppConstants.WS_SQL,wizardSequenceSQLBasedLinear.get(1)); + assertEquals(AppConstants.WS_COLUMNS, wizardSequenceSQLBasedLinear.get(2)); + assertEquals(AppConstants.WS_FORM_FIELDS, wizardSequenceSQLBasedLinear.get(3)); + assertEquals(AppConstants.WS_USER_ACCESS, wizardSequenceSQLBasedLinear.get(4)); + assertEquals(AppConstants.WS_REPORT_LOG, wizardSequenceSQLBasedLinear.get(5)); + assertEquals(AppConstants.WS_RUN, wizardSequenceSQLBasedLinear.get(6)); + } + + @Test + public void testSize() { + assertEquals(7,wizardSequenceSQLBasedLinear.size()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceTest.java new file mode 100644 index 00000000..76842d05 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceTest.java @@ -0,0 +1,78 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.controller; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.util.AppConstants; + +public class WizardSequenceTest { + WizardSequence wizardSequence; + + @Before + public void init() { + wizardSequence = new WizardSequence(); + } + + @Test + public void testPerformActionWithWABackAction() { + wizardSequence.performAction(AppConstants.WA_BACK, null); + assertEquals(1, wizardSequence.getCurrentStepIndex()); + } + + @Test + public void testPerformActionWithWAAddAction() { + wizardSequence.performAction(AppConstants.WA_ADD, null); + assertEquals(AppConstants.WA_ADD, wizardSequence.getCurrentSubStep()); + } + + + @Test + public void testPerformActionWithWANextAction() { + wizardSequence.performAction(AppConstants.WA_NEXT, null); + assertEquals("", wizardSequence.getCurrentSubStep()); + } + + @Test + public void testPerformGoToStep() { + wizardSequence.performGoToStep(AppConstants.WS_DEFINITION); + assertEquals("", wizardSequence.getCurrentSubStep()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineCollectionTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineCollectionTest.java new file mode 100644 index 00000000..13b7fbfe --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineCollectionTest.java @@ -0,0 +1,141 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.gmap.line; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.List; +import java.util.Set; + +import org.junit.Before; +import org.junit.Test; + +public class LineCollectionTest { + + LineCollection lineCollection; + LineInfo lineInfo; + private String LINE_ID = "lineID"; + private String LINE_TYPE = "test"; + private String NODE1 = "nodeID1"; + private String NODE2 = "nodeID2"; + + @Before + public void init() throws Exception { + lineCollection = new LineCollection(); + lineInfo = new LineInfo(NODE1, NODE2); + lineInfo.setLineID(LINE_ID); + lineInfo.setLineType(LINE_TYPE); + lineCollection.addLine(lineInfo); + lineCollection.addSelectedLine(LINE_ID); + } + + @Test + public void testGetLineCollection() { + List<LineInfo> lineInfoList = lineCollection.getLineCollection(); + assertNotNull(lineInfoList); + assertEquals(1,lineCollection.getSize()); + } + + @Test + public void testGetSelectedLine() { + Set<String> selectedLine = lineCollection.getSelectedLine(); + assertNotNull(selectedLine); + } + + @Test + public void testContainsSelectedLine() { + assertEquals(true,lineCollection.containSelectedLine(LINE_ID)); + } + + @Test + public void testRemoveSelectedLine() { + lineCollection.removeSelectedLine(LINE_ID); + assertEquals(false,lineCollection.containSelectedLine(LINE_ID)); + } + + @Test + public void testClearAllCollection() { + lineCollection.addSelectedLine(LINE_ID); + lineCollection.clearAllCollection(); + assertEquals(false,lineCollection.containSelectedLine(LINE_ID)); + } + + @Test + public void testGetLineByLineID() { + LineInfo lineInfo = lineCollection.getLine(LINE_ID); + assertEquals("lineID", lineInfo.getLineID()); + } + + @Test + public void testGetLineByLineIDAndType() { + LineInfo lineInfo = lineCollection.getLine(LINE_ID,LINE_TYPE); + assertEquals("lineID", lineInfo.getLineID()); + assertEquals("test", lineInfo.getLineType()); + } + + @Test + public void testGetLineByNode() { + LineInfo lineInfo = lineCollection.getLine(NODE1,NODE2,true); + assertEquals("nodeID1", lineInfo.getNodeID1()); + assertEquals("nodeID2", lineInfo.getNodeID2()); + } + + @Test + public void testGetWildCardLine() { + String[] lineIDArr = lineCollection.getWildCardLine("li"); + assertEquals("lineID", lineIDArr[0]); + } + + @Test + public void testRemoveLineByLineID() { + LineInfo lineInfo = lineCollection.removeLine(LINE_ID); + LineInfo lineInfo1 = lineCollection.getLine(lineInfo.getLineID()); + lineCollection.addLine(lineInfo1); + assertNull(lineInfo1); + } + + @Test + public void testRemoveLineByLineIDAndType() { + LineInfo lineInfo = lineCollection.removeLine(LINE_ID,LINE_TYPE); + LineInfo lineInfo1 = lineCollection.getLine(lineInfo.getLineID()); + assertNull(lineInfo1); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineInfoTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineInfoTest.java new file mode 100644 index 00000000..5ff6e78b --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineInfoTest.java @@ -0,0 +1,117 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.gmap.line; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +public class LineInfoTest { + + LineInfo lineInfo; + + private String NODE_ID1 = "nodeID1"; + private String NODE_ID2 = "nodeID2"; + private String LINE_ID = "lineID"; + private String LINE_TYPE = "lineType"; + private String LINE_DESCRIPTION = "lineDescription"; + private boolean MOVEABLE = true; + private boolean DELETEABLE = true; + private int STATE = 1; + + @Before + public void init() { + lineInfo = new LineInfo(NODE_ID1, NODE_ID2); + lineInfo.setNodeID1(NODE_ID1); + lineInfo.setNodeID2(NODE_ID2); + lineInfo.setLineID(LINE_ID); + lineInfo.setLineType(LINE_TYPE); + lineInfo.setDescription(LINE_DESCRIPTION); + lineInfo.setMoveable(MOVEABLE); + lineInfo.setDeleteable(DELETEABLE); + lineInfo.setState(STATE); + Map<String, String> lineAttributes = new HashMap<>(); + lineAttributes.put("x_length", "200cm"); + lineInfo.initializeAttributes(lineAttributes); + lineInfo.setAttribute("x_length", "300cm"); + } + + @Test + public void testNotNull() { + assertNotNull(lineInfo); + } + + @Test + public void testLineInfoProperties() { + assertEquals(NODE_ID1, lineInfo.getNodeID1()); + assertEquals(NODE_ID2, lineInfo.getNodeID2()); + assertEquals(LINE_ID, lineInfo.getLineID()); + assertEquals(LINE_TYPE, lineInfo.getLineType()); + assertEquals(LINE_DESCRIPTION, lineInfo.getDescription()); + assertEquals(MOVEABLE, lineInfo.isMoveable()); + assertEquals(DELETEABLE, lineInfo.isDeleteable()); + assertEquals(STATE, lineInfo.getState()); + assertEquals("300cm", lineInfo.getAttribute("x_length")); + } + + @Test + public void testClone() { + LineInfo lineInfo2 = lineInfo.clone(); + assertEquals(NODE_ID1, lineInfo2.getNodeID1()); + assertEquals(NODE_ID2, lineInfo2.getNodeID2()); + assertEquals(LINE_ID, lineInfo2.getLineID()); + assertEquals(LINE_TYPE, lineInfo2.getLineType()); + assertEquals(LINE_DESCRIPTION, lineInfo2.getDescription()); + assertEquals(MOVEABLE, lineInfo2.isMoveable()); + assertEquals(DELETEABLE, lineInfo2.isDeleteable()); + assertEquals(STATE, lineInfo2.getState()); + } + + @Test + public void getAttributeInternalKeys() { + List<String> list = lineInfo.getAttributeInternalKeys(); + assertEquals("length", list.get(0)); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineTest.java index c3ea5ead..dc4171ce 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/line/LineTest.java @@ -37,23 +37,55 @@ */ package org.onap.portalsdk.analytics.gmap.line; +import static org.junit.Assert.assertNotNull; + +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.onap.portalsdk.analytics.gmap.map.NovaMap; - +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.test.util.ReflectionTestUtils; +@RunWith(PowerMockRunner.class) +@PrepareForTest({Line.class}) public class LineTest { + Line line; + Point2D screenPoint; + private String LINE_ID = "lineID"; + private String LINE_TYPE = "test"; + private String NODE1 = "nodeID1"; + private String NODE2 = "nodeID2"; - public Line mockLineTest() - { + @Before + public void init() throws Exception{ NovaMap novaMap= new NovaMap(); novaMap.setDataLoaded("dataLoaded"); - Line line = new Line(novaMap); - return line; + ReflectionTestUtils.setField(novaMap, "transform", new AffineTransform()); + LineCollection lineCollection = Mockito.mock(LineCollection.class); + ArrayList<LineInfo> list = new ArrayList<LineInfo>(); + LineInfo lineInfo = new LineInfo(NODE1, NODE2); + lineInfo.setLineID(LINE_ID); + lineInfo.setLineType(LINE_TYPE); + lineCollection.addLine(lineInfo); + lineCollection.addSelectedLine(LINE_ID); + list.add(lineInfo); + PowerMockito.whenNew(LineCollection.class).withNoArguments().thenReturn(lineCollection); + Mockito.when(lineCollection.getLineCollection()).thenReturn(list); + screenPoint = Mockito.mock(Point2D.class); + line = new Line(novaMap); } @Test - public void lineExistTest() - { - Line line = mockLineTest(); + public void lineExistTest(){ + assertNotNull(line); + line.lineExist(screenPoint); } } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/ColorPropertiesTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/ColorPropertiesTest.java new file mode 100644 index 00000000..07d9a926 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/ColorPropertiesTest.java @@ -0,0 +1,93 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.gmap.map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.awt.Color; + +import org.junit.Before; +import org.junit.Test; + +public class ColorPropertiesTest { + + ColorProperties colorProperties; + private String TYPE = "type"; + private String COLOR = "10,10,10"; + private String SHAPE = "circle"; + private String SIZE = "100"; + private int NUMBER = 1; + + @Before + public void init() { + NovaMap map = new NovaMap(); + colorProperties = new ColorProperties(map); + colorProperties.setColor(TYPE, COLOR); + colorProperties.setShape(TYPE, SHAPE); + colorProperties.setSize(TYPE, SIZE); + colorProperties.setShape(TYPE, NUMBER, SHAPE); + } + + @Test + public void testNotNull() { + assertNotNull(colorProperties); + } + + @Test + public void testGetColor() { + Color color1 = new Color(10,10,10); + Color color2 = colorProperties.getColor(TYPE); + assertEquals(true, color1.equals(color2)); + } + + @Test + public void testGetShape() { + assertEquals(SHAPE, colorProperties.getShape(TYPE)); + } + + @Test + public void testGetShapeWithNumber() { + assertEquals(SHAPE, colorProperties.getShape(TYPE, NUMBER)); + } + + @Test + public void testGetSize() { + assertEquals(100, colorProperties.getSize(TYPE)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/NovaMapTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/NovaMapTest.java new file mode 100644 index 00000000..7be34b74 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/NovaMapTest.java @@ -0,0 +1,148 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.gmap.map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.awt.Rectangle; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.util.HashSet; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.gmap.line.Line; +import org.onap.portalsdk.analytics.gmap.map.layer.SwingLayer; +import org.onap.portalsdk.analytics.gmap.node.Node; +import org.springframework.test.util.ReflectionTestUtils; + +public class NovaMapTest { + + NovaMap novaMap; + private SwingLayer swingLayer; + + @Before + public void init() { + novaMap = new NovaMap(); + swingLayer = new SwingLayer(novaMap); + novaMap.setBoundingBox(10, 10); + novaMap.setNode(new Node(novaMap)); + novaMap.setLine(new Line(novaMap)); + novaMap.setColorProperties(new ColorProperties(novaMap)); + novaMap.setZoomLevel(10); + novaMap.addShowList("test-1"); + novaMap.addShowList("test-2", 10); + novaMap.addSwingLayer(swingLayer); + novaMap.setCurrentYearMonth("2018/05"); + novaMap.setDefaultBoundary(new Rectangle2D.Double()); + novaMap.setShowLegend(true); + ReflectionTestUtils.setField(novaMap, "transform", new AffineTransform()); + } + + + @Test + public void testNotNull() { + assertNotNull(novaMap); + } + + @Test + public void testNovaMapProperties() { + assertEquals(Rectangle.class, novaMap.getBoundingBox().getClass()); + assertEquals(Node.class, novaMap.getNode().getClass()); + assertEquals(Line.class, novaMap.getLine().getClass()); + assertEquals(ColorProperties.class, novaMap.getColorProperties().getClass()); + assertEquals(10, novaMap.getZoomLevel()); + assertEquals(HashSet.class, novaMap.getShowList().getClass()); + assertEquals(SwingLayer.class, novaMap.getSwingLayers().get(0).getClass()); + assertEquals("2018/05", novaMap.getCurrentYearMonth()); + assertNotNull(novaMap.getDefaultBoundary()); + assertTrue(novaMap.isShowLegend()); + assertEquals(2, novaMap.getShowListSize()); + assertTrue(novaMap.containsShowList("test-1")); + assertTrue(novaMap.containsShowList("test-2", 10)); + novaMap.removeShowList("test-1"); + novaMap.removeShowList("test-2", 10); + novaMap.clearShowList(); + assertEquals(0, novaMap.getShowListSize()); + novaMap.removeSwingLayer(swingLayer); + novaMap.clearSwingLayers(); + assertNotEquals(null, novaMap.getTransform()); + } + + @Test + public void testGetBestZoomLevel() { + novaMap.getBestZoomLevel(13.13d, 28.28d, 23.13d, 38.28d, 10d, 10d); + } + + @Test + public void testGetPixelPos() { + novaMap.getPixelPos(13.13d, 28.28d); + } + + @Test + public void testGetLonLatFromPixel() { + novaMap.getLonLatFromPixel(10, 20); + } + + @Test + public void testGetImage() { + HttpServletRequest reuqest = Mockito.mock(HttpServletRequest.class); + novaMap.getImage(reuqest, new Rectangle2D.Double()); + } + + @Test + public void testSingleLeftClick() { + novaMap.singleLeftClick(13.13d, 10.10d, new Rectangle2D.Double()); + } + + @Test(expected=NullPointerException.class) + public void testSingleLeftClick_WhenTransFormIsNull() { + ReflectionTestUtils.setField(novaMap, "transform", null); + Rectangle2D.Double rd =new Rectangle2D.Double(); + rd.setRect(10d, 10d, 10d, 10d); + novaMap.singleLeftClick(13.13d, 10.10d, new Rectangle2D.Double()); + } + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayerTest.java new file mode 100644 index 00000000..e52d01b6 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayerTest.java @@ -0,0 +1,112 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.gmap.map.layer; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.gmap.line.Line; +import org.onap.portalsdk.analytics.gmap.map.ColorProperties; +import org.onap.portalsdk.analytics.gmap.map.NovaMap; +import org.onap.portalsdk.analytics.gmap.node.Node; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.springframework.test.util.ReflectionTestUtils; + +public class SwingLayerTest { + + SwingLayer swingLayer; + NovaMap novaMap; + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + Graphics2D g2d; + Graphics2D g2Legend; + + @Before + public void init() { + novaMap = new NovaMap(); + swingLayer = new SwingLayer(novaMap); + novaMap.setBoundingBox(10, 10); + novaMap.setNode(new Node(novaMap)); + novaMap.setLine(new Line(novaMap)); + novaMap.setColorProperties(new ColorProperties(novaMap)); + novaMap.setZoomLevel(10); + novaMap.addShowList("test-1"); + novaMap.addShowList("test-2", 10); + novaMap.addSwingLayer(swingLayer); + novaMap.setCurrentYearMonth("2018/05"); + novaMap.setDefaultBoundary(new Rectangle2D.Double()); + novaMap.setShowLegend(true); + ReflectionTestUtils.setField(novaMap, "transform", new AffineTransform()); + Node nodeObj = new Node(new NovaMap()); + nodeObj.addNode(13.13d, 10.10d, "nodeType", "nodeID", "type=domestic|year=2016", 13, true, true); + nodeObj.addNode(13.14d, 10.11d, "nodeType", "nodeID", "type=international|year=2017", 13, true, true); + nodeObj.addNode(13.15d, 10.12d, "nodeType", "nodeID", "type=local|year=2018", 13, true, true); + novaMap.setNode(nodeObj); + swingLayer = new SwingLayer(novaMap); + BufferedImage image = new BufferedImage(novaMap.getBoundingBox().width, novaMap.getBoundingBox().height, BufferedImage.TYPE_INT_ARGB); + g2d = image.createGraphics(); + BufferedImage legendImage = new BufferedImage(novaMap.getBoundingBox().width, (int) (20 * novaMap.getShowListSize()) + 20, + BufferedImage.TYPE_INT_ARGB); + g2Legend = legendImage.createGraphics(); + g2Legend.setBackground(Color.WHITE); + } + + @Test + public void teestPaintLayer_WhenID1NotEqualToID2() { + Mockito.when(mockedRequest.getAttribute("server_process_id")).thenReturn("1"); + Mockito.when(mockedRequest.getSession().getAttribute("server_process_id")).thenReturn("2"); + swingLayer.paintLayer(mockedRequest, g2d, novaMap.getBoundingBox(), new Rectangle2D.Double(), g2Legend); + } + + @Test + public void teestPaintLayer_WhenID1EqualToID2() { + Mockito.when(mockedRequest.getAttribute("server_process_id")).thenReturn("1"); + Mockito.when(mockedRequest.getSession().getAttribute("server_process_id")).thenReturn("1"); + Rectangle2D rd = new Rectangle2D.Double(); + rd.setFrame(14064d, 12366d, 10d, 10d); + swingLayer.paintLayer(mockedRequest, g2d, novaMap.getBoundingBox(), rd, g2Legend); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeCollectionTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeCollectionTest.java new file mode 100644 index 00000000..1bd35c37 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeCollectionTest.java @@ -0,0 +1,122 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.gmap.node; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class NodeCollectionTest { + + NodeCollection nodeCollection; + private String NODE_ID = "nodeID"; + private String NODE_TYPE = "nodeType"; + + @Before + public void init() { + nodeCollection = new NodeCollection(); + NodeInfo nodeInfo = new NodeInfo(NODE_ID); + nodeInfo.setNodeType(NODE_TYPE); + nodeCollection.setNodeID(NODE_ID); + nodeCollection.addNode(nodeInfo); + nodeCollection.addSelectedNode(NODE_ID); + nodeCollection.addSelectedNode(NODE_ID, NODE_TYPE); + } + + @Test + public void testNotNull() { + assertNotNull(nodeCollection); + } + + @Test + public void testGetNode() { + NodeInfo nodeInfo = nodeCollection.getNode(NODE_ID+NODE_TYPE); + assertEquals(NODE_TYPE, nodeInfo.getNodeType()); + assertEquals(NODE_ID, nodeInfo.getNodeID()); + } + + @Test + public void testContainSelectedNodeByNodeID() { + assertEquals(true, nodeCollection.containSelectedNode(NODE_ID)); + } + + @Test + public void testContainSelectedNodeByNodeIDAndType() { + assertEquals(true, nodeCollection.containSelectedNode(NODE_ID, NODE_TYPE)); + } + + @Test + public void testRemoveSelectedNodeByNodeID() { + nodeCollection.removeSelectedNode(NODE_ID); + assertEquals(false, nodeCollection.containSelectedNode(NODE_ID)); + } + + @Test + public void testRemoveSelectedNodeByNodeIDAndNodeType() { + nodeCollection.removeSelectedNode(NODE_ID, NODE_TYPE); + assertEquals(false, nodeCollection.containSelectedNode(NODE_ID, NODE_TYPE)); + } + + @Test + public void testGetNodeID() { + assertEquals(NODE_ID, nodeCollection.getNodeID()); + } + + @Test + public void testGetSelectedNode() { + assertEquals(2, nodeCollection.getSelectedNode().size()); + } + + @Test + public void testClearNode() { + nodeCollection.clearNode(); + } + + @Test + public void testClearAllCollection() { + nodeCollection.clearAllCollection(); + } + + @Test + public void testGetSize() { + nodeCollection.clearAllCollection(); + assertEquals(0, nodeCollection.getSize()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeInfoTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeInfoTest.java new file mode 100644 index 00000000..bdc66784 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeInfoTest.java @@ -0,0 +1,130 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.gmap.node; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +public class NodeInfoTest { + + NodeInfo nodeInfo; + + private String NODE_ID = "nodeID"; + private String NODE_TYPE = "nodeType"; + private boolean MOVEABLE = true; + private boolean DELETEABLE = true; + private int STATE = 1; + + @Before + public void init() { + nodeInfo = new NodeInfo(NODE_ID); + nodeInfo.setNodeID(NODE_ID); + nodeInfo.setNodeType(NODE_TYPE); + nodeInfo.setMoveable(MOVEABLE); + nodeInfo.setDeleteable(DELETEABLE); + nodeInfo.setState(STATE); + List<String> lineIDs = new ArrayList<>(); + lineIDs.add("test"); + nodeInfo.setLineIDS(lineIDs); + } + + @Test + public void testNotNull() { + assertNotNull(nodeInfo); + } + + @Test + public void testNodeInfoProperties() { + assertEquals(NODE_ID, nodeInfo.getNodeID()); + assertEquals(NODE_TYPE, nodeInfo.getNodeType()); + assertEquals(MOVEABLE, nodeInfo.isMoveable()); + assertEquals(DELETEABLE, nodeInfo.isDeleteable()); + assertEquals(STATE, nodeInfo.getState()); + } + + @Test + public void testAddLineID() { + nodeInfo.addLineID("test", "test"); + assertEquals("test>>test", nodeInfo.getLineID("test", "test")); + } + + @Test + public void testremoveLineID() { + nodeInfo.removeLineID("test", "test"); + assertEquals(null, nodeInfo.getLineID("test", "test")); + } + + @Test + public void testGetLineIDS() { + nodeInfo.getLineIDS(); + assertEquals("test", nodeInfo.getLineIDS().get(0)); + } + + @Test + public void testPrintLineIDS() { + nodeInfo.printLineIDS(); + } + + @Test + public void testCloneLineIDS() { + assertEquals("test",nodeInfo.cloneLineIDS().get(0)); + } + + @Test + public void testInitializeAttributes() { + Map<String,String >nodeAttributes = new HashMap<>(); + nodeAttributes.put("test", "test"); + nodeInfo.initializeAttributes(nodeAttributes); + assertEquals("test",nodeInfo.getAttribute("test")); + assertEquals("test",nodeInfo.getAttributeKeys().get(0)); + } + + @Test + public void testClone() { + assertEquals("test",nodeInfo.clone().cloneLineIDS().get(0)); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeTest.java index 1f7b710e..a6cd2933 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/node/NodeTest.java @@ -1,5 +1,5 @@ /* - * ============LICENxSE_START========================================== + * ============LICENSE_START========================================== * ONAP Portal SDK * =================================================================== * Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -40,13 +40,18 @@ package org.onap.portalsdk.analytics.gmap.node; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.awt.Point; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.junit.Test; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.gmap.map.ColorProperties; import org.onap.portalsdk.analytics.gmap.map.NovaMap; import org.onap.portalsdk.analytics.gmap.node.Node; +import org.springframework.test.util.ReflectionTestUtils; public class NodeTest { @@ -158,8 +163,12 @@ public class NodeTest { @Test public void testNodeExist() { - Node nodeObj = new Node(new NovaMap()); - + NovaMap novaMap = new NovaMap(); + novaMap.addShowList("nodeType"); + novaMap.addShowList("nodeType"); + novaMap.setColorProperties(new ColorProperties(novaMap)); + ReflectionTestUtils.setField(novaMap, "transform", new AffineTransform()); + Node nodeObj = new Node(novaMap); nodeObj.addNode(13.13d, 10.10d, "nodeType", "nodeID", "type=domestic|year=2016", 13, true, true); nodeObj.addNode(13.14d, 10.11d, "nodeType", "nodeID", "type=international|year=2017", 13, true, true); nodeObj.addNode(13.15d, 10.12d, "nodeType", "nodeID", "type=local|year=2018", 13, true, true); diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/DataCacheTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/DataCacheTest.java new file mode 100644 index 00000000..a9b1bac2 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/DataCacheTest.java @@ -0,0 +1,328 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model; + +import java.util.Vector; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.model.pdf.PdfReportHandler; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.DbUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.DataSet; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ Globals.class, DbUtils.class, AppUtils.class }) +public class DataCacheTest { + @InjectMocks + DataCache dataCache = new DataCache(); + + @Before + public void init() throws Exception { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + @Mock + DataSet ds; + + @SuppressWarnings("static-access") + @Test + public void getDataViewActionsTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheDataViewActions()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery("test")).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(1, 0)).thenReturn("test"); + dataCache.getDataViewActions(); + } + + @SuppressWarnings("static-access") + @Test + public void getPublicReportIdNamesTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getThePublicReportIdNames()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery("test")).thenReturn(ds); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getPublicReportIdNames(); + } + + @SuppressWarnings("static-access") + @Test + public void getPublicReportIdNamesTest1() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getThePublicReportIdNames()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery("test")).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getPublicReportIdNames(); + } + + @SuppressWarnings("static-access") + @Test + public void getPrivateAccessibleReportIdNamesTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getThePrivateAccessibleNamesA()).thenReturn("test"); + Mockito.when(Globals.getThePrivateAccessibleNamesB()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + dataCache.getPrivateAccessibleReportIdNames("test12", vc); + } + + @SuppressWarnings("static-access") + @Test + public void getPrivateAccessibleReportIdNamesTest1() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getThePrivateAccessibleNamesA()).thenReturn("test"); + Mockito.when(Globals.getThePrivateAccessibleNamesB()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + dataCache.getPrivateAccessibleReportIdNames("test12", vc); + } + + @SuppressWarnings("static-access") + @Test + public void getGroupAccessibleReportIdNamesTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheGroupAccessibleNamesA()).thenReturn("test"); + Mockito.when(Globals.getTheGroupAccessibleNamesB()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + dataCache.getGroupAccessibleReportIdNames("test12", vc); + } + + @SuppressWarnings("static-access") + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void getTableSourceTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.grabTheReportTableA()).thenReturn("tablename"); + Mockito.when(Globals.grabTheReportTableIf()).thenReturn("reporttable"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(true); + Mockito.when(Globals.grabTheReportTableB()).thenReturn("tableB"); + dataCache.getTableSource("tableName", "dBinfo", vc, "test12", mockedRequest); + } + + @SuppressWarnings("static-access") + @Test + public void getTableSourceTest1() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.grabTheReportTableA()).thenReturn("tablename"); + Mockito.when(Globals.grabTheReportTableIf()).thenReturn("reporttable"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false); + Mockito.when(Globals.grabTheReportTableB()).thenReturn("tableB"); + Mockito.when(Globals.grabTheReportTableC()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getTableSource("tableName", "dBinfo", vc, "test12", mockedRequest); + } + + @SuppressWarnings("static-access") + @Test + public void getTableSourceTest2() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.grabTheReportTableA()).thenReturn("tablename"); + Mockito.when(Globals.grabTheReportTableIf()).thenReturn("reporttable"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false); + Mockito.when(Globals.grabTheReportTableB()).thenReturn("tableB"); + Mockito.when(Globals.grabTheReportTableC()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Mockito.when(Globals.grabTheReportTableElse()).thenReturn("abcd"); + dataCache.getTableSource("tableName", "local", vc, "test12", mockedRequest); + } + + @SuppressWarnings("static-access") + @Test + public void getTableSourceTest3() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(false); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.grabTheReportTableA()).thenReturn("tablename"); + Mockito.when(Globals.grabTheReportTableIf()).thenReturn("reporttable"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false); + Mockito.when(Globals.grabTheReportTableB()).thenReturn("tableB"); + Mockito.when(Globals.grabTheReportTableC()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Mockito.when(Globals.grabTheReportTableElse()).thenReturn("abcd"); + dataCache.getTableSource("tableName", "local", vc, "test12", mockedRequest); + } + + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getReportTableJoins(); + } + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest1() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(0); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getReportTableJoins(); + } + + + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest2() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(0); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(false); + dataCache.getReportTableJoins(vc); + } + + + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest3() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(0); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Mockito.when(Globals.getTheReportTableJoins()).thenReturn("test"); + dataCache.getReportTableJoins(vc); + } + + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest4() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Mockito.when(Globals.getTheReportTableJoins()).thenReturn("test"); + dataCache.getReportTableJoins(vc); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java index 6a21dd10..77950ae7 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java @@ -36,11 +36,8 @@ * */ - package org.onap.portalsdk.analytics.model; - - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -52,6 +49,7 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -83,7 +81,10 @@ import org.onap.portalsdk.analytics.view.DataRow; import org.onap.portalsdk.analytics.view.DataValue; import org.onap.portalsdk.analytics.view.ReportColumnHeaderRows; import org.onap.portalsdk.analytics.view.ReportData; +import org.onap.portalsdk.analytics.view.ReportDataRows; import org.onap.portalsdk.analytics.view.ReportRowHeaderCols; +import org.onap.portalsdk.analytics.view.RowHeader; +import org.onap.portalsdk.analytics.view.RowHeaderCol; import org.onap.portalsdk.analytics.xmlobj.DataColumnList; import org.onap.portalsdk.analytics.xmlobj.DataColumnType; import org.onap.portalsdk.analytics.xmlobj.DataSourceList; @@ -98,43 +99,43 @@ import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; - @RunWith(PowerMockRunner.class) -@PrepareForTest({Globals.class, DbUtils.class, ESAPI.class, IAppUtils.class, AppUtils.class, ConnectionUtils.class}) +@PrepareForTest({ Globals.class, DbUtils.class, ESAPI.class, IAppUtils.class, AppUtils.class, ConnectionUtils.class, + ReportLoader.class, HashMap.class }) public class ReportHandlerTest { private ReportHandler reportHandler; - + @Mock HttpServletRequest httpServletRequest; @Mock HttpServletResponse httpServletResponse; - + @Mock ServletOutputStream servletOutputStream; - + @Mock ServletContext servletContext; - + @Mock HttpSession httpSession; @Mock AppUtils appUtils; - + @Mock ReportRuntime reportRuntime; - + @Mock ReportDefinition reportDefinition; @Mock WizardSequence wizardSequence; - + @Mock Encoder encoder; - + @Mock IAppUtils iAppUtils; @@ -143,92 +144,74 @@ public class ReportHandlerTest { @Mock FileOutputStream fileOutputStream; - + @Mock PrintWriter printWriter; - + @Mock DataSourceList dataSourceList; - - @Mock + + @Mock ReportRowHeaderCols reportRowHeaderCols; - + @Mock ReportColumnHeaderRows reportColumnHeaderRows; - + @Mock + ReportDataRows reportDataRows; + @Mock Writer iowriter; - + @Mock File file; @Mock Connection connection; - + @Mock Statement statement; - + @Mock ResultSet resultSet; - + @Mock ResultSetMetaData resultSetMetaData; private String REPORT_ID = "1000"; - + @Before - public void setUp() throws Exception { - + public void setUp() throws Exception { + PowerMockito.mockStatic(DbUtils.class); PowerMockito.mockStatic(Globals.class); PowerMockito.mockStatic(IAppUtils.class); PowerMockito.mockStatic(ESAPI.class); PowerMockito.mockStatic(AppUtils.class); PowerMockito.mockStatic(ConnectionUtils.class); - + PowerMockito.whenNew(File.class).withAnyArguments().thenReturn(file); - Mockito.when(file.createNewFile()).thenReturn(true); - - PowerMockito.whenNew(FileInputStream.class).withArguments(Matchers.anyString()).thenReturn(fileInputStream); - PowerMockito.whenNew(FileOutputStream.class).withArguments(Matchers.anyString()).thenReturn(fileOutputStream); + Mockito.when(file.createNewFile()).thenReturn(true); - /* - PowerMockito.whenNew(FileOutputStream.class).withArguments(Matchers.anyString()).thenAnswer( - - new Answer<FileOutputStream>() { - - @Override - public FileOutputStream answer(InvocationOnMock invocation) throws Throwable { - Object[] args = invocation.getArguments(); - String string = (String)args[0]; - - System.out.println("------------------------------ callled -------------------------=============>>>>>>>>>>>>>>>> " + string); - - return fileOutputStream; - } - - - } - ); - */ + PowerMockito.whenNew(FileInputStream.class).withArguments(Matchers.anyString()).thenReturn(fileInputStream); + PowerMockito.whenNew(FileOutputStream.class).withArguments(Matchers.anyString()).thenReturn(fileOutputStream); Mockito.when(httpServletRequest.getSession()).thenReturn(httpSession); Mockito.when(httpSession.getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition); Mockito.when(httpSession.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(reportRuntime); - + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); - + PowerMockito.when(ESAPI.encoder()).thenReturn(encoder); PowerMockito.when(Globals.getAppUtils()).thenReturn(iAppUtils); - + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); - - //Mockito.when(appUtils.getUserID(httpServletRequest)).thenReturn("USER1"); + + // Mockito.when(appUtils.getUserID(httpServletRequest)).thenReturn("USER1"); reportHandler = Mockito.spy(ReportHandler.class); } - + @Test public void testSaveAsExcelFile_case1() { String saveOutput = ""; @@ -236,7 +219,7 @@ public class ReportHandlerTest { DataSourceList dataSourceList = new DataSourceList(); reportData.setReportDataList(prepareDataRowList()); - + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true); @@ -246,19 +229,19 @@ public class ReportHandlerTest { PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); - ArrayList <IdNameValue> paramList = null; + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); paramList.add(new IdNameValue("Status", "Active")); - + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); - + String para = ""; - - int i=1; - while(i<20) { - para = para + "<p>This is a paragraph.</p>" + "\n" + "<p>This is another paragraph.</p>" + "\n"; + + int i = 1; + while (i < 20) { + para = para + "<p>This is a paragraph.</p>" + "\n" + "<p>This is another paragraph.</p>" + "\n"; i++; } @@ -270,42 +253,27 @@ public class ReportHandlerTest { Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); - //ReflectionTestUtils.setField(reportData, "reportRowHeaderCols", reportRowHeaderCols); saveOutput = reportHandler.saveAsExcelFile(httpServletRequest, reportData, null, "Report 1", "Report 1 Desc"); - //Assert.assertNotNull(saveOutput); - Mockito.verify(reportHandler, Mockito.times(1)).saveAsExcelFile(httpServletRequest, reportData, null, "Report 1", "Report 1 Desc"); + Mockito.verify(reportHandler, Mockito.times(1)).saveAsExcelFile(httpServletRequest, reportData, null, + "Report 1", "Report 1 Desc"); } - - - - - @Test public void testSaveAsExcelFile_case2() throws Exception { String saveOutput = ""; ReportData reportData = prepareReportData(); DataSourceList dataSourceList = new DataSourceList(); - List<DataSourceType> listDataSourceType = dataSourceList.getDataSource(); - DataSourceType dataSourceType1 = new DataSourceType(); - DataColumnList dataColumnList1 = new DataColumnList(); - List<DataColumnType> listDataColumnType1 = dataColumnList1.getDataColumn(); - + List<DataColumnType> listDataColumnType1 = dataColumnList1.getDataColumn(); DataColumnType dataColumnType1 = new DataColumnType(); dataColumnType1.setSemaphoreId("Id1"); listDataColumnType1.add(dataColumnType1); - dataSourceType1.setDataColumnList(dataColumnList1); - listDataSourceType.add(dataSourceType1); - - reportData.setReportDataList(prepareDataRowList()); - PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true); @@ -315,19 +283,19 @@ public class ReportHandlerTest { PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); - ArrayList <IdNameValue> paramList = null; + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); paramList.add(new IdNameValue("Status", "Active")); - + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); - + String para = ""; - - int i=1; - while(i<20) { - para = para + "<p>This is a paragraph.</p>" + "\n" + "<p>This is another paragraph.</p>" + "\n"; + + int i = 1; + while (i < 20) { + para = para + "<p>This is a paragraph.</p>" + "\n" + "<p>This is another paragraph.</p>" + "\n"; i++; } @@ -339,23 +307,21 @@ public class ReportHandlerTest { Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); - //ReflectionTestUtils.setField(reportData, "reportRowHeaderCols", reportRowHeaderCols); - - SemaphoreList semaphoreList = new SemaphoreList(); + SemaphoreList semaphoreList = new SemaphoreList(); List<SemaphoreType> listSemaphoreType = semaphoreList.getSemaphore(); - + SemaphoreType st1 = new SemaphoreType(); SemaphoreType st2 = new SemaphoreType(); FormatList formatList = new FormatList(); - + List<FormatType> listFormatType = formatList.getFormat(); - + FormatType formatType1 = new FormatType(); FormatType formatType2 = new FormatType(); - + listFormatType.add(formatType1); - + formatType2.setBgColor("blue"); formatType2.setFontColor("black"); formatType2.setBold(true); @@ -365,101 +331,80 @@ public class ReportHandlerTest { formatType2.setUnderline(true); formatType2.setUnderline(true); formatType2.setFontSize("20"); - + listFormatType.add(formatType2); - - + st1.setSemaphoreName("Name1"); - st1.setSemaphoreId("Id1"); - - st1.setFormatList(formatList); - + st1.setSemaphoreId("Id1"); + + st1.setFormatList(formatList); + st2.setSemaphoreName("Name2"); - st2.setSemaphoreId("Id2"); - - st2.setFormatList(formatList); - listSemaphoreType.add(st1); - listSemaphoreType.add(st2); - - mockHttpAttribute(AppConstants.RI_REPORT_ID, REPORT_ID); - + st2.setSemaphoreId("Id2"); + + st2.setFormatList(formatList); + listSemaphoreType.add(st1); + listSemaphoreType.add(st2); + + mockHttpAttribute(AppConstants.RI_REPORT_ID, REPORT_ID); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); Mockito.when(reportRuntime.getSemaphoreList()).thenReturn(semaphoreList); Mockito.when(reportDefinition.addSemaphore(Mockito.anyObject(), Mockito.anyObject())).thenReturn(st1); - - - + saveOutput = reportHandler.saveAsExcelFile(httpServletRequest, reportData, null, "Report 1", "Report 1 Desc"); - //Assert.assertNotNull(saveOutput); - Mockito.verify(reportHandler, Mockito.times(1)).saveAsExcelFile(httpServletRequest, reportData, null, "Report 1", "Report 1 Desc"); + Mockito.verify(reportHandler, Mockito.times(1)).saveAsExcelFile(httpServletRequest, reportData, null, + "Report 1", "Report 1 Desc"); } - - + private ArrayList<DataRow> prepareDataRowList() { + ArrayList<DataRow> alDataRow = new ArrayList<DataRow>(); - - - - - - - - - - - - - - - private ArrayList<DataRow> prepareDataRowList(){ - ArrayList <DataRow> alDataRow = new ArrayList<DataRow>(); - DataRow dataRow = new DataRow(); - + dataRow.setRowNum(1); dataRow.setRowFormat(true); - + DataValue dataValue1 = new DataValue(); dataValue1.setColId("REPORT_ID"); dataValue1.setColName("REPORT_ID"); dataValue1.setDisplayName("REPORT ID"); - dataValue1.setVisible(true); - + dataValue1.setVisible(true); + DataValue dataValue2 = new DataValue(); dataValue2.setColId("ORDER_ID"); dataValue2.setColName("ORDER_ID"); dataValue2.setDisplayName("ORDER ID"); dataValue2.setVisible(true); - + dataRow.addDataValue(dataValue1); dataRow.addDataValue(dataValue2); - + alDataRow.add(dataRow); - + return alDataRow; } - + private ReportData prepareReportData() { - + ReportData reportData = new ReportData(1, true); reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); - + DataRow dataRow = new DataRow(); - + dataRow.setRowNum(1); dataRow.setRowFormat(true); - + reportData.addRowNumbers(1, prepareDataRowList()); - + return reportData; } - @Test public void testCreateExcelFileContent_case1() throws Exception { ReportData reportData = prepareReportData(); - + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(false); @@ -478,37 +423,38 @@ public class ReportHandlerTest { Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 2); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); - Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 2); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - } - + @Test public void testCreateExcelFileContent_case2() throws Exception { ReportData reportData = prepareReportData(); - + DataSourceList dataSourceList = new DataSourceList(); reportData.setReportDataList(prepareDataRowList()); - + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); - ArrayList <IdNameValue> paramList = null; + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); paramList.add(new IdNameValue("Status", "Active")); - + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); - + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); - + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); @@ -518,46 +464,37 @@ public class ReportHandlerTest { Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - - PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); - /* - PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); - PowerMockito.when(Globals.getPrintFooterInDownload()).thenReturn(true); - PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); - */ - reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 1); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 1); } - @Test public void testCreateExcelFileContent_case3() throws Exception { ReportData reportData = prepareReportData(); - + DataSourceList dataSourceList = new DataSourceList(); reportData.setReportDataList(prepareDataRowList()); - - + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); - ArrayList <IdNameValue> paramList = null; + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); paramList.add(new IdNameValue("Status", "Active")); Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); - + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); - + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); @@ -567,54 +504,88 @@ public class ReportHandlerTest { Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); - - + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - /* - PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); - PowerMockito.when(Globals.getPrintFooterInDownload()).thenReturn(true); - PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); - */ - reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 3); + } + + @Test + public void testCreateExcelFileContent_case4() throws Exception { + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); } - - @Test - public void testCreateExcel2007FileContent_case1() throws Exception { - - + public void testCreateExcelFileContent_case5() throws Exception { ReportData reportData = prepareReportData(); - + DataSourceList dataSourceList = new DataSourceList(); reportData.setReportDataList(prepareDataRowList()); - - + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); - ArrayList <IdNameValue> paramList = null; + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); paramList.add(new IdNameValue("Status", "Active")); Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); - + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); - + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); @@ -624,57 +595,1122 @@ public class ReportHandlerTest { Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); - - + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); - /* - PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true); + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcelFileContent_case6() throws Exception { + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + private ReportData prepareReportData1() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData2() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setDisplayTotal("SUM("); + value.setBold(true); + DataValue value1 = null; + // value1.setColId("test"); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData3() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("date"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setBold(true); + DataValue value1 = null; + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData4() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setBold(true); + DataValue value1 = null; + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData5() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setBold(true); + DataValue value1 = new DataValue(); + value1.setColId("test"); + value1.setColName("date"); + value1.setDisplayTotal("SUM("); + value1.setBold(false); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData6() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setDisplayValue("$Test123"); + value.setBold(true); + DataValue value1 = new DataValue(); + value1.setColId("test"); + value1.setColName("date"); + value1.setDisplayTotal("SUM("); + value1.setColName("test999"); + value1.setBold(false); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData7() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setDisplayValue("$Test123."); + value.setBold(true); + DataValue value1 = new DataValue(); + value1.setColId("test"); + value1.setColName("date"); + value1.setDisplayTotal("SUM("); + value1.setColName("test999"); + value1.setDisplayValue("$Test123."); + value1.setBold(false); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + + private ReportData prepareReportData8() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName(null); + value.setDisplayTotal("SUM("); + value.setDisplayValue("$Test123"); + value.setBold(true); + DataValue value1 = new DataValue(); + value1.setColId("test"); + value1.setColName("date"); + value1.setDisplayTotal("SUM("); + value1.setColName("test999"); + value1.setBold(false); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + + @Test + public void testCreateExcelFileContent_case7() throws Exception { + ReportData reportData = prepareReportData1(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); - PowerMockito.when(Globals.getPrintFooterInDownload()).thenReturn(true); - PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); - */ - reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 3); - + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case8() throws Exception { + ReportData reportData = prepareReportData1(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case9() throws Exception { + ReportData reportData = prepareReportData2(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case10() throws Exception { + ReportData reportData = prepareReportData2(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("$test"); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case35() throws Exception { + ReportData reportData = prepareReportData2(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("test."); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + } - + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case36() throws Exception { + ReportData reportData = prepareReportData2(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1,"); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case11() throws Exception { + ReportData reportData = prepareReportData2(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("$1"); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case12() throws Exception { + ReportData reportData = prepareReportData2(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("$.1"); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcel2007FileContent_case1() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + @Test public void testCreateExcel2007FileContent_case2() throws Exception { - - + ReportData reportData = prepareReportData(); - + DataSourceList dataSourceList = new DataSourceList(); reportData.setReportDataList(prepareDataRowList()); - - + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); - ArrayList <IdNameValue> paramList = null; + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); paramList.add(new IdNameValue("Status", "Active")); Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); - + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); - - Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); @@ -684,55 +1720,35 @@ public class ReportHandlerTest { Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn(REPORT_ID); - Map<String, ReportRuntime> mapReportRuntime = new TreeMap<String, ReportRuntime>(); Map<String, ReportData> mapReportData = new TreeMap<String, ReportData>(); - + mapReportRuntime.put("ReportRuntime#1", reportRuntime); mapReportData.put("ReportData#1", reportData); - - Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(mapReportRuntime); - + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); - + Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); - + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - /* - PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); - PowerMockito.when(Globals.getPrintFooterInDownload()).thenReturn(true); - PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); - */ - reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 3); - - } - - - - - - - - - - - - @Test public void testCreateCSVFileContent_WithoutSql_case1() throws Exception { ReportData reportData = prepareReportData(); - + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); mockHttpAttribute("pdfAttachmentKey", "PdfKey"); @@ -743,17 +1759,16 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); - + mockHttpAttribute(AppConstants.RI_REPORT_SQL_WHOLE, null); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); PowerMockito.when(Globals.getFooterFirstLine()).thenReturn("Footer First Line"); PowerMockito.when(Globals.getFooterSecondLine()).thenReturn("Footer Second Line"); PowerMockito.when(Globals.getPrintParamsInCSVDownload()).thenReturn(true); PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - - ArrayList <IdNameValue> paramList = null; + + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); @@ -761,23 +1776,21 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("(column1='Y'~column2='N')"); - + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); - - //Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); - + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); - Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - - reportHandler.createCSVFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse); + + reportHandler.createCSVFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse); } @Test public void testCreateCSVFileContent_WithSql_case1() throws Exception { ReportData reportData = prepareReportData(); - + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); mockHttpAttribute("pdfAttachmentKey", "PdfKey"); @@ -788,15 +1801,15 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); - + mockHttpAttribute(AppConstants.RI_REPORT_SQL_WHOLE, "select column1 from table1 where column2='test'"); - + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); PowerMockito.when(Globals.getFooterFirstLine()).thenReturn("Footer First Line"); PowerMockito.when(Globals.getFooterSecondLine()).thenReturn("Footer Second Line"); PowerMockito.when(Globals.getPrintParamsInCSVDownload()).thenReturn(true); PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - + Mockito.when(ConnectionUtils.getConnection(Mockito.anyString())).thenReturn(connection); Mockito.when(connection.createStatement()).thenReturn(statement); @@ -807,9 +1820,8 @@ public class ReportHandlerTest { Mockito.when(resultSetMetaData.getColumnLabel(Mockito.anyInt())).thenReturn("column1"); Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("value1"); - - - ArrayList <IdNameValue> paramList = null; + + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); @@ -817,26 +1829,24 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("(column1='Y'~column2='N')"); - + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); - - Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - - reportHandler.createCSVFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse); + + reportHandler.createCSVFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse); } - private void mockHttpAttribute(String attributeName, String attributeValue) { Mockito.when(httpServletRequest.getAttribute(attributeName)).thenReturn(attributeValue); } - + @Test public void testCreateHTMLFileContent_WithoutSql_case1() throws Exception { - + ReportData reportData = prepareReportData(); - + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); mockHttpAttribute("pdfAttachmentKey", "PdfKey"); @@ -847,17 +1857,16 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); - + mockHttpAttribute(AppConstants.RI_REPORT_SQL_WHOLE, null); - PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); PowerMockito.when(Globals.getFooterFirstLine()).thenReturn("Footer First Line"); PowerMockito.when(Globals.getFooterSecondLine()).thenReturn("Footer Second Line"); PowerMockito.when(Globals.getPrintParamsInCSVDownload()).thenReturn(true); PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - - ArrayList <IdNameValue> paramList = null; + + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); @@ -865,26 +1874,24 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("(column1='Y'~column2='N')"); - + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); - - - //Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); - + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); Mockito.when(httpServletResponse.getWriter()).thenReturn(printWriter); - + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - - reportHandler.createHTMLFileContent(iowriter, reportData, reportRuntime, "", httpServletRequest, httpServletResponse); + + reportHandler.createHTMLFileContent(iowriter, reportData, reportRuntime, "", httpServletRequest, + httpServletResponse); } - - @Test(expected =RaptorException.class) + + @Test(expected = RaptorException.class) public void testCreateHTMLFileContent_WithSql_case1() throws Exception { - + ReportData reportData = prepareReportData(); - + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); mockHttpAttribute("pdfAttachmentKey", "PdfKey"); @@ -895,15 +1902,15 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); - + mockHttpAttribute(AppConstants.RI_REPORT_SQL_WHOLE, "select column1 from table1 where column2='test'"); - + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); PowerMockito.when(Globals.getFooterFirstLine()).thenReturn("Footer First Line"); PowerMockito.when(Globals.getFooterSecondLine()).thenReturn("Footer Second Line"); PowerMockito.when(Globals.getPrintParamsInCSVDownload()).thenReturn(true); PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - + Mockito.when(ConnectionUtils.getConnection(Mockito.anyString())).thenReturn(connection); Mockito.when(connection.createStatement()).thenReturn(statement); @@ -914,8 +1921,8 @@ public class ReportHandlerTest { Mockito.when(resultSetMetaData.getColumnLabel(Mockito.anyInt())).thenReturn("column1"); Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("value1"); - - ArrayList <IdNameValue> paramList = null; + + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); @@ -923,26 +1930,23 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("(column1='Y'~column2='N')"); - + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); - - - //Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); - + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); Mockito.when(httpServletResponse.getWriter()).thenReturn(printWriter); - + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - - reportHandler.createHTMLFileContent(iowriter, reportData, reportRuntime, "select column1 from table1 where column2='test'", httpServletRequest, httpServletResponse); + + reportHandler.createHTMLFileContent(iowriter, reportData, reportRuntime, + "select column1 from table1 where column2='test'", httpServletRequest, httpServletResponse); } - @Test public void testCreateFlatFileContent_case1() throws IOException, Exception { ReportData reportData = prepareReportData(); - + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); mockHttpAttribute("pdfAttachmentKey", "PdfKey"); @@ -953,134 +1957,1152 @@ public class ReportHandlerTest { Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); - + mockHttpAttribute(AppConstants.RI_REPORT_SQL_WHOLE, "select column1 from table1 where column2='test'"); - + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); PowerMockito.when(Globals.getFooterFirstLine()).thenReturn("Footer First Line"); PowerMockito.when(Globals.getFooterSecondLine()).thenReturn("Footer Second Line"); PowerMockito.when(Globals.getPrintParamsInCSVDownload()).thenReturn(true); PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); - + Mockito.when(ConnectionUtils.getConnection(Mockito.anyString())).thenReturn(connection); Mockito.when(connection.createStatement()).thenReturn(statement); Mockito.when(statement.executeQuery(Mockito.anyString())).thenReturn(resultSet); Mockito.when(resultSet.next()).thenReturn(true).thenReturn(false); - - ArrayList <IdNameValue> paramList = null; + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); paramList.add(new IdNameValue("Status", "Active")); - Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); - Mockito.when(reportRuntime.loadReportData(Mockito.anyInt(), Mockito.anyString(), Mockito.anyInt(), Mockito.anyObject(), Mockito.anyBoolean())).thenReturn(reportData); + Mockito.when(reportRuntime.loadReportData(Mockito.anyInt(), Mockito.anyString(), Mockito.anyInt(), + Mockito.anyObject(), Mockito.anyBoolean())).thenReturn(reportData); Mockito.when(httpServletResponse.getWriter()).thenReturn(printWriter); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); DataColumnType dataColumnType1 = new DataColumnType(); - + dataColumnType1.setTableId("reportaccess"); dataColumnType1.setDbColName("REP_ID"); dataColumnType1.setColName("REP_ID"); dataColumnType1.setDbColType("INTEGER"); dataColumnType1.setDisplayName("Report Id"); - + DataColumnType dataColumnType2 = new DataColumnType(); - + dataColumnType2.setTableId("reportaccess"); dataColumnType2.setDbColName("ORDER_NO"); dataColumnType2.setColName("ORDER_NO"); dataColumnType2.setDbColType("INTEGER"); dataColumnType2.setDisplayName("Order No"); - + List<DataColumnType> listDataColumnType = new ArrayList<DataColumnType>(); listDataColumnType.add(dataColumnType1); listDataColumnType.add(dataColumnType2); - - Mockito.when(reportRuntime.getAllColumns()).thenReturn(listDataColumnType); - - - reportHandler.createFlatFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "USER#1"); + + Mockito.when(reportRuntime.getAllColumns()).thenReturn(listDataColumnType); + + reportHandler.createFlatFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "USER#1"); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case15() throws Exception { + ReportData reportData = prepareReportData3(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("$test"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case16() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case17() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case18() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/11 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case19() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case25() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1/1/2011 1:11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + } - /* + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case26() throws Exception { + ReportData reportData = prepareReportData4(); - @Test + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1/1/2011 1:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testSaveAsExcelFileHttpServletRequestReportDataArrayListStringStringInt() { - fail("Not yet implemented"); } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case27() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1/1/2011"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testCreateExcelFileContent() { - fail("Not yet implemented"); } + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case28() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("2011/1/1"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testCreateFlatFileContent() { - fail("Not yet implemented"); } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case29() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("2011-1-1 1:11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testSaveXMLFile() { - fail("Not yet implemented"); } + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case30() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("111 2011"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testLoadReportRuntimeHttpServletRequestString() { - fail("Not yet implemented"); } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case31() throws Exception { + ReportData reportData = prepareReportData4(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1/2011"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testLoadReportRuntimeHttpServletRequestStringBoolean() { - fail("Not yet implemented"); } + + + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case20() throws Exception { + ReportData reportData = prepareReportData5(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(false); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testLoadReportRuntimeHttpServletRequestStringBooleanInt() { - fail("Not yet implemented"); } + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case21() throws Exception { + ReportData reportData = prepareReportData6(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(false); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11:11"); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testCreateReportDefinition() { - fail("Not yet implemented"); } + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case22() throws Exception { + ReportData reportData = prepareReportData6(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(false); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11:11"); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testLoadReportDefinition() { - fail("Not yet implemented"); } + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case23() throws Exception { + ReportData reportData = prepareReportData7(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(false); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011"); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testSetSheetName() { - fail("Not yet implemented"); } + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case24() throws Exception { + ReportData reportData = prepareReportData8(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(false); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011"); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testGetSheetName() { - fail("Not yet implemented"); } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case37() throws Exception { + ReportData reportData = prepareReportData2(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1."); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testGetColumnCountForDownloadFile() { - fail("Not yet implemented"); } + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case38() throws Exception { + ReportData reportData = prepareReportData2(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1"); + Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report"); + Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor"); + + Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("test,."); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testCreateHTMLFileContent() { - fail("Not yet implemented"); } - */ } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java new file mode 100644 index 00000000..25b70b8b --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java @@ -0,0 +1,66 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertNotEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class ChartSeqComparatorTest { + + ChartSeqComparator chartSeqComparator; + + private Integer CHAR_SEQ = 1000; + + @Before + public void init() { + chartSeqComparator = new ChartSeqComparator(); + } + + + @Test + public void testCompare() { + DataColumnType dct1 = new DataColumnType(); + DataColumnType dct2 = new DataColumnType(); + dct1.setChartSeq(CHAR_SEQ); + dct2.setChartSeq(CHAR_SEQ); + assertNotEquals(true, chartSeqComparator.compare(dct1, dct2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java new file mode 100644 index 00000000..9269d240 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java @@ -0,0 +1,75 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameColLookupTest { + + IdNameColLookup idNameColLookup; + + private String COL_ID = "colId"; + private String DB_TABLE_NAME = "dbTableName"; + private String DB_ID_FIELD = "dbIdField"; + private String DB_NAME_FIELD = "dbNameField"; + private String DB_SORT_BY_FIELD = "dbSortByField"; + + @Before + public void init() { + idNameColLookup = new IdNameColLookup(COL_ID, DB_TABLE_NAME, DB_ID_FIELD, DB_NAME_FIELD, DB_SORT_BY_FIELD); + } + + @Test + public void testNotNull() { + assertNotNull(idNameColLookup); + } + + @Test + public void testIdNameColLookupProperties() { + assertEquals(COL_ID, idNameColLookup.getColId()); + assertEquals(DB_TABLE_NAME, idNameColLookup.getDbTableName()); + assertEquals(DB_ID_FIELD, idNameColLookup.getDbIdField()); + assertEquals(DB_NAME_FIELD, idNameColLookup.getDbNameField()); + assertEquals(DB_SORT_BY_FIELD, idNameColLookup.getDbSortByField()); + } +} + diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java new file mode 100644 index 00000000..cff2eb83 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java @@ -0,0 +1,82 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class IdNameListTest { + + IdNameList idNameList; + + private String ID = "testID"; + private String NAME = "test"; + private boolean DEFAULT_VALUE = true; + private boolean READ_ONLY = true; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getFormFieldsListSize()).thenReturn(100); + idNameList = new IdNameList(); + idNameList.addValue(ID, NAME, DEFAULT_VALUE, READ_ONLY); + } + + @Test + public void testGetIdByName() { + assertEquals(ID, idNameList.getIdByName(NAME)); + } + + @Test + public void testGetNameById() { + assertEquals(NAME, idNameList.getNameById(ID)); + } + + + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java new file mode 100644 index 00000000..725d179d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java @@ -0,0 +1,76 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameLookupTest { + + IdNameLookup idNameLookup; + + private String DB_TABLE_NAME = "dbTableName"; + private String DB_ID_FIELD = "dbIdField"; + private String DB_NAME_FIELD = "dbNameField"; + private String DB_SORT_BY_FIELD = "dbSortByField"; + private String DEFAULT_SQL = "defaultSQL"; + private boolean TEXT_FIELD = true; + + @Before + public void init() { + idNameLookup = new IdNameLookup(DB_TABLE_NAME, DB_ID_FIELD, DB_NAME_FIELD, DB_SORT_BY_FIELD, DEFAULT_SQL, TEXT_FIELD); + } + + @Test + public void testNotNull() { + assertNotNull(idNameLookup); + } + + @Test + public void testIdNameLookupProperties() { + assertEquals(DB_TABLE_NAME, idNameLookup.getDbTableName()); + assertEquals(DB_ID_FIELD, idNameLookup.getDbIdField()); + assertEquals(DB_NAME_FIELD, idNameLookup.getDbNameField()); + assertEquals(DB_SORT_BY_FIELD, idNameLookup.getDbSortByField()); + assertEquals(DEFAULT_SQL, idNameLookup.getDefaultSQL()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java new file mode 100644 index 00000000..78e8dffa --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java @@ -0,0 +1,80 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.system.ConnectionUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class, IdNameSql.class, ConnectionUtils.class}) +public class IdNameSqlTest { + + IdNameSql idNameSql; + + @Before + public void init() { + idNameSql = new IdNameSql("select * from test", "select * from test"); + } + + @Test + public void testLoadData() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + Mockito.when(Globals.getDBType()).thenReturn("test"); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.anyString())).thenReturn("test"); + Mockito.when(Globals.getReportSqlForFormfield()).thenReturn("test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(), Mockito.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + idNameSql.loadData("select", 10, "testDB"); + } +} + diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java new file mode 100644 index 00000000..0c798684 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java @@ -0,0 +1,69 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameValueTest { + + IdNameValue idNameValue; + + private String ID = "id"; + private String NMAE = "name"; + + @Before + public void init() { + idNameValue = new IdNameValue(ID, NMAE); + } + + @Test + public void testNotNull() { + assertNotNull(idNameValue); + } + + @Test + public void testIdNameValueProperties() { + assertEquals(ID, idNameValue.getId()); + assertEquals(NMAE, idNameValue.getName()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java new file mode 100644 index 00000000..8d9c3385 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java @@ -0,0 +1,64 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class NameComparatorTest { + + NameComparator nameComparator; + private String NAME = "name"; + + @Before + public void init() { + nameComparator = new NameComparator(); + } + + @Test + public void testCompare() { + IdNameValue idNameValue1 = new IdNameValue(); + idNameValue1.setName(NAME); + IdNameValue idNameValue2 = new IdNameValue(); + idNameValue2.setName(NAME); + + assertEquals(0, nameComparator.compare(idNameValue1, idNameValue2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java new file mode 100644 index 00000000..cd403e7c --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java @@ -0,0 +1,65 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class OrderBySeqComparatorTest { + + OrderBySeqComparator orderBySeqComparator; + private Integer CHAR_SEQ = 100; + + @Before + public void init() { + orderBySeqComparator = new OrderBySeqComparator(); + } + + @Test + public void testCompare() { + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setOrderBySeq(CHAR_SEQ); + DataColumnType dataColumnType2 = new DataColumnType(); + dataColumnType2.setOrderBySeq(CHAR_SEQ); + + assertEquals(0, orderBySeqComparator.compare(dataColumnType1, dataColumnType2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java new file mode 100644 index 00000000..dd6c7050 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java @@ -0,0 +1,64 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class OrderSeqComparatorTest { + OrderSeqComparator orderSeqComparator; + private Integer CHAR_SEQ = 100; + + @Before + public void init() { + orderSeqComparator = new OrderSeqComparator(); + } + + @Test + public void testCompare() { + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setOrderSeq(CHAR_SEQ); + DataColumnType dataColumnType2 = new DataColumnType(); + dataColumnType2.setOrderSeq(CHAR_SEQ); + + assertEquals(0, orderSeqComparator.compare(dataColumnType1, dataColumnType2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java new file mode 100644 index 00000000..c8a2a97e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java @@ -0,0 +1,105 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import java.util.Vector; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.DbUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({AppUtils.class, Globals.class, DbUtils.class}) +public class ReportSecurityTest { + + ReportSecurity reportSecurity; + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + + @Before + public void setUp() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getReportSecurity()).thenReturn("select * from test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(DbUtils.executeQuery(Mockito.anyString())).thenReturn(ds); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(Globals.getReportUserAccess()).thenReturn("select * test"); + reportSecurity = new ReportSecurity("test"); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("USERID"); + Vector userRoles = new Vector(); + userRoles.add("test"); + Mockito.when(AppUtils.getUserRoles(Mockito.anyString())).thenReturn(userRoles); + Mockito.when(AppUtils.getUserName(Mockito.anyString())).thenReturn("test"); + Mockito.when(AppUtils.getAdminRoleIDs()).thenReturn(userRoles); + Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(userRoles); + Mockito.when(Globals.getDeleteOnlyByOwner()).thenReturn(false); + } + + @Test + public void testCheckUserReadAccess() throws RaptorException { + reportSecurity.checkUserReadAccess(mockedRequest, null); + } + + @Test + public void testCheckUserWriteAccess() throws RaptorException { + reportSecurity.checkUserWriteAccess(mockedRequest); + } + + @Test + public void testCheckUserDeleteAccess() throws RaptorException { + reportSecurity.checkUserWriteAccess(mockedRequest); + } + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java new file mode 100644 index 00000000..19d1eddc --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java @@ -0,0 +1,74 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportUserRoleTest { + + ReportUserRole reportUserRole; + private Long REP_ID = 1L; + private Long ORDER_NO = 2L; + private Long ROLE_ID = 3L; + private Long USER_ID = 4L; + private String READ_ONLY_YN = "Y"; + + @Before + public void init() { + reportUserRole = new ReportUserRole(REP_ID, ORDER_NO, ROLE_ID, USER_ID, READ_ONLY_YN); + } + + @Test + public void testNotNull() { + assertNotNull(reportUserRole); + } + + @Test + public void testReportUserRoleProperties() { + assertEquals(REP_ID, reportUserRole.getRepId()); + assertEquals(ORDER_NO, reportUserRole.getOrderNo()); + assertEquals(ROLE_ID, reportUserRole.getRoleId()); + assertEquals(USER_ID, reportUserRole.getUserId()); + assertEquals(READ_ONLY_YN, reportUserRole.getReadOnlyYn()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java new file mode 100644 index 00000000..c4e9d7f4 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java @@ -0,0 +1,73 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class DBColumnInfoTest { + + DBColumnInfo dbColumnInfo; + + private String TABLE_NAME = "tableName"; + private String COL_NAME = "colName"; + private String COL_TYPE = "colType"; + private String LABEL = "label"; + + @Before + public void init() { + dbColumnInfo = new DBColumnInfo(TABLE_NAME, COL_NAME, COL_TYPE, LABEL); + } + + @Test + public void testNotNull() { + assertNotNull(dbColumnInfo); + } + + @Test + public void testDBColumnInfoProperties() { + assertEquals(TABLE_NAME, dbColumnInfo.getTableName()); + assertEquals(COL_NAME, dbColumnInfo.getColName()); + assertEquals(COL_TYPE, dbColumnInfo.getColType()); + assertEquals(LABEL, dbColumnInfo.getLabel()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java new file mode 100644 index 00000000..df1d5693 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java @@ -0,0 +1,62 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class DrillDownParamDefTest { + + DrillDownParamDef drillDownParamDef; + String DRILL_DOWN_PARAM_DEF_STR = "fieldName=[valColId!valFieldId]"; + + @Before + public void init() { + drillDownParamDef = new DrillDownParamDef(DRILL_DOWN_PARAM_DEF_STR); + } + + @Test + public void testDrillDownParamDefProperties() { + assertEquals("fieldName", drillDownParamDef.getFieldName()); + assertEquals("valColId", drillDownParamDef.getValColId()); + assertEquals("valFieldId", drillDownParamDef.getValFieldId()); + assertEquals("4", drillDownParamDef.getValType()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java new file mode 100644 index 00000000..3aa5d24e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java @@ -0,0 +1,79 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class MarkerTest { + + Marker marker; + + private String MARKER_COLOR = "markerColor"; + private String ADDRESS_COLUMN = "addressColumn"; + private String DATA_COLUMN = "dataColumn"; + private String ADDRESS = "address"; + private String DATA = "data"; + private String COLOR = "color"; + + @Before + public void init() { + marker = new Marker(MARKER_COLOR, ADDRESS_COLUMN, DATA_COLUMN); + marker.setAddress(ADDRESS); + marker.setData(DATA); + marker.setColor(COLOR); + } + + @Test + public void testNotNull() { + assertNotNull(marker); + } + + @Test + public void testMarkerProperties() { + assertEquals(MARKER_COLOR, marker.getMarkerColor()); + assertEquals(ADDRESS_COLUMN, marker.getAddressColumn()); + assertEquals(DATA_COLUMN, marker.getDataColumn()); + assertEquals(DATA, marker.getData()); + assertEquals(COLOR, marker.getColor()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java new file mode 100644 index 00000000..d92f2565 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java @@ -0,0 +1,75 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportLogEntryTest { + + ReportLogEntry reportlogEntry; + + private String LOGTIME = "logTime"; + private String USERNAME = "userName"; + private String ACTION = "action"; + private String TIME_TAKEN = "timeTaken"; + private String RUN_ICON = "runIcon"; + + @Before + public void init() { + reportlogEntry = new ReportLogEntry(LOGTIME, USERNAME, ACTION, TIME_TAKEN, RUN_ICON); + } + + @Test + public void testNotNull() { + assertNotNull(reportlogEntry); + } + + @Test + public void testReportLogEntryProperties() { + assertEquals(LOGTIME, reportlogEntry.getLogTime()); + assertEquals(USERNAME, reportlogEntry.getUserName()); + assertEquals(ACTION, reportlogEntry.getAction()); + assertEquals(TIME_TAKEN, reportlogEntry.getTimeTaken()); + assertEquals(RUN_ICON, reportlogEntry.getRunIcon()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java new file mode 100644 index 00000000..fcbae7bc --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java @@ -0,0 +1,75 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportMapTest { + + ReportMap reportMap; + + private String MARKER_COLOR = "markerColor"; + private String ADDRESS_COLUMN = "addressColumn"; + private String DATA_COLUMN = "dataColumn"; + private String IS_MAP_ALLOWED_YN = "isMapAllowedYN"; + private String ADD_ADDRESS_IN_DATA_YN = "addAddressInDataYN"; + + @Before + public void init() { + reportMap = new ReportMap(MARKER_COLOR, ADDRESS_COLUMN, DATA_COLUMN, IS_MAP_ALLOWED_YN, ADD_ADDRESS_IN_DATA_YN); + } + + @Test + public void testNotNull() { + assertNotNull(reportMap); + } + + @Test + public void testReportMapProperties() { + assertEquals(MARKER_COLOR, reportMap.getMarkerColor()); + assertEquals(ADDRESS_COLUMN, reportMap.getAddressColumn()); + assertEquals(DATA_COLUMN, reportMap.getDataColumn()); + assertEquals(IS_MAP_ALLOWED_YN, reportMap.getIsMapAllowedYN()); + assertEquals(ADD_ADDRESS_IN_DATA_YN, reportMap.getAddAddressInDataYN()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java index 40ab05de..3ba80d9f 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java @@ -37,36 +37,56 @@ */ package org.onap.portalsdk.analytics.model.definition; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.FileInputStream; import java.io.InputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.model.base.IdNameValue; +import org.onap.portalsdk.analytics.model.runtime.FormField; +import org.onap.portalsdk.analytics.model.runtime.ReportParamValues; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.ConnectionUtils; import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; +import org.onap.portalsdk.analytics.xmlobj.DataSourceType; +import org.onap.portalsdk.analytics.xmlobj.FormFieldList; +import org.onap.portalsdk.analytics.xmlobj.FormFieldType; import org.owasp.esapi.ESAPI; import org.owasp.esapi.Encoder; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import com.mchange.v2.debug.ThreadNameStackTraceRecorder; + @RunWith(PowerMockRunner.class) -@PrepareForTest({ AppUtils.class, Globals.class, DbUtils.class, AppUtils.class, ESAPI.class}) +@PrepareForTest({ AppUtils.class, Globals.class, DbUtils.class, AppUtils.class, ESAPI.class, ConnectionUtils.class, ReportSchedule.class}) public class ReportScheduleTest { @@ -116,7 +136,8 @@ public class ReportScheduleTest { PowerMockito.mockStatic(DbUtils.class); PowerMockito.mockStatic(AppUtils.class); PowerMockito.mockStatic(ESAPI.class); - + PowerMockito.mockStatic(ConnectionUtils.class); + MockitoAnnotations.initMocks(this); Mockito.when(httpSession.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(reportRuntime); @@ -166,7 +187,13 @@ public class ReportScheduleTest { Mockito.when(dataSet1.getString(Mockito.anyInt(), Mockito.anyString())).thenReturn("Some Value2"); reportSchedule = new ReportSchedule(REPORT_ID, USER_ID, true, httpServletRequest); - + reportSchedule.setEncryptMode("test"); + reportSchedule.setEndAMPM("AM"); + reportSchedule.setEndHour("10"); + reportSchedule.setEndMin("00"); + reportSchedule.addZero("0"); + + /* Mockito.when(dataSet1.getString(Mockito.anyInt(), Mockito.anyObject())).thenAnswer(new Answer<String>() { @@ -345,6 +372,353 @@ public class ReportScheduleTest { reportSchedule.persistScheduleData(connection, httpServletRequest); } + @Test + public void testPersistScheduleData_FormFieldList_case1() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("test"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn(""); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE AND [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case2() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("test"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case3() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_MIN); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [report_id] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case4() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_MIN); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [report_id] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case5() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_SEC); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("TESTDB"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + + @Test + public void testPersistScheduleData_WithRaptorException() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + String new_schedule_data = "select coalesce(max(schedule_id),0)+1 AS sequence from cr_report_schedule"; + String persist_cond_sql_set = "update cr_report_schedule set condition_sql = ? where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getPersistCondSqlSet()).thenReturn(persist_cond_sql_update); + + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + PowerMockito.when(Globals.getNewScheduleData()).thenReturn(new_schedule_data); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeUpdate()).thenReturn(1); + Mockito.when(resultSet.next()).thenReturn(false); + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setStartDate("10/10/2018"); + reportSchedule.setEndDate("10/10/2019"); + reportSchedule.setRunDate("10/10/2019"); + reportSchedule.setRecurrence("Y"); + reportSchedule.addEmailToUser("UserID1", "UserName1"); + reportSchedule.addEmailToRole("roleId1", "roleName1"); + reportSchedule.setConditionSQL("SELECT coalesce(cr.owner_id, cr.create_id) owner_id, cr.create_id, DATE_FORMAT(cr.create_date, '[Globals.getTimeFormat()]') create_date, maint_id, DATE_FORMAT(cr.maint_date, '[Globals.getTimeFormat()]') update_date, cr.menu_id, cr.menu_approved_yn FROM cr_report cr WHERE cr.rep_id= [reportID]"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + @Test public void testDeleteScheduleData_case1() throws RaptorException { @@ -416,10 +790,9 @@ public class ReportScheduleTest { ReportSchedule.loadConditionalSQL("scheduleId#123"); } - /* - @Test - public void testLoadConditionalSQL_Error_case2() throws Exception { + @Test(expected=RaptorException.class) + public void testLoadConditionalSQL_Error_case2() throws Exception { String load_cond_sql = "SELECT condition_large_sql FROM cr_report_schedule WHERE schedule_id=?"; Mockito.when(DbUtils.getConnection()).thenReturn(connection); Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); @@ -433,50 +806,73 @@ public class ReportScheduleTest { PowerMockito.when(Globals.getLoadCondSql()).thenReturn(load_cond_sql); ReportSchedule.loadConditionalSQL("scheduleId#123"); - }*/ - + } - /* + @Test + public void testLoadConditionalSQL_Error_case3() throws Exception { + String load_cond_sql = "SELECT condition_large_sql FROM cr_report_schedule WHERE schedule_id=?"; + Mockito.when(DbUtils.getConnection()).thenReturn(connection); + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(Globals.isWeblogicServer()).thenReturn(false); + Mockito.when(Globals.isPostgreSQL()).thenReturn(false); + Mockito.when(Globals.isMySQL()).thenReturn(true); + + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(1)).thenThrow(new SQLException()); + PowerMockito.when(Globals.getLoadCondSql()).thenReturn(load_cond_sql); + + ReportSchedule.loadConditionalSQL("scheduleId#123"); + } + @Test public void testAddEmailArrayToUser() { - fail("Not yet implemented"); + ArrayList<IdNameValue> allSelectedUsers= new ArrayList<>(); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("1"); + idNameValue.setName("test"); + idNameValue.setReadOnly(true); + idNameValue.setDefaultValue(true); + allSelectedUsers.add(idNameValue); + reportSchedule.addEmailArrayToUser(allSelectedUsers); + assertEquals("1",((IdNameValue)reportSchedule.getEmailToUsers().get(0)).getId()); } @Test public void testRemoveEmailToUser() { - fail("Not yet implemented"); + reportSchedule.removeEmailToUser("1"); } - @Test - public void testAddEmailToRole() { - fail("Not yet implemented"); - } @Test public void testAddEmailArrayToRole() { - fail("Not yet implemented"); + ArrayList<IdNameValue> allSelectedUsers= new ArrayList<>(); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("roleID1"); + idNameValue.setName("roleName1"); + idNameValue.setReadOnly(true); + idNameValue.setDefaultValue(true); + allSelectedUsers.add(idNameValue); + reportSchedule.addEmailArrayToRole(allSelectedUsers); + assertEquals("roleID1",((IdNameValue)reportSchedule.getEmailToRoles().get(0)).getId()); } - + @Test public void testRemoveEmailToRole() { - fail("Not yet implemented"); + reportSchedule.removeEmailToRole("roleID1"); } @Test - public void testPersistScheduleData() { - fail("Not yet implemented"); + public void testIsAttachmentMode() { + reportSchedule.setAttachmentMode("Y"); + assertTrue(reportSchedule.isAttachmentMode()); } @Test - public void testDeleteScheduleData() { - fail("Not yet implemented"); + public void testSetConditional() { + reportSchedule.setConditional("Y"); + assertEquals("Y",reportSchedule.getConditional()); } - - @Test - public void testLoadConditionalSQL() { - fail("Not yet implemented"); - } - */ - + } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java new file mode 100644 index 00000000..156a2adf --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class SecurityEntryTest { + + SecurityEntry securityEntry; + + private String ID = "testID"; + private String NAME = "testName"; + private boolean READ_ONLY = true; + + @Before + public void init() { + securityEntry = new SecurityEntry(ID, NAME, READ_ONLY); + } + + @Test + public void testNotNull() { + assertNotNull(securityEntry); + } + + @Test + public void testTableJoinProperties() { + assertEquals(ID, securityEntry.getId()); + assertEquals(NAME, securityEntry.getName()); + assertEquals(READ_ONLY, securityEntry.isReadOnly()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java new file mode 100644 index 00000000..d7912415 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class TableJoinTest { + + TableJoin tableJoin; + + private String SRC_TABLE_NAME = "srcTableName"; + private String DEST_TABLE_NAME = "destTableName"; + private String JOIN_EXPR = "joinExpr"; + + @Before + public void init() { + tableJoin = new TableJoin(SRC_TABLE_NAME, DEST_TABLE_NAME, JOIN_EXPR); + } + + @Test + public void testNotNull() { + assertNotNull(tableJoin); + } + + @Test + public void testTableJoinProperties() { + assertEquals(SRC_TABLE_NAME, tableJoin.getSrcTableName()); + assertEquals(DEST_TABLE_NAME, tableJoin.getDestTableName()); + assertEquals(JOIN_EXPR, tableJoin.getJoinExpr()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java new file mode 100644 index 00000000..c6554c12 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java @@ -0,0 +1,76 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class TableSourceTest { + + TableSource tableSource; + + private String TABLE_NAME = "tableName"; + private String DISPLAY_NAME = "displayName"; + private String PK_FIELDS = "pkFields"; + private String VIEW_ACTION = "viewAction"; + private String IS_LARGE_DATA = "isLargeData"; + private String FILTER_SQL = "filterSql"; + + @Before + public void init() { + tableSource = new TableSource(TABLE_NAME, DISPLAY_NAME, PK_FIELDS, VIEW_ACTION, IS_LARGE_DATA, FILTER_SQL); + } + + @Test + public void testNotNull() { + assertNotNull(tableSource); + } + + @Test + public void testTableSourceProperties() { + assertEquals(TABLE_NAME, tableSource.getTableName()); + assertEquals(DISPLAY_NAME, tableSource.getDisplayName()); + assertEquals(PK_FIELDS, tableSource.getPkFields()); + assertEquals(VIEW_ACTION, tableSource.getViewAction()); + assertEquals(IS_LARGE_DATA, tableSource.getIsLargeData()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java index 3bdb5bc1..e1f99ec0 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal SDK * =================================================================== - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java new file mode 100644 index 00000000..da99f464 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class MessageJSONTest { + + MessageJSON messageJSON; + private String MESSAGE = "testMessage"; + private String ANY_STACKTRACE = "testStacktrace"; + + @Before + public void init() { + messageJSON = new MessageJSON(); + messageJSON.setMessage(MESSAGE); + messageJSON.setAnyStacktrace(ANY_STACKTRACE); + } + + @Test + public void testNotNull() { + assertEquals(MESSAGE, messageJSON.getMessage()); + assertEquals(ANY_STACKTRACE, messageJSON.getAnyStacktrace()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java new file mode 100644 index 00000000..271e2d5a --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java @@ -0,0 +1,67 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class RaptorErrorTest { + + RaptorError raptorError1; + RaptorError raptorError2; + private String MESSAGE = "theMessage"; + private Throwable THROWABLE = new Throwable(MESSAGE); + + @Before + public void init() { + raptorError1 = new RaptorError(MESSAGE); + raptorError2 = new RaptorError(MESSAGE, THROWABLE); + } + + @Test + public void testRaptorErrorMessage() { + assertEquals(MESSAGE, raptorError1.error().get("message")); + } + + @Test + public void testRaptorErrorThrowable() { + assertEquals(THROWABLE.toString(), raptorError2.error().get("exception")); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PageEventTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PageEventTest.java new file mode 100644 index 00000000..4b94657d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PageEventTest.java @@ -0,0 +1,184 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.pdf; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.lowagie.text.Document; +import com.lowagie.text.Font; +import com.lowagie.text.Rectangle; +import com.lowagie.text.pdf.PdfContentByte; +import com.lowagie.text.pdf.PdfWriter; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ Globals.class, AppUtils.class, PdfReportHandler.class }) +public class PageEventTest { + + PdfBean pb = Mockito.mock(PdfBean.class); + PageEvent pageEvent = new PageEvent(pb); + @Mock + Document document; + @Mock + PdfWriter writer; + @Mock + Font font; + @Mock + PdfContentByte pdfContentByte; + + Rectangle rectangle = new Rectangle(1, 1, 1, 1); + + @Test + public void onStartPageTest() { + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + Mockito.when(pb.getLogo1Url()).thenReturn("<no logo>"); + Mockito.when(pb.getLogo2Url()).thenReturn("<no logo>"); + pageEvent.onStartPage(writer, document); + } + + @Test(expected = java.lang.RuntimeException.class) + public void onStartPage1Test() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + Mockito.when(pb.getLogo1Url()).thenReturn("test"); + Mockito.when(pb.getLogo2Url()).thenReturn("test"); + Mockito.when(AppUtils.getImgFolderURL()).thenReturn("test"); + Mockito.when(pb.getFullWebContextPath()).thenReturn("testpath"); + Mockito.when(AppUtils.isNotEmpty(Matchers.anyString())).thenReturn(true); + Mockito.when(document.getPageSize()).thenReturn(rectangle); + Mockito.when(document.leftMargin()).thenReturn((float) 1.0); + Mockito.when(document.rightMargin()).thenReturn((float) 0.1); + Mockito.when(writer.getDirectContent()).thenReturn(pdfContentByte); + pageEvent.onStartPage(writer, document); + } + + @Test(expected = java.lang.RuntimeException.class) + public void onStartPage2Test() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + + Mockito.when(pb.getLogo1Url()).thenReturn("<no logo>"); + Mockito.when(pb.getLogo2Url()).thenReturn("test"); + Mockito.when(AppUtils.getImgFolderURL()).thenReturn("test"); + Mockito.when(pb.getFullWebContextPath()).thenReturn("testpath"); + Mockito.when(AppUtils.isNotEmpty(Matchers.anyString())).thenReturn(true); + Mockito.when(document.getPageSize()).thenReturn(rectangle); + Mockito.when(document.leftMargin()).thenReturn((float) 1.0); + Mockito.when(document.rightMargin()).thenReturn((float) 0.1); + Mockito.when(writer.getDirectContent()).thenReturn(pdfContentByte); + pageEvent.onStartPage(writer, document); + } + + @Test(expected = java.lang.Exception.class) + public void onEndPageTest() { + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + Mockito.when(pb.getLogo1Url()).thenReturn("<no logo>"); + Mockito.when(pb.getLogo2Url()).thenReturn("<no logo>"); + pageEvent.onEndPage(writer, document); + } + + @Test(expected = java.lang.Exception.class) + public void onEndPage1Test() { + Rectangle rectangle1 = Mockito.mock(Rectangle.class); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + Mockito.when(pb.getLogo1Url()).thenReturn("<no logo>"); + Mockito.when(pb.getLogo2Url()).thenReturn("<no logo>"); + Mockito.when(pb.getTimestampPattern()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.mockStatic(PdfReportHandler.class); + Mockito.when(PdfReportHandler.currentTime(Matchers.anyString())).thenReturn("test"); + Mockito.when(document.getPageSize()).thenReturn(rectangle1); + Mockito.when(rectangle1.width()).thenReturn((float) 20); + Mockito.when(document.leftMargin()).thenReturn((float) 11.0); + Mockito.when(document.rightMargin()).thenReturn((float) 0.1); + Mockito.when(writer.getDirectContent()).thenReturn(pdfContentByte); + pageEvent.onEndPage(writer, document); + } + + @SuppressWarnings("static-access") + @Test + public void getPageHeightTest() { + Rectangle rectangle1 = Mockito.mock(Rectangle.class); + Mockito.when(document.getPageSize()).thenReturn(rectangle1); + Mockito.when(rectangle1.width()).thenReturn((float) 20); + Mockito.when(document.leftMargin()).thenReturn((float) 11.0); + Mockito.when(document.rightMargin()).thenReturn((float) 0.1); + pageEvent.getPageHeight(document); + } + + @Test + public void pdfbeanTest() { + PdfBean pb = new PdfBean(); + pb.setLeftFooter("leftFooter"); + assertEquals(pb.getLeftFooter(), "leftFooter"); + pb.setTitle("title"); + assertEquals(pb.getTitle(), "title"); + pb.setCurrentPage(1); + assertEquals(pb.getCurrentPage(), 1); + assertEquals(pb.getTimestampPattern(), null); + assertEquals(pb.getWhereToShowPageNumber(), 0); + assertTrue(pb.isPageNumberAtHeader()); + assertFalse(pb.isPageNumberAtFooter()); + assertEquals(pb.getLogo1Url(), null); + assertEquals(pb.getLogo2Url(), null); + assertEquals(pb.getLogo1Size(), null); + assertEquals(pb.getLogo2Size(), null); + assertEquals(pb.getFullWebContextPath(), null); + assertEquals(pb.toString(), "title 1 null null 0 false false"); + pb.setAttachmentOfEmail(false); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PdfBeanTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PdfBeanTest.java new file mode 100644 index 00000000..a1db0d82 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PdfBeanTest.java @@ -0,0 +1,113 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.pdf; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class PdfBeanTest { + PdfBean pdfBean; + + public static final int NUMBER_IN_HEADER = 0; + public static final int NUMBER_IN_FOOTER = 1; + public static final int NUMBER_IN_BOTH = 2; + + private boolean ALTERNATE_COLOR = true; + private boolean IS_PORTRAIT = true; + private boolean IS_COVER_PAGE_INCLUDED = true; + private boolean IS_DISPLAY_CHART = true; + private int CURRENT_PAGE = 1; + private int WHERE_TO_SHOW_PAGE_NUMBER = 2; + private String USER_ID = "userID"; + private String TIMESTAMP_PATTERN = "timestampPattern"; + private String TITLE = "title"; + private String LEFT_FOOTER = "leftFooter"; + private String PAGE_SIZE = "pageSize"; + private boolean IS_ATTACHMENT_OF_EMAIL = true; + private String LOGO1_URL = "logo1Url"; + private Integer LOGO1_SIZE = 100; + private String LOGO2_URL= "logo2Url"; + private Integer LOGO2_SIZE = 200; + private String FULL_WEB_CONTEXT_PATH = "fullWebContextPath"; + + + @Before + public void init() { + pdfBean = new PdfBean(); + pdfBean.setAlternateColor(ALTERNATE_COLOR); + pdfBean.setPortrait(IS_PORTRAIT); + pdfBean.setCoverPageIncluded(IS_COVER_PAGE_INCLUDED); + pdfBean.setDisplayChart(IS_DISPLAY_CHART); + pdfBean.setCurrentPage(CURRENT_PAGE); + pdfBean.setWhereToShowPageNumber(WHERE_TO_SHOW_PAGE_NUMBER); + pdfBean.setUserId(USER_ID); + pdfBean.setTimestampPattern(TIMESTAMP_PATTERN); + pdfBean.setTitle(TITLE); + pdfBean.setLeftFooter(LEFT_FOOTER); + pdfBean.setPagesize(PAGE_SIZE); + pdfBean.setAttachmentOfEmail(IS_ATTACHMENT_OF_EMAIL); + pdfBean.setLogo1Url(LOGO1_URL); + pdfBean.setLogo1Size(LOGO1_SIZE); + pdfBean.setLogo2Url(LOGO2_URL); + pdfBean.setLogo2Size(LOGO2_SIZE); + pdfBean.setFullWebContextPath(FULL_WEB_CONTEXT_PATH); + } + + @Test + public void testPdfBeanProperties() { + assertEquals(ALTERNATE_COLOR, pdfBean.isAlternateColor()); + assertEquals(IS_PORTRAIT, pdfBean.isPortrait()); + assertEquals(IS_COVER_PAGE_INCLUDED, pdfBean.isCoverPageIncluded()); + assertEquals(IS_DISPLAY_CHART, pdfBean.isDisplayChart()); + assertEquals(CURRENT_PAGE, pdfBean.getCurrentPage()); + assertEquals(2, pdfBean.getWhereToShowPageNumber()); + assertEquals(USER_ID, pdfBean.getUserId()); + assertEquals(TIMESTAMP_PATTERN, pdfBean.getTimestampPattern()); + assertEquals(TITLE, pdfBean.getTitle()); + assertEquals(LEFT_FOOTER, pdfBean.getLeftFooter()); + assertEquals(PAGE_SIZE, pdfBean.getPagesize()); + assertEquals(IS_ATTACHMENT_OF_EMAIL, pdfBean.isAttachmentOfEmail()); + assertEquals(LOGO1_URL, pdfBean.getLogo1Url()); + assertEquals(LOGO1_SIZE, pdfBean.getLogo1Size()); + assertEquals(LOGO2_URL, pdfBean.getLogo2Url()); + assertEquals(LOGO2_SIZE, pdfBean.getLogo2Size()); + assertEquals(FULL_WEB_CONTEXT_PATH, pdfBean.getFullWebContextPath()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/BarChartOptionsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/BarChartOptionsTest.java new file mode 100644 index 00000000..d7422e94 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/BarChartOptionsTest.java @@ -0,0 +1,79 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class BarChartOptionsTest { + BarChartOptions barChartOptions; + + private boolean VERTICAL_ORIENTATION = true; + private boolean STACKED_CHART = true; + private boolean DISPLAY_BAR_CONTROLS = true; + private boolean X_AXIS_DATE_TYPE = true; + private boolean MINIMIZE_X_AXIS_TICKERS = true; + private boolean TIME_AXIS = true; + private boolean Y_AXIS_LOG_SCALE = true; + + @Before + public void init() { + barChartOptions = new BarChartOptions(); + barChartOptions.setVerticalOrientation(VERTICAL_ORIENTATION); + barChartOptions.setStackedChart(STACKED_CHART); + barChartOptions.setDisplayBarControls(DISPLAY_BAR_CONTROLS); + barChartOptions.setxAxisDateType(X_AXIS_DATE_TYPE); + barChartOptions.setMinimizeXAxisTickers(MINIMIZE_X_AXIS_TICKERS); + barChartOptions.setTimeAxis(TIME_AXIS); + barChartOptions.setyAxisLogScale(Y_AXIS_LOG_SCALE); + } + + @Test + public void testBarChartOptionsProperties() { + assertEquals(VERTICAL_ORIENTATION, barChartOptions.isVerticalOrientation()); + assertEquals(STACKED_CHART, barChartOptions.isStackedChart()); + assertEquals(DISPLAY_BAR_CONTROLS, barChartOptions.isDisplayBarControls()); + assertEquals(X_AXIS_DATE_TYPE, barChartOptions.isxAxisDateType()); + assertEquals(MINIMIZE_X_AXIS_TICKERS, barChartOptions.isMinimizeXAxisTickers()); + assertEquals(TIME_AXIS, barChartOptions.isTimeAxis()); + assertEquals(Y_AXIS_LOG_SCALE, barChartOptions.isyAxisLogScale()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntimeTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntimeTest.java new file mode 100644 index 00000000..2dce46c0 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntimeTest.java @@ -0,0 +1,117 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import java.util.ArrayList; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.model.base.ReportWrapper; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.onap.portalsdk.core.web.support.UserUtils; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ UserUtils.class, AppUtils.class}) +public class ChartWebRuntimeTest { + ChartWebRuntime chartWebRuntime; + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + + @Before + public void init() { + chartWebRuntime = new ChartWebRuntime(); + ArrayList chartList = new ArrayList<>(); + chartList.add("test"); + ArrayList infoList = new ArrayList<>(); + infoList.add("test"); + chartWebRuntime.setChartList(chartList); + chartWebRuntime.setInfoList(infoList); + chartWebRuntime.setTotalSql("select * from test"); + } + + @Test + public void testBarChartOptionsProperties() throws RaptorException { + PowerMockito.mockStatic(UserUtils.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(mockedRequest.getParameter("action")).thenReturn("test"); + Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(10); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); + Mockito.when(AppUtils.nvl(Mockito.anyString())).thenReturn("test"); + Mockito.when(mockedRequest.getParameter("refresh")).thenReturn("N"); + Mockito.when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("1"); + Mockito.when(AppUtils.getRequestNvlValue(Mockito.any(HttpServletRequest.class), Mockito.anyString())).thenReturn("test"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + Mockito.when(rr.getReportID()).thenReturn("1"); + Mockito.when(rr.getReportType()).thenReturn("Hive"); + Mockito.when(rr.getReportSQL()).thenReturn("select * from test"); + Mockito.when(rr.getLegendLabelAngle()).thenReturn("standard"); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", new ArrayList(), true, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", new ArrayList(), false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", new ArrayList(), false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + Mockito.when(rr.getReportFormFields()).thenReturn(reportFormFields); + Mockito.when(rr.getReportDefType()).thenReturn(AppConstants.RD_SQL_BASED); + Mockito.when(rr.getReportTitle()).thenReturn("test"); + Mockito.when(mockedRequest.getParameterValues(Matchers.anyString())).thenReturn(new String[] { "test" }); + chartWebRuntime.generateChart(mockedRequest); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/CommonChartOptionsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/CommonChartOptionsTest.java new file mode 100644 index 00000000..c8bee8ec --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/CommonChartOptionsTest.java @@ -0,0 +1,81 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +public class CommonChartOptionsTest { + CommonChartOptions commonChartOptions; + + private String LEGEND_POSITION = "top"; + private String LEGEND_LABEL_ANGLE = "up45"; + private boolean HIDE_LEGEND = false; + private boolean ANIMATE_ANIMATED_CHART = true; + private int TOP_MARGIN = 30; + private int BOTTOM_MARGIN = 50; + private int LEFT_MARGIN = 100; + private int RIGHT_MARGIN = 60; + + @Before + public void init(){ + commonChartOptions = new CommonChartOptions(); + commonChartOptions.setLegendPosition(LEGEND_POSITION); + commonChartOptions.setLegendLabelAngle(LEGEND_LABEL_ANGLE); + commonChartOptions.setHideLegend(HIDE_LEGEND); + commonChartOptions.setAnimateAnimatedChart(ANIMATE_ANIMATED_CHART); + commonChartOptions.setTopMargin(TOP_MARGIN); + commonChartOptions.setBottomMargin(BOTTOM_MARGIN); + commonChartOptions.setLeftMargin(LEFT_MARGIN); + commonChartOptions.setRightMargin(RIGHT_MARGIN); + } + + @Test + public void testCommonChartOptionsProperties(){ + assertEquals(LEGEND_POSITION, commonChartOptions.getLegendPosition()); + assertEquals(LEGEND_LABEL_ANGLE, commonChartOptions.getLegendLabelAngle()); + assertEquals(HIDE_LEGEND, commonChartOptions.isHideLegend()); + assertEquals(ANIMATE_ANIMATED_CHART, commonChartOptions.isAnimateAnimatedChart()); + assertEquals(TOP_MARGIN, commonChartOptions.getTopMargin()); + assertEquals(BOTTOM_MARGIN, commonChartOptions.getBottomMargin()); + assertEquals(LEFT_MARGIN, commonChartOptions.getLeftMargin()); + assertEquals(RIGHT_MARGIN, commonChartOptions.getRightMargin()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntimeTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntimeTest.java new file mode 100644 index 00000000..c5b42989 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntimeTest.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class ErrorJSONRuntimeTest { + ErrorJSONRuntime errorJSONRuntime; + + private String ERROR_MESSAGE = "testMesage"; + private String STACKTRACE = "testStacktrace"; + + @Before + public void init(){ + errorJSONRuntime = new ErrorJSONRuntime(); + errorJSONRuntime.setErrormessage(ERROR_MESSAGE); + errorJSONRuntime.setStacktrace(STACKTRACE); + } + + @Test + public void testErrorJSONRuntimeProperties(){ + assertEquals(ERROR_MESSAGE, errorJSONRuntime.getErrormessage()); + assertEquals(STACKTRACE, errorJSONRuntime.getStacktrace()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptionsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptionsTest.java new file mode 100644 index 00000000..85fede3e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptionsTest.java @@ -0,0 +1,64 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class FlexTimeSeriesChartOptionsTest { + FlexTimeSeriesChartOptions flexTimeSeriesChartOptions; + + private int ZOOM_IN = 25; + private String TIME_AXIS_TYPE = ""; + + @Before + public void init(){ + flexTimeSeriesChartOptions = new FlexTimeSeriesChartOptions(); + flexTimeSeriesChartOptions.setZoomIn(ZOOM_IN); + flexTimeSeriesChartOptions.setTimeAxisType(TIME_AXIS_TYPE); + } + + @Test + public void testFlexTimeSeriesChartOptionsProperties(){ + assertEquals(ZOOM_IN, flexTimeSeriesChartOptions.getZoomIn()); + assertEquals(TIME_AXIS_TYPE, flexTimeSeriesChartOptions.getTimeAxisType()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java new file mode 100644 index 00000000..d89074cd --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java @@ -0,0 +1,82 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.FormatList; +import org.onap.portalsdk.analytics.xmlobj.FormatType; +import org.onap.portalsdk.analytics.xmlobj.SemaphoreType; + +public class FormatProcessorTest { + FormatProcessor formatProcessor; + + @Before + public void init(){ + SemaphoreType semaphoreType = new SemaphoreType(); + semaphoreType.setSemaphoreName("semaphoreName"); + semaphoreType.setSemaphoreType("semaphoreType"); + semaphoreType.setComment("comment"); + semaphoreType.setTarget("target"); + FormatList formatList = new FormatList(); + FormatType formatType = new FormatType(); + formatType.setLessThanValue("lessThanValue"); + formatType.setExpression("expression"); + formatType.setBold(false); + formatType.setItalic(false); + formatType.setUnderline(false); + formatType.setBgColor("bgColor"); + formatType.setFontColor("fontColor"); + formatType.setFontFace("fontFace"); + formatType.setFontSize("fontSize"); + formatType.setAlignment("alignment"); + formatType.setComment("comment"); + formatType.setFormatId("formatId"); + formatList.getFormat().add(formatType); + semaphoreType.setFormatList(formatList); + semaphoreType.setSemaphoreId("semaphoreId"); + formatProcessor = new FormatProcessor(semaphoreType, "test", "test", true); + } + + @Test + public void testNotNull(){ + assertNotNull(formatProcessor); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ItemTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ItemTest.java new file mode 100644 index 00000000..086b9d9d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ItemTest.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class ItemTest { + Item item; + + private String ID = "testID"; + private String NAME = "name"; + + @Before + public void init(){ + item = new Item(); + item.setId(ID); + item.setName(NAME); + } + + @Test + public void testItemProperties(){ + assertEquals(ID, item.getId()); + assertEquals(NAME, item.getName()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/LookupDBInfoTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/LookupDBInfoTest.java new file mode 100644 index 00000000..71ad8c28 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/LookupDBInfoTest.java @@ -0,0 +1,67 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class LookupDBInfoTest { + LookupDBInfo lookupDBInfo; + + private String TABLE_NAME = "tableName"; + private String FIELD_NAME = "fieldName"; + private String LOOKUP_TABLE = "lookupTable"; + private String LOOKUP_ID_FIELD = "lookupIdField"; + private String LOOKUP_NAME_FIELD = "lookupNameField"; + + @Before + public void init(){ + lookupDBInfo = new LookupDBInfo(TABLE_NAME, FIELD_NAME, LOOKUP_TABLE, LOOKUP_ID_FIELD, LOOKUP_NAME_FIELD); + } + + @Test + public void testItemProperties(){ + assertEquals(TABLE_NAME, lookupDBInfo.getTableName()); + assertEquals(FIELD_NAME, lookupDBInfo.getFieldName()); + assertEquals(LOOKUP_TABLE, lookupDBInfo.getLookupTable()); + assertEquals(LOOKUP_ID_FIELD, lookupDBInfo.getLookupIdField()); + assertEquals(LOOKUP_NAME_FIELD, lookupDBInfo.getLookupNameField()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RangeAxisJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RangeAxisJSONTest.java new file mode 100644 index 00000000..e0a9b371 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RangeAxisJSONTest.java @@ -0,0 +1,77 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class RangeAxisJSONTest { + RangeAxisJSON rangeAxisJSON; + + private RangeAxisLabelJSON rangeAxisLabelJSON; + private RangeColorJSON rangeColorJSON; + private RangeLineTypeJSON rangeLineTypeJSON; + private String RANGE_CHART_GROUP = "rangeChartGroup"; + private String RANGE_Y_AXIS = "rangeYAxis"; + private boolean SHOW_AS_AREA = true; + + @Before + public void init(){ + rangeAxisLabelJSON = new RangeAxisLabelJSON(); + rangeColorJSON = new RangeColorJSON(); + rangeLineTypeJSON = new RangeLineTypeJSON(); + rangeAxisJSON = new RangeAxisJSON(); + rangeAxisJSON.setRangeAxisLabelJSON(rangeAxisLabelJSON); + rangeAxisJSON.setRangeColorJSON(rangeColorJSON); + rangeAxisJSON.setRangeLineTypeJSON(rangeLineTypeJSON); + rangeAxisJSON.setRangeChartGroup(RANGE_CHART_GROUP); + rangeAxisJSON.setRangeYAxis(RANGE_Y_AXIS); + rangeAxisJSON.setShowAsArea(SHOW_AS_AREA); + } + + @Test + public void testItemProperties(){ + assertEquals(rangeAxisLabelJSON, rangeAxisJSON.getRangeAxisLabelJSON()); + assertEquals(rangeColorJSON, rangeAxisJSON.getRangeColorJSON()); + assertEquals(rangeLineTypeJSON, rangeAxisJSON.getRangeLineTypeJSON()); + assertEquals(RANGE_Y_AXIS, rangeAxisJSON.getRangeYAxis()); + assertEquals(SHOW_AS_AREA, rangeAxisJSON.isShowAsArea()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java index 07e1745b..c5010c1a 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java @@ -39,13 +39,16 @@ package org.onap.portalsdk.analytics.model.runtime; import static org.junit.Assert.assertEquals; +import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StringWriter; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Vector; import javax.servlet.ServletContext; @@ -71,6 +74,7 @@ import org.onap.portalsdk.analytics.model.ReportLoader; import org.onap.portalsdk.analytics.model.base.IdNameValue; import org.onap.portalsdk.analytics.model.base.ReportWrapper; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; +import org.onap.portalsdk.analytics.model.definition.SecurityEntry; import org.onap.portalsdk.analytics.model.definition.wizard.ColumnJSON; import org.onap.portalsdk.analytics.model.definition.wizard.DefinitionJSON; import org.onap.portalsdk.analytics.system.AppUtils; @@ -104,7 +108,7 @@ import org.powermock.reflect.exceptions.MethodInvocationException; @RunWith(PowerMockRunner.class) @PrepareForTest({ AppConstants.class, Globals.class, AppUtils.class, ReportWrapper.class, DataCache.class, DbUtils.class, DataSet.class , ReportLoader.class ,ReportRuntime.class, Utils.class, ESAPI.class, - Codec.class,SecurityCodecUtil.class , ConnectionUtils.class, XSSFilter.class}) + Codec.class,SecurityCodecUtil.class , ConnectionUtils.class, XSSFilter.class, RaptorControllerAsync.class}) public class RaptorControllerAsyncTest { @InjectMocks @@ -617,4 +621,100 @@ public class RaptorControllerAsyncTest { return chartJSON; } + @Test + public void listChildReportColsTest() throws Exception { + ReportRuntime rr = Mockito.mock(ReportRuntime.class); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportRuntime(Mockito.any(HttpServletRequest.class), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(rr); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setColName("test"); + dataColumnType.setColId("1"); + dataColumnTypeList.add(dataColumnType); + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + raptorControllerAsync.listChildReportCols("reportID", mockedRequest, mockedResponse); + } + + @Test + public void listChildReportFormFieldsTest() throws Exception { + ReportRuntime rr = Mockito.mock(ReportRuntime.class); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportRuntime(Mockito.any(HttpServletRequest.class), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(rr); + List predefinedValues = new ArrayList<>(); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, true, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + Mockito.when(rr.getReportFormFields()).thenReturn(reportFormFields); + raptorControllerAsync.listChildReportFormFields("reportID", mockedRequest, mockedResponse); + } + + @Test + public void getReportSecurityUsersTest() throws Exception { + ReportDefinition rdef = Mockito.mock(ReportDefinition.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + Vector vc = new Vector<>(); + vc.add(new SecurityEntry("1", "test", true)); + Mockito.when(rdef.getReportUsers(mockedRequest)).thenReturn(vc); + raptorControllerAsync.getReportSecurityUsers(mockedRequest); + } + + @Test + public void getReportSecurityRolesTest() throws Exception { + ReportDefinition rdef = Mockito.mock(ReportDefinition.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + Vector vc = new Vector<>(); + vc.add(new SecurityEntry("1", "test", true)); + Mockito.when(rdef.getReportRoles(mockedRequest)).thenReturn(vc); + raptorControllerAsync.getReportSecurityRoles(mockedRequest); + } + + public ReportDefinition mockReportDefinition() throws RaptorException { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + DataSet datset = PowerMockito.mock(DataSet.class); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + customReportType.setFormFieldList(formFieldList); + customReportType.setPublic(true); + customReportType.setReportType("test"); + customReportType.setReportTitle("test"); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + reportWrapper.setReportDefType("SQL-based"); + ReportDefinition reportDefinition = new ReportDefinition(reportWrapper, mockedRequest); + return reportDefinition; + } + @Test + public void retrieveDefTabWiseDataTest() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + ReportDefinition rdef = mockReportDefinition(); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + Map<String, String> pathVariables = new HashMap<>(); + pathVariables.put("id", "InSession"); + pathVariables.put("detailId", "test"); + Vector vc = new Vector<>(); + vc.add("test"); + PowerMockito.when(AppUtils.getQuickLinksMenuIDs()).thenReturn(vc); + raptorControllerAsync.retrieveDefTabWiseData(pathVariables, mockedRequest, mockedResponse); + } + + + } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParserTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParserTest.java new file mode 100644 index 00000000..88bcd6b9 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParserTest.java @@ -0,0 +1,67 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ReportParamDateValueParserTest { + + @Test + public void testIsDateHrParam() { + assertFalse(ReportParamDateValueParser.isDateHrParam("29-MAY-2018")); + } + + @Test + public void testIsDateParam() { + assertTrue(ReportParamDateValueParser.isDateParam("29-MAY-2018")); + } + + @Test + public void testFormatDateParamValue() { + assertNotNull(ReportParamDateValueParser.formatDateParamValue("29-MAY-2018")); + } + + @Test + public void testFormatDateHrParamValue() { + assertNotNull(ReportParamDateValueParser.formatDateHrParamValue("29-MAY-2018")); + } +}
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcelTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcelTest.java new file mode 100644 index 00000000..e9e43a7e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcelTest.java @@ -0,0 +1,133 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.model.base.ReportWrapper; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.ConnectionUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.onap.portalsdk.core.util.SecurityCodecUtil; +import org.owasp.esapi.ESAPI; +import org.owasp.esapi.Encoder; +import org.owasp.esapi.codecs.Codec; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class, ESAPI.class, AppUtils.class, SecurityCodecUtil.class, ConnectionUtils.class}) +public class ReportParamValuesForPDFExcelTest { + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + ReportParamValuesForPDFExcel reportParamValuesForPDFExcel; + ReportFormFields reportFormFields; + ReportRuntime rr; + @Before + public void setUp() throws RaptorException { + rr = Mockito.mock(ReportRuntime.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + reportFormFields = new ReportFormFields(rw, mockedRequest); + List predefinedValues = new ArrayList(); + FormField formField = Mockito.mock(FormField.class); + Mockito.when(formField.getFieldName()).thenReturn("fftest"); + Mockito.when(formField.getFieldDisplayName()).thenReturn("fieldDisplayName"); + Mockito.when(formField.getBaseSQLForPDFExcel()).thenReturn("select * from test"); + Mockito.when(formField.getFieldDefaultSQL()).thenReturn("select * from test"); + reportFormFields.add(formField); + Mockito.when(rr.getReportFormFields()).thenReturn(reportFormFields); + Mockito.when(rr.getReportType()).thenReturn("test"); + Mockito.when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("test"); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + Mockito.when(Globals.getRequestParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + PowerMockito.mockStatic(ConnectionUtils.class); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(),Mockito.anyInt())).thenReturn("test"); + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(),Mockito.anyString())).thenReturn(ds); + } + + @Test + public void testSetParamValues_WithCombo() throws Exception { + Mockito.when(reportFormFields.getFormField(0).getFieldType()).thenReturn(FormField.FFT_COMBO_BOX); + Mockito.when(reportFormFields.getFormField(0).getValidationType()).thenReturn(FormField.VT_TIMESTAMP_HR); + ReportParamValues params = new ReportParamValues(reportFormFields, "test"); + Mockito.when(rr.getParamKeys()).thenReturn(params.keys()); + reportParamValuesForPDFExcel = new ReportParamValuesForPDFExcel(reportFormFields, "test"); + reportParamValuesForPDFExcel.setParamValues(mockedRequest, true); + } + + @Test + public void testSetParamValues_WithCheckBox() throws Exception { + Mockito.when(reportFormFields.getFormField(0).getFieldType()).thenReturn(FormField.FFT_CHECK_BOX); + Mockito.when(reportFormFields.getFormField(0).getValidationType()).thenReturn(FormField.VT_TIMESTAMP_MIN); + ReportParamValues params = new ReportParamValues(reportFormFields, "test"); + Mockito.when(rr.getParamKeys()).thenReturn(params.keys()); + reportParamValuesForPDFExcel = new ReportParamValuesForPDFExcel(reportFormFields, "test"); + reportParamValuesForPDFExcel.setParamValues(mockedRequest, true); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/TimeSeriesChartOptionsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/TimeSeriesChartOptionsTest.java new file mode 100644 index 00000000..1d555574 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/TimeSeriesChartOptionsTest.java @@ -0,0 +1,73 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class TimeSeriesChartOptionsTest { + TimeSeriesChartOptions timeSeriesChartOptions; + + private String LINE_CHART_RENDERER = "lineChartRenderer"; + private boolean MULTI_SERIES = true; + private boolean NON_TIME_AXIS = true; + private boolean SHOW_X_AXIS_LABEL = true; + private boolean ADD_X_AXIS_TICKER = true; + + @Before + public void init() { + timeSeriesChartOptions = new TimeSeriesChartOptions(); + timeSeriesChartOptions.setLineChartRenderer(LINE_CHART_RENDERER); + timeSeriesChartOptions.setMultiSeries(MULTI_SERIES);; + timeSeriesChartOptions.setNonTimeAxis(NON_TIME_AXIS); + timeSeriesChartOptions.setShowXAxisLabel(SHOW_X_AXIS_LABEL); + timeSeriesChartOptions.setAddXAxisTicker(ADD_X_AXIS_TICKER); + } + + @Test + public void testBarChartOptionsProperties() { + assertEquals(LINE_CHART_RENDERER, timeSeriesChartOptions.getLineChartRenderer()); + assertEquals(MULTI_SERIES, timeSeriesChartOptions.isMultiSeries()); + assertEquals(NON_TIME_AXIS, timeSeriesChartOptions.isNonTimeAxis()); + assertEquals(SHOW_X_AXIS_LABEL, timeSeriesChartOptions.isShowXAxisLabel()); + assertEquals(ADD_X_AXIS_TICKER, timeSeriesChartOptions.isAddXAxisTicker()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/util/UtilsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/util/UtilsTest.java new file mode 100644 index 00000000..63a72c37 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/util/UtilsTest.java @@ -0,0 +1,192 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.util; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.model.base.IdNameValue; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class, AppUtils.class, Utils.class}) +public class UtilsTest { + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpSession session = mockedRequest.getSession(); + + @Test + public void getUsersNotInListTest() throws RaptorException { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getCustomizedScheduleQueryForUsers()).thenReturn("select * from test"); + Mockito.when(AppUtils.getUserBackdoorLoginId(mockedRequest)).thenReturn("test"); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + Mockito.when(session.getAttribute(Mockito.anyString())).thenReturn("test"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("1"); + Vector vc = new Vector(); + vc.add(idNameValue); + List list = new ArrayList(); + list.add(idNameValue); + Mockito.when(AppUtils.getAllUsers(Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(vc); + Utils.getUsersNotInList(list, mockedRequest); + } + + @Test + public void getRolesNotInListTest() throws RaptorException { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getCustomizedScheduleQueryForRoles()).thenReturn("select * from test"); + Mockito.when(AppUtils.getUserBackdoorLoginId(mockedRequest)).thenReturn("test"); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + Mockito.when(session.getAttribute(Mockito.anyString())).thenReturn("test"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("1"); + Vector vc = new Vector(); + vc.add(idNameValue); + List list = new ArrayList(); + list.add(idNameValue); + Mockito.when(AppUtils.getAllRoles(Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(vc); + Mockito.when(AppUtils.getSuperRoleID()).thenReturn("1"); + Utils.getRolesNotInList(list, mockedRequest); + } + + @Test + public void getUsersNotInListLatestTest() throws RaptorException { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getCustomizedScheduleQueryForUsers()).thenReturn("select * from test"); + Mockito.when(AppUtils.getUserBackdoorLoginId(mockedRequest)).thenReturn("test"); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + Mockito.when(session.getAttribute(Mockito.anyString())).thenReturn("test"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("1"); + Vector vc = new Vector(); + vc.add(idNameValue); + List list = new ArrayList(); + list.add(idNameValue); + Mockito.when(AppUtils.getAllUsers(Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(vc); + Utils.getUsersNotInListLatest(list, mockedRequest); + } + + @Test + public void getRolesNotInListLatestTest() throws RaptorException { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getCustomizedScheduleQueryForRoles()).thenReturn("select * from test"); + Mockito.when(AppUtils.getUserBackdoorLoginId(mockedRequest)).thenReturn("test"); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + Mockito.when(session.getAttribute(Mockito.anyString())).thenReturn("test"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("1"); + Vector vc = new Vector(); + vc.add(idNameValue); + List list = new ArrayList(); + list.add(idNameValue); + Mockito.when(AppUtils.getAllRoles(Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(vc); + Mockito.when(AppUtils.getSuperRoleID()).thenReturn("1"); + Utils.getRolesNotInListLatest(list, mockedRequest); + } + + @Test + public void isDownloadFileExistsTest() throws Exception { + File file = Mockito.mock(File.class); + String[] fileNames = new String[] {"test.txt"}; + Mockito.when(file.list()).thenReturn(fileNames); + PowerMockito.whenNew(File.class).withArguments(Mockito.anyString()).thenReturn(file); + Utils.isDownloadFileExists("test"); + } + + @Test + public void getLatestDownloadableFileTest() throws Exception { + File file = Mockito.mock(File.class); + String[] fileNames = new String[] {"test.txt","test1.txt"}; + Mockito.when(file.list()).thenReturn(fileNames); + PowerMockito.whenNew(File.class).withArguments(Mockito.anyString()).thenReturn(file); + Utils.getLatestDownloadableFile("test"); + } + + @Test + public void javaSafeTest() throws Exception { + Utils.javaSafe("Hel'oo world!"); + } + + @Test(expected=RuntimeException.class) + public void _assertTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getDebugLevel()).thenReturn(1); + Utils._assert(false, "errorMsg"); + } + + @Test + public void getCurrentDateTimeTest() { + Utils.getCurrentDateTime(); + } + + @Test + public void htmlEncodeTest() { + Utils.htmlEncode("<html>test</html>"); + } + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ActionHandlerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ActionHandlerTest.java deleted file mode 100644 index 9abd87fe..00000000 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ActionHandlerTest.java +++ /dev/null @@ -1,547 +0,0 @@ -/* - * ============LICENSE_START========================================== - * ONAP Portal SDK - * =================================================================== - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software 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. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * 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.portalsdk.analytics.xmlobj; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; - -import java.io.InputStream; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.onap.portalsdk.analytics.controller.ActionHandler; -import org.onap.portalsdk.analytics.model.ReportLoader; -import org.onap.portalsdk.analytics.model.SearchHandler; -import org.onap.portalsdk.analytics.model.base.ReportWrapper; -import org.onap.portalsdk.analytics.model.definition.ReportDefinition; -import org.onap.portalsdk.analytics.model.runtime.ChartWebRuntime; -import org.onap.portalsdk.analytics.model.runtime.FormField; -import org.onap.portalsdk.analytics.model.runtime.ReportFormFields; -import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; -import org.onap.portalsdk.analytics.system.AppUtils; -import org.onap.portalsdk.analytics.system.DbUtils; -import org.onap.portalsdk.analytics.system.Globals; -import org.onap.portalsdk.analytics.util.AppConstants; -import org.onap.portalsdk.analytics.util.DataSet; -import org.onap.portalsdk.core.logging.format.AlarmSeverityEnum; -import org.onap.portalsdk.core.util.SecurityCodecUtil; -import org.onap.portalsdk.core.web.support.UserUtils; -import org.owasp.esapi.ESAPI; -import org.owasp.esapi.Encoder; -import org.owasp.esapi.codecs.Codec; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ AppUtils.class, UserUtils.class, ESAPI.class, AppConstants.class, AlarmSeverityEnum.class, ReportWrapper.class, - ReportDefinition.class, SecurityCodecUtil.class, Globals.class, DbUtils.class, ReportLoader.class }) -public class ActionHandlerTest { - - @InjectMocks - ActionHandler actionHandler = new ActionHandler(); - - @Mock - Connection connection; - @Mock - PreparedStatement stmt; - @Mock - ResultSet rs; - @Mock - java.sql.Clob clob; - @Mock - InputStream in; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); - HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); - HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); - - - @Test - public void reportRunExceptionTest() { - when(mockedRequest.getParameter("action")).thenReturn("test"); - PowerMockito.mockStatic(AppUtils.class); - when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(true); - assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); - } - - @SuppressWarnings("unchecked") - @Test - public void reportRunRaptorReportExceptionTest() throws Exception { - PowerMockito.mockStatic(Globals.class); - PowerMockito.mockStatic(DbUtils.class); - PowerMockito.mockStatic(ReportLoader.class); - PowerMockito.mockStatic(ReportWrapper.class); - PowerMockito.mockStatic(AppUtils.class); - PowerMockito.mock(AppConstants.class); - PowerMockito.mockStatic(ReportDefinition.class); - PowerMockito.mockStatic(ESAPI.class); - PowerMockito.mockStatic(SecurityCodecUtil.class); - when(mockedRequest.getParameter("action")).thenReturn("test"); - when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); - when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("testxyz"); - ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); - when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); - when(mockedRequest.getSession().getAttribute("FirstDashReport")).thenReturn(rr); - when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("report.download"); - Encoder encoder = PowerMockito.mock(Encoder.class); - when(ESAPI.encoder()).thenReturn(encoder); - Codec codec = PowerMockito.mock(Codec.class); - when(SecurityCodecUtil.getCodec()).thenReturn(codec); - when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); - when(Globals.getDownloadAllEmailSent()).thenReturn("test"); - DataSet set = Mockito.mock(DataSet.class); - when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); - when(DbUtils.getConnection()).thenReturn(connection); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("test2"); - when(rr.getReportID()).thenReturn("test"); - when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_SHOW_BACK_BTN)).thenReturn(true); - when(Globals.getLoadCustomReportXml()).thenReturn("java.lang.String"); - String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CustomReportType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"><reportName>name</reportName><reportDescr>desc</reportDescr><chartType>type</chartType><showChartTitle>false</showChartTitle><public>false</public><createId>id</createId><pageNav>false</pageNav></CustomReportType>"; - when(connection.prepareStatement("1")).thenReturn(stmt); - when(stmt.executeQuery()).thenReturn(rs); - when(Globals.isWeblogicServer()).thenReturn(true); - when(rs.getClob(1)).thenReturn(clob); - when(rs.next()).thenReturn(true); - when(clob.getAsciiStream()).thenReturn(in); - when(in.read(Matchers.any())).thenReturn(1); - when(AppUtils.nvl(rr.getLegendLabelAngle())).thenReturn("standard"); - when(AppUtils.nvl("Y")).thenReturn("Y"); - when(AppUtils.nvl("bottom")).thenReturn("Y"); - when(AppUtils.nvl("test")).thenReturn("test|"); - when(AppUtils.getRequestValue(mockedRequest, "c_dashboard")).thenReturn("1"); - when(ReportLoader.isDashboardType("-1")).thenReturn(false); - ReportDefinition rdf = PowerMockito.mock(ReportDefinition.class); - whenNew(ReportDefinition.class) - .withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class)) - .thenReturn(rdf); - when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject())).thenReturn(rdf); - CustomReportType crType = Mockito.mock(CustomReportType.class); - when(ReportWrapper.unmarshalCR(Matchers.anyString())).thenReturn(crType); - when(Globals.getReportWrapperFormat()).thenReturn("[Globals.getTimeFormat()]"); - when(Globals.getTimeFormat()).thenReturn("[reportID]"); - when(Globals.getReportUserAccess()).thenReturn("[reportID]"); - when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set); - when(set.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); - when(ReportLoader.loadCustomReportXML("test2")).thenReturn(str); - FormFieldType formFieldType = new FormFieldType(); - formFieldType.setFieldId("test"); - formFieldType.setColId("1"); - formFieldType.setFieldName("test"); - formFieldType.setFieldType("type"); - formFieldType.setValidationType("validation"); - formFieldType.setMandatory("Y"); - formFieldType.setDefaultValue("test"); - formFieldType.setGroupFormField(true); - List formFieldTypeList = new ArrayList<>(); - formFieldTypeList.add(formFieldType); - FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class); - when(formFieldList.getFormField()).thenReturn(formFieldTypeList); - Mockito.when(crType.getFormFieldList()).thenReturn(formFieldList); - when(Globals.getRequestParams()).thenReturn("test,case"); - when( Globals.getSessionParams()).thenReturn("test,abc"); - when(Globals.getSessionParamsForScheduling()).thenReturn("test"); - - DataSourceList dataSourceList = new DataSourceList(); - List<DataSourceType> list = new ArrayList<>(); - DataSourceType dataSourceType = new DataSourceType(); - dataSourceType.setTableName("test"); - dataSourceType.setRefTableId("1"); - dataSourceType.setTableId("1"); - List<DataColumnType> dataColumnTypeList = new ArrayList<>(); - DataColumnType dataColumnType = new DataColumnType(); - dataColumnType.setChartGroup("test"); - dataColumnType.setYAxis("test"); - dataColumnType.setColName("[test"); - dataColumnType.setColOnChart("LEGEND"); - dataColumnType.setDisplayName("chart_total"); - dataColumnType.setColId("1"); - dataColumnType.setTableId("1"); - dataColumnType.setColType("DATE"); - dataColumnType.setCrossTabValue("ROW"); - dataColumnType.setPdfDisplayWidthInPxls("0.0"); - dataColumnType.setVisible(true); - dataColumnType.setCalculated(true); - dataColumnTypeList.add(dataColumnType); - DataColumnType dataColumnType1 = new DataColumnType(); - dataColumnType1.setCrossTabValue("COLUMN"); - dataColumnType1.setColId("1"); - dataColumnType1.setVisible(true); - dataColumnType1.setPdfDisplayWidthInPxls("1.0"); - dataColumnTypeList.add(dataColumnType1); - - DataColumnList dataColumnList = new DataColumnList(); - dataColumnList.dataColumn = dataColumnTypeList; - dataSourceType.setDataColumnList(dataColumnList); - list.add(dataSourceType); - dataSourceList.dataSource = list; - when(crType.getDataSourceList()).thenReturn(dataSourceList); - when(rr.getReportType()).thenReturn(AppConstants.RT_DASHBOARD); - - List predefinedValues = new ArrayList<>(); - ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); - ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); - FormField formField = new FormField("test", "fieldDisplayName", FormField.FFT_COMBO_BOX, "validationType", false, - "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", - "rangeEndDateSQL", "multiSelectListSize"); - FormField formField1 = new FormField("test", "fieldDisplayName", FormField.FFT_LIST_MULTI, "validationType", false, - "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", - "rangeEndDateSQL", "multiSelectListSize"); - FormField formField2 = new FormField("test", "fieldDisplayName", FormField.FFT_BLANK, "validationType", false, - "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", - "rangeEndDateSQL", "multiSelectListSize"); - - reportFormFields.add(formField); - reportFormFields.add(formField1); - reportFormFields.add(formField2); - rr.setReportFormFields(null); - rr.setReportFormFields(reportFormFields); - when(rr.getReportFormFields()).thenReturn(reportFormFields); - when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("test"); - Enumeration<String> enums; - Vector<String> attrs = new Vector<String>(); - attrs.add("ff_test"); - enums = attrs.elements(); - when(rr.getParamKeys()).thenReturn(enums); - assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); - } - - - @Test - public void reportRunForCSVDownloadTest() throws Exception { - when(mockedRequest.getParameter("action")).thenReturn("test"); - when(mockedRequest.getParameter("r_action")).thenReturn("report.csv.download"); - PowerMockito.mockStatic(AppUtils.class); - PowerMockito.mockStatic(Globals.class); - PowerMockito.mockStatic(DbUtils.class); - - when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); - when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn(""); - ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); - when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); - when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); - when(AppUtils.getRequestFlag(mockedRequest, "fromReportLog")).thenReturn(true); - when(rr.getReportType()).thenReturn(AppConstants.RT_LINEAR); - when(rr.getReportDataSQL(Matchers.anyString(), Matchers.anyInt(), Matchers.any())).thenReturn("test"); - PowerMockito.mockStatic(ESAPI.class); - Encoder encoder = PowerMockito.mock(Encoder.class); - when(ESAPI.encoder()).thenReturn(encoder); - Codec codec = PowerMockito.mock(Codec.class); - PowerMockito.mockStatic(SecurityCodecUtil.class); - when(SecurityCodecUtil.getCodec()).thenReturn(codec); - when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); - when(Globals.getDownloadAllEmailSent()).thenReturn("test"); - DataSet set = new DataSet(); - when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); - assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); - } - - public ReportRuntime mockReportRunTime1() throws Exception { - PowerMockito.mockStatic(Globals.class); - PowerMockito.mockStatic(DbUtils.class); - when(Globals.getReportUserAccess()).thenReturn("test"); - ResultSet rs = PowerMockito.mock(ResultSet.class); - ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); - when(rsmd.getColumnCount()).thenReturn(1); - when(rs.getMetaData()).thenReturn(rsmd); - DataSet datset = PowerMockito.mock(DataSet.class); - // datset = new DataSet(rs); - when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); - when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); - when(Globals.getNewScheduleData()).thenReturn("test"); - CustomReportType customReportType = new CustomReportType(); - DataSourceList dataSourceList = new DataSourceList(); - DataSourceType dataSourceType = new DataSourceType(); - dataSourceType.setTableName("test"); - dataSourceType.setRefTableId("1"); - dataSourceType.setTableId("1"); - List<DataColumnType> dataColumnTypeList = new ArrayList<>(); - DataColumnType dataColumnType = new DataColumnType(); - dataColumnType.setChartGroup("test"); - dataColumnType.setYAxis("test"); - dataColumnType.setColName("[test"); - dataColumnType.setColOnChart("LEGEND"); - dataColumnType.setDisplayName("chart_total"); - dataColumnType.setColId("1"); - dataColumnType.setTableId("1"); - dataColumnType.setColType("DATE"); - dataColumnTypeList.add(dataColumnType); - customReportType.setReportType("test"); - customReportType.setReportTitle("test"); - customReportType.setDataSourceList(dataSourceList); - ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions(); - chartAdditionalOptions.setLabelAngle("test"); - chartAdditionalOptions.setTimeSeriesRender("test"); - chartAdditionalOptions.setMultiSeries(false); - customReportType.setChartAdditionalOptions(chartAdditionalOptions); - ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", - "1", true); - PowerMockito.mockStatic(UserUtils.class); - when(Globals.getRequestParams()).thenReturn("test"); - when(Globals.getSessionParams()).thenReturn("test"); - when(Globals.getSessionParamsForScheduling()).thenReturn("test"); - PowerMockito.mockStatic(AppUtils.class); - when(AppUtils.getUserID(mockedRequest)).thenReturn("test12"); - ReportRuntime rr = new ReportRuntime(reportWrapper, mockedRequest); - rr.setLegendLabelAngle("test"); - rr.setMultiSeries(false); - rr.setChartType("test"); - return rr; - } - - - @Test - public void reportRunTestCase1() throws Exception { - when(mockedRequest.getParameter("action")).thenReturn("test"); - PowerMockito.mockStatic(AppUtils.class); - PowerMockito.mockStatic(Globals.class); - PowerMockito.mockStatic(DbUtils.class); - - when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false); - when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); - ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); - when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); - - PowerMockito.mockStatic(ESAPI.class); - Encoder encoder = PowerMockito.mock(Encoder.class); - when(ESAPI.encoder()).thenReturn(encoder); - Codec codec = PowerMockito.mock(Codec.class); - PowerMockito.mockStatic(SecurityCodecUtil.class); - when(SecurityCodecUtil.getCodec()).thenReturn(codec); - when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); - when(Globals.getDownloadAllEmailSent()).thenReturn("test"); - DataSet set = PowerMockito.mock(DataSet.class); - when(set.isEmpty()).thenReturn(false); - when(DbUtils.executeQuery(Matchers.anyString(), Matchers.anyInt())).thenReturn(set); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn(null); - PowerMockito.mockStatic(ReportLoader.class); - when(ReportLoader.loadCustomReportXML(Matchers.anyString())).thenReturn("test"); - assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class); - } - - - @Test - public void reportDeleteTest() throws Exception { - PowerMockito.mockStatic(ESAPI.class); - PowerMockito.mockStatic(AppUtils.class); - PowerMockito.mockStatic(Globals.class); - PowerMockito.mockStatic(DbUtils.class); - PowerMockito.mockStatic(AlarmSeverityEnum.class); - DataSet set = Mockito.mock(DataSet.class); - Encoder encoder = PowerMockito.mock(Encoder.class); - ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); - ReportDefinition rd = PowerMockito.mock(ReportDefinition.class); - when(ESAPI.encoder()).thenReturn(encoder); - Codec codec = PowerMockito.mock(Codec.class); - PowerMockito.mockStatic(SecurityCodecUtil.class); - when(SecurityCodecUtil.getCodec()).thenReturn(codec); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("1"); - when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("1"); - when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); - when(Globals.getReportSecurity()).thenReturn("[rw.getReportID()]"); - when(Globals.getReportUserAccess()).thenReturn("[reportID]"); - when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set); - when(Globals.getDeleteOnlyByOwner()).thenReturn(true); - when(Globals.getLogVariablesInSession()).thenReturn("test"); - HttpSession session = Mockito.mock(HttpSession.class); - when(session.getAttribute(Matchers.anyString())).thenReturn(rr); - when(session.getAttribute(Matchers.anyString())).thenReturn(rd); - assertEquals(actionHandler.reportDelete(mockedRequest, "10").getClass(), String.class); - } - - - @Test - public void reportSearchTest() throws Exception { - PowerMockito.mockStatic(ESAPI.class); - PowerMockito.mockStatic(AppUtils.class); - PowerMockito.mockStatic(Globals.class); - PowerMockito.mockStatic(DbUtils.class); - when(AppUtils.getImgFolderURL()).thenReturn("test"); - when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_F_REPORT_ID)).thenReturn("test"); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_F_REPORT_NAME)).thenReturn("test"); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_SORT_ORDER)).thenReturn("f_owner_id"); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_LIST_CATEGORY)).thenReturn("test"); - when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_USER_REPORTS)).thenReturn(true); - when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_PUBLIC_REPORTS)).thenReturn(true); - when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_FAVORITE_REPORTS)).thenReturn(true); - when(AppUtils.nvl(Matchers.anyString())).thenReturn("te"); - when(Globals.getLoadReportSearchResult()).thenReturn("test"); - when(Globals.getLoadReportSearchRepIdSql()).thenReturn("test"); - when(Globals.getLoadReportSearchInstr()).thenReturn("test"); - when(Globals.getLoadReportSearchResultUser()).thenReturn("test"); - when(Globals.getLoadReportSearchResultPublic()).thenReturn("test"); - when(Globals.getLoadReportSearchResultFav()).thenReturn("test"); - when(Globals.getLoadReportSearchResultSort()).thenReturn("test"); - when(AppUtils.getRequestNvlValue(mockedRequest, "r_page")).thenReturn("10"); - Vector<String> vc = new Vector<>(); - vc.add("test"); - vc.add("test2"); - when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc); - when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false); - DataSet set = Mockito.mock(DataSet.class); - when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set); - Enumeration<String> enums; - Vector<String> attrs = new Vector<String>(); - attrs.add("parent_test"); - attrs.add("child_test"); - enums = attrs.elements(); - when(mockedRequest.getSession().getAttributeNames()).thenReturn(enums); - when(mockedRequest.getParameter("rep_id")).thenReturn("test"); - when(mockedRequest.getParameter("rep_id_options")).thenReturn("test"); - when(mockedRequest.getParameter("rep_name_options")).thenReturn("test"); - when(mockedRequest.getParameter("rep_name")).thenReturn("test"); - SearchHandler sh = Mockito.mock(SearchHandler.class); - whenNew(SearchHandler.class).withNoArguments().thenReturn(sh); - actionHandler.reportSearch(mockedRequest, "10"); - } - - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test(expected = NullPointerException.class) - public void reportChartRunTest() throws Exception { - PowerMockito.mockStatic(Globals.class); - PowerMockito.mockStatic(DbUtils.class); - PowerMockito.mockStatic(ReportLoader.class); - PowerMockito.mockStatic(ReportWrapper.class); - PowerMockito.mockStatic(AppUtils.class); - PowerMockito.mockStatic(ReportDefinition.class); - PowerMockito.mockStatic(ESAPI.class); - PowerMockito.mockStatic(SecurityCodecUtil.class); - PowerMockito.mockStatic(UserUtils.class); - when(UserUtils.getUserId(mockedRequest)).thenReturn(1); - when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); - when(AppUtils.isSuperUser(mockedRequest)).thenReturn(true); - Map roles = new HashMap<>(); - roles.put("role1", "test1"); - roles.put("role2", "test2"); - when(UserUtils.getRoles(mockedRequest)).thenReturn(roles); - when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("chart.data.json"); - ChartWebRuntime cwr = Mockito.mock(ChartWebRuntime.class); - whenNew(ChartWebRuntime.class).withNoArguments().thenReturn(cwr); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("test"); - ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); - when(DbUtils.getConnection()).thenReturn(connection); - when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("1"); - when(rr.getReportID()).thenReturn("test"); - when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_SHOW_BACK_BTN)).thenReturn(true); - when(Globals.getLoadCustomReportXml()).thenReturn("java.lang.String"); - String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CustomReportType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"><reportType>Hive</reportType><reportName>name</reportName><reportDescr>desc</reportDescr><chartType>type</chartType><showChartTitle>false</showChartTitle><public>false</public><createId>id</createId><pageNav>false</pageNav></CustomReportType>"; - when(connection.prepareStatement("1")).thenReturn(stmt); - when(stmt.executeQuery()).thenReturn(rs); - when(Globals.isWeblogicServer()).thenReturn(true); - when(rs.getClob(1)).thenReturn(clob); - when(rs.next()).thenReturn(true); - when(clob.getAsciiStream()).thenReturn(in); - when(in.read(Matchers.any())).thenReturn(1); - when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); - when(AppUtils.nvl(rr.getLegendLabelAngle())).thenReturn("standard"); - when(AppUtils.getRequestNvlValue(Matchers.any(), Matchers.anyString())).thenReturn("test"); - when(AppUtils.nvl("Y")).thenReturn("Y"); - when(AppUtils.nvl("bottom")).thenReturn("Y"); - when(AppUtils.nvl("test")).thenReturn("test|"); - when(AppUtils.getRequestValue(mockedRequest, "c_dashboard")).thenReturn("1"); - when(ReportLoader.isDashboardType("-1")).thenReturn(false); - ReportDefinition rdf = PowerMockito.mock(ReportDefinition.class); - whenNew(ReportDefinition.class) - .withArguments(Matchers.any(ReportWrapper.class), Matchers.any(HttpServletRequest.class)) - .thenReturn(rdf); - PowerMockito.mockStatic(ReportDefinition.class); - when(ReportDefinition.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject())).thenReturn(rdf); - CustomReportType crType = Mockito.mock(CustomReportType.class); - when(ReportWrapper.unmarshalCR(Matchers.anyString())).thenReturn(crType); - when(Globals.getReportWrapperFormat()).thenReturn("[Globals.getTimeFormat()]"); - when(Globals.getTimeFormat()).thenReturn("[reportID]"); - when(Globals.getReportUserAccess()).thenReturn("[reportID]"); - DataSet set = PowerMockito.mock(DataSet.class); - when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set); - when(set.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); - whenNew(ReportRuntime.class).withArguments(Matchers.any(CustomReportType.class), Matchers.anyString(), - Matchers.any(HttpServletRequest.class), Matchers.anyString(), Matchers.anyString(), - Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), - Matchers.anyBoolean()).thenReturn(rr); - DataSourceList dsl = Mockito.mock(DataSourceList.class); - List<DataSourceType> list = new ArrayList<>(); - DataSourceType sr1 = new DataSourceType(); - sr1.setComment("test"); - sr1.setRefDefinition("test"); - sr1.setDataColumnList(new DataColumnList()); - sr1.setTableId("test"); - sr1.setTableName("test"); - list.add(sr1); - when(crType.getDataSourceList()).thenReturn(dsl); - when(dsl.getDataSource()).thenReturn(list); - DashboardReports rps = Mockito.mock(DashboardReports.class); - List<Reports> reportList = new ArrayList<>(); - Reports rp = new Reports(); - rp.setBgcolor("white"); - rp.setReportId("1"); - reportList.add(rp); - when(rdf.getDashBoardReports()).thenReturn(rps); - when(rps.getReportsList()).thenReturn(reportList); - when(ReportLoader.loadCustomReportXML("1")).thenReturn(str); - actionHandler.reportChartRun(mockedRequest, "10"); - } -} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ChartJSONHelperTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ChartJSONHelperTest.java index f69c5dae..8901e73b 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ChartJSONHelperTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ChartJSONHelperTest.java @@ -70,6 +70,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.model.ReportHandler; import org.onap.portalsdk.analytics.model.ReportLoader; import org.onap.portalsdk.analytics.model.base.ReportWrapper; import org.onap.portalsdk.analytics.model.runtime.ChartJSONHelper; @@ -89,7 +90,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(PowerMockRunner.class) -@PrepareForTest({UserUtils.class,AppUtils.class, DbUtils.class, ReportRuntime.class, Globals.class, UserUtils.class,ReportLoader.class}) +@PrepareForTest({UserUtils.class,AppUtils.class, DbUtils.class, ReportRuntime.class, Globals.class, UserUtils.class,ReportLoader.class,ChartJSONHelper.class}) public class ChartJSONHelperTest { @InjectMocks @@ -116,7 +117,7 @@ public class ChartJSONHelperTest { HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); - @Test(expected = java.lang.ClassCastException.class) + @Test(expected = java.lang.NullPointerException.class) public void generateJSONTest() throws RaptorException, Exception { EcompRole role = new EcompRole(); @@ -142,6 +143,8 @@ public class ChartJSONHelperTest { rr.setChartType("BarChart3D"); rr.setMultiSeries(true); rr.setDashboardType(true); + rr.setLegendLabelAngle("standard"); + rr.setWholeSQL("SELECT * FROM test"); Mockito.when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); PowerMockito.mockStatic(Globals.class); @@ -165,7 +168,7 @@ public class ChartJSONHelperTest { Mockito.when(rs.next()).thenReturn(true); Mockito.when(clob.getAsciiStream()).thenReturn(in); Mockito.when(in.read(Matchers.any())).thenReturn(1); -// PowerMockito.mockStatic(ReportRuntime.class); + PowerMockito.mockStatic(ReportRuntime.class); Mockito.when(ReportRuntime.unmarshal(str, "1", mockedRequest)).thenReturn(rr); Mockito.when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); Mockito.when(AppUtils.nvl(rr.getLegendLabelAngle())).thenReturn("standard"); @@ -175,7 +178,10 @@ public class ChartJSONHelperTest { Mockito.when(AppUtils.nvl("test")).thenReturn("test|"); Mockito.when(AppUtils.getRequestValue(mockedRequest, "c_dashboard")).thenReturn("1"); Mockito.when(ReportLoader.isDashboardType("-1")).thenReturn(false); - assertEquals(chartJSONHelper.generateJSON("1", mockedRequest, false).getClass(), String.class); + ReportHandler reportHandler = Mockito.mock(ReportHandler.class); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportRuntime(Mockito.any(HttpServletRequest.class), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyInt())).thenReturn(rr); + assertEquals(chartJSONHelper.generateJSON("1", mockedRequest, true).getClass(), String.class); } @@ -368,6 +374,7 @@ public class ChartJSONHelperTest { dataColumnType.setColId("1"); dataColumnType.setTableId("1"); dataColumnType.setColType("DATE"); + dataColumnType.setColOnChart("LEGEND"); dataColumnTypeList.add(dataColumnType); DataColumnList dataColumnList = new DataColumnList(); dataColumnList.dataColumn = dataColumnTypeList; diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/PdfReportHandlerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/PdfReportHandlerTest.java index c94dd41a..76dd83ed 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/PdfReportHandlerTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/PdfReportHandlerTest.java @@ -51,6 +51,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.TreeMap; +import java.util.Vector; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -60,11 +61,12 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; import org.mockito.Matchers; +import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalsdk.analytics.model.DataCache; +import org.onap.portalsdk.analytics.model.ReportHandler; import org.onap.portalsdk.analytics.model.ReportLoader; import org.onap.portalsdk.analytics.model.base.ReportWrapper; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; @@ -83,6 +85,8 @@ import org.onap.portalsdk.analytics.util.XSSFilter; import org.onap.portalsdk.analytics.view.ColumnHeader; import org.onap.portalsdk.analytics.view.ColumnHeaderRow; import org.onap.portalsdk.analytics.view.DataRow; +import org.onap.portalsdk.analytics.view.DataValue; +import org.onap.portalsdk.analytics.view.HtmlFormatter; import org.onap.portalsdk.analytics.view.ReportColumnHeaderRows; import org.onap.portalsdk.analytics.view.ReportData; import org.onap.portalsdk.analytics.view.ReportDataRows; @@ -99,33 +103,38 @@ import org.powermock.modules.junit4.PowerMockRunner; import com.lowagie.text.Document; import com.lowagie.text.Image; +import com.lowagie.text.Rectangle; @RunWith(PowerMockRunner.class) -@PrepareForTest({ PdfReportHandler.class, PdfReportHandlerTest.class, AppConstants.class, Globals.class, AppUtils.class, ReportWrapper.class, DataCache.class, - DbUtils.class, DataSet.class, Font.class, ReportLoader.class, ReportRuntime.class, Utils.class, ESAPI.class, Codec.class, - SecurityCodecUtil.class, ConnectionUtils.class, XSSFilter.class, ReportDefinition.class, UserUtils.class}) +@PrepareForTest({ PdfReportHandler.class, PdfReportHandlerTest.class, AppConstants.class, Globals.class, AppUtils.class, + ReportWrapper.class, DataCache.class, DbUtils.class, DataSet.class, Font.class, ReportLoader.class, + ReportRuntime.class, Utils.class, ESAPI.class, Codec.class, SecurityCodecUtil.class, ConnectionUtils.class, + XSSFilter.class, ReportDefinition.class, UserUtils.class, Color.class }) public class PdfReportHandlerTest { - @InjectMocks - PdfReportHandler pdfReportHandler; - + PdfReportHandler pdfReportHandler = new PdfReportHandler(); + @Mock + ReportHandler reportHandler; + @Mock + ReportDefinition rdef; + @Before - public void init() throws Exception { + public void init() throws Exception { PowerMockito.mockStatic(Globals.class); PowerMockito.mockStatic(AppUtils.class); - PowerMockito.mockStatic(DbUtils.class); + PowerMockito.mockStatic(DbUtils.class); MockitoAnnotations.initMocks(this); } - + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); - - @Ignore + + @Ignore @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void createPdfFileContentTest() throws Exception { - Document doc = mock(Document.class); + Document doc = mock(Document.class); PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); PowerMockito.when(doc.newPage()).thenReturn(true); when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); @@ -160,7 +169,7 @@ public class PdfReportHandlerTest { when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); } - + @Ignore @SuppressWarnings({ "rawtypes", "unchecked" }) @Test @@ -173,8 +182,8 @@ public class PdfReportHandlerTest { ReportRuntime rr = mock(ReportRuntime.class); ReportData rd = mock(ReportData.class); - ReportDataRows rdr = new ReportDataRows(); - CustomReportType crType = mock(CustomReportType.class); + ReportDataRows rdr = new ReportDataRows(); + CustomReportType crType = mock(CustomReportType.class); Connection conn = mock(Connection.class); Statement st = mock(Statement.class); ResultSet resSet = mock(ResultSet.class); @@ -222,12 +231,12 @@ public class PdfReportHandlerTest { list.add(dataSourceType); dataSourceList.dataSource = list; when(crType.getDataSourceList()).thenReturn(dataSourceList); - + when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(conn); when(conn.createStatement()).thenReturn(st); - when( st.executeQuery(Matchers.anyString())).thenReturn(resSet); + when(st.executeQuery(Matchers.anyString())).thenReturn(resSet); when(resSet.getMetaData()).thenReturn(resSetMD); - + when(mockedRequest.getParameter("parent")).thenReturn("parent_test"); when(mockedRequest.getSession().getAttribute("parent_test_rr")).thenReturn(rr); when(mockedRequest.getSession().getAttribute("parent_test_rd")).thenReturn(rd); @@ -242,7 +251,7 @@ public class PdfReportHandlerTest { columnHeaderRow.add(columnHeader); reportColumnHeaderRows.add(columnHeaderRow); rd.reportColumnHeaderRows = reportColumnHeaderRows; - + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); RowHeaderCol rowHeaderCol = new RowHeaderCol(); RowHeader rowHeader = new RowHeader(); @@ -258,14 +267,13 @@ public class PdfReportHandlerTest { when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("report.edit"); when(mockedRequest.getParameter(AppConstants.RI_WIZARD_ACTION)).thenReturn("test"); - when(mockedRequest.getSession().getAttribute( - AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); DataSet datset = PowerMockito.mock(DataSet.class); when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); - - Document doc = mock(Document.class); + + Document doc = mock(Document.class); PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); PowerMockito.when(doc.newPage()).thenReturn(true); when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); @@ -297,7 +305,7 @@ public class PdfReportHandlerTest { when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); } - + @Ignore @SuppressWarnings({ "rawtypes", "unchecked" }) @Test @@ -313,8 +321,8 @@ public class PdfReportHandlerTest { when(htmlStr.stripHtml(Matchers.anyString())).thenReturn("test"); ReportRuntime rr = mock(ReportRuntime.class); ReportData rd = mock(ReportData.class); - ReportDataRows rdr = new ReportDataRows(); - CustomReportType crType = mock(CustomReportType.class); + ReportDataRows rdr = new ReportDataRows(); + CustomReportType crType = mock(CustomReportType.class); Connection conn = mock(Connection.class); Statement st = mock(Statement.class); ResultSet resSet = mock(ResultSet.class); @@ -362,12 +370,12 @@ public class PdfReportHandlerTest { list.add(dataSourceType); dataSourceList.dataSource = list; when(crType.getDataSourceList()).thenReturn(dataSourceList); - + when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(conn); when(conn.createStatement()).thenReturn(st); - when( st.executeQuery(Matchers.anyString())).thenReturn(resSet); + when(st.executeQuery(Matchers.anyString())).thenReturn(resSet); when(resSet.getMetaData()).thenReturn(resSetMD); - + when(mockedRequest.getParameter("parent")).thenReturn("parent_test"); when(mockedRequest.getSession().getAttribute("parent_test_rr")).thenReturn(rr); when(mockedRequest.getSession().getAttribute("parent_test_rd")).thenReturn(rd); @@ -382,20 +390,19 @@ public class PdfReportHandlerTest { columnHeaderRow.add(columnHeader); reportColumnHeaderRows.add(columnHeaderRow); rd.reportColumnHeaderRows = reportColumnHeaderRows; - + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); rd.reportRowHeaderCols = reportRowHeaderCols; when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("report.edit"); when(mockedRequest.getParameter(AppConstants.RI_WIZARD_ACTION)).thenReturn("test"); - when(mockedRequest.getSession().getAttribute( - AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); DataSet datset = PowerMockito.mock(DataSet.class); when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); - - Document doc = mock(Document.class); + + Document doc = mock(Document.class); PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); PowerMockito.when(doc.newPage()).thenReturn(true); when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); @@ -427,13 +434,13 @@ public class PdfReportHandlerTest { when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 2); } - + @SuppressWarnings({ "rawtypes", "unchecked", "static-access" }) @Test public void createPdfFileContent2Test() throws Exception { PowerMockito.mockStatic(Image.class); - Document doc = mock(Document.class); - CustomReportType crType = mock(CustomReportType.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); DataSet ds = mock(DataSet.class); PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); @@ -472,13 +479,13 @@ public class PdfReportHandlerTest { when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); List chartGroups = new ArrayList<>(); when(rr.getAllChartGroups()).thenReturn(chartGroups); - ReportParamValues reportValues= new ReportParamValues(); + ReportParamValues reportValues = new ReportParamValues(); when(rr.getReportParamValues()).thenReturn(reportValues); when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); HashMap requestParams = new HashMap<>(); requestParams.put("", "test"); - + DataSourceList dataSourceList = new DataSourceList(); List<DataSourceType> list = new ArrayList<>(); @@ -515,7 +522,1828 @@ public class PdfReportHandlerTest { list.add(dataSourceType); dataSourceList.dataSource = list; when(crType.getDataSourceList()).thenReturn(dataSourceList); - + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent_case5Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataRows = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + rowHeaderCol1.add("test1"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + ReportDataRows rdr = new ReportDataRows(); + Connection conn = mock(Connection.class); + Statement st = mock(Statement.class); + ResultSet resSet = mock(ResultSet.class); + ResultSetMetaData resSetMD = mock(ResultSetMetaData.class); + DataRow dr = new DataRow(); + rdr.add(dr); + rd.reportDataRows = rdr; + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieOrder")).thenReturn("row"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieLabelDisplay")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(AppConstants.GT_PIE_MULTIPLE); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn("test123"); + List newlist = new ArrayList<>(); + newlist.add(1); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)) + .thenReturn(newlist); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_REPORT_DATA)).thenReturn(rd); + Mockito.when(rr.getReportType()).thenReturn("test"); + Mockito.when(rd.getTotalColumnCount()).thenReturn(2); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent_case6Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataRows = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + rowHeaderCol1.add("test1"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + ReportDataRows rdr = new ReportDataRows(); + Connection conn = mock(Connection.class); + Statement st = mock(Statement.class); + ResultSet resSet = mock(ResultSet.class); + ResultSetMetaData resSetMD = mock(ResultSetMetaData.class); + DataRow dr = new DataRow(); + rdr.add(dr); + rd.reportDataRows = rdr; + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieOrder")).thenReturn("row"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieLabelDisplay")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(AppConstants.GT_PIE_MULTIPLE); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn("test123"); + List newlist = new ArrayList<>(); + newlist.add(1); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)) + .thenReturn(newlist); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_REPORT_DATA)).thenReturn(rd); + Mockito.when(rr.getReportType()).thenReturn("test"); + Mockito.when(rd.getTotalColumnCount()).thenReturn(2); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(2); + + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + Mockito.when(rdef.getAllColumns()).thenReturn(dataColumnTypeList); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent_case7Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataRows = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + rowHeaderCol1.add("test1"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + ReportDataRows rdr = new ReportDataRows(); + Connection conn = mock(Connection.class); + Statement st = mock(Statement.class); + ResultSet resSet = mock(ResultSet.class); + ResultSetMetaData resSetMD = mock(ResultSetMetaData.class); + DataRow dr = new DataRow(); + rdr.add(dr); + rd.reportDataRows = rdr; + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieOrder")).thenReturn("row"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieLabelDisplay")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(AppConstants.GT_PIE_MULTIPLE); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn("test123"); + List newlist = new ArrayList<>(); + newlist.add(1); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)) + .thenReturn(newlist); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_REPORT_DATA)).thenReturn(rd); + Mockito.when(rr.getReportType()).thenReturn("test"); + Mockito.when(rd.getTotalColumnCount()).thenReturn(2); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(2); + + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + Mockito.when(rdef.getAllColumns()).thenReturn(dataColumnTypeList); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + when(mockedRequest.getSession().getAttribute("TITLE_0")).thenReturn("title"); + when(mockedRequest.getSession().getAttribute("drilldown_index")).thenReturn("drilldown_index"); + when(mockedRequest.getSession().getAttribute("SUBTITLE_0")).thenReturn("subtitle"); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void createPdfFileContent_case8Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataRows = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + rowHeaderCol1.add("test1"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + ReportDataRows rdr = new ReportDataRows(); + Connection conn = mock(Connection.class); + Statement st = mock(Statement.class); + ResultSet resSet = mock(ResultSet.class); + ResultSetMetaData resSetMD = mock(ResultSetMetaData.class); + DataRow dr = new DataRow(); + rdr.add(dr); + rd.reportDataRows = rdr; + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieOrder")).thenReturn("row"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieLabelDisplay")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(AppConstants.GT_PIE_MULTIPLE); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn("test123"); + List newlist = new ArrayList<>(); + newlist.add(1); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)) + .thenReturn(newlist); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_REPORT_DATA)).thenReturn(rd); + Mockito.when(rr.getReportType()).thenReturn("Linear"); + Mockito.when(rd.getTotalColumnCount()).thenReturn(2); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(2); + + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + List<DataColumnType> dataColumnTypeList1 = new ArrayList<>(); + Mockito.when(rdef.getAllColumns()).thenReturn(dataColumnTypeList); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + when(mockedRequest.getSession().getAttribute("TITLE_0")).thenReturn("title"); + when(mockedRequest.getSession().getAttribute("drilldown_index")).thenReturn("drilldown_index"); + when(mockedRequest.getSession().getAttribute("SUBTITLE_0")).thenReturn("subtitle"); + Mockito.when(mockedRequest.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE)).thenReturn("test"); + PowerMockito.mockStatic(ConnectionUtils.class); + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(conn); + Mockito.when(conn.createStatement()).thenReturn(st); + Mockito.when(st.executeQuery(Matchers.anyString())).thenReturn(resSet); + Mockito.when(resSet.getMetaData()).thenReturn(resSetMD); + Mockito.when(resSetMD.getColumnCount()).thenReturn(2); + Mockito.when(resSet.next()).thenReturn(true); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void createPdfFileContent_case9Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + DataRow dataRow2 = new DataRow(); + + ArrayList dataValueList = new ArrayList<>(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setVisible(true); + DataValue value1 = new DataValue(); + DataValue value2 = new DataValue(); + + dataValueList.add(value); + dataValueList.add(value1); + dataValueList.add(value2); + dataRow.addDataValue(value); + dataRow.addDataValue(value1); + dataRow.addDataValue(value2); + dataRow.setDataValueList(dataValueList); + + dataRow2.addDataValue(value); + dataRow2.addDataValue(value1); + dataRow2.addDataValue(value2); + dataRow2.setDataValueList(dataValueList); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + dataRow1.addDataValue(value2); + dataRow1.setDataValueList(dataValueList); + + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow2); + reportDataRows.add(dataRow2); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataRows = reportDataRows; + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + rowHeaderCol1.add("test1"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + ReportDataRows rdr = new ReportDataRows(); + Connection conn = mock(Connection.class); + Statement st = mock(Statement.class); + ResultSet resSet = mock(ResultSet.class); + ResultSetMetaData resSetMD = mock(ResultSetMetaData.class); + DataRow dr = new DataRow(); + rdr.add(dr); + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieOrder")).thenReturn("row"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieLabelDisplay")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(AppConstants.GT_PIE_MULTIPLE); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn("test123"); + List newlist = new ArrayList<>(); + newlist.add(1); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)) + .thenReturn(newlist); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_REPORT_DATA)).thenReturn(rd); + Mockito.when(rr.getReportType()).thenReturn("Linear"); + Mockito.when(rd.getTotalColumnCount()).thenReturn(2); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(2); + + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + List<DataColumnType> dataColumnTypeList1 = new ArrayList<>(); + Mockito.when(rdef.getAllColumns()).thenReturn(dataColumnTypeList); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + when(mockedRequest.getSession().getAttribute("TITLE_0")).thenReturn("title"); + when(mockedRequest.getSession().getAttribute("drilldown_index")).thenReturn("drilldown_index"); + when(mockedRequest.getSession().getAttribute("SUBTITLE_0")).thenReturn("subtitle"); + Mockito.when(mockedRequest.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE)).thenReturn("test"); + PowerMockito.mockStatic(ConnectionUtils.class); + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(conn); + Mockito.when(conn.createStatement()).thenReturn(st); + Mockito.when(st.executeQuery(Matchers.anyString())).thenReturn(resSet); + Mockito.when(resSet.getMetaData()).thenReturn(resSetMD); + Mockito.when(resSetMD.getColumnCount()).thenReturn(2); + Mockito.when(resSet.next()).thenReturn(true); + Mockito.when(resSetMD.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(resSet.getString(Matchers.anyInt())).thenReturn("test"); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent10Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartOrientation")).thenReturn("vertical"); + when(AppUtils.getRequestNvlValue(mockedRequest, "secondaryChartRenderer")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn("TimeSeriesChart"); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setDependsOnFormField("test"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + ArrayList chartValueColAxis = new ArrayList(); + chartValueColAxis.add("test"); + Mockito.when(rr.getChartValueColumnAxisList(Matchers.anyInt(), Matchers.any(HashMap.class))) + .thenReturn(chartValueColAxis); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent11Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartOrientation")).thenReturn("vertical"); + when(AppUtils.getRequestNvlValue(mockedRequest, "secondaryChartRenderer")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn("BarChart3D"); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + chartGroups.add("test"); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setDependsOnFormField("test"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnType.setColType("chart_total"); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + ArrayList chartValueColAxis = new ArrayList(); + chartValueColAxis.add("test"); + Mockito.when(rr.getChartValueColumnAxisList(Matchers.anyInt(), Matchers.any(HashMap.class))) + .thenReturn(chartValueColAxis); + + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent12Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartOrientation")).thenReturn("vertical"); + when(AppUtils.getRequestNvlValue(mockedRequest, "secondaryChartRenderer")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn("BarChart3D"); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + chartGroups.add("test|123"); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("chart_total"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setDependsOnFormField("test"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnType.setColType("chart_total"); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + ArrayList chartValueColAxis = new ArrayList(); + chartValueColAxis.add("test|123"); + Mockito.when(rr.getChartValueColumnAxisList(Matchers.anyInt(), Matchers.any(HashMap.class))) + .thenReturn(chartValueColAxis); + + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test(expected = java.lang.NullPointerException.class) + public void createPdfFileContent13Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + Rectangle rectangle = Mockito.mock(Rectangle.class); + Mockito.when(doc.getPageSize()).thenReturn(rectangle); + Mockito.when(rectangle.rotate()).thenReturn(rectangle); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartOrientation")).thenReturn("vertical"); + when(AppUtils.getRequestNvlValue(mockedRequest, "secondaryChartRenderer")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(""); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + chartGroups.add("test|123"); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("chart_total"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setDependsOnFormField("test"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnType.setColType("chart_total"); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + ArrayList chartValueColAxis = new ArrayList(); + chartValueColAxis.add("test|123"); + Mockito.when(rr.getChartValueColumnAxisList(Matchers.anyInt(), Matchers.any(HashMap.class))) + .thenReturn(chartValueColAxis); + Mockito.when(rr.getReportType()).thenReturn("Linear"); + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + DataRow dataRow2 = new DataRow(); + + ArrayList dataValueList = new ArrayList<>(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setVisible(true); + value.setBold(true); + HtmlFormatter cfmt = new HtmlFormatter(); + value.setCellFormatter(cfmt); + DataValue value1 = new DataValue(); + HtmlFormatter cfmt1 = new HtmlFormatter(); + cfmt1.setBold(true); + cfmt1.setItalic(true); + cfmt1.setUnderline(true); + cfmt1.setFontColor("red"); + cfmt1.setFontSize("1.1"); + value1.setRowFormatter(cfmt1); + + DataValue value2 = new DataValue(); + value2.setColId("test"); + value2.setVisible(true); + value2.setBold(true); + dataValueList.add(value); + dataValueList.add(value1); + dataValueList.add(value2); + dataRow.addDataValue(value); + dataRow.addDataValue(value1); + dataRow.addDataValue(value2); + dataRow.setDataValueList(dataValueList); + + dataRow2.addDataValue(value); + dataRow2.addDataValue(value1); + dataRow2.addDataValue(value2); + dataRow2.setDataValueList(dataValueList); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + dataRow1.addDataValue(value2); + dataRow1.setDataValueList(dataValueList); + + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow2); + reportDataRows.add(dataRow2); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + + rd.reportDataRows = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + + RowHeader rowHeader = new RowHeader(); + RowHeader rowHeader1 = new RowHeader(); + RowHeader rowHeader2 = new RowHeader(); + + rowHeader.setBold(false); + rowHeader1.setBold(true); + rowHeaderCol.add(rowHeader); + rowHeaderCol.add(rowHeader1); + rowHeaderCol.add(rowHeader2); + + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + + rowHeaderCol1.add(rowHeader); + rowHeaderCol1.add(rowHeader1); + rowHeaderCol1.add(rowHeader2); + + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(reportHandler.loadReportRuntime(Matchers.any(HttpServletRequest.class), Matchers.anyString(), + Matchers.anyBoolean(), Matchers.anyInt())).thenReturn(rr); + Mockito.when(rr.getPDFOrientation()).thenReturn("orientation"); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(1); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + Mockito.when(Globals.getDataFontSizeOffset()).thenReturn((float) 1.0); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent14Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + Rectangle rectangle = Mockito.mock(Rectangle.class); + Mockito.when(doc.getPageSize()).thenReturn(rectangle); + Mockito.when(rectangle.rotate()).thenReturn(rectangle); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartOrientation")).thenReturn("vertical"); + when(AppUtils.getRequestNvlValue(mockedRequest, "secondaryChartRenderer")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(""); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + chartGroups.add("test|123"); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("chart_total"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setDependsOnFormField("test"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnType.setColType("chart_total"); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + ArrayList chartValueColAxis = new ArrayList(); + chartValueColAxis.add("test|123"); + Mockito.when(rr.getChartValueColumnAxisList(Matchers.anyInt(), Matchers.any(HashMap.class))) + .thenReturn(chartValueColAxis); + Mockito.when(rr.getReportType()).thenReturn("Linear"); + + ReportDataRows reportDataRows1 = new ReportDataRows(); + + rd.reportDataRows = reportDataRows1; + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataTotalRow = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + + RowHeader rowHeader = new RowHeader(); + RowHeader rowHeader1 = new RowHeader(); + RowHeader rowHeader2 = new RowHeader(); + + rowHeader.setBold(false); + rowHeader1.setBold(true); + rowHeaderCol.add(rowHeader); + rowHeaderCol.add(rowHeader1); + rowHeaderCol.add(rowHeader2); + + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + + rowHeaderCol1.add(rowHeader); + rowHeaderCol1.add(rowHeader1); + rowHeaderCol1.add(rowHeader2); + + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(reportHandler.loadReportRuntime(Matchers.any(HttpServletRequest.class), Matchers.anyString(), + Matchers.anyBoolean(), Matchers.anyInt())).thenReturn(rr); + Mockito.when(rr.getPDFOrientation()).thenReturn("orientation"); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(1); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + Mockito.when(Globals.getDataFontSizeOffset()).thenReturn((float) 1.0); + when(mockedRequest.getSession().getAttribute("FOOTER_0")).thenReturn("footer"); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent15Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + Rectangle rectangle = Mockito.mock(Rectangle.class); + Mockito.when(doc.getPageSize()).thenReturn(rectangle); + Mockito.when(rectangle.rotate()).thenReturn(rectangle); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartOrientation")).thenReturn("vertical"); + when(AppUtils.getRequestNvlValue(mockedRequest, "secondaryChartRenderer")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(""); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + chartGroups.add("test|123"); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("chart_total"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setDependsOnFormField("test"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnType.setColType("chart_total"); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + ArrayList chartValueColAxis = new ArrayList(); + chartValueColAxis.add("test|123"); + Mockito.when(rr.getChartValueColumnAxisList(Matchers.anyInt(), Matchers.any(HashMap.class))) + .thenReturn(chartValueColAxis); + Mockito.when(rr.getReportType()).thenReturn("Cross-Tab"); + + ReportDataRows reportDataRows1 = new ReportDataRows(); + + rd.reportDataRows = reportDataRows1; + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataTotalRow = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + + RowHeader rowHeader = new RowHeader(); + RowHeader rowHeader1 = new RowHeader(); + RowHeader rowHeader2 = new RowHeader(); + + rowHeader.setBold(false); + rowHeader1.setBold(true); + rowHeaderCol.add(rowHeader); + rowHeaderCol.add(rowHeader1); + rowHeaderCol.add(rowHeader2); + + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + + rowHeaderCol1.add(rowHeader); + rowHeaderCol1.add(rowHeader1); + rowHeaderCol1.add(rowHeader2); + + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(reportHandler.loadReportRuntime(Matchers.any(HttpServletRequest.class), Matchers.anyString(), + Matchers.anyBoolean(), Matchers.anyInt())).thenReturn(rr); + Mockito.when(rr.getPDFOrientation()).thenReturn("orientation"); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(1); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + Mockito.when(Globals.getDataFontSizeOffset()).thenReturn((float) 1.0); + when(mockedRequest.getSession().getAttribute("FOOTER_0")).thenReturn("footer"); + + List getReportDataList = new ArrayList<>(); + getReportDataList.add(dataRow); + getReportDataList.add(dataRow1); + Mockito.when(rd.getReportDataList()).thenReturn(getReportDataList); + + Vector<DataValue> rowValues = new Vector(); + rowValues.add(value1); + rowValues.add(value1); + + ArrayList dataValueList = new ArrayList<>(); + value.setColId("test"); + value.setVisible(true); + DataValue value2 = new DataValue(); + HtmlFormatter cfmt = new HtmlFormatter(); + value.setCellFormatter(cfmt); + + dataValueList.add(value); + dataValueList.add(value1); + dataValueList.add(value2); + dataRow.addDataValue(value); + dataRow.addDataValue(value1); + dataRow.addDataValue(value2); + dataRow.setDataValueList(dataValueList); + dataRow1.setDataValueList(dataValueList); + + dataRow.setRowValues(rowValues); + dataRow1.setRowValues(rowValues); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); + } + + @Test + public void createPdfFileContent_case15Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataRows = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + rowHeaderCol1.add("test1"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + ReportDataRows rdr = new ReportDataRows(); + Connection conn = mock(Connection.class); + Statement st = mock(Statement.class); + ResultSet resSet = mock(ResultSet.class); + ResultSetMetaData resSetMD = mock(ResultSetMetaData.class); + DataRow dr = new DataRow(); + rdr.add(dr); + rd.reportDataRows = rdr; + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieOrder")).thenReturn("row"); + when(AppUtils.getRequestNvlValue(mockedRequest, "multiplePieLabelDisplay")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(AppConstants.GT_PIE_MULTIPLE); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + when(crType.getDataSourceList()).thenReturn(dataSourceList); + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); ds.set(0, "test"); when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); @@ -529,7 +2357,259 @@ public class PdfReportHandlerTest { when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn("test123"); + List newlist = new ArrayList<>(); + newlist.add(1); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)) + .thenReturn(newlist); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_REPORT_DATA)).thenReturn(rd); + Mockito.when(rr.getReportType()).thenReturn("Linear"); + Mockito.when(rd.getTotalColumnCount()).thenReturn(2); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(2); + + List<DataColumnType> dataColumnTypeList = mockDataList(); + List<DataColumnType> dataColumnTypeList1 = new ArrayList<>(); + Mockito.when(rdef.getAllColumns()).thenReturn(dataColumnTypeList); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + when(mockedRequest.getSession().getAttribute("TITLE_0")).thenReturn("title"); + when(mockedRequest.getSession().getAttribute("drilldown_index")).thenReturn("drilldown_index"); + when(mockedRequest.getSession().getAttribute("SUBTITLE_0")).thenReturn("subtitle"); + Mockito.when(mockedRequest.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE)).thenReturn("test"); + PowerMockito.mockStatic(ConnectionUtils.class); + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(conn); + Mockito.when(conn.createStatement()).thenReturn(st); + Mockito.when(st.executeQuery(Matchers.anyString())).thenReturn(resSet); + Mockito.when(resSet.getMetaData()).thenReturn(resSetMD); + Mockito.when(resSetMD.getColumnCount()).thenReturn(2); + Mockito.when(resSet.next()).thenReturn(false); + + rd.reportDataTotalRow = reportDataRows; pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 3); } + + @Test + public void currentTimeTest() { + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getTimeZone()).thenReturn("EST"); + pdfReportHandler.currentTime("11/11/2011 11:11:11"); + } + + public List<DataColumnType> mockDataList() { + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + return dataColumnTypeList; + } + + + @Test(expected = java.lang.NullPointerException.class) + public void createPdfFileContent17Test() throws Exception { + PowerMockito.mockStatic(Image.class); + Document doc = mock(Document.class); + CustomReportType crType = mock(CustomReportType.class); + DataSet ds = mock(DataSet.class); + PowerMockito.whenNew(Document.class).withNoArguments().thenReturn(doc); + PowerMockito.when(doc.newPage()).thenReturn(true); + Rectangle rectangle = Mockito.mock(Rectangle.class); + Mockito.when(doc.getPageSize()).thenReturn(rectangle); + Mockito.when(rectangle.rotate()).thenReturn(rectangle); + when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + ReportRuntime rr = mock(ReportRuntime.class); + ReportData rd = mock(ReportData.class); + when(Globals.isCoverPageNeeded()).thenReturn(true); + when(Globals.getSessionInfoForTheCoverPage()).thenReturn("test,test1"); + when(AppUtils.getRequestNvlValue(mockedRequest, "test1")).thenReturn("test1"); + when(rr.isPDFCoverPage()).thenReturn(true); + when(rr.getReportID()).thenReturn("test"); + when(rr.getPDFOrientation()).thenReturn("portait"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartOrientation")).thenReturn("vertical"); + when(AppUtils.getRequestNvlValue(mockedRequest, "secondaryChartRenderer")).thenReturn("test"); + when(AppUtils.getRequestNvlValue(mockedRequest, "chartDisplay")).thenReturn("3D"); + when(mockedRequest.getSession().getAttribute("report_runtime")).thenReturn(rr); + when(mockedRequest.getSession().getAttribute("dashboard_report_id")).thenReturn("test123"); + ServletContext servConxt = mock(ServletContext.class); + when(mockedRequest.getSession().getServletContext()).thenReturn(servConxt); + when(servConxt.getRealPath(File.separator)).thenReturn("testpath"); + when(rr.getChartType()).thenReturn(""); + when(rr.getDisplayChart()).thenReturn(true); + ArrayList paramNamePDFValues = new ArrayList(); + paramNamePDFValues.add("test1"); + paramNamePDFValues.add("test2"); + when(rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2)).thenReturn(paramNamePDFValues); + when(rr.getFormFieldComments(mockedRequest)).thenReturn("test"); + when(rr.getLegendPosition()).thenReturn("test"); + when(rr.hideChartToolTips()).thenReturn(true); + when(AppUtils.getRequestNvlValue(mockedRequest, "hideLegend")).thenReturn("Y"); + when(rr.getLegendLabelAngle()).thenReturn("test"); + when(rr.getMaxLabelsInDomainAxis()).thenReturn("test"); + when(rr.getRangeAxisLowerLimit()).thenReturn("10"); + when(rr.getRangeAxisUpperLimit()).thenReturn("10"); + when(AppUtils.getRequestNvlValue(mockedRequest, "totalOnChart")).thenReturn("Y"); + List chartGroups = new ArrayList<>(); + chartGroups.add("test|123"); + when(rr.getAllChartGroups()).thenReturn(chartGroups); + ReportParamValues reportValues = new ReportParamValues(); + when(rr.getReportParamValues()).thenReturn(reportValues); + when(rr.getFormFieldFilled(rr.getChartLeftAxisLabel())).thenReturn("test"); + when(rr.getFormFieldFilled(rr.getChartRightAxisLabel())).thenReturn("test"); + HashMap requestParams = new HashMap<>(); + requestParams.put("", "test"); + + DataSourceList dataSourceList = new DataSourceList(); + + List<DataSourceType> list = new ArrayList<>(); + DataSourceType dataSourceType = new DataSourceType(); + dataSourceType.setTableName("test"); + dataSourceType.setRefTableId("1"); + dataSourceType.setTableId("1"); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("chart_total"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("chart_total"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setDependsOnFormField("test"); + dataColumnType.setColType("DATE"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setPdfDisplayWidthInPxls("0.0"); + dataColumnType.setVisible(true); + dataColumnType.setCalculated(true); + dataColumnType.setColType("chart_total"); + dataColumnTypeList.add(dataColumnType); + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setCrossTabValue("COLUMN"); + dataColumnType1.setColId("1"); + dataColumnType1.setVisible(true); + dataColumnType1.setPdfDisplayWidthInPxls("1.0"); + dataColumnTypeList.add(dataColumnType1); + + DataColumnList dataColumnList = new DataColumnList(); + dataColumnList.dataColumn = dataColumnTypeList; + dataSourceType.setDataColumnList(dataColumnList); + list.add(dataSourceType); + dataSourceList.dataSource = list; + when(crType.getDataSourceList()).thenReturn(dataSourceList); + + when(Globals.getRequestParamtersMap(mockedRequest, false)).thenReturn(requestParams); + ds.set(0, "test"); + when(mockedRequest.getSession().getAttribute(AppConstants.RI_CHART_DATA)).thenReturn(ds); + when(rr.hasSeriesColumn()).thenReturn(true); + TreeMap values = new TreeMap<>(); + values.put("test", rr); + TreeMap values2 = new TreeMap<>(); + values2.put("test3", rd); + TreeMap values3 = new TreeMap<>(); + values3.put("test4", "c"); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(values); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(values2); + when(mockedRequest.getSession().getAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP)).thenReturn(values3); + + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + ArrayList chartValueColAxis = new ArrayList(); + chartValueColAxis.add("test|123"); + Mockito.when(rr.getChartValueColumnAxisList(Matchers.anyInt(), Matchers.any(HashMap.class))) + .thenReturn(chartValueColAxis); + Mockito.when(rr.getReportType()).thenReturn("Linear"); + + + + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataRow dataRow = new DataRow(); + + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + rd.reportDataTotalRow = reportDataRows; + rd.reportDataRows = reportDataRows; + + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + + RowHeader rowHeader = new RowHeader(); + RowHeader rowHeader1 = new RowHeader(); + RowHeader rowHeader2 = new RowHeader(); + + rowHeader.setBold(false); + rowHeader1.setBold(true); + rowHeaderCol.add(rowHeader); + rowHeaderCol.add(rowHeader1); + rowHeaderCol.add(rowHeader2); + + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + + rowHeaderCol1.add(rowHeader); + rowHeaderCol1.add(rowHeader1); + rowHeaderCol1.add(rowHeader2); + + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportDefinition(Matchers.any(HttpServletRequest.class), Matchers.anyString())) + .thenReturn(rdef); + Mockito.when(reportHandler.loadReportRuntime(Matchers.any(HttpServletRequest.class), Matchers.anyString(), + Matchers.anyBoolean(), Matchers.anyInt())).thenReturn(rr); + Mockito.when(rr.getPDFOrientation()).thenReturn("orientation"); + Mockito.when(rdef.getVisibleColumnCount()).thenReturn(1); + Mockito.when(Globals.getDataTableHeaderFontColor()).thenReturn("test"); + PowerMockito.mockStatic(Color.class); + Color color = new Color(1); + Mockito.when(Color.decode(Matchers.anyString())).thenReturn(color); + Mockito.when(Globals.getDataFontSizeOffset()).thenReturn((float) 1.0); + when(mockedRequest.getSession().getAttribute("FOOTER_0")).thenReturn("footer"); + List newlist = new ArrayList<>(); + newlist.add(1); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)) + .thenReturn(newlist); + Mockito.when(rd.getTotalColumnCount()).thenReturn(2); + pdfReportHandler.createPdfFileContent(mockedRequest, mockedResponse, 2); + } + + } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ReportRuntimeTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ReportRuntimeTest.java index 668304fd..0bdaeb0f 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ReportRuntimeTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ReportRuntimeTest.java @@ -37,9 +37,15 @@ */ package org.onap.portalsdk.analytics.xmlobj; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.ArrayList; +import java.util.Enumeration; import java.util.List; import java.util.Vector; @@ -57,7 +63,9 @@ import org.onap.portalsdk.analytics.model.base.ReportWrapper; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; import org.onap.portalsdk.analytics.model.runtime.FormField; import org.onap.portalsdk.analytics.model.runtime.ReportFormFields; +import org.onap.portalsdk.analytics.model.runtime.ReportJSONRuntime; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; +import org.onap.portalsdk.analytics.model.runtime.VisualManager; import org.onap.portalsdk.analytics.system.AppUtils; import org.onap.portalsdk.analytics.system.ConnectionUtils; import org.onap.portalsdk.analytics.system.DbUtils; @@ -69,10 +77,16 @@ import org.onap.portalsdk.analytics.util.Utils; import org.onap.portalsdk.analytics.util.XSSFilter; import org.onap.portalsdk.analytics.view.ColumnHeader; import org.onap.portalsdk.analytics.view.ColumnHeaderRow; +import org.onap.portalsdk.analytics.view.ColumnVisual; +import org.onap.portalsdk.analytics.view.DataRow; +import org.onap.portalsdk.analytics.view.DataValue; +import org.onap.portalsdk.analytics.view.HtmlFormatter; import org.onap.portalsdk.analytics.view.ReportColumnHeaderRows; import org.onap.portalsdk.analytics.view.ReportData; +import org.onap.portalsdk.analytics.view.ReportDataRows; import org.onap.portalsdk.analytics.view.ReportRowHeaderCols; import org.onap.portalsdk.analytics.view.RowHeaderCol; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SecurityCodecUtil; import org.onap.portalsdk.core.web.support.UserUtils; import org.owasp.esapi.ESAPI; @@ -123,10 +137,13 @@ public class ReportRuntimeTest { dataColumnType.setColId("1"); dataColumnType.setTableId("1"); dataColumnType.setColType("DATE"); - dataColumnType.setDependsOnFormField("tes[t"); + dataColumnType.setDependsOnFormField("[test]"); dataColumnType.setDrillDownParams("drilldown[#]"); dataColumnType.setCrossTabValue("VALUE"); - dataColumnType.setDrillDownURL("url"); + dataColumnType.setDrillDownURL("drillDownUrl"); + dataColumnType.setDisplayTotal("test|test2"); + dataColumnType.setOrderBySeq(10); + dataColumnType.setVisible(true); dataColumnTypeList.add(dataColumnType); DataColumnList dataColumnList = new DataColumnList(); dataColumnList.dataColumn = dataColumnTypeList; @@ -176,8 +193,46 @@ public class ReportRuntimeTest { rr.setLegendLabelAngle("test"); rr.setMultiSeries(false); rr.setChartType("test"); + rr.setXmlFileName("test"); + rr.setXmlFileURL("test"); + rr.setFlatFileName("test"); + rr.setExcelPageFileName("test"); + rr.setTotalSql("test"); + rr.setDisplayMode(10); + rr.setDateOption(10); return rr; } + + @Test + public void testReportRuntimeProperties() throws Exception { + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.isDashboardType(Mockito.any(String.class))).thenReturn(true); + ReportRuntime rr = mockReportRunTime1(); + assertEquals("test", rr.getXmlFileURL()); + assertEquals("test", rr.getXmlFileName()); + assertEquals("test", rr.getFlatFileName()); + assertEquals("test", rr.getExcelPageFileName()); + assertTrue(rr.getDisplayForm()); + assertTrue(rr.getDisplayContent()); + assertEquals(-1, rr.getCachedPageNo()); + assertEquals(null, rr.getCachedSQL()); + assertTrue(rr.isDashboardType()); + assertEquals("test", rr.getParamValue("test")); + assertEquals("test", rr.getParamDisplayValue("test")); + rr.getParamKeys(); + rr.getParamKeysForPDFExcel(); + assertEquals("test", rr.getParamValueForPDFExcel("test")); + assertEquals(FormField.class, rr.getFormField("test").getClass()); + assertEquals("test", rr.getTotalSql()); + assertEquals(VisualManager.class, rr.getVisualManager().getClass()); + assertEquals(" null) x ", rr.getReportSQLWithRowNum("test", true)); + assertEquals(10, rr.getDisplayMode()); + assertEquals(10, rr.getDateOption()); + assertFalse(rr.isDisplayColTotals()); + assertFalse(rr.isDisplayRowTotals()); + rr.showColVisual("test"); + rr.sortColVisual("test"); + } @Test public void getParamNameValuePairsTest() throws Exception { @@ -188,13 +243,53 @@ public class ReportRuntimeTest { @Test public void getParamNameValuePairsforPDFExcelTest() throws Exception { ReportRuntime rr = mockReportRunTime1(); - rr.setReportFormFields(null); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(ESAPI.class); List predefinedValues = new ArrayList<>(); ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, true, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + rr.setReportFormFields(null); + rr.setReportFormFields(reportFormFields); + + + Mockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + Mockito.when(Globals.getDisplaySessionParamInPDFEXCEL()).thenReturn("test,test"); + HttpSession session = mockedRequest.getSession(); + Mockito.when(session.getAttribute("test")).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,test"); + Mockito.when(mockedRequest.getParameter(Mockito.any(String.class))).thenReturn("test"); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("test"); + rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2); + + } + + @Test + public void getParamNameValuePairsforPDFExcelTest_WhenIsScheduleFlagTrue() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(ESAPI.class); + List predefinedValues = new ArrayList<>(); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, true, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", "rangeEndDateSQL", "multiSelectListSize"); @@ -208,17 +303,23 @@ public class ReportRuntimeTest { rr.setReportFormFields(null); rr.setReportFormFields(reportFormFields); - PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); Mockito.when(Globals.getDisplaySessionParamInPDFEXCEL()).thenReturn("test,test"); HttpSession session = mockedRequest.getSession(); Mockito.when(session.getAttribute("test")).thenReturn("test"); Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,test"); + Mockito.when(AppUtils.getRequestValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); + Mockito.when(mockedRequest.getParameter(Mockito.any(String.class))).thenReturn("test"); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("test"); rr.getParamNameValuePairsforPDFExcel(mockedRequest, 2); } - @Test(expected = java.lang.ArrayIndexOutOfBoundsException.class) + @Test public void getParamNameValuePairsforPDFExcel1Test() throws Exception { ReportRuntime rr = mockReportRunTime1(); rr.setReportFormFields(null); @@ -226,7 +327,7 @@ public class ReportRuntimeTest { ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", true, - "defaultValue", "helpText", predefinedValues, true, "dependsOn", null, null, "rangeStartDateSQL", + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", "rangeEndDateSQL", "multiSelectListSize"); FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", @@ -241,15 +342,65 @@ public class ReportRuntimeTest { reportFormFields.add(formField2); reportFormFields.add(formField3); - rr.setReportFormFields(null); rr.setReportFormFields(reportFormFields); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + Mockito.when(Globals.getDisplaySessionParamInPDFEXCEL()).thenReturn(";test,;test"); + HttpSession session = mockedRequest.getSession(); + Mockito.when(session.getAttribute("test")).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + rr.getParamNameValuePairsforPDFExcel(mockedRequest, 1); + } + + @Test + public void getParamNameValuePairsforPDFExcel1Test_WhenIsScheduleFlagTrue() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + rr.setReportFormFields(null); + List predefinedValues = new ArrayList<>(); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", true, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField3 = PowerMockito.mock(FormField.class); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + reportFormFields.add(formField3); + + rr.setReportFormFields(reportFormFields); PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ESAPI.class); Mockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); - Mockito.when(Globals.getDisplaySessionParamInPDFEXCEL()).thenReturn("test,test"); + Mockito.when(Globals.getDisplaySessionParamInPDFEXCEL()).thenReturn(";test,;test"); + Mockito.when(Globals.getDisplayScheduleSessionParamInPDFEXCEL()).thenReturn(";test,;test"); HttpSession session = mockedRequest.getSession(); Mockito.when(session.getAttribute("test")).thenReturn("test"); Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(AppUtils.getRequestValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("DATE"); + rr.getParamNameValuePairsforPDFExcel(mockedRequest, 1); + + } + + @Test + public void getParamNameValuePairsforPDFExcelTest_WhenValueExistInSession() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + List paramList = new ArrayList<>(); + paramList.add("test"); + HttpSession session = mockedRequest.getSession(); + Mockito.when(session.getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)).thenReturn(paramList); rr.getParamNameValuePairsforPDFExcel(mockedRequest, 1); } @@ -257,7 +408,40 @@ public class ReportRuntimeTest { @Test public void getFormFieldCommentsTest() throws Exception { ReportRuntime rr = mockReportRunTime1(); - rr.getCustomReport().getFormFieldList().setComment(""); + rr.getCustomReport().getFormFieldList().setComment("test"); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(ESAPI.class); + List predefinedValues = new ArrayList<>(); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, true, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + rr.setReportFormFields(null); + rr.setReportFormFields(reportFormFields); + + + Mockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + Mockito.when(Globals.getDisplaySessionParamInPDFEXCEL()).thenReturn("test,test"); + HttpSession session = mockedRequest.getSession(); + Mockito.when(session.getAttribute("test")).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,test"); + Mockito.when(AppUtils.getRequestValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test"); + Mockito.when(mockedRequest.getParameter(Mockito.any(String.class))).thenReturn("test"); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("DATE"); rr.getFormFieldComments(mockedRequest); } @@ -265,8 +449,7 @@ public class ReportRuntimeTest { public void loadChartDataTest() throws Exception { ReportRuntime rr = mockReportRunTime1(); rr.getCustomReport().getFormFieldList().setComment(""); - DataSet ds = PowerMockito.mock(DataSet.class); - rr.setChartDataCache(ds); + rr.setChartDataCache(null); rr.loadChartData("test", mockedRequest); } @@ -304,6 +487,40 @@ public class ReportRuntimeTest { rr.getCustomReport().getFormFieldList().setComment(""); rr.getCustomReport().setReportType("Linear"); rr.setWholeSQL("testFROMORDERBY"); + rr.getFormFieldList().getFormField().get(0).setGroupFormField(true); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test]"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("testLEGEND"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setDependsOnFormField("[test]"); + dataColumnType.setDrillDownParams("drilldown[#]"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setDrillDownURL("drillDownUrl"); + dataColumnType.setDisplayTotal("test|test2"); + dataColumnType.setVisible(true); + rr.getCustomReport().getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn().add(dataColumnType); + rr.getAllColumns().add(dataColumnType); + dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test]"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("testLEGEND"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setDependsOnFormField("[test]"); + dataColumnType.setDrillDownParams("drilldown[#]"); + dataColumnType.setCrossTabValue("COLUMN"); + dataColumnType.setDrillDownURL("drillDownUrl"); + dataColumnType.setDisplayTotal("test|test2"); + rr.getCustomReport().getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn().add(dataColumnType); + rr.getAllColumns().add(dataColumnType); DataSet ds = PowerMockito.mock(DataSet.class); rr.setChartDataCache(ds); PowerMockito.mockStatic(AppUtils.class); @@ -312,13 +529,156 @@ public class ReportRuntimeTest { Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("actionsession"); Mockito.when(ConnectionUtils.getDataSet(Matchers.anyString(), Matchers.anyString())).thenReturn(ds); Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getColumnCount()).thenReturn(1); + Mockito.when(ds.getColumnName(Mockito.anyInt())).thenReturn("1"); Mockito.when(Globals.getGenerateSubsetSql()).thenReturn("subsetSql"); Mockito.when(Globals.getReportSqlOnlyFirstPart()).thenReturn("subsetSql"); Mockito.when(Globals.getReportSqlOnlySecondPartA()).thenReturn("secondpartA"); Mockito.when(Globals.getReportSqlOnlySecondPartB()).thenReturn("secondpartB"); Mockito.when(AppUtils.isNotEmpty(Matchers.anyString())).thenReturn(false); Mockito.when(Globals.getDBType()).thenReturn("db"); - rr.loadReportData(1, "userId", 1, mockedRequest, false); + + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + Mockito.when(Globals.getLoadCrosstabReportData()).thenReturn("test FROM ORDER BY"); + ReportData rd = PowerMockito.mock(ReportData.class); + PowerMockito.whenNew(ReportData.class).withArguments(Mockito.anyInt(), Mockito.anyBoolean()).thenReturn(rd); + ReportDataRows reportDataRows = new ReportDataRows(); + rd.reportDataRows= reportDataRows; + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + rowHeaderCol1.add("test1"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(), Mockito.anyString())).thenReturn(ds); + ReportRuntime rr1 = PowerMockito.mock(ReportRuntime.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr1); + Mockito.when(rr1.getReportID()).thenReturn("lDownUrl"); + Mockito.when(rr1.getReportFormFields()).thenReturn(rr.getReportFormFields()); + rr.setDisplayColTotals(true); + rr.setDisplayRowTotals(true); + Mockito.when(Globals.getCacheCurPageData()).thenReturn(true); + Mockito.when(mockedRequest.getParameter(Mockito.anyString())).thenReturn("test"); + rr.loadReportData(1, "userId", 1, mockedRequest, true); + } + + @Test(expected=RuntimeException.class) + public void loadReportData1Test_WhenReportDataSizeIsLessThanZero() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + rr.getCustomReport().getFormFieldList().setComment(""); + rr.getCustomReport().setReportType("Linear"); + rr.setWholeSQL("SELECT report_id test FROM WHERE ORDER BY"); + rr.setPageSize(-2); + rr.getFormFieldList().getFormField().get(0).setGroupFormField(true); + rr.setDBInfo("DEV"); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test]"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("testLEGEND"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setDependsOnFormField("[test]"); + dataColumnType.setDrillDownParams("drilldown[#]"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setDrillDownURL("drillDownUrl"); + dataColumnType.setDisplayTotal("test|test2"); + dataColumnType.setVisible(true); + rr.getCustomReport().getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn().add(dataColumnType); + rr.getAllColumns().add(dataColumnType); + dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test]"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("testLEGEND"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setDependsOnFormField("[test]"); + dataColumnType.setDrillDownParams("drilldown[#]"); + dataColumnType.setCrossTabValue("COLUMN"); + dataColumnType.setDrillDownURL("drillDownUrl"); + dataColumnType.setDisplayTotal("test|test2"); + rr.getCustomReport().getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn().add(dataColumnType); + rr.getAllColumns().add(dataColumnType); + DataSet ds = PowerMockito.mock(DataSet.class); + rr.setChartDataCache(ds); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(ConnectionUtils.class); + Mockito.when(AppUtils.getRequestFlag(mockedRequest, AppConstants.RI_GO_BACK)).thenReturn(false); + Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("actionsession"); + Mockito.when(ConnectionUtils.getDataSet(Matchers.anyString(), Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(-1); + Mockito.when(Globals.getGenerateSubsetSql()).thenReturn("subsetSql"); + Mockito.when(Globals.getReportSqlOnlyFirstPart()).thenReturn("subsetSql"); + Mockito.when(Globals.getReportSqlOnlySecondPartA()).thenReturn("secondpartA"); + Mockito.when(Globals.getReportSqlOnlySecondPartB()).thenReturn("secondpartB"); + Mockito.when(AppUtils.isNotEmpty(Matchers.anyString())).thenReturn(false); + Mockito.when(Globals.getDBType()).thenReturn("db"); + + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + Mockito.when(Globals.getLoadCrosstabReportData()).thenReturn("test FROM ORDER BY"); + ReportData rd = PowerMockito.mock(ReportData.class); + PowerMockito.whenNew(ReportData.class).withArguments(Mockito.anyInt(), Mockito.anyBoolean()).thenReturn(rd); + ReportDataRows reportDataRows = new ReportDataRows(); + rd.reportDataRows= reportDataRows; + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); + ColumnHeader columnHeader = new ColumnHeader(); + columnHeaderRow.add(columnHeader); + ColumnHeader columnHeader1 = new ColumnHeader(); + columnHeader1.setRowSpan(1); + columnHeaderRow.add(columnHeader1); + reportColumnHeaderRows.add(columnHeaderRow); + rd.reportColumnHeaderRows = reportColumnHeaderRows; + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + rowHeaderCol1.add("test1"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + rd.reportRowHeaderCols = reportRowHeaderCols; + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(), Mockito.anyString())).thenReturn(ds); + ReportRuntime rr1 = PowerMockito.mock(ReportRuntime.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr1); + Mockito.when(rr1.getReportID()).thenReturn("lDownUrl"); + Mockito.when(rr1.getReportFormFields()).thenReturn(rr.getReportFormFields()); + rr.setDisplayColTotals(true); + rr.setDisplayRowTotals(true); + Mockito.when(Globals.getCacheCurPageData()).thenReturn(true); + Mockito.when(mockedRequest.getParameter(Mockito.anyString())).thenReturn("test"); + rr.getCustomReport().setDbInfo("DAYTONA"); + RemDbInfo rdemo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(rdemo); + Mockito.when(rdemo.getDBType(Matchers.anyString())).thenReturn("DAYTONA"); + rr.loadReportData(1, "userId", 1, mockedRequest, true); } @Test @@ -356,6 +716,39 @@ public class ReportRuntimeTest { rr.getCustomReport().getFormFieldList().setComment(""); rr.getCustomReport().setReportType("Cross-Tab"); rr.setWholeSQL("testFROMORDERBY"); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("testLEGEND"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setDependsOnFormField("[test]"); + dataColumnType.setDrillDownParams("drilldown[#]"); + dataColumnType.setCrossTabValue("ROW"); + dataColumnType.setDrillDownURL("drillDownUrl"); + dataColumnType.setDisplayTotal("test|test2"); + dataColumnType.setVisible(true); + rr.getCustomReport().getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn().add(dataColumnType); + rr.getAllColumns().add(dataColumnType); + dataColumnType = new DataColumnType(); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("testLEGEND"); + dataColumnType.setColId("1"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setDependsOnFormField("[test]"); + dataColumnType.setDrillDownParams("drilldown[#]"); + dataColumnType.setCrossTabValue("COLUMN"); + dataColumnType.setDrillDownURL("drillDownUrl"); + dataColumnType.setDisplayTotal("test|test2"); + rr.getCustomReport().getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn().add(dataColumnType); + rr.getAllColumns().add(dataColumnType); DataSet ds = PowerMockito.mock(DataSet.class); rr.setChartDataCache(ds); PowerMockito.mockStatic(AppUtils.class); @@ -364,10 +757,13 @@ public class ReportRuntimeTest { Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("actionsession"); Mockito.when(ConnectionUtils.getDataSet(Matchers.anyString(), Matchers.anyString())).thenReturn(ds); Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getColumnCount()).thenReturn(1); + Mockito.when(ds.getColumnName(Mockito.anyInt())).thenReturn("1"); Mockito.when(Globals.getGenerateSubsetSql()).thenReturn("subsetSql"); Mockito.when(Globals.getReportSqlOnlyFirstPart()).thenReturn("subsetSql"); Mockito.when(Globals.getReportSqlOnlySecondPartA()).thenReturn("secondpartA"); Mockito.when(Globals.getReportSqlOnlySecondPartB()).thenReturn("secondpartB"); + Mockito.when(Globals.getMergeCrosstabRowHeadings()).thenReturn(true); Mockito.when(AppUtils.isNotEmpty(Matchers.anyString())).thenReturn(false); Mockito.when(Globals.getDBType()).thenReturn("db"); PowerMockito.mockStatic(ESAPI.class); @@ -377,7 +773,7 @@ public class ReportRuntimeTest { Codec codec = PowerMockito.mock(Codec.class); Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); - Mockito.when(Globals.getLoadCrosstabReportData()).thenReturn("reportdata"); + Mockito.when(Globals.getLoadCrosstabReportData()).thenReturn("test FROM ORDER BY"); ReportData rd = PowerMockito.mock(ReportData.class); PowerMockito.whenNew(ReportData.class).withArguments(Mockito.anyInt(), Mockito.anyBoolean()).thenReturn(rd); ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); @@ -397,6 +793,14 @@ public class ReportRuntimeTest { reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); rd.reportRowHeaderCols = reportRowHeaderCols; + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(), Mockito.anyString())).thenReturn(ds); + ReportRuntime rr1 = PowerMockito.mock(ReportRuntime.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr1); + Mockito.when(rr1.getReportID()).thenReturn("nUrl"); + Mockito.when(rr1.getReportFormFields()).thenReturn(rr.getReportFormFields()); + rr.setDisplayColTotals(true); + rr.setDisplayRowTotals(true); + Mockito.when(Globals.getMergeCrosstabRowHeadings()).thenReturn(true); rr.loadReportData(1, "userId", 1, mockedRequest, false); } @@ -512,6 +916,49 @@ public class ReportRuntimeTest { Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyString())).thenReturn("test"); rr.parseDrillDownURL(1, ds, dataColumnType, mockedRequest, reportFormFields); } + + @Test + public void parseDrillDownURL2Test() throws Exception { + DataSet ds = PowerMockito.mock(DataSet.class); + ReportRuntime rr = mockReportRunTime1(); + DataColumnType dataColumnType = rr.getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn().get(0); + dataColumnType.setChartGroup("test"); + dataColumnType.setYAxis("test"); + dataColumnType.setColName("[test"); + dataColumnType.setColOnChart("LEGEND"); + dataColumnType.setDisplayName("testLEGEND"); + dataColumnType.setColId("test"); + dataColumnType.setTableId("1"); + dataColumnType.setColType("DATE"); + dataColumnType.setDependsOnFormField("tes[t"); + dataColumnType.setDrillDownParams("drilldown[test!test]"); + dataColumnType.setCrossTabValue("VALUE"); + dataColumnType.setDrillDownURL("testutilstest1"); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "testLEGEND", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", new ArrayList(), true, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + reportFormFields.add(formField); + PowerMockito.mockStatic(DataCache.class); + PowerMockito.mockStatic(AppUtils.class); + + Vector vc = new Vector<>(); + vc.add("test"); + Mockito.when(DataCache.getDataViewActions()).thenReturn(vc); + Mockito.when(Globals.getPassRequestParamInDrilldown()).thenReturn(true); + Mockito.when(Globals.getRequestParams()).thenReturn("FFtest,1"); + Mockito.when(Globals.getRequestParams()).thenReturn("test,1"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,2"); + Mockito.when(Globals.getSessionParams()).thenReturn("FFtest,2"); + + Mockito.when(mockedRequest.getParameter(Matchers.anyString())).thenReturn("test"); + Mockito.when(AppUtils.getBaseActionURL()).thenReturn("testutils"); + Mockito.when(AppUtils.getBaseActionParam()).thenReturn("utils"); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyString())).thenReturn("test"); + Mockito.when(mockedRequest.getSession().getAttribute("FFTEST")).thenReturn("test"); + rr.parseDrillDownURL(1, ds, dataColumnType, mockedRequest, reportFormFields); + } @Test public void parseReportSQLTest() throws Exception { @@ -537,6 +984,13 @@ public class ReportRuntimeTest { rr.getCustomReport().setDbInfo("test"); rr.parseReportSQL("select * from test"); } + + @Test + public void parseReportSQL5Test() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + rr.getCustomReport().setDbInfo("test"); + rr.parseReportSQL("select id,report_id from test"); + } @Test(expected = org.onap.portalsdk.analytics.error.ValidationException.class) public void parseReportSQL4Test() throws Exception { @@ -547,6 +1001,7 @@ public class ReportRuntimeTest { Mockito.when(rdemo.getDBType(Matchers.anyString())).thenReturn("DAYTONA"); rr.parseReportSQL(""); } + @Test public void setDisplayFlagsTest() throws Exception { @@ -912,4 +1367,212 @@ public class ReportRuntimeTest { rr.parseAndFillWithCurrentValues(mockedRequest, "test", formField); } + + @Test + public void testParseAndFillReq_Session_UserValues_WhenStartWithff() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + Mockito.when(Globals.getRequestParams()).thenReturn("fftest"); + Mockito.when(Globals.getSessionParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn(""); + PowerMockito.when(AppUtils.nvl(Mockito.any(String.class))).thenReturn("test"); + Mockito.when(mockedRequest.getParameter(Mockito.any(String.class))).thenReturn("test"); + Mockito.when(mockedRequest.getAttribute(Mockito.any(String.class))).thenReturn("test"); + rr.parseAndFillReq_Session_UserValues(mockedRequest, "SELECT FROM test", "userID"); + } + + @Test + public void testCreateFormFieldJSONRuntime() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + PowerMockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + Mockito.when(Globals.getRequestParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + PowerMockito.when(AppUtils.nvl(Mockito.any(String.class))).thenReturn("test"); + Mockito.when(mockedRequest.getParameter(Mockito.any(String.class))).thenReturn("test"); + rr.createFormFieldJSONRuntime(mockedRequest); + } + + + + @Test + public void testCreateReportJSONRuntime() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + ReportData rd = mockReportData(); + PowerMockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + PowerMockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + PowerMockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(true); + Mockito.when(Globals.getRequestParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + PowerMockito.when(AppUtils.nvl(Mockito.any(String.class))).thenReturn("test"); + Mockito.when(mockedRequest.getParameter(Mockito.any(String.class))).thenReturn("test"); + rr.createReportJSONRuntime(mockedRequest, rd); + } + + @Test + public void testPersistLinearReport() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + PowerMockito.mockStatic(Utils.class); + PowerMockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + PowerMockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + PowerMockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(true); + Mockito.when(Globals.getRequestParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + PowerMockito.when(AppUtils.nvl(Mockito.any(String.class))).thenReturn("test"); + Mockito.when(mockedRequest.getParameter(Mockito.any(String.class))).thenReturn("test"); + Mockito.when(Utils.getCurrentDateTime()).thenReturn("20/05/2018"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.doNothing().when(ReportLoader.class, "updateCustomReportRec", new Object[] {Mockito.any(Connection.class), Mockito.any(ReportRuntime.class), Mockito.any(String.class)}); + PowerMockito.doNothing().when(ReportLoader.class, "createReportLogEntry", new Object[] {Mockito.any(Connection.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class)}); + rr.persistLinearReport(mockedRequest); + } + + @Test + public void testPersistDashboardReport() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + PowerMockito.mockStatic(Utils.class); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + PowerMockito.when(Utils.getCurrentDateTime()).thenReturn("10/05/2018"); + PowerMockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + PowerMockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(true); + Mockito.when(Globals.getRequestParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + PowerMockito.when(AppUtils.nvl(Mockito.any(String.class))).thenReturn("test"); + Mockito.when(mockedRequest.getParameter(Mockito.any(String.class))).thenReturn("test"); + PowerMockito.doNothing().when(ReportLoader.class, "updateCustomReportRec", new Object[] {Mockito.any(Connection.class), Mockito.any(ReportRuntime.class), Mockito.any(String.class)}); + PowerMockito.doNothing().when(ReportLoader.class, "createReportLogEntry", new Object[] {Mockito.any(Connection.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class)}); + rr.persistDashboardReport(mockedRequest); + } + + public ReportData mockReportData() { + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); + ReportDataRows reportDataRows = new ReportDataRows(); + + DataRow dataRow = new DataRow(); + DataValue dataValue = new DataValue(); + dataValue.setDisplayName("displayName"); + dataValue.setDisplayCalculatedValue("displayCalculatedValue"); + dataValue.setDrillDownURL("drillDownURL"); + dataValue.setDrillDowninPoPUp(false); + dataValue.setIndentation("indentation"); + dataValue.setAlignment("alignment"); + dataValue.setVisible(false); + dataValue.setHidden(false); + HtmlFormatter formatter = new HtmlFormatter(); + dataValue.setCellFormatter(formatter); + dataValue.setBold(false); + dataValue.setRowFormatter(formatter); + dataValue.setFormatId("formatId"); + dataValue.setCellFormat(false); + dataValue.setColId("colId"); + dataValue.setDisplayName("displayName"); + dataValue.setNowrap("nowrap"); + dataValue.setHyperlinkURL("hyperlinkURL"); + dataValue.setDisplayType("displayType"); + dataValue.setActionImg("actionImg"); + dataRow.addDataValue(dataValue); + reportDataRows.addDataRow(dataRow); + ArrayList<DataValue> list = new ArrayList<>(); + list.add(dataValue); + dataRow.setDataValueList(list); + ReportData reportData = new ReportData(1, true); + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + rowHeaderCol.add("test"); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + reportData.reportColumnHeaderRows = reportColumnHeaderRows; + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + reportData.reportDataRows = reportDataRows; + + Vector vc = new Vector<>(); + ColumnVisual col = new ColumnVisual("colId", "colDisplay", true, "sortType"); + vc.add(col); + reportData.setColumnVisuals(vc); + return reportData; + } + + public ReportMap mockReportMap() { + ReportMap reportMap = new ReportMap(); + reportMap.setMarkerColor("test"); + reportMap.setUseDefaultSize("size"); + reportMap.setHeight("height"); + reportMap.setWidth("width"); + reportMap.setIsMapAllowedYN("isMapAllowedYN"); + reportMap.setAddAddressInDataYN("addAddressInDataYN"); + reportMap.setAddressColumn("column"); + reportMap.setDataColumn("data"); + reportMap.setDefaultMapType("dafaultType"); + reportMap.setLatColumn("latColumn"); + reportMap.setLongColumn("longColumn"); + reportMap.setColorColumn("colorColumn"); + reportMap.setLegendColumn("legendColumn"); + Marker marker = new Marker(); + marker.setMarkerColor("markerColor"); + marker.setDataHeader("dataHeader"); + marker.setAddressColumn("addressColumn"); + marker.setDataColumn("dataColumn"); + reportMap.getMarkers().add(marker); + return reportMap; + } + + @Test + public void testGetMapMarkers() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + ReportData rd = mockReportData(); + ReportMap rm = mockReportMap(); + rr.getMapMarkers(rd, rm); + } + + @Test + public void testHideColVisual() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + rr.hideColVisual("test"); + } + + @Test + public void testResetVisualSettings() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + rr.resetVisualSettings(); + } + + @Test + public void testLogReportRun() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.doNothing().when(ReportLoader.class, "createReportLogEntry", new Object[] {Mockito.any(Connection.class), Mockito.anyString(), + Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),Mockito.anyString()}); + rr.logReportRun("userID", "100 ms", "formFields"); + } + + @Test + public void testLogReportExecutionTime() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.doNothing().when(ReportLoader.class, "createReportLogEntryForExecutionTime", new Object[] {Mockito.any(Connection.class), Mockito.anyString(), + Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),Mockito.anyString()} ); + rr.logReportExecutionTime("userID", "100 ms", "test", "formFields"); + } + + @Test + public void testLogReportExecutionTimeFromLogList() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.doNothing().when(ReportLoader.class, "createReportLogEntryForExecutionTime", new Object[] {Mockito.any(Connection.class), Mockito.anyString(), + Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),Mockito.anyString()} ); + rr.logReportExecutionTimeFromLogList("userID", "100 ms", "formFields"); + } + + @Test + public void testGenerateColumnDataTotalsLinear() throws Exception { + ReportRuntime rr = mockReportRunTime1(); + PowerMockito.mockStatic(ConnectionUtils.class); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(),Mockito.anyString())).thenReturn(ds); + ArrayList list = (ArrayList) rr.getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn(); + rr.generateColumnDataTotalsLinear(list, "userID", "dbInfo", "reportSQL"); + } + } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ReportWrapperTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ReportWrapperTest.java index ece90c8c..de3f4fff 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ReportWrapperTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ReportWrapperTest.java @@ -37,11 +37,12 @@ */ package org.onap.portalsdk.analytics.xmlobj; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.sql.ResultSet; import java.sql.ResultSetMetaData; -import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -54,12 +55,12 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mockito; -import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.model.DataCache; import org.onap.portalsdk.analytics.model.ReportLoader; import org.onap.portalsdk.analytics.model.base.ReportWrapper; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; import org.onap.portalsdk.analytics.model.definition.TableSource; +import org.onap.portalsdk.analytics.model.runtime.FormField; import org.onap.portalsdk.analytics.model.runtime.ReportParamValues; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; import org.onap.portalsdk.analytics.system.AppUtils; @@ -68,6 +69,7 @@ import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; import org.onap.portalsdk.analytics.util.SQLCorrector; import org.onap.portalsdk.analytics.util.Utils; import org.onap.portalsdk.analytics.util.XSSFilter; @@ -83,7 +85,7 @@ import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) @PrepareForTest({ AppConstants.class, Globals.class, AppUtils.class, DataCache.class, DbUtils.class, DataSet.class, ReportLoader.class, ReportRuntime.class, Utils.class, ESAPI.class, Codec.class, SecurityCodecUtil.class, - ConnectionUtils.class, XSSFilter.class, ReportDefinition.class, UserUtils.class }) + ConnectionUtils.class, XSSFilter.class, ReportDefinition.class, UserUtils.class, ReportWrapper.class }) public class ReportWrapperTest { MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); @@ -93,7 +95,10 @@ public class ReportWrapperTest { public ReportWrapper mockReportWrapper() throws Exception { PowerMockito.mockStatic(Globals.class); PowerMockito.mockStatic(DbUtils.class); + PowerMockito.when(Globals.getReportWrapperFormat()).thenReturn("test"); + PowerMockito.when(Globals.getTimeFormat()).thenReturn("test"); Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + Mockito.when(Globals.getReportSecurity()).thenReturn("test"); ResultSet rs = PowerMockito.mock(ResultSet.class); ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); Mockito.when(rsmd.getColumnCount()).thenReturn(1); @@ -132,16 +137,8 @@ public class ReportWrapperTest { dataSourceType.setDataColumnList(dataColumnList); list.add(dataSourceType); dataSourceList.dataSource = list; - customReportType.setReportType("test"); - customReportType.setReportTitle("test"); - customReportType.setChartMultiSeries("Y"); customReportType.setDataSourceList(dataSourceList); - customReportType.setChartMultiSeries("Y"); - customReportType.setChartRightAxisLabel("test"); - customReportType.setChartLeftAxisLabel("test"); ChartAdditionalOptions chartAdditionalOptions = new ChartAdditionalOptions(); - chartAdditionalOptions.setLabelAngle("test"); - chartAdditionalOptions.setTimeSeriesRender("test"); chartAdditionalOptions.setMultiSeries(false); customReportType.setChartAdditionalOptions(chartAdditionalOptions); FormFieldList formFieldList = new FormFieldList(); @@ -159,16 +156,383 @@ public class ReportWrapperTest { // FormFieldType formFieldType1 = new FormFieldType(); formFields.add(formFieldType); // formFields.add(formFieldType1); - formFieldList.formField = formFields; customReportType.setFormFieldList(formFieldList); - ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + DashboardReports dr = new DashboardReports(); + customReportType.setDashBoardReports(dr); + customReportType.setDrillURLInPoPUpPresent(true); + List<JavascriptItemType> javascriptItem = new ArrayList<>(); + JavascriptItemType ji = new JavascriptItemType(); + ji.setId("1"); + ji.setCallText("test"); + ji.setFieldId("2"); + JavascriptList javascriptList = new JavascriptList(); + javascriptList.setJavascriptItem(javascriptItem); + customReportType.setJavascriptList(javascriptList); + FormatType ft = new FormatType(); + ft.setAlignment("left"); + FormatList fl = new FormatList(); + fl.getFormat().add(ft); + SemaphoreType st = new SemaphoreType(); + st.setComment("test"); + st.setFormatList(fl); + st.setSemaphoreId("1"); + st.setSemaphoreName("test"); + st.setTarget("test"); + SemaphoreList smlist = new SemaphoreList(); + smlist.getSemaphore().add(st); + customReportType.setSemaphoreList(smlist); + chartAdditionalOptions.setChartOrientation("test"); + chartAdditionalOptions.setSecondaryChartRenderer("test"); + chartAdditionalOptions.setHideToolTips("test"); + chartAdditionalOptions.setHidechartLegend("test"); + chartAdditionalOptions.setLegendPosition("test"); + chartAdditionalOptions.setLabelAngle("test"); + chartAdditionalOptions.setIntervalFromdate("test"); + chartAdditionalOptions.setIntervalTodate("test"); + chartAdditionalOptions.setIntervalLabel("test"); + chartAdditionalOptions.setLastSeriesALineChart("test"); + chartAdditionalOptions.setLastSeriesABarChart("test"); + chartAdditionalOptions.setMaxLabelsInDomainAxis("test"); + chartAdditionalOptions.setLinearRegression("test"); + chartAdditionalOptions.setLinearRegressionColor("test"); + chartAdditionalOptions.setExponentialRegressionColor("test"); + chartAdditionalOptions.setMaxRegression("test"); + chartAdditionalOptions.setRangeAxisUpperLimit("test"); + chartAdditionalOptions.setRangeAxisLowerLimit("test"); + chartAdditionalOptions.setOverlayItemValueOnStackBar("test"); + chartAdditionalOptions.setAnimate(true); + chartAdditionalOptions.setKeepDomainAxisValueAsString("test"); + chartAdditionalOptions.setAnimateAnimatedChart(true); + chartAdditionalOptions.setStacked(true); + chartAdditionalOptions.setBarControls(true); + chartAdditionalOptions.setXAxisDateType(true); + chartAdditionalOptions.setLessXaxisTickers(true); + chartAdditionalOptions.setTimeAxis(true); + chartAdditionalOptions.setTimeSeriesRender("test"); + chartAdditionalOptions.setLeftMargin(10); + chartAdditionalOptions.setRightMargin(10); + chartAdditionalOptions.setTopMargin(10); + chartAdditionalOptions.setBottomMargin(10); + ReportMap rm = new ReportMap(); + rm.setMarkerColor("test"); + rm.setUseDefaultSize("10"); + rm.setHeight("10cm"); + rm.setWidth("10cm"); + rm.setIsMapAllowedYN("Y"); + rm.setAddAddressInDataYN("Y"); + rm.setAddressColumn("test"); + rm.setDataColumn("test"); + rm.setDefaultMapType("test"); + rm.setLatColumn("test"); + rm.setLegendColumn("test"); + rm.setLongColumn("test"); + rm.setColorColumn("test"); + Marker marker = new Marker(); + marker.setAddressColumn("test"); + marker.setDataColumn("test"); + marker.setDataHeader("test"); + marker.setMarkerColor("test"); + rm.getMarkers().add(marker); + customReportType.setReportMap(rm); + ChartDrillOptions chartDrillOptions = new ChartDrillOptions(); + ChartDrillFormfield cdff = new ChartDrillFormfield(); + cdff.setFormfield("test"); + chartDrillOptions.getTargetFormfield().add(cdff); + customReportType.setChartDrillOptions(chartDrillOptions); + customReportType.setReportSQL("test"); + dataSourceType.setRefDefinition("test"); + dataSourceType.setComment("test"); + dataColumnType.setDisplayWidthInPxls("test"); + dataColumnType.setDisplayAlignment("test"); + dataColumnType.setDisplayHeaderAlignment("test"); + dataColumnType.setColType(AppConstants.CT_HYPERLINK); + dataColumnType.setHyperlinkType("IMAGE"); + dataColumnType.setIndentation(10); + dataColumnType.setColFormat("test"); + dataColumnType.setOrderBySeq(10); + dataColumnType.setOrderByAscDesc("test"); + dataColumnType.setDisplayTotal("test"); + dataColumnType.setChartColor("test"); + dataColumnType.setChartLineType("test"); + dataColumnType.setIsRangeAxisFilled(true); + dataColumnType.setChartSeries(true); + dataColumnType.setCreateInNewChart(true); + dataColumnType.setDrillDownType("test"); + dataColumnType.setDrillinPoPUp(true); + dataColumnType.setComment("test"); + dataColumnType.setSemaphoreId("test"); + dataColumnType.setDbColType("test"); + dataColumnType.setNowrap("test"); + dataColumnType.setEnhancedPagination(true); + dataColumnType.setDataMiningCol("test"); + ColFilterList colFilterList = new ColFilterList(); + ColFilterType colFilterType = new ColFilterType(); + colFilterType.setArgValue("[test]"); + colFilterType.setCloseBrackets("test"); + colFilterType.setColId("test"); + colFilterType.setComment("test"); + colFilterType.setExpression("test"); + colFilterType.setFilterSeq(10); + colFilterType.setJoinCondition("test"); + colFilterType.setOpenBrackets("test"); + colFilterType.setArgType("FORM"); + colFilterList.getColFilter().add(colFilterType); + dataColumnType.setColFilterList(colFilterList); + formFieldType.setVisible("test"); + formFieldType.setFieldSQL("test"); + formFieldType.setFieldDefaultSQL("test"); + //fft.setRangeStartDate(); + formFieldType.setRangeEndDateSQL("test"); + formFieldType.setRangeStartDateSQL("test"); + //fft.setRangeEndDate(value); + formFieldType.setComment("test"); + formFieldType.setDependsOn("test"); + formFieldType.setGroupFormField(true); + formFieldType.setMultiSelectListSize("test"); + PredefinedValueList predefinedValueList = new PredefinedValueList(); + List<String> values = new ArrayList<>(); + values.add("test"); + predefinedValueList.predefinedValue= values; + formFieldType.setPredefinedValueList(predefinedValueList); + DataminingOptions dataminingOptions = new DataminingOptions(); + customReportType.setDataminingOptions(dataminingOptions); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "1", null, "testId", "test", "test", "1", "1", true); - reportWrapper.setWholeSQL("test"); + reportWrapper.setWholeSQL("test"); + reportWrapper.setPdfImg("testLogo"); + reportWrapper.setEmptyMessage("test"); + reportWrapper.setDrillReportIdForChart("test"); + reportWrapper.setDrillXAxisFormField("test"); + reportWrapper.setDrillYAxisFormField("test"); + reportWrapper.setDrillYAxisFormField("test"); + reportWrapper.setDrillSeriesFormField("test"); + reportWrapper.setDataGridAlign("test"); + reportWrapper.setWidthNoColumn("test"); + reportWrapper.setClassifier("test"); + reportWrapper.setForecastingPeriod("10"); + reportWrapper.setForecastingTimeFormat("test"); + reportWrapper.setReportSQLOnlyFirstPart("test"); + reportWrapper.setReportSQLWithRowNum("test"); + reportWrapper.setIsWeeklyScheduleAllowed("true"); + reportWrapper.setIsOneTimeScheduleAllowed("true"); + reportWrapper.setIsMonthlyScheduleAllowed("true"); + reportWrapper.setIsHourlyScheduleAllowed("true"); + reportWrapper.setIsDailyScheduleAllowed("true"); + reportWrapper.setIsDailyMFScheduleAllowed("true"); + reportWrapper.setHideFormFieldAfterRun(true); + reportWrapper.setChartTypeFixed("test"); + reportWrapper.setDrillDownURLInPopupPresent(true); + reportWrapper.setLinearRegression("test"); + reportWrapper.setCustomizedRegressionPoint("test"); + reportWrapper.setLinearRegressionColor("test"); + reportWrapper.setExponentialRegressionColor("test"); + reportWrapper.setTimeSeriesRender("test"); + reportWrapper.setShowXAxisLabel(true); + reportWrapper.setAddXAxisTickers(true); + reportWrapper.setZoomIn(10); + reportWrapper.setTimeAxisType("test"); + reportWrapper.setToggleLayout(true); + reportWrapper.setShowPageSize(true); + reportWrapper.setChartToolTips("test"); + reportWrapper.setDomainAxisValuesAsString("test"); + reportWrapper.setJumpTo(10); + reportWrapper.setSearchPageSize(10); + reportWrapper.setShowGotoOption(true); + reportWrapper.setShowNavPos(true); + reportWrapper.setPageNav(true); + reportWrapper.setNavPosition("test"); + reportWrapper.setDashboardEditor("test"); + DashboardEditorReport dashboardEditorReport =new DashboardEditorReport(); + dashboardEditorReport.setDataType("test"); + dashboardEditorReport.setPosition("test"); + dashboardEditorReport.setReportId("test"); + dashboardEditorReport.setReportName("test"); + DashboardEditorList deList = new DashboardEditorList(); + deList.getEditorList().add(dashboardEditorReport); + reportWrapper.setDashboardEditorList(deList); + reportWrapper.setPDFFont("test"); + reportWrapper.setPDFFontSize(10); + reportWrapper.setPDFOrientation("test"); + reportWrapper.setPDFLogo1("test"); + reportWrapper.setPDFLogo1Size(10); + reportWrapper.setPDFLogo2("test"); + reportWrapper.setPDFLogo2Size(10); + reportWrapper.setPDFCoverPage(true); + reportWrapper.setPDFFooter1("test"); + reportWrapper.setPDFFooter2("test"); + reportWrapper.setMultiGroupColumn("test"); + reportWrapper.setTopDown("test"); + reportWrapper.setSizedByContent("test"); + reportWrapper.setPageSize(10); + reportWrapper.setAllowSchedule("test"); + reportWrapper.setMaxRowsInExcelDownload (10); + reportWrapper.setReportInNewWindow(true); + reportWrapper.setDisplayFolderTree(true); + reportWrapper.setReportDescr("test"); + reportWrapper.setChartMultiplePieOrder("test"); + reportWrapper.setChartMultiplePieLabelDisplay("test"); + reportWrapper.setSecondaryChartRenderer("test"); + reportWrapper.setOverlayItemValueOnStackBar("test"); + reportWrapper.setIntervalFromdate("test"); + reportWrapper.setIntervalLabel("test"); + reportWrapper.setIntervalTodate("test"); + reportWrapper.setMaxLabelsInDomainAxis("test"); + reportWrapper.setLastSeriesALineChart("test"); + reportWrapper.setLastSeriesABarChart("test"); + reportWrapper.setChartDisplay("test"); + ObjectFactory objFactory = new ObjectFactory(); + reportWrapper.addDashboardReportsNew(objFactory); + reportWrapper.addPDFAdditionalOptions(objFactory); + reportWrapper.setChartTypeFixed("test"); + reportWrapper.setChartMultiSeries("test"); + reportWrapper.setReportTitle("test"); + reportWrapper.setReportSubTitle("test"); + reportWrapper.setReportHeader("test"); + reportWrapper.setReportFooter("test"); + reportWrapper.setNumFormCols("test"); + reportWrapper.setNumDashCols("test"); + reportWrapper.setDisplayOptions("test"); + reportWrapper.setDataContainerHeight("test"); + reportWrapper.setDataContainerWidth("test"); + reportWrapper.setDashboardOptions("test"); + reportWrapper.setDashboardLayoutHTML("testHTML"); + reportWrapper.setReportType("test"); + reportWrapper.setChartRightAxisLabel("test"); + reportWrapper.setChartLeftAxisLabel("test"); + reportWrapper.setDBInfo("testDB"); + reportWrapper.setChartWidth("100 cm"); + reportWrapper.setChartHeight("100 cm"); + reportWrapper.setFrozenColumns(10); + reportWrapper.setComment("test"); + reportWrapper.setDashboardType(true); + reportWrapper.setJavascriptElement("test"); + reportWrapper.setFolderId("1"); + reportWrapper.setReportMap(rm); + reportWrapper.setReportChartDrillOptions(chartDrillOptions); + reportWrapper.setFormHelpText("test"); + DataSet ds= Mockito.mock(DataSet.class); + PowerMockito.when(DbUtils.executeQuery(Mockito.any(String.class))).thenReturn(ds); + PowerMockito.when(ds.getString(Mockito.anyInt(),Mockito.anyInt())).thenReturn("test"); + PowerMockito.when(ds.getRowCount()).thenReturn(1); + return reportWrapper; } @Test + public void testReportWrapperProperties() throws Exception { + ReportWrapper rw = mockReportWrapper(); + assertTrue(rw.isDisplayFolderTree()); + assertTrue(rw.isHideFormFieldAfterRun()); + assertTrue(rw.isReportInNewWindow()); + assertTrue(rw.isDrillDownURLInPopupPresent()); + assertFalse(rw.isChartTypeFixed()); + assertFalse(rw.displayPieOrderinRunPage()); + assertFalse(rw.isMultiplePieOrderByRow()); + assertFalse(rw.isMultiplePieOrderByColumn()); + assertFalse(rw.displayPieLabelDisplayinRunPage()); + assertEquals("test", rw.getMultiplePieLabelDisplay()); + assertFalse(rw.displayChartDisplayinRunPage()); + assertFalse(rw.isChartDisplayIn3D()); + assertTrue(rw.isChartAnimate()); + assertTrue(rw.isXAxisDateType()); + assertFalse(rw.displayChartOrientationInRunPage()); + assertFalse(rw.isVerticalOrientation()); + assertFalse(rw.displaySecondaryChartRendererInRunPage()); + assertFalse(rw.displayIntervalInputInRunPage()); + assertFalse(rw.showLegendDisplayOptionsInRunPage()); + assertFalse(rw.isLastSeriesALineChart()); + assertFalse(rw.hideChartToolTips()); + assertFalse(rw.keepDomainAxisValueInChartAsString()); + assertTrue(rw.isDashboardType()); + assertTrue(rw.isToggleLayout()); + assertTrue(rw.isShowPageSize()); + assertTrue(rw.isShowNavPos()); + assertTrue(rw.isShowGotoOption()); + assertTrue(rw.isPageNav()); + assertTrue(rw.isPDFCoverPage()); + assertFalse(rw.isAllowSchedule()); + assertFalse(rw.isMultiGroupColumn()); + assertFalse(rw.isTopDown()); + assertFalse(rw.isSizedByContent()); + assertFalse(rw.isDashboardOptionHideChart()); + assertFalse(rw.isDashboardOptionHideData()); + assertFalse(rw.isDashboardOptionHideBtns()); + assertFalse(rw.isDisplayOptionHideForm()); + assertFalse(rw.isDisplayOptionHideData()); + assertFalse(rw.isDisplayOptionHideBtns()); + assertFalse(rw.isDisplayOptionHideMap()); + assertFalse(rw.isDisplayOptionHideExcelIcons()); + assertFalse(rw.isDisplayOptionHidePDFIcons()); + assertEquals("test", rw.getChartTypeFixed()); + assertEquals("test", rw.getLinearRegression()); + assertEquals("test", rw.getCustomizedRegressionPoint()); + assertEquals("test", rw.getLinearRegressionColor()); + assertEquals(0, rw.getChartWidthAsInt()); + assertEquals("test", rw.getExponentialRegressionColor()); + assertEquals("test", rw.getSecondaryChartRenderer()); + assertEquals("test", rw.getOverlayItemValueOnStackBar()); + assertEquals("test", rw.getIntervalFromdate()); + assertEquals("test", rw.getIntervalTodate()); + assertEquals("test", rw.getIntervalLabel()); + assertEquals("test", rw.getMaxLabelsInDomainAxis()); + assertEquals(0, rw.getChartHeightAsInt()); + assertEquals("test", rw.getReportHeader()); + assertEquals("test", rw.getReportFooter()); + assertEquals("test", rw.getNumDashCols()); + assertEquals(1, rw.getNumDashColsAsInt()); + assertEquals("test", rw.getNumFormCols()); + assertEquals(5, rw.getNumFormColsAsInt()); + assertEquals(10, rw.getJumpTo()); + assertEquals("test", rw.getNavPosition()); + assertEquals(null, rw.getDashboardEditorList()); + assertEquals(PDFAdditionalOptions.class, rw.getPDFAdditionalOptions().getClass()); + assertEquals(null, rw.getPDFFont()); + assertEquals(9, rw.getPDFFontSize()); + assertEquals("landscape", rw.getPDFOrientation()); + assertEquals(null, rw.getPDFLogo1()); + assertEquals(0, rw.getPDFLogo1Size()); + assertEquals(null, rw.getPDFLogo2()); + assertEquals(0, rw.getPDFLogo2Size()); + assertEquals(null, rw.getPDFFooter1()); + assertEquals(null, rw.getPDFFooter2()); + assertEquals("test", rw.getDataContainerHeight()); + assertEquals("test", rw.getDataContainerWidth()); + assertEquals("test", rw.getAllowSchedule()); + assertEquals("test", rw.getMultiGroupColumn()); + assertEquals(0, rw.getMaxGroupLevel()); + assertEquals(ChartAdditionalOptions.class, rw.getChartAdditionalOptions().getClass()); + assertEquals(DataminingOptions.class, rw.getDataminingOptions().getClass()); + assertEquals(DashboardReports.class, rw.getDashBoardReports().getClass()); + assertEquals(DashboardReportsNew.class, rw.getDashBoardReportsNew().getClass()); + assertEquals("test", rw.getClassifier()); + assertEquals(10, rw.getForecastingPeriod()); + assertEquals("test", rw.getForecastingTimeFormat()); + assertEquals(10, rw.getFrozenColumns()); + assertEquals("testLogo", rw.getPdfImg()); + assertEquals("test", rw.getEmptyMessage()); + assertEquals("test", rw.getDrillReportIdForChart()); + assertEquals("test", rw.getDrillXAxisFormField()); + assertEquals("test", rw.getDrillYAxisFormField()); + assertEquals("test", rw.getDrillSeriesFormField()); + assertEquals("test", rw.getDataGridAlign()); + assertEquals("test", rw.getWidthNoColumn()); + assertEquals(10, rw.getSearchPageSize()); + assertEquals(null, rw.getDashboardEditor()); + assertEquals(ReportMap.class, rw.getReportMap().getClass()); + assertEquals(ChartDrillOptions.class, rw.getReportChartDrillOptions().getClass()); + assertEquals("test", rw.getFormHelpText()); + assertEquals("test", rw.getReportSQLWithRowNum()); + assertEquals("true", rw.getIsWeeklyScheduleAllowed()); + assertEquals("true", rw.getIsOneTimeScheduleAllowed()); + assertEquals("true", rw.getIsMonthlyScheduleAllowed()); + assertEquals("true", rw.getIsHourlyScheduleAllowed()); + assertEquals("true", rw.getIsDailyScheduleAllowed()); + assertEquals("true", rw.getIsDailyMFScheduleAllowed()); + assertEquals("1", rw.getFolderId()); + } + + @Test public void cloneCustomReportTest() throws Exception { ReportWrapper rw = mockReportWrapper(); rw.cloneCustomReport(); @@ -237,16 +601,16 @@ public class ReportWrapperTest { public void rwTest() throws Exception { ReportWrapper rw = new ReportWrapper(mockReportWrapper()); assertEquals(rw.getCustomReport().getClass(), CustomReportType.class); - assertEquals(rw.getReportID(), "-1"); - assertEquals(rw.getMenuID(), "1"); + assertEquals(rw.getReportID(), "1"); + assertEquals(rw.getMenuID(), ""); assertFalse(rw.checkMenuIDSelected("test")); - assertTrue(rw.isMenuApproved()); - assertEquals(rw.getReportDefType(), ""); + assertFalse(rw.isMenuApproved()); + assertEquals(rw.getReportDefType(), "SQL-based"); rw.setMenuID("test"); rw.setMenuApproved(false); rw.setReportDefType("test"); rw.updateReportDefType(); - assertEquals(rw.getJavascriptElement(), null); + assertEquals(rw.getJavascriptElement(), "test"); } @Test @@ -727,6 +1091,166 @@ public class ReportWrapperTest { Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(true); rw.generateSQLSQLBased(paramValues, "overrideSortByColId", "overrideSortByAscDesc", "userId", mockedRequest); } + + @Test + public void generateSQLSQLBased2Test() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getRequestParams()).thenReturn("test,req"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,session"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,sessionSche"); + rw.getCustomReport().setReportSQL("SELECT WHEN FROM TABLE WHERE [test] AND ORDER BY"); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + rw.getFormFieldList().formField.get(0).setFieldType("BLANK1"); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(true); + rw.generateSQLSQLBased(paramValues, "overrideSortByColId", "overrideSortByAscDesc", "userId", mockedRequest); + } + + @Test + public void generateSQLSQLBased3Test() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getRequestParams()).thenReturn("test,req"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,session"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,sessionSche"); + rw.getCustomReport().setReportSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + rw.getFormFieldList().formField.get(0).setFieldType("BLANK1"); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(true); + rw.generateSQLSQLBased(paramValues, "overrideSortByColId", "overrideSortByAscDesc", "userId", mockedRequest); + } + + @Test + public void generateSQLSQLBased4Test() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + Mockito.when(Globals.getRequestParams()).thenReturn("test,req"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,session"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,sessionSche"); + rw.getCustomReport().setReportSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + rw.getFormFieldList().formField.get(0).setFieldType("BLANK1"); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + rw.getFormFieldList().formField.get(0).setValidationType(FormField.VT_TIMESTAMP_HR); + rw.generateSQLSQLBased(paramValues, "overrideSortByColId", "overrideSortByAscDesc", "userId", mockedRequest); + } + + @Test + public void generateSQLSQLBased5Test() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + Mockito.when(Globals.getRequestParams()).thenReturn("test,req"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,session"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,sessionSche"); + rw.getCustomReport().setReportSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + rw.getFormFieldList().formField.get(0).setFieldType("BLANK1"); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + rw.getFormFieldList().formField.get(0).setValidationType(FormField.VT_TIMESTAMP_MIN); + rw.generateSQLSQLBased(paramValues, "overrideSortByColId", "overrideSortByAscDesc", "userId", mockedRequest); + } + + @Test + public void generateSQLSQLBased6Test() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + Mockito.when(Globals.getRequestParams()).thenReturn("test,req"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,session"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,sessionSche"); + rw.getCustomReport().setReportSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + rw.getFormFieldList().formField.get(0).setFieldType("BLANK1"); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + rw.getFormFieldList().formField.get(0).setValidationType(FormField.VT_TIMESTAMP_SEC); + rw.generateSQLSQLBased(paramValues, "overrideSortByColId", "overrideSortByAscDesc", "userId", mockedRequest); + } + + @Test + public void generateSQLSQLBased7Test() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + Mockito.when(Globals.getRequestParams()).thenReturn("test,req"); + Mockito.when(Globals.getSessionParams()).thenReturn("test,session"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test,sessionSche"); + rw.getCustomReport().setReportSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + rw.getFormFieldList().formField.get(0).setFieldType("BLANK1"); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + //Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn(""); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + rw.generateSQLSQLBased(paramValues, "overrideSortByColId", "overrideSortByAscDesc", "userId", mockedRequest); + } @Test public void generateSQLVisualTest() throws Exception { @@ -853,7 +1377,7 @@ public class ReportWrapperTest { @Test public void getFrozenColumnId1Test() throws Exception { ReportWrapper rw = mockReportWrapper(); - rw.getCustomReport().setFrozenColumns(1); + rw.setFrozenColumns(1); rw.getCustomReport().getDataSourceList().getDataSource().get(0).getDataColumnList().getDataColumn().get(0) .setVisible(true); rw.getFrozenColumnId(); @@ -1146,4 +1670,55 @@ public class ReportWrapperTest { DataSourceType dataSourceType = new DataSourceType(); rw.formatListValue("[MAX_VALUE]", "[MAX_VALUE]", dataColumnType, false, false, dataSourceType, "listBaseSQL"); } + + @Test + public void testIsChartDrillDownContainsName() throws Exception { + ReportWrapper rw = mockReportWrapper(); + rw.isChartDrillDownContainsName("test"); + } + + @Test + public void testCloneChartDrillFormfield() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ObjectFactory objFactory = new ObjectFactory(); + ChartDrillFormfield cdff = new ChartDrillFormfield(); + cdff.setFormfield("test"); + rw.cloneChartDrillFormfield(objFactory, cdff); + } + + @Test + public void testCloneMarkerType() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ObjectFactory objFactory = new ObjectFactory(); + Marker marker = new Marker(); + marker.setAddressColumn("test"); + marker.setDataColumn("test"); + marker.setDataHeader("test"); + marker.setMarkerColor("test"); + rw.cloneMarkerType(objFactory, marker); + } + + @Test + public void testCloneDashboardType() throws Exception { + ReportWrapper rw = mockReportWrapper(); + ObjectFactory objFactory = new ObjectFactory(); + Reports reports = new Reports(); + reports.setBgcolor("test"); + reports.setReportId("1"); + rw.cloneDashboardType(objFactory, reports); + } + + @Test + public void testIsEnhancedPaginationNeeded() throws Exception { + ReportWrapper rw = mockReportWrapper(); + rw.isEnhancedPaginationNeeded(); + } + + @Test + public void testGetColumnWhichNeedEnhancedPagination() throws Exception { + ReportWrapper rw = mockReportWrapper(); + rw.getColumnWhichNeedEnhancedPagination(); + } + + }
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/pom.xml b/ecomp-sdk/epsdk-app-common/pom.xml index 2d38b6a5..5757988b 100644 --- a/ecomp-sdk/epsdk-app-common/pom.xml +++ b/ecomp-sdk/epsdk-app-common/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java index 3aeb0147..138a805d 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java @@ -49,9 +49,8 @@ import org.springframework.web.servlet.ModelAndView; @Controller @RequestMapping("/") public class AngularAdminController extends RestrictedBaseController{ - public static final String API_VERSION = "/v3"; - @RequestMapping(value = {API_VERSION + "/userProfile" }, method = RequestMethod.GET) + @RequestMapping(value = {"/userProfile" }, method = RequestMethod.GET) public ModelAndView view() { Map<String, Object> model = new HashMap<>(); return new ModelAndView("user_profile_list","model", model); diff --git a/ecomp-sdk/epsdk-app-os/README.md b/ecomp-sdk/epsdk-app-os/README.md index c61ebe63..675919bb 100644 --- a/ecomp-sdk/epsdk-app-os/README.md +++ b/ecomp-sdk/epsdk-app-os/README.md @@ -14,6 +14,7 @@ https://www.eclipse.org/m2e-wtp/ ## Release Notes Version 2.3.0 - PORTAL 254 ECOMP AAF jar +- PORTAL-281 Portal SDK AAF jar throws null pointer exception Version 2.2.0 - PORTAL 136 Junits for SDK diff --git a/ecomp-sdk/epsdk-app-os/pom.xml b/ecomp-sdk/epsdk-app-os/pom.xml index 733a1798..8b67bd5b 100644 --- a/ecomp-sdk/epsdk-app-os/pom.xml +++ b/ecomp-sdk/epsdk-app-os/pom.xml @@ -10,7 +10,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-app-overlay/pom.xml b/ecomp-sdk/epsdk-app-overlay/pom.xml index f0d15a73..98143b71 100644 --- a/ecomp-sdk/epsdk-app-overlay/pom.xml +++ b/ecomp-sdk/epsdk-app-overlay/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js index 8fa14643..b15205fc 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js @@ -1,4 +1,4 @@ -appDS2.controller('reportChartController', function ($scope, $rootScope, $timeout, $window, $http, $routeParams,modalService) { +appDS2.controller('reportChartController', function ($scope, $rootScope, $timeout, $window, $modal, $http, $routeParams,modalService) { $scope.showLoader = true; $scope.commonOptionOpen = false; $scope.additionalOptionOpen = false; @@ -15,11 +15,16 @@ appDS2.controller('reportChartController', function ($scope, $rootScope, $timeou $scope.populateChrtWzdFields = function() { $scope.reportRunJson = {}; + $scope.showLoader=true; $http.get("raptor.htm?action=chart.json&c_master="+$routeParams.reportId).then(function (response) { + $scope.showLoader=false; $scope.reportRunJson = response.data; //Set chart type - $scope.reportRunJson.commonChartOptions.animateAnimatedChart = $scope.reportRunJson.commonChartOptions.animateAnimatedChart+""; - $scope.reportRunJson.commonChartOptions.hideLegend = $scope.reportRunJson.commonChartOptions.hideLegend + ""; + if($scope.reportRunJson.commonChartOptions!=null){ + $scope.reportRunJson.commonChartOptions.animateAnimatedChart = $scope.reportRunJson.commonChartOptions.animateAnimatedChart+""; + $scope.reportRunJson.commonChartOptions.hideLegend = $scope.reportRunJson.commonChartOptions.hideLegend + ""; + } + $scope.reportRunJson.showTitle = $scope.reportRunJson.showTitle + ""; // if barChartOptions is not null @@ -126,9 +131,11 @@ appDS2.controller('reportChartController', function ($scope, $rootScope, $timeou $scope.saveChartData = function() { $scope.showLoader = true; - - $scope.reportRunJson.commonChartOptions.animateAnimatedChart = ($scope.reportRunJson.commonChartOptions.animateAnimatedChart=="true") - $scope.reportRunJson.commonChartOptions.hideLegend = ($scope.reportRunJson.commonChartOptions.hideLegend=="true"); + if($scope.reportRunJson.commonChartOptions){ + $scope.reportRunJson.commonChartOptions.animateAnimatedChart = ($scope.reportRunJson.commonChartOptions.animateAnimatedChart=="true") + $scope.reportRunJson.commonChartOptions.hideLegend = ($scope.reportRunJson.commonChartOptions.hideLegend=="true"); + } + $scope.reportRunJson.showTitle = ($scope.reportRunJson.showTitle=="true"); $scope.reportRunJson.chartTypeJSON = { @@ -190,12 +197,12 @@ appDS2.controller('reportChartController', function ($scope, $rootScope, $timeou //add the remove list to the json $scope.reportRunJson.rangeAxisRemoveList= $scope.rangeAxisRemoveList; $http.post("save_chart", JSON.stringify($scope.reportRunJson)).success(function(data, status) { - $scope.successSubmit=true; + $scope.successSubmit=true; $scope.showLoader = false; $scope.reportRunJson.commonChartOptions.animateAnimatedChart = $scope.reportRunJson.commonChartOptions.animateAnimatedChart+""; $scope.reportRunJson.commonChartOptions.hideLegend = $scope.reportRunJson.commonChartOptions.hideLegend + ""; $scope.reportRunJson.showTitle = $scope.reportRunJson.showTitle + ""; - if ($scope.reportRunJson.chartType == "BarChart3D") { + if ($scope.reportRunJson.chartType == "BarChart3D" && $scope.reportRunJson.barChartOptions) { $scope.reportRunJson.barChartOptions.displayBarControls = $scope.reportRunJson.barChartOptions.displayBarControls+""; $scope.reportRunJson.barChartOptions.minimizeXAxisTickers = $scope.reportRunJson.barChartOptions.minimizeXAxisTickers+""; $scope.reportRunJson.barChartOptions.stackedChart = $scope.reportRunJson.barChartOptions.stackedChart+""; @@ -203,6 +210,7 @@ appDS2.controller('reportChartController', function ($scope, $rootScope, $timeou $scope.reportRunJson.barChartOptions.verticalOrientation = $scope.reportRunJson.barChartOptions.verticalOrientation +""; $scope.reportRunJson.barChartOptions.xAxisDateType = $scope.reportRunJson.barChartOptions.xAxisDateType +""; } + $scope.successPopUp(); $scope.populateChrtWzdFields(); }) } @@ -419,6 +427,38 @@ appDS2.controller('reportChartController', function ($scope, $rootScope, $timeou $rootScope.isViewRendering = false; }); + $scope.successPopUp = function (msg) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + msg: function () { + var message = { + title: '', + text: msg + }; + return message; + } + } + }); + }; + + $scope.errorPopUp = function (msg) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + msg: function () { + return msg; + } + } + }); + }; + var ModalInstanceCtrl = function ($scope, $modalInstance, msg,$rootScope) { + $scope.msg=msg; + } }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js index 1e22cca3..58913a40 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js @@ -1,41 +1,41 @@ appDS2.config(['$routeProvider', - function($routeProvider) { - $routeProvider. - when('/', { - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html', - controller: 'reportSearchController' - }). - when('/report_search', { - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html', - controller: 'reportSearchController' - }). - when('/report_run/:reportUrlParams*', { - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-run.html', - controller: 'reportRunController' - }). - when('/report_chart_wizard/:reportId', { - templateUrl: 'static/fusion/raptor/ebz/report_chart_wizard.html', - controller: 'ChartController' - }). - when('/report_chart/:reportId', { - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html', - controller: 'reportChartController' - }). - when("/report_wizard", { - templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html", - controller: "reportStepController" - }). - when("/report_wizard/:reportId", { - templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html", - controller: "reportStepController" - }). - when("/report_wizard/:reportMode/:reportId", { - templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html", - controller: "reportStepController" - }). - when("/report_import", { - templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/report-import.html", - controller: "reportImportController" - }) - ; - }]);
\ No newline at end of file + function($routeProvider) { + $routeProvider. + when('/', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html', + controller: 'reportSearchController' + }). + when('/report_search', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html', + controller: 'reportSearchController' + }). + when('/report_run/:reportUrlParams*', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-run.html', + controller: 'reportRunController' + }). + when('/report_chart_wizard/:reportId', { + templateUrl: 'static/fusion/raptor/ebz/report_chart_wizard.html', + controller: 'ChartController' + }). + when('/report_chart/:reportId', { + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html', + controller: 'reportChartController' + }). + when("/report_wizard", { + templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/report-step.html", + controller: "reportStepController" + }). + when("/report_wizard/:reportId", { + templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/report-step.html", + controller: "reportStepController" + }). + when("/report_wizard/:reportMode/:reportId", { + templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/report-step.html", + controller: "reportStepController" + }). + when("/report_import", { + templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/report-import.html", + controller: "reportImportController" + }) + ; +}]);
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js index 6eb0afe6..daa47900 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js @@ -1,5 +1,5 @@ -appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams','$http','dateFilter', '$window', '$timeout', 'rowSorter', - function ($scope,$rootScope,$routeParams,$http,dateFilter,$window,$timeout,rowSorter) { +appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams','$http','dateFilter', '$window', '$timeout', 'rowSorter','$modal', + function ($scope,$rootScope,$routeParams,$http,dateFilter,$window,$timeout,rowSorter,$modal) { $scope.dateformat = "MM/dd/yyyy"; $scope.datetimeformat = "MM/dd/yyyy hh:mm a"; $scope.showFormFields = false; @@ -14,7 +14,7 @@ appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams',' value: false }; $scope.isInProgress = true; - + $scope.showLoader=false; if($routeParams.reportUrlParams.indexOf("parent___params===")>-1) { $scope.showBackButton = true; $scope.parentReportUrlParams = $routeParams.reportUrlParams.substring($routeParams.reportUrlParams.indexOf("parent___params===")+18); @@ -67,36 +67,41 @@ appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams',' function(response){ // console.log(response); $scope.isInProgress = false; - $scope.reportData = response.data; - // console.log('reportData report run container response',$scope.reportData); - if ($scope.reportData.reportTitle) { - $scope.reportData.reportHeading = $scope.reportData.reportTitle; - if ($scope.reportData.reportSubTitle) { - $scope.reportData.reportSubTitle = $scope.reportData.reportSubTitle; + if(response.data.errormessage!=null && response.data.errormessage!=''){ + $scope.errorPopUp(response.data.errormessage); + }else{ + $scope.reportData = response.data; + // console.log('reportData report run container response',$scope.reportData); + if ($scope.reportData.reportTitle) { + $scope.reportData.reportHeading = $scope.reportData.reportTitle; + if ($scope.reportData.reportSubTitle) { + $scope.reportData.reportSubTitle = $scope.reportData.reportSubTitle; + } } + else + $scope.reportData.reportHeading = $scope.reportData.reportName; + if(!$scope.urlParams.hideChart && $scope.reportData.chartAvailable && $scope.reportData.totalRows>1){ + // console.log('raptor.htm?action=chart.run&'+convertQueryString($scope.urlParams)); + $http.get('raptor.htm?action=chart.run&'+convertQueryString($scope.urlParams)).then( + function(response){ + $scope.showChart = true; + document.getElementById('chartiframe').contentWindow.document.write(response.data); + document.getElementById('chartiframe').contentWindow.document.close(); + }); + } + + if($scope.reportData.displayForm && $scope.reportData.formFieldList && $scope.reportData.formFieldList.length>0 && !$scope.urlParams.hideFormFields){ + $scope.showFormFields = true; + } } - else - $scope.reportData.reportHeading = $scope.reportData.reportName; - if(!$scope.urlParams.hideChart && $scope.reportData.chartAvailable && $scope.reportData.totalRows>1){ - // console.log('raptor.htm?action=chart.run&'+convertQueryString($scope.urlParams)); - $http.get('raptor.htm?action=chart.run&'+convertQueryString($scope.urlParams)).then( - function(response){ - $scope.showChart = true; - document.getElementById('chartiframe').contentWindow.document.write(response.data); - document.getElementById('chartiframe').contentWindow.document.close(); - }); - } - - if($scope.reportData.displayForm && $scope.reportData.formFieldList && $scope.reportData.formFieldList.length>0 && !$scope.urlParams.hideFormFields){ - $scope.showFormFields = true; - } + }); $scope.getFormFieldSelectedValuesAsURL = function(){ var formFieldsUrl = ''; $scope.reportData.formFieldList.forEach(function(formField) { if(formField.fieldType==='LIST_BOX') { - if($scope.formFieldSelectedValues && $scope.formFieldSelectedValues[formField.fieldId] && $scope.formFieldSelectedValues[formField.fieldId].value != '') { - formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId].value+'&'; + if($scope.formFieldSelectedValues && $scope.formFieldSelectedValues[formField.fieldId] ) { + formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId]+'&'; } } else if(formField.fieldType==='LIST_MULTI_SELECT') { if($scope.formFieldSelectedValues[formField.fieldId].length >0) { @@ -114,11 +119,13 @@ appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams',' formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId]+'&'; } }); + //formFieldsUrl = str.slice(0, -1); return formFieldsUrl; } $scope.runReport = function(pagination){ + $scope.showLoader=true; var formFieldsUrl = $scope.getFormFieldSelectedValuesAsURL(); /*if ($scope.reportData.reportTitle) $scope.reportData.reportHeading = $scope.reportData.reportTitle; @@ -149,6 +156,7 @@ appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams',' // console.log('raptor.htm?action=report.run.container&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'refresh=Y&display_content=Y&r_page='+(paginationOptions.pageNumber-1)); $http.get('raptor.htm?action=report.run.container&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'refresh=Y&display_content=Y&r_page='+(paginationOptions.pageNumber-1)).then( function(response){ + $scope.showLoader=false; $scope.reportData = response.data; if ($scope.reportData.reportTitle) { $scope.reportData.reportHeading = $scope.reportData.reportTitle; @@ -207,6 +215,7 @@ appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams',' paginationTemplate: correctTotalPaginationTemplate, columnDefs: [], data: [], + enableSorting: true, enableGridMenu: true, enableSelectAll: true, gridMenuCustomItems : [ @@ -218,10 +227,10 @@ appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams',' action : function($event) { $window.open($scope.reportEditURL,'_self'); }, order : 211 }, - { title : 'Export All data as Excel 2007', + /*{ title : 'Export All data as Excel 2007', action : function($event) { $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.excel2007.session','_self'); - }, order : 212 }, + }, order : 212 },*/ { title : 'Export All data as Excel', action : function($event) { $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.excel.session','_self'); @@ -323,9 +332,43 @@ appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams',' $http.get('raptor.htm?action=report.formfields.run.container&c_master='+$scope.reportData.reportID+'&'+formFieldsUrl).then( function(response){ $scope.reportData = response.data; + if($scope.reportData.reportHeading==null || $scope.reportData.reportHeading=='') + $scope.reportData.reportHeading = ($scope.reportData.reportTitle=='')?$scope.reportData.reportName:$scope.reportData.reportTitle; }); }; $timeout(function() { $rootScope.isViewRendering = false; }); + $scope.successPopUp = function (msg) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + msg: function () { + var message = { + title: '', + text: msg + }; + return message; + } + } + }); + }; + + $scope.errorPopUp = function (msg) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + msg: function () { + return msg; + } + } + }); + }; + var ModalInstanceCtrl = function ($scope, $modalInstance, msg,$rootScope) { + $scope.msg=msg; + } }]); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js index e1c5e1e8..36a541ed 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js @@ -2,13 +2,17 @@ appDS2.requires.push('ui.grid'); appDS2.requires.push('ui.grid.pagination'); appDS2.requires.push('ui.grid.resizeColumns'); appDS2.controller("reportSearchController", ['$scope','$rootScope','$http','$timeout','uiGridConstants','$modal','$q','$log','raptorReportFactory',function ($scope,$rootScope,$http,$timeout,uiGridConstants,$modal,$q,$log,raptorReportFactory) { - + $scope.showLoader=false; $scope.getSearchData = function(){ + $scope.showLoader=true; + raptorReportFactory.getSearchData().then(function(data){ $scope.searchdData = data; },function(error){ $log.error("raptorReportFactory: getSearchData failed."); - }); + }).finally(function() { + $scope.showLoader=false;// Always execute this on both error and success + });; } $scope.getSearchData(); @@ -21,12 +25,15 @@ appDS2.controller("reportSearchController", ['$scope','$rootScope','$http','$tim if($scope.reportName && $scope.reportName!=''){ searchParams = searchParams+'&rep_name='+$scope.reportName+'&rep_name_options='+$scope.operatorRepName.index; } - + $scope.showLoader=true; var pageSearchParameter = ($scope.paginationOptions.pageNumber-1)+searchParams raptorReportFactory.getSearchDataAtPage(pageSearchParameter).then(function(data){ $scope.searchdData = data },function(error){ $log.error("raptorReportFactory: getSearchDataAtPage failed."); + }).finally(function() { + $scope.showLoader=false;// Always execute this on both error and success + }); }; @@ -37,6 +44,57 @@ appDS2.controller("reportSearchController", ['$scope','$rootScope','$http','$tim sort: null }; + function convertValue(v){ + return parseInt(v.displayValue); + } + + $scope.getSortingAlgorithm= function (columnName) { + return function(a, b, rowA, rowB, direction) { + console.log("sorting by column " + columnName,a,b); + if(columnName=='rep_id'){ + if(a && b && a.displayValue && b.displayValue){ + if (convertValue(a) == convertValue(b)) return 0; + if (convertValue(a) < convertValue(b)) return -1; + if (convertValue(a) > convertValue(b)) return 1; + }else{ + return 0; + } + }else if(columnName=='rep_name'){ + if(a && b && a.displayValue && b.displayValue){ + if (a.displayValue == b.displayValue) return 0; + if (a.displayValue < b.displayValue) return -1; + if (a.displayValue > b.displayValue) return 1; + }else{ + return 0; + } + }else if(columnName=='descr'){ + if(a && b && a.displayValue && b.displayValue){ + if (a.displayValue == b.displayValue) return 0; + if (a.displayValue < b.displayValue) return -1; + if (a.displayValue > b.displayValue) return 1; + }else{ + return 0; + } + }else if(columnName=='owner'){ + if(a && b && a.displayValue && b.displayValue){ + if (a.displayValue == b.displayValue) return 0; + if (a.displayValue < b.displayValue) return -1; + if (a.displayValue > b.displayValue) return 1; + }else{ + return 0; + } + }else if(columnName=='create_date'){ + if(a && b && a.displayValue && b.displayValue){ + if (a.displayValue == b.displayValue) return 0; + if (a.displayValue < b.displayValue) return -1; + if (a.displayValue > b.displayValue) return 1; + }else{ + return 0; + } + } + } + }; + var correctTotalPaginationTemplate = //same as normal template, but fixed totals: {{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}} "<div role=\"contentinfo\" class=\"ui-grid-pager-panel\" ui-grid-pager ng-show=\"grid.options.enablePaginationControls\"><div role=\"navigation\" class=\"ui-grid-pager-container\"><div role=\"menubar\" class=\"ui-grid-pager-control\"><button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-first\" ui-grid-one-bind-title=\"aria.pageToFirst\" ui-grid-one-bind-aria-label=\"aria.pageToFirst\" ng-click=\"pageFirstPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle\"><div class=\"first-bar\"></div></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-previous\" ui-grid-one-bind-title=\"aria.pageBack\" ui-grid-one-bind-aria-label=\"aria.pageBack\" ng-click=\"pagePreviousPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle prev-triangle\"></div></button> <input type=\"number\" ui-grid-one-bind-title=\"aria.pageSelected\" ui-grid-one-bind-aria-label=\"aria.pageSelected\" class=\"ui-grid-pager-control-input\" ng-model=\"grid.options.paginationCurrentPage\" min=\"1\" max=\"{{ paginationApi.getTotalPages() }}\" required> <span class=\"ui-grid-pager-max-pages-number\" ng-show=\"paginationApi.getTotalPages() > 0\"><abbr ui-grid-one-bind-title=\"paginationOf\">/</abbr> {{ paginationApi.getTotalPages() }}</span> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-next\" ui-grid-one-bind-title=\"aria.pageForward\" ui-grid-one-bind-aria-label=\"aria.pageForward\" ng-click=\"pageNextPageClick()\" ng-disabled=\"cantPageForward()\"><div class=\"last-triangle next-triangle\"></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-last\" ui-grid-one-bind-title=\"aria.pageToLast\" ui-grid-one-bind-aria-label=\"aria.pageToLast\" ng-click=\"pageLastPageClick()\" ng-disabled=\"cantPageToLast()\"><div class=\"last-triangle\"><div class=\"last-bar\"></div></div></button></div><div class=\"ui-grid-pager-row-count-picker\" ng-if=\"grid.options.paginationPageSizes.length > 1\"><select ui-grid-one-bind-aria-labelledby-grid=\"'items-per-page-label'\" ng-model=\"grid.options.paginationPageSize\" ng-options=\"o as o for o in grid.options.paginationPageSizes\"></select><span ui-grid-one-bind-id-grid=\"'items-per-page-label'\" class=\"ui-grid-pager-row-count-label\"> {{sizesLabel}}</span></div><span ng-if=\"grid.options.paginationPageSizes.length <= 1\" class=\"ui-grid-pager-row-count-label\">{{grid.options.paginationPageSize}} {{sizesLabel}}</span></div><div class=\"ui-grid-pager-count-container\"><div class=\"ui-grid-pager-count\"><span ng-show=\"grid.options.totalItems > 0\">{{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} <abbr ui-grid-one-bind-title=\"paginationThrough\">-</abbr> {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}</span></div></div></div>"; @@ -103,15 +161,15 @@ appDS2.controller("reportSearchController", ['$scope','$rootScope','$http','$tim } else { $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: true, + sortingAlgorithm: $scope.getSortingAlgorithm(entry.columnId), cellTemplate: '<div class="ui-grid-cell-contents" style="text-align:{{COL_FIELD.alignment}};" title="TOOLTIP"> <div>{{COL_FIELD.displayValue}}</div> </div>' }); } }); - + $scope.gridOptions.useExternalPagination=true; $scope.gridOptions.paginationPageSizes= [$scope.searchdData.metaReport.pageSize]; - $scope.gridOptions.paginationPageSize= $scope.searchdData.metaReport.pageSize; + $scope.gridOptions.paginationPageSize= 50;//$scope.searchdData.metaReport.pageSize; $scope.gridOptions.totalItems = $scope.searchdData.metaReport.totalSize; - $scope.gridOptions.data = []; $scope.searchdData.rows[0].forEach(function(entry) { var localData = {}; diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js index 3196b336..43f877c3 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js @@ -1,1263 +1,763 @@ appDS2.controller('reportStepController', function($scope,$http,$location, $routeParams, $q, $modal,$log,$window, raptorReportFactory, stepFormFactory) { + /*****************Init values*********************/ + $scope.reportIdURL = $routeParams.reportId; + $scope.isEdit = ($scope.reportIdURL==null||$scope.reportIdURL=='')?false:true; + $scope.isDefReady = $scope.isEdit; + $scope.activeTabsId = 'definition'; + $scope.pageMsg ='' + $scope.stepNum = 0; + $scope.stepTabs=[ + { + title: 'Definition', + id: 'definition', + uniqueId: 'uniqueStep1', + tabPanelId: 'definitionTab', + disabled: false + + }, { + title: 'SQL', + id: 'sql', + uniqueId: 'uniqueStep2', + tabPanelId: 'sqlTab', + disabled: (!$scope.isDefReady) + }, { + title: 'Columns', + id: 'columns', + uniqueId: 'uniqueTab3x', + tabPanelId: 'columnsTab', + disabled: (!$scope.isDefReady) + }, { + title: 'Form Fields', + id: 'formFields', + uniqueId: 'uniqueTab4x', + tabPanelId: 'formFieldsTab', + disabled: (!$scope.isDefReady) + }, { + title: 'Security', + id: 'security', + uniqueId: 'uniqueTab5x', + tabPanelId: 'securityTab', + disabled: (!$scope.isDefReady) + }, { + title: 'Log', + id: 'log', + uniqueId: 'uniqueTab6x', + tabPanelId: 'logTab', + disabled: (!$scope.isDefReady) + }, { + title: 'Run', + id: 'run', + uniqueId: 'uniqueTab7x', + tabPanelId: 'runTab', + disabled: (!$scope.isDefReady) + } + + ]; + $scope.$watch('activeTabsId', function (newVal, oldVal) { + if(newVal !== oldVal) { + $scope.init(); + } + }); - $scope.showLoader = true; - // tabs for report wizard steps: - $scope.activeTabsId = 'Definition'; - $scope.addReportUserId = {'id':''}; - $scope.addReportRoleId = {'id':''}; - // For all the dropdown box, please declare the active selection variable in the following manner: - // $scope.selectedOpt = {}; - // $scope.selectedOpt.value = ""; + $scope.renderStep = function(stepNum){ + var containerElement = angular.element(document.getElementById("stepView")); + containerElement.empty(); + $scope.stepNum = stepNum; + var jsonSrcName = getJsonSrcName(stepNum); + stepFormFactory.renderForm(jsonSrcName, containerElement, $scope); + } + $scope.next = function(){ + $scope.stepNum = $scope.stepNum +1; + $scope.activeTabsId = $scope.stepTabs[$scope.stepNum].id; + }; + + + $scope.previous = function(){ + $scope.stepNum = $scope.stepNum -1; + $scope.activeTabsId = $scope.stepTabs[$scope.stepNum].id; + } + + /*******************Step 1 Definitions****************/ + $scope.displayOptions={ + hideFormFields:false, + hideChart:false, + hideReportData:false, + hideExcel:false, + hidePdf:false + } + $scope.reportIdURL = $routeParams.reportId; + $scope.definitionData={}; + $scope.definitionData.displayOptions=[ + {name:'HideFormFields', selected:false}, + {name:'HideChart', selected:false}, + {name:'HideReportData', selected:false}, + {name:'HideExcel', selected:false}, + {name:'HidePdf', selected:false} + ] + + $scope.pageSizeValues=['10','25','50','100','500']; + $scope.pageSizeOptions =[]; + $scope.maxRowValues = ['500','1000','2000','3000','4000','5000','10000','15000','20000','25000','30000','35000','40000','45000','50000','65000'] + $scope.maxRowOptions =[]; + $scope.frozenColValues = ['0','1','2','3','4']; + $scope.frozenColOptions =[]; + $scope.dataGridAlignValues = ['Left','Right','Center']; + $scope.dataGridAlignOptions =[]; + $scope.dataContainerValues = ['10','20','30','40','50','60','70','80','90','100','110','120','130','140','150','160','170','180','190','200']; + $scope.dataContainerOptions =[]; + $scope.runTimeFormNumValues = ['1','2','3','4']; + $scope.runTimeFormNumOptions =[]; + /******create*****/ + if(!$scope.isEdit){ + $scope.definitionData.reportType = 'Linear'; + $scope.definitionData.dbInfo = 'Local'; + } + /****end create***/ + + /*functions*/ $scope.getDefinitionById = function(id) { + $scope.showLoader=true; raptorReportFactory.getDefinitionByReportId(id).then(function(data){ - $scope.loadDefinition(data); + $scope.showLoader=false; $scope.definitionData = data; $scope.showLoader = false; + for(x in data.displayOptions){ + if(data.displayOptions[x].name=='HideFormFields') + $scope.displayOptions.hideFormFields = data.displayOptions[x].selected; + else if(data.displayOptions[x].name=='HideChart') + $scope.displayOptions.hideChart = data.displayOptions[x].selected; + else if(data.displayOptions[x].name=='HideReportData') + $scope.displayOptions.hideReportData = data.displayOptions[x].selected; + else if(data.displayOptions[x].name=='HideExcel') + $scope.displayOptions.hideExcel = data.displayOptions[x].selected; + else if(data.displayOptions[x].name=='HidePdf') + $scope.displayOptions.hidePdf = data.displayOptions[x].selected; + } + + $scope.definitionData.frozenColumns = $scope.definitionData.frozenColumns+''; + $scope.definitionData.numFormCols = $scope.definitionData.numFormCols+''; + $scope.definitionData.allowScheduler = data.allowScheduler=='Y'?true:false; + $scope.definitionData.sizedByContent = data.sizedByContent=='Y'?true:false; + + $scope.definitionData.oneTimeRec = data.oneTimeRec=='Y'?true:false; + $scope.definitionData.hourlyRec = data.hourlyRec=='Y'?true:false; + $scope.definitionData.dailyRec = data.dailyRec=='Y'?true:false; + $scope.definitionData.dailyMFRec = data.dailyMFRec=='Y'?true:false; + $scope.definitionData.weeklyRec = data.weeklyRec=='Y'?true:false; + $scope.definitionData.monthlyRec = data.monthlyRec=='Y'?true:false; + + if($scope.definitionData.reportTitle==null || $scope.definitionData.reportTitle=='') + $scope.definitionData.reportTitle = $scope.definitionData.reportName; },function(error){ - $log.error("raptorReportFactory: getSearchData failed."); + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getDefinitionById failed."); $scope.showLoader = false; }); } - $scope.addReportSecurityUser = function(userId) { - raptorReportFactory.addReportSecurityUser(userId).then(function(data){ - $scope.loadSecurityPage(); - },function(error){ - $log.error("raptorReportFactory: addReportSecurityUser failed."); - }); + $scope.constructureDefDropDown = function(){ + for(i in $scope.pageSizeValues){ + var v = { + value :$scope.pageSizeValues[i], + text :$scope.pageSizeValues[i] + } + $scope.pageSizeOptions.push(v); + } + for(i in $scope.maxRowValues){ + var v = { + value :$scope.maxRowValues[i], + text :$scope.maxRowValues[i] + } + $scope.maxRowOptions.push(v); + } + for(i in $scope.frozenColValues){ + var v = { + value :$scope.frozenColValues[i]+'', + text :$scope.frozenColValues[i] + } + $scope.frozenColOptions.push(v); + } + for(i in $scope.dataGridAlignValues){ + var v = { + value :$scope.dataGridAlignValues[i].toLowerCase(), + text :$scope.dataGridAlignValues[i] + } + $scope.dataGridAlignOptions.push(v); + } + for(i in $scope.dataContainerValues){ + var v = { + value :$scope.dataContainerValues[i], + text :$scope.dataContainerValues[i] + } + $scope.dataContainerOptions.push(v); + } + for(i in $scope.runTimeFormNumValues){ + var v = { + value :$scope.runTimeFormNumValues[i], + text :$scope.runTimeFormNumValues[i] + } + $scope.runTimeFormNumOptions.push(v); + } } - - $scope.removeReportSecurityUser = function(securityUser) { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-user-del-confirm.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','securityUser', function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityUser) { - $scope.securityUserName = securityUser.name; - $scope.ok = function() { - raptorReportFactory.removeReportSecurityUser(securityUser.id).then(function(data){ - $modalInstance.close(); - },function(error){ - $log.error("raptorReportFactory: removeReportSecurityUser failed."); - }); - } - $scope.cancel = function() { - $modalInstance.dismiss(); - }; - }], - resolve:{ - securityUser: function(){ - return securityUser; - } - } - }); - modalInstance.result.then(function () { - $scope.loadSecurityPage(); - }, function () { - }); - }; - - - $scope.addReportSecurityRole = function(roleId) { - raptorReportFactory.addReportSecurityRole(roleId).then(function(data){ - $scope.loadSecurityPage(); - },function(error){ - $log.error("raptorReportFactory: addReportSecurityRole failed."); - }); - } - - $scope.removeReportSecurityRole = function(securityRole) { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-role-del-confirm.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','securityRole', function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityRole) { - $scope.securityRoleName = securityRole.name; - $scope.ok = function() { - raptorReportFactory.removeReportSecurityRole(securityRole.id).then(function(data){ - $modalInstance.close(); - },function(error){ - $log.error("raptorReportFactory: removeReportSecurityRole failed."); - }); - } - $scope.cancel = function() { - $modalInstance.dismiss(); - }; - }], - resolve:{ - securityRole: function(){ - return securityRole; - } - } - }); - modalInstance.result.then(function () { - $scope.loadSecurityPage(); - }, function () { - }); - } - $scope.saveReportSecurityInfo = function(userId, isPublic) { - var securityInfo = {'userId':userId+"",'isPublic':isPublic}; - raptorReportFactory.updateReportSecurityInfo(securityInfo).then(function(data){ - $scope.loadSecurityPage(); - },function(error){ - $log.error("raptorReportFactory: updateReportSecurityInfo failed."); - }); - }; - - $scope.createNewDefinition = function() { - raptorReportFactory.createNewDefinition().then(function(data){ - $scope.loadDefinition(data); - $scope.definitionData = data; - $scope.showLoader = false; + $scope.constructDef = function(){ + var data =Object.assign({}, $scope.definitionData); + for(x in $scope.definitionData.displayOptions){ + if($scope.definitionData.displayOptions[x].name=='HideFormFields') + data.displayOptions[x].selected = $scope.displayOptions.hideFormFields + else if($scope.definitionData.displayOptions[x].name=='HideChart') + data.displayOptions[x].selected = $scope.displayOptions.hideChart + else if($scope.definitionData.displayOptions[x].name=='HideReportData') + data.displayOptions[x].selected = $scope.displayOptions.hideReportData + else if($scope.definitionData.displayOptions[x].name=='HideExcel') + data.displayOptions[x].selected = $scope.displayOptions.hideExcel + else if($scope.definitionData.displayOptions[x].name=='HidePdf') + data.displayOptions[x].selected = $scope.displayOptions.hidePdf + } + if(data.pageSize==null || data.pageSize.startsWith("Select")) + data.pageSize = null; + if(data.maxRowsInExcelCSVDownload==null || data.maxRowsInExcelCSVDownload.startsWith("Select")) + data.maxRowsInExcelCSVDownload = null; + if(data.frozenColumns==null || data.frozenColumns.startsWith("Select")) + data.frozenColumns = null; + if(data.dataGridAlign==null || data.dataGridAlign.startsWith("Select")) + data.dataGridAlign = null; + if(data.dataContainerHeight==null || data.dataContainerHeight.startsWith("Select")) + data.dataContainerHeight = null; + if(data.dataContainerWidth ==null || data.dataContainerWidth.startsWith("Select")) + data.dataContainerWidth = null; + if(data.numFormCols ==null || data.numFormCols.startsWith("Select")) + data.numFormCols = null; + + if(!$scope.isEdit) + data.reportId=-1; + if(data.reportTitle==null || data.reportTitle=='') + data.reportTitle = data.reportName; + return data; + } + $scope.updateDef = function(){ + $scope.showLoader=true; + var dataToSave = $scope.constructDef(); + raptorReportFactory.updateDefinition(dataToSave,$scope.isEdit).then(function(data){ + $scope.successPopUp('Definition is updated'); + for(x in $scope.stepTabs){ + $scope.stepTabs[x].disabled=false; + } + $scope.showLoader=false; },function(error){ - $log.error("raptorReportFactory: getSearchData failed."); + $scope.errorPopUp(error); + $log.error("report-step-controller: updateDefinition by Id failed."); }); - } - - var initializeCreateReport = function() { - $scope["selectedReportType"] ={}; - $scope.selectedReportType.value ="linear"; - $scope.selectedReportType2 ={}; - $scope.selectedReportType2.value =""; - $scope.selectedDataSource ={}; - $scope.selectedDataSource.value="local"; - $scope.sqlScript = "SELECT "; - $scope.pageSize = {"value":"50"}; } - - - var loadSqlInSession = function(){ + /*******************Step1 Ends****************/ + /*******************Step2 SQL****************/ + $scope.pageisCreating = false; + $scope.sqlScript={ + value:'' + }; + $scope.sqlTestTableData=''; + /*function*/ + $scope.getSql = function(){ + $scope.showLoader = true; raptorReportFactory.getSqlInSession().then(function(data){ $scope.sqlInSessionJSON = data; - $scope.sqlScript = data.query; - $scope.showLoader = false; + $scope.sqlScript.value = data.query; + $scope.showLoader = false; },function(error){ + $scope.errorPopUp(error); $log.error("raptorReportFactory: getSearchData failed."); }); - }; - - initializeCreateReport(); - if ($routeParams.reportMode) { - if ($routeParams.reportMode=="copy") { - raptorReportFactory.copyReportById($routeParams.reportId).then(function(data){ - $scope.$emit('RefreshInsession'); - },function(error){ - $log.error("raptorReportFactory: deleteFormFieldById failed."); - }); - } else if ($routeParams.reportMode=="import") { - $scope.$emit('RefreshInsession'); - } - } else if ($routeParams.reportId) { - $scope.getDefinitionById($routeParams.reportId); - $scope.isEdit = true; - $scope.reportId = $routeParams.reportId; - } else { - $scope.isEdit = false; - $scope.createNewDefinition(); - } - - - $scope.RunCurrentReport = function (){ - $window.location.href = "#/report_run/c_master="+$scope.reportId+"&refresh=Y"; - } - - $scope.deleteFormField = function(rowData) { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-formfield-del-confirm.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { - $scope.tempFieldId = rowData.id; - $scope.ok = function() { - raptorReportFactory.deleteFormFieldById(rowData.id).then(function(data){ - $modalInstance.close(); - },function(error){ - $log.error("raptorReportFactory: deleteFormFieldById failed."); - }); - } - $scope.cancel = function() { - $modalInstance.dismiss(); - }; - }], - resolve:{ - rowData: function(){ - return rowData; - } - } - }); - modalInstance.result.then(function () { - $scope.$emit('RefreshFormField'); - }, function () { - }); - } - - $scope.loadDefinition = function(definitionData) { - $scope.reportId = definitionData.reportId+""; - $scope.reportName = definitionData.reportName; - $scope.reportDescr = definitionData.reportDescr; - $scope.formHelpText = definitionData.formHelpText; - $scope.selectedPageSize = {"value": definitionData.pageSize+''}; - $scope.selectedMaxRowsInExcelCSVDownload = {"value": definitionData.maxRowsInExcelCSVDownload}; - $scope.reportTitle = definitionData.reportTitle; - $scope.reportSubTitle = definitionData.reportSubTitle; - $scope.selectedNumFormCols ={"value": definitionData.numFormCols+''}; - $scope.selectedFrozenColumns={"value": definitionData.frozenColumns+''}; - $scope.selectedDataGridAlign = {"value":definitionData.dataGridAlign+''}; - $scope.emptyMessage = definitionData.emptyMessage+''; - $scope.selectedDataContainerHeight = {"value":definitionData.dataContainerHeight+''}; - $scope.selectedDataContainerWidth = {"value":definitionData.dataContainerWidth+''}; - var displayAreaValue = "null" - for (var i=0; i<3; i++ ) { - if (definitionData.displayArea[i].selected) { - displayAreaValue = definitionData.displayArea[i].name; - } - } - $scope.selectedDisplayArea = {"value":displayAreaValue+""}; - - $scope.hideFormFieldsAfterRunSelected = {"value": definitionData.hideFormFieldsAfterRun} - - $scope.hideFormFieldsSelected = {"value":definitionData.displayOptions[0].selected}; - $scope.hideChartSelected = {"value":definitionData.displayOptions[1].selected}; - $scope.hideReportDataSelected = {"value":definitionData.displayOptions[2].selected}; - $scope.hideExcelSelected = {"value":definitionData.displayOptions[3].selected}; - $scope.hidePdfSelected = {"value":definitionData.displayOptions[4].selected}; - $scope.runtimeColSortDisabled = {"value":definitionData.runtimeColSortDisabled}; - $scope.showLoader = false; - } - - - var setDefinition = function(){ - $scope.updatedDefJson = { - "tabName" : "Definition", - "tabId" : "Def", - "reportId" : ($scope.isEdit?$scope.reportId+'':"-1"), - "reportName" : $scope.reportName, - "reportDescr" : $scope.reportDescr, - "reportType" : "Linear", - "dbInfo" : "local", - "formHelpText" : $scope.formHelpText, - "pageSize" : Number($scope.selectedPageSize.value), - "displayArea" : [ { - "id" : "HOME", - "name" : "HOME", - "selected" : ($scope.selectedDisplayArea.value=="HOME") - }, { - "id" : "CUSTOMER", - "name" : "CUSTOMER", - "selected" : ($scope.selectedDisplayArea.value==="CUSTOMER") - }, { - "id" : "REPORTS", - "name" : "REPORTS", - "selected" : ($scope.selectedDisplayArea.value==="REPORTS") - } ], - "hideFormFieldsAfterRun" : $scope.hideFormFieldsAfterRunSelected.value, - "maxRowsInExcelCSVDownload" : Number($scope.selectedMaxRowsInExcelCSVDownload.value), - "frozenColumns" : Number($scope.selectedFrozenColumns.value), - "dataGridAlign" : $scope.selectedDataGridAlign.value, - "emptyMessage" : $scope.emptyMessage, - "dataContainerHeight" : $scope.selectedDataContainerHeight.value, - "dataContainerWidth" : $scope.selectedDataContainerWidth.value, - "displayOptions" : [ { - "name" : "HideFormFields", - "selected" : $scope.hideFormFieldsSelected.value - }, { - "name" : "HideChart", - "selected" : $scope.hideChartSelected.value - }, { - "name" : "HideReportData", - "selected" : $scope.hideReportDataSelected.value - }, { - "name" : "HideExcel", - "selected" : $scope.hideExcelSelected.value - }, { - "name" : "HidePdf", - "selected" : $scope.hidePdfSelected.value - } ], - "runtimeColSortDisabled" : $scope.runtimeColSortDisabled.value, - "numFormCols" : Number($scope.selectedNumFormCols.value), - "reportTitle" : $scope.reportTitle, - "reportSubTitle" : $scope.reportSubTitle - } - } - - var updateDefinitionData = function() { - setDefinition(); - raptorReportFactory.updateDefinition($scope.updatedDefJson,$scope.isEdit).then(function(data){ - },function(error){ - $log.error("raptorReportFactory: updateDefinition by Id failed."); - }); - } - - var saveNewDefinitionData = function() { - setDefinition(); - raptorReportFactory.saveNewDefinition($scope.updatedDefJson).then(function(data){ - },function(error){ - $log.error("raptorReportFactory: saveNewDefinition by Id failed."); - }); - } - $scope.testRunSql = function(){ - var queryJSON = {query: $scope.sqlScript}; + $scope.showLoader=true; + var queryJSON = {query: $scope.sqlScript.value}; queryJSON = JSON.stringify(queryJSON); raptorReportFactory.testRunSQL(queryJSON).then(function(data){ + $scope.showLoader=false; var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','queriedData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) { - var init = function() { - $scope.isError = false; - if (queriedData.errormessage) { - $scope.isError = true; - $scope.errormessage = queriedData.errormessage; - $scope.stacktrace = queriedData.stacktrace; - } else { - $scope.queryData = queriedData; - } - } - init(); - $scope.close = function() { - $modalInstance.dismiss(); - }; - }], + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html', + windowClass:'modal-docked', + sizeClass: 'modal-large', + controller: testRunSqlController, resolve:{ queriedData: function(){ - return data; + return data; } - } - }) + } + }); + modalInstance.result.finally(function () { + if(!$scope.isEdit){ + $scope.showLoader=true; + $scope.pageisCreating = true; + $scope.pageMsg = 'Please wait while we are creating the report. Page will be reloaded after the creation is done.' + raptorReportFactory.getDefinitionInSession().then(function(data){ + var newReportId = data.reportId; + if(newReportId!=null && newReportId!='' && newReportId!=-1) + $window.location.href = "#/report_wizard/"+newReportId; + + $scope.showLoader = false; + $scope.pageisCreating = false; + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: get Definition In Session failed."); + $scope.showLoader = false; + }); + } + }); + },function(error){ + $scope.errorPopUp(error); $log.error("raptorReportFactory: test run SQL failed."); }); } + + /*******************Step2 End****************/ + /*******************Step3 Column****************/ + $scope.colTableRowData=''; + $scope.isEditCol= true; + + $scope.getColumn = function(){ + $scope.showLoader = true; + raptorReportFactory.getColumnList().then(function(data){ + $scope.colTableRowData = data; + $scope.showLoader = false; + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: get column list failed."); + }); + } + + $scope.openColumnPopup = function (rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-col-edit.html', + windowClass:'modal-docked', + sizeClass: 'modal-jumbo', + controller: openColumnPopupController, + resolve:{ + colData: function(){ + return rowData; + } + } + }); + modalInstance.result.finally(function () { + $scope.getColumn(); + }); + }; + /*******************Step3 End****************/ + /*******************Step4 Starts Form Fields****************/ + + $scope.dataProcessing = false; + $scope.formFieldData = []; + $scope.getFormFieldList = function(){ + $scope.showLoader= true; + $scope.formFieldData = []; + raptorReportFactory.getFormFieldList().then(function(data){ + $scope.showLoader= false; + $scope.formFieldData = data; + $scope.formFieldData.sort(function(obj1, obj2) { + // Ascending: first age less than the previous + return obj1.orderSeq - obj2.orderSeq; + }); + $scope.showLoader = false; + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: get formfields failed."); + $scope.showLoader = false; + }); + } + + $scope.formFieldReOrder = function(upID, downID){ + + $scope.moveUpFF={}; + $scope.moveDownFF={}; + $scope.showLoader=true; + raptorReportFactory.getFormFieldEditInfoById(upID).then(function(data){ + $scope.moveUpFF = data; + raptorReportFactory.getFormFieldEditInfoById(downID).then(function(data){ + $scope.moveDownFF = data; + var downOrder = $scope.moveDownFF.orderSeq; + $scope.moveDownFF.orderSeq = $scope.moveUpFF.orderSeq; + $scope.moveUpFF.orderSeq = downOrder; + raptorReportFactory.saveFormFieldEditInfo($scope.moveDownFF).then(function(data){ + raptorReportFactory.saveFormFieldEditInfo($scope.moveUpFF).then(function(data){ + $scope.successPopUp(''); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: saveFormFieldEditInfo failed."); + }).finally(function() { + $scope.showLoader=false; + $scope.getFormFieldList(); + }) + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: saveFormFieldEditInfo failed."); + }); + + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getColumnEditInfoById failed."); + }); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getColumnEditInfoById failed."); + }) + + + } + $scope.formFieldVerifySQL= function(sqlScript){ var queryJSON = {query: sqlScript}; queryJSON = JSON.stringify(queryJSON); raptorReportFactory.formFieldVerifySQL(queryJSON).then(function(data){ var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','queriedData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) { - var init = function() { - $scope.isError = false; - if (queriedData.errormessage) { - $scope.isError = true; - $scope.errormessage = queriedData.errormessage; - $scope.stacktrace = queriedData.stacktrace; - } else { - $scope.queryData = queriedData; - } - } - init(); - $scope.close = function() { - $modalInstance.dismiss(); - }; - }], + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html', + sizeClass: 'modal-large', + controller: formFieldVerifySQLController, resolve:{ queriedData: function(){ - return data; + return data; } - } - }) - + } + }) + },function(error){ + $scope.errorPopUp(error); $log.error("raptorReportFactory: test run SQL failed."); }); } - /* $scope.selectedDataSource.allowSchedule={}; - $scope.selectedDataSource.allowSchedule.value=""*/ - - var getJsonSrcName = function(stepNum){ - var JsonSrcPrefix = "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step" - return JsonSrcPrefix + stepNum +".json"; - } - - $scope.gTabs = [ - { - title: 'Definition', - id: 'Definition', - uniqueId: 'uniqueTab1x', - tabPanelId: 'threetab1x' - }, { - title: 'SQL', - id: 'SQL', - uniqueId: 'uniqueTab2x', - tabPanelId: 'threetab2x', - disabled: (!$scope.isEdit) - }, { - title: 'Columns', - id: 'Columns', - uniqueId: 'uniqueTab3x', - tabPanelId: 'threetab3x', - disabled: (!$scope.isEdit) - }, { - title: 'Form Fields', - id: 'Form Fields', - uniqueId: 'uniqueTab4x', - tabPanelId: 'threetab4x', - disabled: (!$scope.isEdit) - }, { - title: 'Security', - id: 'Security', - uniqueId: 'uniqueTab5x', - tabPanelId: 'threetab5x', - disabled: (!$scope.isEdit) - }, { - title: 'Run', - id: 'Run', - uniqueId: 'uniqueTab6x', - tabPanelId: 'threetab6x', - disabled: (!$scope.isEdit) - } - ]; - - $scope.unhideAllOtherTabs = function(){ - for (var selectedTab = 0; selectedTab < $scope.gTabs.length; selectedTab++) { - $scope.gTabs[selectedTab].disabled = false; - } - } - - $scope.openColumnPopup = function (rowData) { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-col-edit.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','colData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, colData) { - raptorReportFactory.getColumnEditInfoById(colData.id).then(function(data){ - $scope.columnEditData = data; - $scope.colId = data.colId; -/* $scope.colName = data.colName;*/ - $scope.colName = {'value':data.colName+''}; - $scope.selectedDisplayAlignment = {"value":data.displayAlignment+''}; - $scope.selectedDisplayHeaderAlignment = {"value":data.displayHeaderAlignment+''}; - $scope.sortable = {"value":''+data.sortable}; - $scope.visible = {"value":''+data.visible}; - $scope.drilldownURL = data.drilldownURL; - $scope.drilldownParams = data.drilldownParams; - $scope.drilldownType = data.drilldownType; - $scope.selectedDrillDownReport = {"value":""}; - - - },function(error){ - $log.error("raptorReportFactory: getColumnEditInfoById failed."); - }); - - var init = function() { - - raptorReportFactory.getDrillDownReportList().then(function(data2){ - $scope.drilldownReports = data2; - },function(error){ - $log.error("raptorReportFactory: getDrillDownReportList failed."); - }); - -/* $scope.colTableRowData = colData;*/ - $scope.displayAlignmentOptions = [ - {value:"null", text:""}, - {value:"Left", text:"Left"}, - {value:"Center", text:"Center"}, - {value:"Right", text:"Right"} - ]; - $scope.ynOptions = [ - {value:"true", text:"Yes"}, - {value:"false", text:"No"} - ]; - $scope.drillDownOptions = [ - {value:"drillDownOpt1", text:"drillDownOpt1"}, - {value:"drillDownOpt2", text:"drillDownOpt2"}, - {value:"drillDownOpt3", text:"drillDownOpt3"} - ]; - } - - init(); - $scope.$watch('selectedDrillDownReport.value',function(){ - if ($scope.selectedDrillDownReport) { - $scope.$emit('openDrillDownpage',$scope.selectedDrillDownReport.value); - } - }); - - $scope.save = function() { - var drilldownURL = "";//raptorReportFactory.drillDownPopupOptions - //raptorReportFactory.drillDownPopupOptions.radioGroup - var colInfo = { - "tabId" : "ColEdit", - "tabName" : "Column Edit", - "colId" : $scope.colId, - "colName" : $scope.colName.value, - "displayAlignment" : ($scope.selectedDisplayAlignment.value=="null")?null:$scope.selectedDisplayAlignment.value, - "displayHeaderAlignment" : ($scope.selectedDisplayHeaderAlignment.value=="null")?null:$scope.selectedDisplayHeaderAlignment.value, - "sortable" : ($scope.sortable.value=="true"), - "visible" : ($scope.visible.value=="true"), - "drilldownURL" : raptorReportFactory.drillDownURL, - "drilldownParams" : raptorReportFactory.drillDownParams, - "drilldownType" : "" - } - raptorReportFactory.saveColumnEditInfo(colInfo).then(function(data){ - $modalInstance.close(); - },function(error){ - $log.error("raptorReportFactory: getColumnEditInfoById failed."); - }); - }; - - $scope.cancel = function() { - $modalInstance.dismiss(); - }; - }], - resolve:{ - colData: function(){ - return rowData; - } - } - }); - - modalInstance.result.then(function () { - $scope.$emit('RefreshColumnList'); - }, function () { - }); - }; - - - $scope.throwReportNameMissingError = function () { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-report-name-validation.html', - sizeClass: 'modal-small', - controller: ['$scope', '$modalInstance', '$http', '$log', function ($scope, $modalInstance, $http, $log) { - $scope.close = function() { - $modalInstance.dismiss(); - }; - }] - }); - modalInstance.result.then(function () { - }, function () { - }); - }; - - - $scope.addNewFormField = function () { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory', function ($scope, $modalInstance, $http, $log, raptorReportFactory) { - raptorReportFactory.getFormFieldEditInfoById("add").then(function(data){ - $scope.formFieldEditData = data; - $scope.fieldId = $scope.formFieldEditData.fieldId; - $scope.fieldName ={"value": $scope.formFieldEditData.fieldName}; - $scope.selectedVisible = {"value":$scope.formFieldEditData.visible+''}; - $scope.defaultValue = {"value": $scope.formFieldEditData.defaultValue}; - $scope.fieldDefaultSQL = {"value": $scope.formFieldEditData.fieldDefaultSQL}; - $scope.fieldSqlContent = {"value": $scope.formFieldEditData.fieldSQL}; - $scope.selectedValidationType = {"value":$scope.formFieldEditData.validationType +''}; - $scope.selectedFieldType = {"value":$scope.formFieldEditData.fieldType +''}; - $scope.sqlDefaultValueSelected= {value:false}; - $scope.sqlDefaultValueSelected ={"value":false}; - if (($scope.fieldDefaultSQL.value)&&($scope.fieldDefaultSQL.value!="")) { - $scope.sqlDefaultValueSelected.value =true; - } - },function(error){ - $log.error("raptorReportFactory: getColumnEditInfoById failed."); - }); - - - $scope.ynOptions = [ - {value:"true", text:"Yes"}, - {value:"false", text:"No"} - ]; - - $scope.verifyFieldValueOptions = [ - {value:"DATE", text:"Date"}, - {value:"TIME_STAMP_HOUR", text:"TimeStamp (Hour)"}, - {value:"TIME_STAMP_HOUR_MIN", text:"TimeStamp (Hour,Min)"}, - {value:"HIDDEN", text:"Hidden"} - ] - - $scope.fieldTypeOptions = [ - {value:"TEXT", text:"Text Box"}, - {value:"LIST_BOX", text:"List Box"}, - {value:"LIST_MULTI_SELECT", text:"Multi-select List Box"}, - {value:"HIDDEN", text:"Hidden"} - ]; - - $scope.save = function() { - var formFieldJSON = { - "tabId" : "FormEdit", - "tabName" : "Form Edit", - "fieldId" : $scope.fieldId, - "fieldName" : $scope.fieldName.value, - "fieldType" : $scope.selectedFieldType.value, - "visible" : ($scope.selectedVisible.value=="true"), - "defaultValue" : ($scope.sqlDefaultValueSelected.value?'':$scope.defaultValue.value), - "fieldDefaultSQL" : ($scope.sqlDefaultValueSelected.value?$scope.fieldDefaultSQL.value:""), - "fieldSQL" :$scope.fieldSqlContent.value, - "validationType" : "NONE", - "predefinedValueList" :null - } - raptorReportFactory.saveFormFieldEditInfo(formFieldJSON).then(function(data){ - $modalInstance.close(); - },function(error){ - $log.error("raptorReportFactory: saveFormFieldEditInfo failed."); - }); - }; - - $scope.cancel = function() { - $modalInstance.dismiss(); - }; - }] - }); - modalInstance.result.then(function () { - $scope.$emit('RefreshFormField'); - }, function () { - }); - }; - - $scope.openFormFieldPopup = function (rowData) { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','fieldData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, fieldData) { - var init = function() { - raptorReportFactory.getFormFieldEditInfoById(fieldData.id).then(function(data){ - $scope.formFieldEditData = data; - $scope.fieldId = $scope.formFieldEditData.fieldId; - $scope.fieldName = {"value":$scope.formFieldEditData.fieldName}; - $scope.selectedVisible = {"value":$scope.formFieldEditData.visible+''}; - $scope.defaultValue = {"value":$scope.formFieldEditData.defaultValue}; - $scope.fieldDefaultSQL = {"value": $scope.formFieldEditData.fieldDefaultSQL}; - $scope.fieldSqlContent = {"value": $scope.formFieldEditData.fieldSQL}; - $scope.selectedValidationType = {"value":$scope.formFieldEditData.validationType +''}; - $scope.selectedFieldType = {"value":$scope.formFieldEditData.fieldType +''}; - $scope.sqlDefaultValueSelected ={"value":false}; - if (($scope.fieldDefaultSQL.value)&&($scope.fieldDefaultSQL.value!="")) { - $scope.sqlDefaultValueSelected.value =true; - } - },function(error){ - $log.error("raptorReportFactory: getColumnEditInfoById failed."); - }); - - $scope.ynOptions = [ - {value:"true", text:"Yes"}, - {value:"false", text:"No"} - ]; - - $scope.verifyFieldValueOptions = [ - {value:"DATE", text:"Date"}, - {value:"TIME_STAMP_HOUR", text:"TimeStamp (Hour)"}, - {value:"TIME_STAMP_HOUR_MIN", text:"TimeStamp (Hour,Min)"}, - {value:"HIDDEN", text:"Hidden"} - ] - - $scope.fieldTypeOptions = [ - {value:"TEXT", text:"Text Box"}, - {value:"LIST_BOX", text:"List Box"}, - {value:"LIST_MULTI_SELECT", text:"Multi-select List Box"}, - {value:"HIDDEN", text:"Hidden"} - ]; - - } - - init(); - - $scope.save = function() { - var formFieldJSON = { - "tabId" : "FormEdit", - "tabName" : "Form Edit", - "fieldId" : $scope.fieldId, - "fieldName" : $scope.fieldName.value, - "fieldType" : $scope.selectedFieldType.value, - "visible" : ($scope.selectedVisible.value=="true"), - "defaultValue" : ($scope.sqlDefaultValueSelected.value?'':$scope.defaultValue.value), - "fieldDefaultSQL" : ($scope.sqlDefaultValueSelected.value?$scope.fieldDefaultSQL.value:""), - "fieldSQL" :$scope.fieldSqlContent.value, - "validationType" : "NONE", - "predefinedValueList" :null - } - raptorReportFactory.saveFormFieldEditInfo(formFieldJSON).then(function(data){ - $modalInstance.close(); - },function(error){ - $log.error("raptorReportFactory: saveFormFieldEditInfo failed."); - }); - }; - - $scope.cancel = function() { - $modalInstance.dismiss(); - }; - }], - resolve:{ - fieldData: function(){ - return rowData; - } - } - }); - - modalInstance.result.then(function () { - $scope.$emit('RefreshFormField'); - }, function () { - }); - }; - - $scope.openDrillDownReportPopup = function (reportId,parentReportId) { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-drilldown-edit.html', - sizeClass: 'modal-large', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','reportId', function ($scope, $modalInstance, $http, $log, raptorReportFactory, reportId) { - - $scope.drillDownOptionList =[]; - $scope.selectedvalueradioGroup = {"name":""}; - $scope.selectedChildReportFormField = {"value":""}; - $scope.selectedChildReportColumn = {"value":""}; - $scope.fixedValue = {"value":""}; - $scope.suppressValues = {"value":""}; + $scope.openFormFieldPopup = function (rowData,type) { + $scope.type= type; + var modalInstance = $modal.open({ + scope: $scope, + animation: true, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html', + sizeClass: 'modal-large', + controller: openFormFieldPopupController, + resolve:{ + fieldData: function(){ + return rowData; + } + } + }); - raptorReportFactory.getChildReportFormField(reportId).then(function(data){ - for (var i=0;i<data.length;i++) { - $scope.drillDownOptionList.push( - { - "name": data[i].name, - "id": data[i].id, - "selectedvalueradioGroup":{"name":""}, - "selectedChildReportFormField":{"value":""}, - "selectedChildReportColumn":{"value":""}, - "fixedValue":{"value":""}, - "suppressValues":{"value":""} - } - ) - } - },function(error){ - $log.error("raptorReportFactory: getChildReportFormField failed."); - }); + modalInstance.result.finally(function () { + $scope.getFormFieldList(); + }); + }; + $scope.addFormField = function(){ + $scope.openFormFieldPopup('','add'); + } + - raptorReportFactory.getChildReportFormField(parentReportId).then(function(data){ - $scope.childReportFF =data; - },function(error){ - $log.error("raptorReportFactory: getChildReportFormField failed."); - }); + $scope.deleteFormField = function(rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-formfield-del-confirm.html', + sizeClass: 'modal-small', + controller: deleteFormFieldController, + resolve:{ + rowData: function(){ + return rowData; + } + } + }); + modalInstance.result.then(function () { + $scope.getFormFieldList(); + }, function () { + }); + } - raptorReportFactory.getChildReportColumn(parentReportId).then(function(data){ - $scope.childReportCol =data; - },function(error){ - $log.error("raptorReportFactory: getChildReportFormField failed."); - }); - - raptorReportFactory.setDrillDownPopupOptions(null); - - $scope.complete = function() { - var drillDownPopupOptions= { - radioGroup : $scope.selectedvalueradioGroup.name, - reportFF: $scope.selectedChildReportFormField.value, - reportCol: $scope.selectedChildReportColumn.value, - fixedValue: $scope.fixedValue.value, - suppressValues: $scope.suppressValues.value - } - var drillDownParams = ""; - var ampStr =""; - for (var i=0;i<$scope.drillDownOptionList.length; i++) { - if (drillDownParams!="") { - ampStr = "&"; - } - if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="fixedValue"){ - drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "="+$scope.drillDownOptionList[i].fixedValue.value; - } else if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="reportFF"){ - drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "=[!"+$scope.drillDownOptionList[i].selectedChildReportFormField.value + "]"; - } else if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="reportCol"){ - drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "=["+$scope.drillDownOptionList[i].selectedChildReportColumn.value + "]"; - } - } - raptorReportFactory.setDrillDownPopupOptions(reportId,drillDownParams); - - $modalInstance.close(); - }; - }], - resolve:{ - reportId: function(){ - return reportId; - } - } - }); + /*******************Step4 End****************/ + /*******************Step5 Starts Security****************/ + $scope.ynOptions = [ + {value:"true", text:"Yes"}, + {value:"false", text:"No"} + ]; + $scope.addReportUserId={ + id:'' + }; + $scope.addReportRoleId={ + id:'' + }; + $scope.loadSecurityPage = function() { + $scope.showLoader = true; + raptorReportFactory.resetSecurityLoadingCounter(); - modalInstance.result.then(function () { -/* $scope.$emit('RefreshFormField');*/ - }, function () { - }); -}; - - $scope.$watch('activeTabsId', function (newVal, oldVal) { - if(newVal !== oldVal) { - $scope.showLoader = true; - var selectedTab; - for (selectedTab = 0; selectedTab < $scope.gTabs.length; selectedTab++) { - if ($scope.gTabs[selectedTab].id === newVal) { - $scope.stepNum = selectedTab; -/* stepFormFactory.getStepJSONData(getJsonSrcName($scope.stepNum))*/ - $scope.isColumnStep = false; - $scope.isFormFieldStep = false; - $scope.isSecurityStep = false; - $scope.renderStep(selectedTab+1); - if ($scope.stepNum == 1) { - $scope.showLoader = false; - } - else if ($scope.stepNum == 2) { - loadSqlInSession(); - } else if ($scope.stepNum == 3) { - $scope.isColumnStep = true; - raptorReportFactory.getColumnList().then(function(data){ - $scope.colTableRowData = data; - $scope.showLoader = false; - },function(error){ - $log.error("raptorReportFactory: get column list failed."); - $scope.showLoader = false;}); - - } else if ($scope.stepNum == 4) { - $scope.isFormFieldStep = true; - // put within then function: - raptorReportFactory.getFormFieldList().then(function(data){ - $scope.formFieldData = data; - $scope.showLoader = false; - },function(error){ - $log.error("raptorReportFactory: get formfields failed."); - $scope.showLoader = false;}); - } else if ($scope.stepNum == 5) { - $scope.isSecurityStep = true; - $scope.reportOwnerId={'id':''}; - $scope.isPublicOptionList = [ - {'value':'true','text':'Yes'}, - {'value':'false','text':'No'}, - ]; - $scope.loadSecurityPage(); - - } - else if ($scope.stepNum == 6) { - raptorReportFactory.getDefinitionInSession().then(function(data){ - $scope.reportId = data.reportId; - $scope.showLoader = false; - },function(error){ - $log.error("raptorReportFactory: getDefinitionInSession failed."); - $scope.showLoader = false;}); - } - - if ($scope.stepNum>1){ - $scope.unhideAllOtherTabs(); - } - break; - } - } - } - }); - - $scope.loadSecurityPage = function() { - $scope.showLoader = true; - raptorReportFactory.resetSecurityLoadingCounter(); - - //API call 1: + //API call 1: raptorReportFactory.getSecurityReportOwnerList().then(function(data){ - $scope.reportOwnerList = data; + $scope.reportOwnerList = data; raptorReportFactory.icrementSecurityLoadingCounter(); if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; - },function(error){ - $log.error("raptorReportFactory: getSecurityReportOwnerList failed."); - }); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getSecurityReportOwnerList failed."); + }); //API call 2: get report role list raptorReportFactory.getReportRoleList().then(function(data){ - $scope.reportRoleList = data; + $scope.reportRoleList = data; raptorReportFactory.icrementSecurityLoadingCounter(); if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; },function(error){ - $log.error("raptorReportFactory: getReportRoleList failed."); - }); + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getReportRoleList failed."); + }); //API call 3: get security page basic info raptorReportFactory.getReportSecurityInfo().then(function(data){ - $scope.reportSecurityInfo = data; - $scope.reportOwnerId ={id: $scope.reportSecurityInfo.ownerId}; + $scope.reportSecurityInfo = data; + $scope.reportOwnerId ={id: $scope.reportSecurityInfo.ownerId}; raptorReportFactory.icrementSecurityLoadingCounter(); if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; - },function(error){ - $log.error("raptorReportFactory: getReportSecurityInfo failed."); - $scope.showLoader = false;}); - + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getReportSecurityInfo failed."); + $scope.showLoader = false;}); + //API call 4: retrieve security users raptorReportFactory.getReportSecurityUsers().then(function(data){ - $scope.reportSecurityUsers = data; - for (var i=0; i<$scope.reportSecurityUsers.length;i++) { - $scope.reportSecurityUsers[i]["accessAllowed"] = !$scope.reportSecurityUsers[i]["readOnly"]; - } - raptorReportFactory.icrementSecurityLoadingCounter(); + + $scope.reportSecurityUsers = data; + for (var i=0; i<$scope.reportSecurityUsers.length;i++) { + $scope.reportSecurityUsers[i]["accessAllowed"] = !$scope.reportSecurityUsers[i]["readOnly"]; + $scope.reportSecurityUsers[i].runAccess = true; // need to check why 1702 version is making it true always + } + raptorReportFactory.icrementSecurityLoadingCounter(); if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; - },function(error){ - $log.error("raptorReportFactory: reportSecurityUsers failed."); - }); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: reportSecurityUsers failed."); + }); //API call 5: retrieve security roles raptorReportFactory.getReportSecurityRoles().then(function(data){ - $scope.reportSecurityRoles = data; - for (var i=0; i<$scope.reportSecurityRoles.length;i++) { - $scope.reportSecurityRoles[i]["accessAllowed"] = !$scope.reportSecurityRoles[i]["readOnly"]; - } - + $scope.reportSecurityRoles = data; + for (var i=0; i<$scope.reportSecurityRoles.length;i++) { + $scope.reportSecurityRoles[i]["accessAllowed"] = !$scope.reportSecurityRoles[i]["readOnly"]; + $scope.reportSecurityRoles[i].runAccess = true; // need to check why 1702 version is making it true always + } + raptorReportFactory.icrementSecurityLoadingCounter(); if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;}; - },function(error){ - $log.error("raptorReportFactory: reportSecurityRoles failed."); - }); - } - - - $scope.renderStep = function(stepNum){ - var containerElement = angular.element(document.getElementById("stepView")); - containerElement.empty(); - $scope.stepNum = stepNum; - var jsonSrcName = getJsonSrcName(stepNum); - stepFormFactory.renderForm(jsonSrcName, containerElement, $scope); - } - - $scope.toggleUserEditAccessActive = function(rowData) { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html', - sizeClass: 'modal-small', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { - $scope.rowData = rowData; - $scope.toggleEditAccessStatus = function(rowData) { - raptorReportFactory.toggleUserEditAccess(rowData); - $modalInstance.close(); - }; - - $scope.cancelEditAccessToggle = function(rowData) { - rowData.accessAllowed = ! rowData.accessAllowed; - $modalInstance.dismiss('cancel');} - }], - resolve:{ - rowData: function(){ - return rowData; - } - } - }); - modalInstance.result.then(function () { - - }, function () { - }); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: reportSecurityRoles failed."); + }); } - - $scope.toggleRoleEditAccessActive = function(rowData) { - var modalInstance = $modal.open({ - scope: $scope, - animation: $scope.animationsEnabled, - templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html', - sizeClass: 'modal-small', - controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { - $scope.rowData = rowData; - $scope.toggleEditAccessStatus = function(rowData) { - raptorReportFactory.toggleRoleEditAccess(rowData); - $modalInstance.close(); - }; - - $scope.cancelEditAccessToggle = function(rowData) { - rowData.accessAllowed = ! rowData.accessAllowed; - $modalInstance.dismiss('cancel');} - }], - resolve:{ - rowData: function(){ - return rowData; - } - } - }); - modalInstance.result.then(function () { - - }, function () { - }); + $scope.addReportSecurityUser = function(userId) { + $scope.showLoader=true; + raptorReportFactory.addReportSecurityUser(userId).then(function(data){ + $scope.loadSecurityPage(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: addReportSecurityUser failed."); + }).finally(function() { + $scope.showLoader=false; + }); } - - - - - - // initialize the page at step 1; - $scope.renderStep(1); - - // create a message to display in our view - $scope.allProjects = []; - if(!$routeParams.step && $routeParams.step == "") $routeParams.step = 1; - if($routeParams.proj && $routeParams.proj > 0) - $scope.projid = $routeParams.proj; - if($routeParams.step) - $scope.stepNum = $routeParams.step; - else - $scope.stepNum = 1; - - $scope.jsonSrcName = getJsonSrcName($scope.stepNum); - - $scope.selectAction = function () { - var containerElement = angular.element(document.getElementById("stepView")); - containerElement.empty(); - $scope.project_name = this.prj.projectName; - $scope.stepNum = 1; - var stepNum = $scope.stepNum; - var jsonSrcName = getJsonSrcName(stepNum); - stepFormFactory.renderForm(jsonSrcName, containerElement, $scope); - renderProject(this.prj.id, 1); - }; - - - $scope.createAction = function () { - var containerElement = angular.element(document.getElementById("stepView")); - containerElement.empty(); - $scope.stepNum = 1; - var stepNum = $scope.stepNum; - $scope.jsonSrcName = "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step"+$scope.stepNum +".json"; - var jsonSrcName = $scope.jsonSrcName; - stepFormFactory.renderForm(jsonSrcName, containerElement, $scope); - }; - // select current project - renderProject = function (proj_id, stepNum) { - var userSelectedPrjId = proj_id; - $http({ - method: 'GET', - url: 'get_selected_project_data', - params:{'selectedPrjId':userSelectedPrjId, 'step': stepNum} - }).then(function successCallback(response) { - var selectedproject = response.data; - $scope.projid = userSelectedPrjId; - //$scope.allProjects = projectLists; - //$location.path('/'+userSelectedPrjId+'/'+stepNum); - var div = d3.select("#stepView"); - div.select("[name='proj_id']").text(userSelectedPrjId); - div.select("[name='proj_id']").property("value", userSelectedPrjId); - d3.select("[name='project_id']").property("value", userSelectedPrjId); - var h3Text = div.select("h3").text(); - div.select("h3").text($scope.project_name+ " - " + h3Text); - for (var key in selectedproject) { - if (selectedproject.hasOwnProperty(key)) { - var val = selectedproject[key]; - var formElement = d3.selectAll("[name='" + key + "']"); - if(formElement[0].length > 0) - console.log(formElement.attr("type")); - if(formElement[0].length > 0 && formElement.attr("type") === "radio") { - var formRadio = d3.selectAll("[id='" + key +"_"+val + "']"); - formRadio.property('checked', true); - } - if(formElement[0].length > 0 && formElement.property("type") === "textarea") { - div.select("textarea[name='" + key +"']").property('value', val); - } - if(formElement[0].length > 0 && formElement.attr("type") === "text") { - var formText = d3.selectAll("[name='" + key + "']"); - formText.property("value", val); - } - if(formElement[0].length > 0 && formElement.html().startsWith("<option")) { - var formSelect = d3.selectAll("[name='" + key + "']"); - - var checkOption = function (e) { - if(e.label === val){ - return formSelect.property("selectedIndex", e.index ); - } - }; + $scope.removeReportSecurityUser = function(securityUser) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-user-del-confirm.html', + sizeClass: 'modal-small', + controller: removeReportSecurityUserController, + resolve:{ + securityUser: function(){ + return securityUser; + } + } + }); + modalInstance.result.then(function () { + $scope.loadSecurityPage(); + }, function () { + }); + }; + $scope.addReportSecurityRole = function(roleId) { + raptorReportFactory.addReportSecurityRole(roleId).then(function(data){ + $scope.loadSecurityPage(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: addReportSecurityRole failed."); + }); + } - formSelect.selectAll("option").forEach(function(d) {d.forEach(function(optionD) {checkOption(optionD); }) }); - } - - if(formElement[0].length == 0) { - if(key != 'step') { - if( Object.prototype.toString.call( val ) === '[object Array]' ) { - val.forEach(function(d){ - for (var keyCheck in d) { - if (d.hasOwnProperty(keyCheck)) { - var valCheck = d[keyCheck]; - var formCheck = d3.selectAll("[name='" + key + "_"+keyCheck + "']"); - if(valCheck === true) - formCheck.property('checked', true); - } - } - }); - } - } - var formElementOther = d3.selectAll("[name='" + key + "_"+ val + "']"); - if(formElementOther[0].length > 0 && formElementOther.attr("type") === "checkbox") { - var formCheckbox = d3.selectAll("[name='" + key +"_"+val + "']"); - formRadio.property('checked', true); - } - } - } - } - - - - }); - } - - //submit function - $scope.submit = function(){ - let defer = $q.defer(); - - var div = d3.select("#stepView"); - var jsonSrcName = $scope.jsonSrcName; - var stepNum = $scope.stepNum; - var values = ""; - $http({ - method: 'GET', - url: jsonSrcName - }).then(function successCallback(response) { - var json = response.data; - var step = json.step; - if(step > 0) { - var sections = json.content.sections; - sections.forEach(function(d, i) { - var elements = d.elements; - if(elements) { - //elements.forEach(function(element, elementIndex) { - values += "{"; - values += "\"step\""+ ":\"" + step + "\","; - values += "\"proj_id\""+ ":\"" + d3.select('input[name="project_id"]').property("value") + "\","; - - for (elementIndex = 0; elementIndex < elements.length; elementIndex++) { - var element = elements[elementIndex]; - - if(elementIndex > 0) values += ","; - values += "\""+element.name +"\""+ ":" ; - if(element.input === "hidden") { - values += "\""+div.select('input[name="'+element.name+'"]').property("value") +"\""; - } - if(element.input === "radio") { - values += "\""+ div.select('input[name="'+element.name+'"]:checked').property("value") +"\""; - } - if(element.input === "checkbox") { - var checkOptions = element.options; - values += "[{"; - checkOptions.forEach(function(d, i) { - // if(document.getElementById("'"+element.name+"_"+d.id+"'") != null) - values += "\""+d.id+"\""+ ":" + div.select('input[name="'+element.name+"_"+d.id+'"]').property("checked") ; - if(i<checkOptions.length-1) { - values += ","; - } - }) - values += "}]"; - } - if(element.input === "text") { - values += "\""+div.select('input[name="'+element.name+'"]').property("value") +"\""; - } - if(element.input === "textarea") { - values += "\""+div.select('textarea[name="'+element.name+'"]').node().value +"\""; - } - if(element.input === "select") { - values += "\""+ div.select('select[name="'+element.name+'"]').property("value") + "\""; - } - - }; - values += "}"; - } - }); - } - var valueJSON = JSON.parse(values); - var valueStr = JSON.stringify(valueJSON, null, 4); - $http({method:'POST', url:'save_steps', data: jsonSrcName, params:{'result' : valueStr, 'proj_id' : values.proj_id}}).success(function(data, status) { - if(data.project_name) - $scope.project_name = data.project_name; - div.select("[name='proj_id']").property("value", data.proj_id); - d3.select("[name='project_id']").property("value", data.proj_id); - //$scope.projid = data.proj_id; - valueStr=JSON.stringify(data, null, 4); - defer.resolve(); - //stepNum = Number(stepNum || 0)+1; - //document.getElementById('itestframe').src = data; - - }) + + $scope.removeReportSecurityRole = function(securityRole) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-role-del-confirm.html', + sizeClass: 'modal-small', + controller: removeReportSecurityRoleController, + resolve:{ + securityRole: function(){ + return securityRole; + } + } + }); + modalInstance.result.then(function () { + $scope.loadSecurityPage(); + }, function () { + }); + } - defer.resolve(); - - }); - // $location.path('/step'+($scope.stepNum+1)); - return defer.promise; - - }; - - //Save function - $scope.save = function() { - if ($scope.stepNum ==1) { - updateDefinitionData(); - } else if($scope.stepNum ==5) { - $scope.saveReportSecurityInfo($scope.reportOwnerId.id,$scope.reportSecurityInfo.isPublic); - } + $scope.saveReportSecurityInfo = function() { + $scope.showLoader = true; + var securityInfo = {'userId':$scope.reportSecurityInfo.ownerId+"",'isPublic':$scope.reportSecurityInfo.isPublic}; + raptorReportFactory.updateReportSecurityInfo(securityInfo).then(function(data){ + $scope.successPopUp(''); + $scope.loadSecurityPage(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: updateReportSecurityInfo failed."); + }); }; - - //Next function - $scope.next = function(){ - if ($scope.stepNum ==1) { - if ($scope.reportName==="") { - $scope.throwReportNameMissingError(); - return; - } - updateDefinitionData(); - } - $scope.stepNum = $scope.stepNum +1; - $scope.activeTabsId = $scope.gTabs[$scope.stepNum-1].id; - }; - - //Previous function - $scope.previous = function(){ - $scope.stepNum = $scope.stepNum -1; - $scope.activeTabsId = $scope.gTabs[$scope.stepNum-1].id; - - }; - - $scope.$on('RefreshInsession', function(event) { - $scope.isEdit = true; - $scope.reportId = -1; - $scope.getDefinitionById(-1); - }); - $scope.$on('openDrillDownpage', function(event, reportId) { - if (reportId!="") { - $scope.openDrillDownReportPopup(reportId,$scope.reportId); - } - }); + $scope.toggleUserEditAccessActive = function(rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html', + sizeClass: 'modal-small', + controller: toggleUserEditAccessActiveController, + resolve:{ + rowData: function(){ + return rowData; + } + } + }); + } - - $scope.$on('RefreshFormField', function(event) { - raptorReportFactory.getFormFieldList().then(function(data){ - $scope.formFieldData = data; + $scope.toggleRoleEditAccessActive = function(rowData) { + var modalInstance = $modal.open({ + scope: $scope, + animation: $scope.animationsEnabled, + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html', + sizeClass: 'modal-small', + controller: toggleRoleEditAccessActiveController, + resolve:{ + rowData: function(){ + return rowData; + } + } + }); + } + + /*******************Step5 End****************/ + /*******************Step6 Starts****************/ + $scope.logs = []; + $scope.getReportID = function(){ + $scope.showLoader = true; + raptorReportFactory.getReportLogs($routeParams.reportId).then(function(data){ + $scope.logs = data; + $scope.showLoader = false; + },function(error){ - $log.error("raptorReportFactory: get formfields failed."); - }); - }); - - $scope.$on('RefreshColumnList', function(event) { - raptorReportFactory.getColumnList().then(function(data){ - $scope.colTableRowData = data; + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getReportID failed."+ error); + }); + } + + + /*******************Step6 End****************/ + /*******************Step7 Starts Run****************/ + $scope.loadDefinitionInSession = function(){ + $scope.showLoader = true; + raptorReportFactory.getDefinitionInSession().then(function(data){ + $scope.reportId = data.reportId; + $scope.showLoader = false; },function(error){ - $log.error("raptorReportFactory: get column list failed."); - }); - }); + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getDefinitionInSession failed."); + $scope.showLoader = false; + }); + } + $scope.runReport = function(){ + $window.location.href = "#/report_run/c_master="+$scope.reportId+"&refresh=Y"; + } + /*******************Step7 End****************/ - $scope.getAllProjects = function(){ - $http({ - method: 'GET', - url: 'get_projects' - }).then(function successCallback(response) { - var projectLists = response.data; - $scope.allProjects = projectLists; - }); - } - - // getAllProjects(); - + /********************Init*************/ + $scope.init = function(){ + if ($routeParams.reportMode=="copy") { + raptorReportFactory.copyReportById($routeParams.reportId).then(function(data){ + $scope.isEdit = true; + $scope.reportId = -1; + $scope.getDefinitionById(-1); + },function(error){ + $log.error("raptorReportFactory: deleteFormFieldById failed."); + }); + } /*else if ($routeParams.reportMode=="import") { + $scope.$emit('RefreshInsession'); + }*/ + + + if($scope.activeTabsId=='definition'){ /*Step 1*/ + $scope.constructureDefDropDown(); + if($scope.isEdit) + $scope.getDefinitionById($scope.reportIdURL); //edit + else + $scope.getDefinitionById(-1); //create + }else if($scope.activeTabsId=='sql'){ /*Step 2*/ + $scope.getSql(); + }else if($scope.activeTabsId=='columns'){ + $scope.getColumn(); + }else if($scope.activeTabsId=='formFields'){ + $scope.getFormFieldList(); + }else if($scope.activeTabsId=='security'){ + $scope.loadSecurityPage(); + }else if($scope.activeTabsId=='log'){ + $scope.getReportID(); + }else if($scope.activeTabsId=='run'){ + $scope.reportId = $scope.reportIdURL; + if($scope.reportId==null || $scope.reportId=='') + $scope.loadDefinitionInSession(); + } + } + + $scope.successPopUp = function (msg) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/success_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + msg: function () { + var message = { + title: '', + text: msg + }; + return message; + } + } + }); + }; + + $scope.errorPopUp = function (msg) { + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-modal/error_modal.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + msg: function () { + return msg; + } + } + }); + }; + + $scope.init(); }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/ds2-raptor-report/raptorReportFactory.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/ds2-raptor-report/raptorReportFactory.js index 83c051db..37845a60 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/ds2-raptor-report/raptorReportFactory.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/ds2-raptor-report/raptorReportFactory.js @@ -175,6 +175,38 @@ appDS2.factory('raptorReportFactory', function($http, $q) { return $q.reject("raptorReportFactory: getDrillDownReportList callback failed"); }); }, + getTotalColList: function() { + return $http({ + method: "GET", + url: "report/wizard/list_drilldown_reports", + }).then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject("raptorReportFactory: getDrillDownReportList did not return a valid JSON object."); + } + return response.data; + }, function(response) { + // something went wrong + return $q.reject("raptorReportFactory: getDrillDownReportList callback failed"); + }); + }, + getTotalForTheColList : function(){ + return $http({ + method: "GET", + url: "report/wizard/retrieveTotalForTheColList", + }).then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject("raptorReportFactory: retrieveTotalForTheColList did not return a valid JSON object."); + } + return response.data; + }, function(response) { + // something went wrong + return $q.reject("raptorReportFactory: retrieveTotalForTheColList callback failed"); + }); + }, getChildReportFormField: function(reportId) { return $http({ method: "GET", @@ -285,6 +317,23 @@ appDS2.factory('raptorReportFactory', function($http, $q) { return $q.reject("raptorReportFactory: saveFormFieldEditInfo callback failed"); }); }, + addFormFieldEditInfo: function(addFormFieldJson){ + return $http({ + method: "POST", + url: "report/wizard/add_formfield_tab_data", + data: addFormFieldJson + }).then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject("raptorReportFactory: saveFormFieldEditInfo did not return a valid JSON object."); + } + }, function(response) { + // something went wrong + return $q.reject("raptorReportFactory: saveFormFieldEditInfo callback failed"); + }); + }, + getFormFieldList: function() { return $http({ method: "GET", @@ -546,6 +595,21 @@ appDS2.factory('raptorReportFactory', function($http, $q) { return $q.reject("raptorReportFactory: updateReportSecurityInfo callback failed"); }); }, + getReportLogs: function(reportId) { + return $http({ + method: "GET", + url: "report/wizard/get_report_log/"+reportId + }).then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject("raptorReportFactory: getReportLogs did not return a valid JSON object."); + } + }, function(response) { + // something went wrong + return $q.reject("raptorReportFactory: getReportLogs callback failed"); + }); + }, toggleUserEditAccess: function(reportUser) { var readOnly = reportUser.accessAllowed?"N":"Y"; @@ -590,6 +654,21 @@ appDS2.factory('raptorReportFactory', function($http, $q) { }, checkSecurityLoadingCounter: function() { return (this.securityPageApiCounter ==this.securityPageApiTotalCount); + }, + getDrillDownParamDef: function(param) { + return $http({ + method: "GET", + url: "report/wizard/drill_down_param/"+param + }).then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject("raptorReportFactory: getDrillDownParamDef did not return a valid JSON object."); + } + }, function(response) { + // something went wrong + return $q.reject("raptorReportFactory: getDrillDownParamDef callback failed"); + }); } }; }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/ds2-raptor-report/reportModalControllers.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/ds2-raptor-report/reportModalControllers.js new file mode 100644 index 00000000..2b59c578 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/ds2-raptor-report/reportModalControllers.js @@ -0,0 +1,423 @@ +var ModalInstanceCtrl = function ($scope, $modalInstance, msg,$rootScope) { + $scope.msg=msg; +} + +var testRunSqlController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) { + var init = function() { + $scope.isError = false; + if (queriedData.errormessage) { + $scope.isError = true; + $scope.errormessage = queriedData.errormessage; + $scope.stacktrace = queriedData.stacktrace; + } else { + $scope.queryData = queriedData; + } + } + init(); + $scope.close = function() { + $modalInstance.dismiss(); + }; +} + +var openColumnPopupController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, colData, $routeParams) { + $scope.processingData=true; + $scope.colInfo={}; + $scope.drilldownReports={}; + $scope.isEditCol = true; + var init = function() { + $scope.displayAlignmentOptions = [ + {value:"null", text:""}, + {value:"Left", text:"Left"}, + {value:"Center", text:"Center"}, + {value:"Right", text:"Right"} + ]; + $scope.dataTypeOptions = [ + {value:"Number", text:"Number"}, + {value:"Date", text:"Date"}, + {value:"VARCHAR2", text:"Character"}, + {value:"Hyperlink", text:"Hyperlink"} + ]; + + $scope.multiGroupColLevel = [ + {value:"1", text:"1"}, + {value:"2", text:"2"}, + {value:"3", text:"3"}, + {value:"4", text:"4"} + ]; + $scope.indentValues = [ + {value:"1", text:"1"}, + {value:"2", text:"2"}, + {value:"3", text:"3"}, + ]; + } + + $scope.totalForTheColList= []; + raptorReportFactory.getTotalForTheColList().then(function(data){ + $scope.totalForTheColList = data; + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: retrieveTotalForTheColList failed."); + }); + + raptorReportFactory.getDrillDownReportList().then(function(data2){ + $scope.drilldownReports = data2; + raptorReportFactory.getColumnEditInfoById(colData.id).then(function(data){ + $scope.colInfo = data; + if($scope.colInfo.noWrap!=null && ($scope.colInfo.noWrap=='Y' || $scope.colInfo.noWrap==true)) + $scope.colInfo.noWrap=true; + else + $scope.colInfo.noWrap=false; + $scope.processingData=false; + init(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getColumnEditInfoById failed."); + }); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getDrillDownReportList failed."); + }); + + $scope.massageData = function(){ + if(!Number.isInteger($scope.colInfo.level)) + $scope.colInfo.level = null; + if(!Number.isInteger($scope.colInfo.indentation)) + $scope.colInfo.indentation = null; + } + + $scope.save = function() { + $scope.processingData=true; + $scope.colInfo.noWrap=($scope.colInfo.noWrap==true)?'Y':'N'; + if($scope.colInfo.level && $scope.colInfo.level.startsWith("Select")) + $scope.colInfo.level = null; + if($scope.colInfo.displayTotal && $scope.colInfo.displayTotal.startsWith("Select")) + $scope.colInfo.displayTotal = null; + + if($scope.colInfo.indentation && $scope.colInfo.indentation.startsWith("Select")) + $scope.colInfo.indentation = null; + raptorReportFactory.saveColumnEditInfo($scope.colInfo).then(function(data){ + $scope.successPopUp(''); + $scope.processingData=false; + $modalInstance.close(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: save failed."); + $scope.processingData=false; + }); + }; + + $scope.cancel = function() { + $modalInstance.dismiss(); + }; + + + /****Drill***/ + $scope.drilDownValues=[]; + $scope.childReportFF =[]; + $scope.childReportCol = []; + $scope.complete = function() { + var drillDownParams=''; + var ampStr = "&"; + var count =0; + for(var i in $scope.selectedDrillReportFormField){ + var selectedRadio = $scope.selectedDrillReportFormField[i]; + if( selectedRadio != (i+'-0')){// if it's not 'No Value' + if (typeof($scope.drillDownParams[i].fieldName) == "undefined"){ + if(i>=($scope.drilDownFormField.length-1)){ + var id = $scope.drilDownFormField[i].id; + drillDownParams+= id+"="; + } + }else + drillDownParams+=$scope.drillDownParams[i].fieldName+"="; + if( selectedRadio == (i+'-1')){//'Fixed Value' + drillDownParams+= $scope.drillDownParams[i].valValue+ampStr; + }else if( selectedRadio == (i+'-2')){//'Value of Column' + drillDownParams+= ('['+$scope.drillDownParams[i].valColId+']'+ampStr); + }else if( selectedRadio == (i+'-3')){//'Value of form field' + drillDownParams+= ('[!'+$scope.drillDownParams[i].valFieldId+']'+ampStr); + }else if( selectedRadio == (i+'-4')){//'Value set' + if($scope.drillDownParams[i].valColId!='' && $scope.drillDownParams[i].valFieldId!='' && $scope.drillDownParams[i].valColId!='Select' && $scope.drillDownParams[i].valFieldId!='Select') + drillDownParams+= ('['+$scope.drillDownParams[i].valColId+'!'+$scope.drillDownParams[i].valFieldId+']'+ampStr); + } + } + } + drillDownParams = drillDownParams.substring(0, drillDownParams.length - 1); + $scope.colInfo.drilldownParams = drillDownParams; + $scope.isEditCol=true; + }; + $scope.selectedDrillReportFormField = []; + $scope.drillDownParams = {}; + $scope.getDrillReportFormField = function(ddReportId,param){ + $scope.isEditCol = false; + $scope.processingData = true; + + raptorReportFactory.getChildReportFormField(ddReportId).then(function(data){ + $scope.drilDownFormField = data; + for(var i in data){ + var array = [ + {selection: 'No Value', value:'Accept Default', radioGroup :i+'-'+'0'}, + {selection: 'Fixed Value', value:'Accept Default' , radioGroup :i+'-'+'1'}, + {selection: 'Value of Column', value:'Accept Default', radioGroup :i+'-'+'2'}, + {selection: 'Value of form field', value:'Accept Default', radioGroup :i+'-'+'3'}, + {selection: 'Value set', value:'Pass the value of the selected column if not empty, otherwise pass the value of the selected form field', radioGroup :i+'-'+'4'} + ] + $scope.drilDownValues.push(array); + } + + if(param!=''){ + raptorReportFactory.getDrillDownParamDef(param).then(function(dataDD){ + var temp = $scope.drilDownFormField; + $scope.drillDownParams = []; + for(var i in $scope.drilDownFormField){ + $scope.selectedDrillReportFormField[i] = i+'-0'; + var tmp = { + fieldName: $scope.drilDownFormField[i].id, + valColId:'', + ValFieldId:'', + valType:'', + valValue:'' + }; + $scope.drillDownParams.push(tmp); + } + for(var i in $scope.drilDownFormField){ + for(var j in dataDD){ + if($scope.drilDownFormField[i].id == dataDD[j].fieldName){ + $scope.selectedDrillReportFormField[i] = i+'-'+dataDD[j].valType; + $scope.drillDownParams[i] = dataDD[j]; + } + } + } + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getChildReportFormField failed."); + }).finally(function() { + $scope.processingData=false; + }); + }else{ + $scope.processingData = false; + } + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getChildReportFormField failed."); + }); + + raptorReportFactory.getChildReportFormField($scope.colInfo.drilldownURL).then(function(data){ + $scope.childReportFF =data; + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getChildReportFormField failed."); + }); + + raptorReportFactory.getChildReportColumn($routeParams.reportId).then(function(data){ + $scope.childReportCol =data; + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getChildReportFormField failed."); + }); + } +} + + +var openFormFieldPopupController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, fieldData) { + $scope.formFieldEditData = {}; + $scope.sqlAsDefaultValue ={ + value:false + }; + $scope.predefinedValues ={ + value:'' + }; + var init = function() { + if($scope.type=='edit'){ + $scope.dataProcessing = true; + raptorReportFactory.getFormFieldEditInfoById(fieldData.id).then(function(data){ + $scope.dataProcessing = false; + $scope.formFieldEditData = data; + if($scope.formFieldEditData.fieldDefaultSQL) + $scope.sqlAsDefaultValue.value = true; + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: getColumnEditInfoById failed."); + }).finally(function() { + $scope.dataProcessing=false; + }); + }else{ + $scope.formFieldEditData ={ + groupFormField: false, + visible:"true" + }; + } + $scope.ynOptions = [ + {value:"true", text:"Yes"}, + {value:"false", text:"No"} + ]; + $scope.verifyFieldValueOptions = [ + {value:null, text:"--- Do Not Perform Validation ---"}, + {value:"DATE", text:"Date"}, + {value:"TIMESTAMP_HR", text:"TimeStamp (Hour)"}, + {value:"TIMESTAMP_MIN", text:"TimeStamp (Hour,Min)"}, + {value:"TIMESTAMP_SEC", text:"TimeStamp (Hour,Min,Sec)"}, + {value:"INTEGER", text:"Integer"}, + {value:"POSITIVE_INTEGER", text:"Positive Integer"}, + {value:"NON_NEGATIVE_INTEGER", text:"Positive Integer. Cannot Be Zero"}, + {value:"FLOAT", text:"Any Number"}, + {value:"NON_NEGATIVE_FLOAT", text:"Positive Number"}, + {value:"POSITIVE_FLOAT", text:"Positive Number. Cannot Be Zero"} + ] + $scope.fieldTypeOptions = [ + {value:"TEXT", text:"Text Box"}, + {value:"LIST_BOX", text:"List Box"}, + {value:"LIST_MULTI_SELECT", text:"Multi-select List Box"}, + {value:"HIDDEN", text:"Hidden"} + ]; + } + init(); + $scope.save = function() { + if($scope.sqlAsDefaultValue.value && ($scope.formFieldEditData.fieldDefaultSQL==null || $scope.formFieldEditData.fieldDefaultSQL=='')){ + $scope.errorPopUp("if SQL as Default Value is checked, 'Default SQL' and 'SQL Generating Custom List of Values' fields cannot be empty"); + return; + }else if(!$scope.sqlAsDefaultValue.value){ + $scope.formFieldEditData.fieldDefaultSQL=null; + } + $scope.dataProcessing = true; + console.log($scope.formFieldEditData.validationType); + if($scope.formFieldEditData.validationType=='Select') + $scope.formFieldEditData.validationType = ''; + raptorReportFactory.saveFormFieldEditInfo($scope.formFieldEditData).then(function(data){ + $scope.dataProcessing = false; + $scope.successPopUp(''); + $modalInstance.close(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: saveFormFieldEditInfo failed."); + }).finally(function() { + $scope.dataProcessing=false; + }); + }; + + $scope.add = function() { + $scope.dataProcessing = true; + $scope.formFieldEditData.visible== + raptorReportFactory.addFormFieldEditInfo($scope.formFieldEditData).then(function(data){ + $scope.dataProcessing = false; + $modalInstance.close(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: add FormFieldEditInfo failed."); + }).finally(function() { + $scope.dataProcessing=false; + }); + }; + + $scope.addPredefinedValueList = function() { + if($scope.formFieldEditData.predefinedValueList==null) + $scope.formFieldEditData.predefinedValueList=[]; + var item ={ + id:$scope.predefinedValues.value, + name:$scope.predefinedValues.value, + selected:false + }; + if($scope.predefinedValues.value!=null && $scope.predefinedValues.value!='') + $scope.formFieldEditData.predefinedValueList.push(item); + }; + + $scope.removePredefinedValueList = function(removeVal) { + var removeIndex = null; + for(i in $scope.formFieldEditData.predefinedValueList){ + if($scope.formFieldEditData.predefinedValueList[i].id == removeVal){ + removeIndex= i; + break; + } + } + $scope.formFieldEditData.predefinedValueList.splice(removeIndex, 1) + }; + + $scope.cancel = function() { + $modalInstance.dismiss(); + }; +} + + +var deleteFormFieldController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { + $scope.tempFieldId = rowData.id; + $scope.ok = function() { + raptorReportFactory.deleteFormFieldById(rowData.id).then(function(data){ + $modalInstance.close(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: deleteFormFieldById failed."); + }); + } + $scope.cancel = function() { + $modalInstance.dismiss(); + }; +} + +var removeReportSecurityUserController = function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityUser) { + $scope.securityUserName = securityUser.name; + $scope.ok = function() { + raptorReportFactory.removeReportSecurityUser(securityUser.id).then(function(data){ + $modalInstance.close(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: removeReportSecurityUser failed."); + }); + } + $scope.cancel = function() { + $modalInstance.dismiss(); + }; +} + +var removeReportSecurityRoleController = function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityRole) { + $scope.securityRoleName = securityRole.name; + $scope.ok = function() { + raptorReportFactory.removeReportSecurityRole(securityRole.id).then(function(data){ + $modalInstance.close(); + },function(error){ + $scope.errorPopUp(error); + $log.error("raptorReportFactory: removeReportSecurityRole failed."); + }); + } + $scope.cancel = function() { + $modalInstance.dismiss(); + }; +} + +var formFieldVerifySQLController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) { + var init = function() { + $scope.isError = false; + if (queriedData.errormessage) { + $scope.isError = true; + $scope.errormessage = queriedData.errormessage; + $scope.stacktrace = queriedData.stacktrace; + } else { + $scope.queryData = queriedData; + } + } + init(); + $scope.close = function() { + $modalInstance.dismiss(); + }; +} +var toggleUserEditAccessActiveController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { + $scope.rowData = rowData; + $scope.toggleEditAccessStatus = function(rowData) { + raptorReportFactory.toggleUserEditAccess(rowData); + $modalInstance.close(); + }; + + $scope.cancelEditAccessToggle = function(rowData) { + rowData.accessAllowed = ! rowData.accessAllowed; + $modalInstance.dismiss('cancel');} +} + +var toggleRoleEditAccessActiveController = function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) { + $scope.rowData = rowData; + $scope.toggleEditAccessStatus = function(rowData) { + raptorReportFactory.toggleRoleEditAccess(rowData); + $modalInstance.close(); + }; + + $scope.cancelEditAccessToggle = function(rowData) { + rowData.accessAllowed = ! rowData.accessAllowed; + $modalInstance.dismiss('cancel');} +}
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/all-reports.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/all-reports.html index 7f470d40..ce70dc58 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/all-reports.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/all-reports.html @@ -21,7 +21,6 @@ <link rel="stylesheet" type="text/css" href="app/fusion/external/angular-bootstrap/ui-bootstrap-csp.css"> <link rel="stylesheet" type="text/css" href="app/fusion/external/angular-gridster/dist/angular-gridster.min.css"> <!-- digital-design-library must be loaded late --> - <link rel="stylesheet" type="text/css" href="app/fusion/external/ds2/css/digital-ng-library/digital-design-library.css"> <link rel="stylesheet" type="text/css" href="app/fusion/styles/ecomp.css"> <!-- Common scripts --> @@ -66,12 +65,14 @@ <script src="./app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js"></script> <script src="./app/fusion/scripts/DS2-view-models/ds2-reports/directive/dynamicform.js"></script> <script src="./app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js"></script> + <script src= "app/fusion/scripts/DS2-services/ds2-raptor-report/reportModalControllers.js"></script> + </head> <body class="appBody" ng-app="abs"> - <div ds2-Header class="header-container" ></div> - <div ds2-menu id="menuContainer" class="menu-container" ></div> + <div ds2-Header class="header-container" ></div> + <div ds2-menu id="menuContainer" class="menu-container" ></div> <div ng-view id="rightContentProfile" class="content-container"></div> - <div ds2-Footer class="footer-container"></div> + <div ds2-Footer class="footer-container"></div> </body> </html> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/directive/dynamicform.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/directive/dynamicform.js index 9064b0dc..5147719f 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/directive/dynamicform.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/directive/dynamicform.js @@ -12,22 +12,42 @@ appDS2 link: function ($scope, element, attrs) { $scope.element=element; $scope.datetimeformat = "MM/dd/yyyy hh:mm a"; - console.log("$scope"); - console.log($scope); $scope.buildField = function (field, parentElement) { var x = ''; if(field.visible) { + if (field.fieldType === 'LIST_MULTI_SELECT') { - x = angular.element('<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label><br>'+ + /*x = angular.element('<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label><br>'+ '<div class="select2-container ebz-listbox form-field" style="height:100px;" tabindex="0" >'+ '<label ng-repeat="item in ngModel.'+field.fieldId+'" style="display:block;">'+ '<input type="checkbox" style="margin-top: 10px;" ng-model="item.defaultValue" ng-change="triggerFormFields('+field.triggerOtherFormFields+')" att-checkbox title="{{item.title}}"/> {{item.title}}<br/>'+ '</label>'+ - '</div>'); + '</div>');*/ + + x = angular.element( + '<div class="listbox-container">'+ + '<h3 id="source_listbox-2---multiselectable">'+field.fieldDisplayName+'</h3>'+ + '<div class="listbox-list" tabindex="-1">'+ + '<b2b-list-box listbox-data= "ngModel.'+field.fieldId+'" aria-multiselectable="true">'+ + '<div tabindex="-1" data-index="{{$index}}" b2b-accessibility-click="13,32" ng-repeat="number in ngModel.'+field.fieldId+'" role="option" class="b2b-list-box-item" ng-class="{'+ + "'b2b-list-box-item--selected'"+ + ': number.selected}" ng-bind-html="number.title | unsafe"></div>'+ + '</b2b-list-box>'+ + '</div>'+ + '</div>'); } else if (field.fieldType === 'LIST_BOX') { - x = angular.element('<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label><br> <div class="form-field" att-select="formFieldLuValues.'+field.fieldId+'" ng-model="ngModel.'+field.fieldId+'" ng-change="triggerFormFields('+field.triggerOtherFormFields+')"></div>'); + var temp = + '<div >'+ + '<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label>'+ + '<select id="dropdown1" name="dropdown1" aria-describedby="dropdown1" b2b-dropdown placeholder-text="Select" ng-model="ngModel.'+field.fieldId+'" ng-change="triggerFormFields('+field.triggerOtherFormFields+')">'+ + ' <option b2b-dropdown-list option-repeat="d in formFieldLuValues.'+ field.fieldId +'" value="{{d.value}}">{{d.title}}</option>'+ + ' </select>'+ + '</div>'; + + x = angular.element(temp); + //x = angular.element('<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label><br> <div class="form-field" att-select="formFieldLuValues.'+field.fieldId+'" ng-model="ngModel.'+field.fieldId+'" ng-change="triggerFormFields('+field.triggerOtherFormFields+')"></div>'); } else if((field.fieldType === 'text' || field.fieldType === 'TEXT') && field.validationType === 'DATE'){ - x = angular.element('<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label><br> <input id="'+field.fieldId+'" type="text" ng-model="ngModel.'+field.fieldId+'" tabindex="0" ng-change="triggerFormFields('+field.triggerOtherFormFields+')" att-datepicker>'); + x = angular.element('<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label><br> <div class="datepicker-container" > <input id="'+field.fieldId+'" type="text" ng-model="ngModel.'+field.fieldId+'" tabindex="0" ng-change="triggerFormFields('+field.triggerOtherFormFields+')" b2b-datepicker></div>'); } else if((field.fieldType === 'text' || field.fieldType === 'TEXT') && field.validationType === 'TIMESTAMP_MIN'){ x = angular.element('<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label><br> <input id="'+field.fieldId+'" type="text" date-format="datetimeformat" ng-model="ngModel.'+field.fieldId+'" tabindex="0" ng-change="triggerFormFields('+field.triggerOtherFormFields+')" att-date-time-picker>'); } else if(field.fieldType === 'text' || field.fieldType === 'TEXT'){ @@ -35,9 +55,10 @@ appDS2 } else if(field.fieldType === 'CHECK_BOX'){ x = angular.element('<label><i>'+field.fieldDisplayName+'<span ng-show="ngShowFieldId"> [ '+field.fieldId+' ] </span>:</i></label><br> <input type="checkbox" ng-model="ngModel.'+field.fieldId+'" tabindex="0" ng-change="triggerFormFields('+field.triggerOtherFormFields+')" att-checkbox>'); } + parentElement.append(x); + $compile(x)($scope); } - parentElement.append(x); - $compile(x)($scope); + }; $scope.buildForm = function() { // create elements <table> and a <tbody> @@ -80,7 +101,7 @@ appDS2 formField.formFieldValues.forEach(function(entry,i) { $scope.formFieldLuValues[formField.fieldId].push({ index: i, value: entry.id, title: entry.name}); if(entry.defaultValue){ - $scope.ngModel[formField.fieldId]={ index: i, value: entry.id, title: entry.name}; + //$scope.ngModel[formField.fieldId]={ index: i, value: entry.id, title: entry.name}; } }); } diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-del-confirm.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-del-confirm.html index da255bbf..3f0338c9 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-del-confirm.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-del-confirm.html @@ -1,26 +1,18 @@ -<div style="height:400px"> - <div class="b2b-modal-header ng-scope in"> - <h2 id="myModalLabel" modal-title="">Remove Report</h2> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" - ng-click="$dismiss('cancel')"></button> - </div> + +<div class="b2b-modal-header ng-scope in"> + <h2 id="myModalLabel" modal-title="">Remove Report</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> </div> - <div class="b2b-modal-body ng-scope ng-isolate-scope in" style="margin-bottom: -50px;"> - <form name="workflowForm" class="css-form" novalidate> - - <div class="form-row input-emphasized-field"> - <label class="span12 input-emphasized" for="textinputID-2a">The selected report will be removed. Do you want to continue</label> - </div> - - <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> - <div class="cta-button-group in"> - <button class="btn btn-alt btn-small" type="button" ng-click="ok()">OK</button> - <button class="btn btn-alt btn-small" type="button" - ng-click="cancel()">Cancel</button> - </div> - </div> - </form> - <br /> +</div> +<div class="b2b-modal-body ng-scope ng-isolate-scope in"> + <h2>The selected report will be removed. Do you want to continue</h2> +</div> +<div class="b2b-modal-footer ng-scope ng-isolate-scope in"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-small" type="button" ng-click="ok()">OK</button> + <button class="btn btn-alt btn-small" type="button" + ng-click="cancel()">Cancel</button> </div> </div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-formfield-del-confirm.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-formfield-del-confirm.html index 7bdf5a29..20dd9202 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-formfield-del-confirm.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-formfield-del-confirm.html @@ -1,26 +1,17 @@ -<div style="height:400px"> - <div class="b2b-modal-header ng-scope in"> - <h2 id="myModalLabel" modal-title="">Remove Formfield</h2> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" - ng-click="$dismiss('cancel')"></button> - </div> +<div class="b2b-modal-header"> + <h2 id="myModalLabel" modal-title="">Remove Formfield</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> </div> - <div class="b2b-modal-body ng-scope ng-isolate-scope in" style="margin-bottom: -50px;"> - <form name="workflowForm" class="css-form" novalidate> - - <div class="form-row input-emphasized-field"> - <label class="span12 input-emphasized" for="textinputID-2a">The selected formfield {{tempFieldId}} will be removed. Do you want to continue</label> - </div> - - <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> - <div class="cta-button-group in"> - <button class="btn btn-alt btn-small" type="button" ng-click="ok()">OK</button> - <button class="btn btn-alt btn-small" type="button" - ng-click="cancel()">Cancel</button> - </div> - </div> - </form> - <br /> +</div> +<div class="b2b-modal-body"> + The selected formfield {{tempFieldId}} will be removed. Do you want to continue? +</div> +<div class="b2b-modal-footer"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-small" type="button" ng-click="ok()">OK</button> + <button class="btn btn-alt btn-small" type="button" + ng-click="cancel()">Cancel</button> </div> </div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-role-del-confirm.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-role-del-confirm.html index 01d1e609..629b9a91 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-role-del-confirm.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-role-del-confirm.html @@ -1,26 +1,19 @@ -<div style="height:300px"> - <div class="b2b-modal-header ng-scope in"> - <h2 id="myModalLabel" modal-title="">Remove Report Role</h2> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" - ng-click="$dismiss('cancel')"></button> - </div> + +<div class="b2b-modal-header"> + <h2 id="myModalLabel" modal-title="">Remove Report Role</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> </div> - <div class="b2b-modal-body ng-scope ng-isolate-scope in" style="margin-bottom: -50px;"> - <form name="workflowForm" class="css-form" novalidate> - - <div class="form-row input-emphasized-field"> - <label class="span12 input-emphasized" for="textinputID-2a">{{securityRoleName}} will be removed. Would you want to continue?</label> - </div> - - <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> - <div class="cta-button-group in"> - <button class="btn btn-alt btn-small" type="button" ng-click="ok()">OK</button> - <button class="btn btn-alt btn-small" type="button" - ng-click="cancel()">Cancel</button> - </div> - </div> - </form> - <br /> +</div> +<div class="b2b-modal-body"> + {{securityRoleName}} + will be removed. Would you want to continue? +</div> +<div class="b2b-modal-footer"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-small" type="button" ng-click="ok()">OK</button> + <button class="btn btn-alt btn-small" type="button" + ng-click="cancel()">Cancel</button> </div> </div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-user-del-confirm.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-user-del-confirm.html index 6620fe7c..5af1b227 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-user-del-confirm.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-user-del-confirm.html @@ -1,26 +1,18 @@ -<div style="height:300px"> - <div class="b2b-modal-header ng-scope in"> - <h2 id="myModalLabel" modal-title="">Remove Report User</h2> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" - ng-click="$dismiss('cancel')"></button> - </div> +<div class="b2b-modal-header"> + <h2 id="myModalLabel" modal-title="">Remove Report User</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> </div> - <div class="b2b-modal-body ng-scope ng-isolate-scope in" style="margin-bottom: -50px;"> - <form name="workflowForm" class="css-form" novalidate> - - <div class="form-row input-emphasized-field"> - <label class="span12 input-emphasized" for="textinputID-2a">{{securityUserName}} will be removed. Would you want to continue?</label> - </div> - - <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> - <div class="cta-button-group in"> - <button class="btn btn-alt btn-small" type="button" ng-click="ok()">OK</button> - <button class="btn btn-alt btn-small" type="button" - ng-click="cancel()">Cancel</button> - </div> - </div> - </form> - <br /> +</div> +<div class="b2b-modal-body""> + {{securityUserName}} + will be removed. Would you want to continue? +</div> +<div class="b2b-modal-footer"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-small" type="button" ng-click="ok()">OK</button> + <button class="btn btn-alt btn-small" type="button" + ng-click="cancel()">Cancel</button> </div> </div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html index 21bb046f..06f2049a 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html @@ -1,23 +1,24 @@ -<div> - <div class="b2b-modal-header ng-scope in"> - <h1><i class="icon-primary-alert"></i></h1> - <h2 id="myModalLabel" modal-title="">Confirm</h2> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" - ng-click="$dismiss('cancel')"></button> - </div> + +<div class="b2b-modal-header"> + <h1> + <i class="icon-primary-alert"></i> + </h1> + <h2 id="myModalLabel" modal-title="">Confirm</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> </div> - <div class="b2b-modal-body ng-scope ng-isolate-scope in" tabindex="0" - role="region" aria-label="Modal header text content" - style="height: 55px;"> - You are about to {{rowData.accessAllowed?"grant":"revoke"}} {{rowData.name}} edit access. Would you like to continue? - </div> - <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> - <div class="cta-button-group in"> - <button class="btn btn-alt btn-medium" type="button" - ng-click="toggleEditAccessStatus(rowData);">Ok</button> - <button class="btn btn-clear btn-medium" type="button" - ng-click="cancelEditAccessToggle(rowData);">Cancel</button> - </div> +</div> +<div class="b2b-modal-body" tabindex="0" role="region" + aria-label="Modal header text content" style="height: 55px;"> + You are about to {{rowData.accessAllowed?"grant":"revoke"}} + {{rowData.name}} edit access. Would you like to continue? +</div> +<div class="b2b-modal-footer"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-medium" type="button" + ng-click="toggleEditAccessStatus(rowData);">Ok</button> + <button class="btn btn-clear btn-medium" type="button" + ng-click="cancelEditAccessToggle(rowData);">Cancel</button> </div> </div> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-col-edit.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-col-edit.html index e74f89a8..3aadf27e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-col-edit.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-col-edit.html @@ -1,130 +1,232 @@ <style> #columnEditTable table tbody td { - border: none; + border: none; } #columnEditTable table tbody tr { - border: none; + border: none; } -.colTableLeftColumn { - width: 45%; - text-align: right; - vertical-align:middle; -} - -.colTableInput { - width:220px; -} - -#columnEditTable .selectWrap{ - width:220px; -} - -#drilldownOption .selectWrap{ - width:450px; -} </style> -<div style="height: 700px;"> - <div class="b2b-modal-header ng-scope in"> - <h2 id="myModalLabel" modal-title="">Report Column - Edit </h2> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" - ng-click="$dismiss('cancel')"></button> - </div> +<div class="b2b-modal-header"> + <h2 id="myModalLabel" modal-title="">Report Column - Edit</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> </div> - <div class="b2b-modal-body ng-scope ng-isolate-scope in" style="margin-bottom: -50px;"> - <form name="workflowForm" class="css-form" novalidate> - -<!-- <div class="form-row input-emphasized-field"> - <label class="span12 input-emphasized" for="textinputID-2a">The selected report will be removed. Do you want to continue</label> - </div> --> - <div id="columnEditTable"> - <table class="striped"> -<!-- <caption><span>Table caption</span></caption> --> -<!-- <thead> - <tr> - <th>Column ID:</th> - <th>Name</th> - <th>ID</th> - <th>Edit</th> - </tr> - </thead> --> - <tbody> - <tr> - <td class="colTableLeftColumn">Column ID:</td> - <td>{{columnEditData.colId}}</td> - </tr> - - <tr> - <td class="colTableLeftColumn">Display Name:</td> - <td><input type="text" name="displayName" ng-model="colName.value" class="colTableInput"></td> - </tr> - -<!-- <tr> - <td class="colTableLeftColumn">Display Width (px):</td> - <td><input type="text" name="displayWidth" ng-model="displayWidth" class="colTableInput"></td> - </tr> --> - - <tr> - <td class="colTableLeftColumn">Display Alignment: </td> - <td> - <select name="displayAlignment" b2b-dropdown ng-model="selectedDisplayAlignment.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in displayAlignmentOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - </tr> - - <tr> - <td class="colTableLeftColumn">Display Header Alignment:</td> - <td> - <select name="displayHeaderAlignment" b2b-dropdown ng-model="selectedDisplayHeaderAlignment.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in displayAlignmentOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - </tr> - - <tr> - <td class="colTableLeftColumn">Sortable:</td> - <td> - <select name="sortable" b2b-dropdown ng-model="sortable.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in ynOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - </tr> - - <tr> - <td class="colTableLeftColumn">Visible:</td> - <td> - <select name="visible" b2b-dropdown ng-model="visible.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in ynOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - </tr> - - <tr> - <td class="colTableLeftColumn" style="width:350px;">Drill-down Link:</td> - <td id="drilldownOption"> - <select name="drillDown" b2b-dropdown ng-model="selectedDrillDownReport.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in drilldownReports" value="{{d.id}}">{{d.name}}</option> - </select> - </td> - </tr> - - - </tbody> - </table> - </div> - <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> - <div class="cta-button-group in"> - <button class="btn btn-alt btn-small" type="button" ng-click="save()">Save</button> - <button class="btn btn-alt btn-small" type="button" - ng-click="cancel()">Cancel</button> +</div> +<div class="b2b-modal-body"> + <div ng-show="processingData" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> </div> - </div> - </form> - <br /> - </div> -</div>
\ No newline at end of file + + <div id="columnEditTable" ng-hide="processingData"> + <table class="striped"> + <tbody> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Column ID:</td> + <td>{{colInfo.colId}}</td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Column Name:</td> + <td>{{colInfo.colName}}</td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Depends on formfield:</td> + <td><input type="text" name="dependsOnFF" + ng-model="colInfo.depeondsOnForField" class="colTableInput"></td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Datatype:</td> + <td> + <select id="dataTypeDD" name="dataTypeDD" aria-describedby="dataTypeDD" b2b-dropdown placeholder-text="Select Data Type" ng-model="colInfo.dataType"> + <option b2b-dropdown-list option-repeat="d in dataTypeOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Group By Pos:</td> + <td> + <input type="text" name="groupByPos" ng-model="colInfo.groupByPos" class="colTableInput"> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Custom Text for Sub-Total:</td> + <td><input type="text" name="subTotalCus" + ng-model="colInfo.subTotalCustomText" class="colTableInput"></td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Hide Repeated Values:</td> + <td> + <label for="noWrap" class="checkbox"> + <input id="hideFormFieldsRun" type="checkbox" ng-model="colInfo.hideRepeatedKey" /> <i class="skin"></i> + </label> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Multi Group Column Level:</td> + <td> + <select id="mgcLevel" name="mgcLevel" aria-describedby="mgcLevel" b2b-dropdown placeholder-text="Select Level" ng-model="colInfo.level"> + <option b2b-dropdown-list option-repeat="d in multiGroupColLevel" value="{{d.value}}">{{d.text}}</option> + </select> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Multi group Column Range : Colspan:</td> + <td> + <input type="text" name="colSpan" ng-model="colInfo.colspan" class="colTableInput"> + </td> + </tr> + <!-- <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Dataformat:</td> + <td> + <select id="mgcLevel" name="mgcLevel" aria-describedby="mgcLevel" b2b-dropdown placeholder-text="Select Level" ng-model="colInfo.level"> + <option b2b-dropdown-list option-repeat="d in multiGroupColLevel" value="{{d.value}}">{{d.text}}</option> + </select> + </td> + </tr> --> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Display Name:</td> + <td> + <input type="text" name="colSpan" ng-model="colInfo.displayName" class="colTableInput"> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Display Width (In Pxls):</td> + <td> + <input type="text" id="displayWidth" name="displayWidth" ng-model="colInfo.displayWidth" class="colTableInput"> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">No Wrap ?:</td> + <td> + <label for="noWrap" class="checkbox"> + <input id="noWrap" type="checkbox" ng-model="colInfo.noWrap" /><i class="skin"></i> + </label> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Indent Parameter to display value:</td> + <td> + <select id="indentPara" name="indentPara" aria-describedby="indentPara" b2b-dropdown placeholder-text="Select Indent" ng-model="colInfo.indentation"> + <option b2b-dropdown-list option-repeat="d in indentValues" value="{{d.value}}">{{d.text}}</option> + </select> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Display Alignment:</td> + <td> + <select id="displayAlign" name="displayAlign" aria-describedby="displayAlign" b2b-dropdown placeholder-text="Select Display Alignment" ng-model="colInfo.displayAlignment"> + <option b2b-dropdown-list option-repeat="d in displayAlignmentOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Display Header Alignment:</td> + <td> + <select id="displayHAlign" name="displayHAlign" aria-describedby="displayAlign" b2b-dropdown placeholder-text="Select Display Header Alignment" ng-model="colInfo.displayHeaderAlignment"> + <option b2b-dropdown-list option-repeat="d in displayAlignmentOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Sortable:</td> + <td> + <label for="sortable" class="checkbox"> + <input id="sortable" type="checkbox" ng-model="colInfo.sortable" /><i class="skin"></i> + </label> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Visible:</td> + <td> + <label for="visibleCheck" class="checkbox"> + <input id="visibleCheck" type="checkbox" ng-model="colInfo.visible" /><i class="skin"></i> + </label> + </td> + </tr> + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Drill-down Link: <a href="javascript:void(0);" ng-click="getDrillReportFormField(colInfo.drilldownURL,colInfo.drilldownParams)"><span class="icon-misc-pen" ></span></a></td> + <td id="drilldownOption"> + <select name="drillDown" b2b-dropdown ng-model="colInfo.drilldownURL"> + <option b2b-dropdown-list option-repeat="d in drilldownReports" value="{{d.id}}">{{d.name}}</option> + </select> + </td> + </tr> + + <tr ng-hide="!isEditCol"> + <td class="colTableLeftColumn">Total for the column:</td> + <td id="totalForTheCol"> + <select name="totalForTheCol" b2b-dropdown ng-model="colInfo.displayTotal" placeholder-text="Select"> + <option b2b-dropdown-list option-repeat="d in totalForTheColList" value="{{d.id}}">{{d.name}}</option> + </select> + </td> + </tr> + <tr > + <table class="striped" ng-repeat="ff in drilDownFormField" ng-init="outerIndex=$index" ng-show="!isEditCol"> + <thead> + <tr> + <th>{{ff.name}}</th> + <th></th> + </tr> + </thead> + <tbody type="body" ng-repeat="dd in drilDownValues[$index]" ng-init="innerIndex=$index"> + <tr> + <td> + <label for="{{dd.radioGroup}}" class="radio"> + <input type="radio" ng-model="selectedDrillReportFormField[outerIndex]" id="{{dd.radioGroup}}" name="optionsRadio{{outerIndex}}" value="{{dd.radioGroup}}"> + <i class="skin"></i> + </label> + </td> + <td>{{ dd.selection }} </td> + <td ng-if="dd.selection=='Value set'" ng-bind="dd.value"></td> + <td ng-if='dd.selection=="No Value"'> + Accept default + </td> + <td ng-if='dd.selection=="Fixed Value"'> + <div class="field-group"> + <input id="emptyMessage" ddh-reset="" class="span12" type="text" data-ng-model="drillDownParams[outerIndex].valValue"> + </div> + </td> + <td ng-if='dd.selection=="Value of Column"'> + <select name="drillDown" b2b-dropdown ng-model="drillDownParams[outerIndex].valColId" placeholder-text="Select"> + <option b2b-dropdown-list option-repeat="d in childReportCol" value="{{d.id}}">{{d.name}}</option> + </select> + </td> + <td ng-if='dd.selection=="Value of form field"'> + <select name="drillDownField" b2b-dropdown ng-model="drillDownParams[outerIndex].valFieldId" placeholder-text="Select"> + <option b2b-dropdown-list option-repeat="d in childReportFF" value="{{d.id}}">{{d.name}}</option> + </select> + </td> + </tr> + </tbody> + </table> + </tr> + + <!-- <tr> + <td class="colTableLeftColumn">Advanced Display Formatting:</td> + <td id="drilldownOption"> + <select name="drillDown" b2b-dropdown ng-model="colInfo.drilldownURL" placeholder-text="Select"> + <option b2b-dropdown-list option-repeat="d in drilldownReports" value="{{d.id}}">{{d.name}}</option> + </select> + </td> + </tr> --> + + </tbody> + </table> + </div> + +</div> +<div class="b2b-modal-footer ng-scope"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-small" type="button" ng-show="isEditCol" + ng-click="save()">Save</button> + <button class="btn btn-alt btn-small" type="button" ng-hide="isEditCol" + ng-click="complete()">Complete</button> + <button class="btn btn-alt btn-small" type="button" + ng-click="cancel()">Cancel</button> + </div> + </div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html index c88eb596..3c17ff7b 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html @@ -1,149 +1,154 @@ <style> #columnEditTable table tbody td { - border: none; + border: none; } #columnEditTable table tbody tr { - border: none; + border: none; } .colTableLeftColumn { width: 45%; text-align: right; - vertical-align:middle; + vertical-align: middle; } .colTableInput { - width:220px; + width: 220px; } -#columnEditTable .selectWrap{ - width:220px; +#columnEditTable .selectWrap { + width: 220px; +} +table { + border-bottom: none; } </style> -<div style="height: 700px;"> - <div class="b2b-modal-header ng-scope in"> - <h2 id="myModalLabel" modal-title="">Report Form Field - Edit</h2> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" - ng-click="$dismiss('cancel')"></button> - </div> +<div class="b2b-modal-header"> + <h2 id="myModalLabel" modal-title="">Report Form Field - Edit</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> </div> - <div class="b2b-modal-body ng-scope ng-isolate-scope in" style="margin-bottom: -50px;"> - <form name="workflowForm" class="css-form" novalidate> - -<!-- <div class="form-row input-emphasized-field"> - <label class="span12 input-emphasized" for="textinputID-2a">The selected report will be removed. Do you want to continue</label> - </div> --> - <div id="columnEditTable"> - <table class="striped"> -<!-- <caption><span>Table caption</span></caption> --> -<!-- <thead> - <tr> - <th>Column ID:</th> - <th>Name</th> - <th>ID</th> - <th>Edit</th> - </tr> - </thead> --> - <tbody> -<!-- <tr> - <td class="colTableLeftColumn">Field ID:</td> - <td>{{formFieldEditData.fieldId}}</td> - </tr> --> - - <tr> - <td class="colTableLeftColumn">Field Name:</td> - <td><input type="text" name="displayName" ng-model="fieldName.value" class="colTableInput"></td> - </tr> - - <tr> - <td class="colTableLeftColumn">Field Type: </td> - <td> - <select name="displayAlignment" b2b-dropdown ng-model="selectedFieldType.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in fieldTypeOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - </tr> - - <tr> - <td class="colTableLeftColumn">Visible:</td> - <td> - <select name="displayHeaderAlignment" b2b-dropdown ng-model="selectedVisible.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in ynOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - </tr> - - <tr> - <td class="colTableLeftColumn">SQL as Default Value:</td> - <td> - <label for="checkbox1" class="checkbox"> - <input id="checkbox1" type="checkbox" ng-model="sqlDefaultValueSelected.value" /><i class="skin"></i><span></span> - </label> - </td> - </tr> - - <tr ng-hide="sqlDefaultValueSelected.value"> - <td class="colTableLeftColumn">Default Value:</td> - <td><input type="text" name="defaultValue" ng-model="defaultValue.value" class="colTableInput"></td> - </tr> - - - <tr ng-show="sqlDefaultValueSelected.value"> - <td class="colTableLeftColumn">Default SQL:</td> - <td> - <textarea b2b-reset b2b-dragon-input b2b-reset-textarea ng-model="fieldDefaultSQL.value" style="height:80px"> - </textarea> - </td> - <td> - <p><button ng-click="formFieldVerifySQL(fieldDefaultSQL.value)" class="btn btn-alt btn-small">Verify</button></p> - </td> - </tr> - -<!-- <tr> - <td class="colTableLeftColumn">Verify Field Value As: </td> - <td> - <select name="displayAlignment" b2b-dropdown ng-model="selectedVerifyFieldValue.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in verifyFieldValueOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - </tr> --> - - <tr> - <td class="colTableLeftColumn">SQL Generating Custom List of Values:</td> - <td> - <textarea b2b-reset b2b-dragon-input b2b-reset-textarea ng-model="fieldSqlContent.value" style="height:80px"> - </textarea> - </td> - <td> - <p><button ng-click="formFieldVerifySQL(fieldSqlContent.value)" class="btn btn-alt btn-small">Verify</button></p> - </td> - </tr> +</div> +<div class="b2b-modal-body"> + <div ng-show="dataProcessing" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> + </div> + <div id="columnEditTable" ng-hide="dataProcessing"> + <table class="striped"> + <tbody> + <tr> + <td class="colTableLeftColumn">Field Name:</td> + <td><input type="text" name="displayName" + ng-model="formFieldEditData.fieldName" class="colTableInput"></td> + </tr> -<!-- <tr> - <td class="colTableLeftColumn">Drill-down Link:</td> - <td> - <select name="drillDown" b2b-dropdown ng-model="selectedDrillDownLink.value" placeholder-text="Select"> - <option b2b-dropdown-list option-repeat="d in drillDownOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - </tr> --> + <tr> + <td class="colTableLeftColumn">Field Type:</td> + <td><select name="fieldType" b2b-dropdown + ng-model="formFieldEditData.fieldType" placeholder-text="Select"> + <option b2b-dropdown-list option-repeat="d in fieldTypeOptions" + value="{{d.value}}">{{d.text}}</option> + </select></td> + </tr> + <tr> + <td class="colTableLeftColumn">Visible:</td> + <td> + <select name="visible" b2b-dropdown ng-model="formFieldEditData.visible"> + <option b2b-dropdown-list option-repeat="d in ynOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </td> + </tr> + <tr> + <td class="colTableLeftColumn">Is used in Group By Clause?</td> + <td> + <label for="checkboxGrp" class="checkbox"> + <input id="checkboxGrp" type="checkbox" ng-model="formFieldEditData.groupFormField" /><i class="skin"></i><span></span> + </label> + </td> + </tr> + <tr> + <td class="colTableLeftColumn">SQL as Default Value:</td> + <td> + <label for="cehckboxSql" class="checkbox"> <input + id="cehckboxSql" type="checkbox" + ng-model="sqlAsDefaultValue.value" /><i class="skin"></i><span></span> + </label> + </td> + </tr> + <tr ng-show="sqlAsDefaultValue.value"> + <td class="colTableLeftColumn">Default SQL:</td> + <td> + <textarea b2b-reset b2b-dragon-input b2b-reset-textarea + ng-model="formFieldEditData.fieldDefaultSQL" style="height: 80px"> + </textarea> + </td> + <td> + <p> + <button ng-click="formFieldVerifySQL(formFieldEditData.fieldDefaultSQL)" + class="btn btn-alt btn-small">Verify</button> + </p> + </td> + </tr> + <tr ng-hide="formFieldEditData.fieldDefaultSQL"> + <td class="colTableLeftColumn">Default Value:</td> + <td><input type="text" name="defaultValue" + ng-model="formFieldEditData.defaultValue" class="colTableInput"></td> + </tr> - </tbody> - </table> - </div> - <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> - <div class="cta-button-group in"> - <button class="btn btn-alt btn-small" type="button" ng-click="save()">Save</button> - <button class="btn btn-alt btn-small" type="button" - ng-click="cancel()">Cancel</button> - </div> - + <tr> + <td class="colTableLeftColumn">Verify Field Value As:</td> + <td><select name="visible" b2b-dropdown + ng-model="formFieldEditData.validationType" placeholder-text="Select"> + <option b2b-dropdown-list option-repeat="d in verifyFieldValueOptions" + value="{{d.value}}">{{d.text}}</option> + </select></td> + </tr> + <tr> + <td class="colTableLeftColumn">SQL Generating Custom List of + Values:</td> + <td><textarea b2b-reset b2b-dragon-input b2b-reset-textarea + ng-model="formFieldEditData.fieldSQL" style="height: 80px"> + </textarea></td> + <td> + <p> + <button ng-click="formFieldVerifySQL(formFieldEditData.fieldSQL)" + class="btn btn-alt btn-small">Verify</button> + </p> + </td> + </tr> + <tr> + <td class="colTableLeftColumn">Provide Predefined List of Values: Do not use Predefined list - Generate list from database :</td> + <td> + <input type="text" name="defaultValue" ng-model="predefinedValues.value" class="colTableInput"> + </td> + <td> + <p> + <button ng-click="addPredefinedValueList();" class="btn btn-alt btn-small">Add to List</button> + </p> + </td> + </tr> + <tr> + <td class="colTableLeftColumn"></td> + <td> + <div ng-repeat = "rowData in formFieldEditData.predefinedValueList"> + <span>{{rowData.id}}</span> + <a ng-click="removePredefinedValueList(rowData.id)" class="icon-misc-trash"></a> + </div> + </td> + </tr> + </tbody> + </table> </div> - </form> - <br /> +</div> +<div class="b2b-modal-footer"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-small" type="button" ng-click="save()" ng-show="type=='edit'">Save</button> + <button class="btn btn-alt btn-small" type="button" ng-click="add()" ng-show="type=='add'">Add</button> + <button class="btn btn-alt btn-small" type="button" ng-click="cancel()">Cancel</button> </div> </div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html index a7955cad..e3fda72b 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html @@ -1,62 +1,57 @@ -<style> +<!-- <style> .colTableLeftColumn { width: 45%; text-align: right; - vertical-align:middle; + vertical-align: middle; } .colTableInput { - width:220px; + width: 220px; } -#columnEditTable .selectWrap{ - width:220px; +#columnEditTable .selectWrap { + width: 220px; } </style> - -<div style="height: 700px;"> - <div class="b2b-modal-header ng-scope in"> - <h2 id="myModalLabel" modal-title="">SQL Test Run - {{isError?'Failed':'Executed'}}</h2> - <div class="corner-button in"> - <button type="button" class="close" aria-label="Close" - ng-click="$dismiss('cancel')"></button> - </div> + --> +<div class="b2b-modal-header"> + <h2 id="myModalLabel" modal-title="">SQL Test Run - + {{isError?'Failed':'Executed'}}</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> </div> - <div class="b2b-modal-body ng-scope ng-isolate-scope in" style="margin-bottom: -50px;"> - <form name="workflowForm" class="css-form" novalidate> -<!-- <div class="form-row input-emphasized-field"> - <label class="span12 input-emphasized" for="textinputID-2a">The selected report will be removed. Do you want to continue</label> - </div> --> - <div> - - <div ng-show="isError"> - <h2>Error Message:</h2><br> - <p>{{errormessage}}</p> - <h2>Stack Trace:</h2><br> - <p>{{stacktrace}}</p> +</div> +<div class="b2b-modal-body"> + <div> - </div> - <table class="striped"> - <thead> - <tr> - <th ng-repeat="colName in queryData.reportDataColumns">{{colName}}</th> - </tr> - </thead> - <tbody> - <tr ng-repeat="rowData in queryData.reportDataRows"> - <td ng-repeat="keyName in queryData.reportDataColumns">{{rowData[keyName]}}</td> - </tr> + <div ng-show="isError"> + <h2>Error Message:</h2> + <br> + <p>{{errormessage}}</p> + <h2>Stack Trace:</h2> + <br> + <p>{{stacktrace}}</p> - </tbody> - </table> - </div> - <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> - <div class="cta-button-group in"> - <button class="btn btn-alt btn-small" type="button" - ng-click="close()">Close</button> + </div> + <table class="striped"> + <thead> + <tr> + <th ng-repeat="colName in queryData.reportDataColumns">{{colName}}</th> + </tr> + </thead> + <tbody> + <tr ng-repeat="rowData in queryData.reportDataRows"> + <td ng-repeat="keyName in queryData.reportDataColumns">{{rowData[keyName]}}</td> + </tr> + + </tbody> + </table> </div> + +</div> +<div class="b2b-modal-footer ng-scope ng-isolate-scope in"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-small" type="button" ng-click="close()">Close</button> </div> - </form> - <br /> - </div> -</div>
\ No newline at end of file +</div> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html index 8558729e..ed3c4ba9 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html @@ -1,897 +1,1080 @@ <style> table tbody td { - border: none; + border: none; } table tbody tr { - border: none; + border: none; } -table{ - border: none; - margin-bottom:0px; +table { + border: none; + margin-bottom: 0px; } -#RangeTable{ +#RangeTable { margin-top: 5px; border: 1px solid black; } </style> <div id="page-content"> -<h1 class="heading-page">Report Chart Configuration</h1> + <h1 class="heading-page">Report Chart Configuration</h1> -<div ng-show="showLoader" class="span loader-container"> - <i class="icon-primary-spinner" role="img" - aria-label="Please wait while we load your content"></i> -</div> + <div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> + </div> -<div ng-hide="showLoader"> -<div> -<table> - <thead> - <tr> - <th width="30%">Chart Type</th> - <th></th> - </tr> - </thead> - - <tbody> - <tr> - <td> - <select name="chartType" b2b-dropdown ng-model="reportRunJson.chartType"> - <option b2b-dropdown-list option-repeat="d in chartTypeOptions" value="{{d.value}}">{{d.text}}</option> - </select> - </td> - <td></td> - </tr> - </tbody> -</table> - -<table> - <thead> - <tr> - <th width="50px">Width (px)</th> - <th>Height (px)</th> - </tr> - </thead> - <tbody> - <tr> - <td> - <input type="text" name="displayName" ng-model="reportRunJson.width" style="width:100px;"> - </td> - <td> - <input type="text" name="displayName" ng-model="reportRunJson.height" style="width:100px;"> - </td> - </tr> - </tbody> -</table> - -<table> - <thead> - <tr> - <th width="50px">Title</th> - </tr> - </thead> - <tbody> - <tr> - <fieldset role="radiogroup" radio-group-accessibility> - <td> - <label for="optionsRadiosShowTitleTrue" class="radio"> - <input type="radio" ng-model="reportRunJson.showTitle" id="optionsRadiosShowTitleTrue" name="optionsRadiosShowTitleTrue" value="true"> - <i class="skin"></i> - <span>Show</span> - </label> - </td> - <td> - <label for="optionsRadiosShowTitleFalse" class="radio"> - <input type="radio" ng-model="reportRunJson.showTitle" id="optionsRadiosShowTitleFalse" name="optionsRadiosShowTitleFalse" value="false"> - <i class="skin"></i> - <span>Hide</span> - </label> - </td> - </fieldset> - </tr> - - </tbody> -</table> - -<table> - <thead> - <tr> - <th width="30%">Domain Axis</th> - <th width="30%">Category</th> - <th width="40%"></th> - </tr> - </thead> - <tbody> - <tr> - <td> - <select name="chartType" b2b-dropdown ng-model="reportRunJson.domainAxis"> - <option b2b-dropdown-list option-repeat="d in reportRunJson.chartColumnJSONList" value="{{d.value}}">{{d.title}}</option> - </select> - </td> - <td> - <select name="chartType" b2b-dropdown ng-model="reportRunJson.categoryAxis"> - <option b2b-dropdown-list option-repeat="d in reportRunJson.chartColumnJSONList" value="{{d.value}}">{{d.title}}</option> - </select> - </td> - </tr> - </tbody> -</table> - - - <div id="RangeTable"> - -<table ng-repeat="rangeReport in reportRunJson.rangeAxisList"> - <thead> - <tr> - <th width="18%">Range Axis</th> - <th width="15%">Y Axis</th> - <th width="15%">Chart Title</th> - <th width="22%">Color</th> - <th width="25%">Line Type</th> - <th></th> - </tr> - </thead> - <tbody> - <tr> - <td> - <select name="chartType" b2b-dropdown ng-model="rangeReport.rangeAxisLabelJSON.value" placeholder-text="Select" ng-disabled="rangeReport.removed=='true'"> - <option b2b-dropdown-list option-repeat="d in reportRunJson.chartColumnJSONList" value="{{d.value}}">{{d.title}}</option> - </select> - </td> - <td> - <input type="text" name="displayName" ng-model="rangeReport.rangeYAxis" ng-disabled="rangeReport.removed=='true'" style="width:100px;"> - </td> - <td> - <input type="text" name="displayName" ng-model="rangeReport.rangeChartGroup" ng-disabled="rangeReport.removed=='true'" style="width:150px;"> - </td> - <td> - <select name="chartType" b2b-dropdown ng-model="rangeReport.rangeColor" ng-disabled="rangeReport.removed=='true'"> - <option b2b-dropdown-list option-repeat="d in rangeColors" value="{{d.value}}">{{d.title}}</option> - </select> - </td> - <td> - <select name="lineType" b2b-dropdown ng-model="rangeReport.rangeLineType" ng-disabled="rangeReport.removed=='true'"> - <option b2b-dropdown-list option-repeat="d in lineTypes" value="{{d.value}}">{{d.title}}</option> - </select> - </td> - <td> - <button ng-show="$index==0" type="submit" style="width: 90px; height:35px;margin-left:5px;" class="btn btn-secondary btn-small" ng-click="addRangeAxisRow()">Add</button> - <span ng-hide="$index==0"> - <button ng-if="rangeReport.removed!='true'" type="submit" style="width: 90px; height:35px;margin-left:5px;" class="btn btn-secondary btn-small" ng-click="removeRangeAxisRow($index)">Remove</button> - <button ng-if="rangeReport.removed=='true'" type="submit" style="width: 90px; height:35px;margin-left:5px;" class="btn btn-secondary btn-small" disabled="disabled">Removed</button> - </span> - </td> - </tr> - - </tbody> -</table> -</div> + <div ng-hide="showLoader"> + <div> + <div class="form-row"> + <label for="checkbox1" class="checkbox"> <input + id="checkbox1" type="checkbox" ng-model="reportRunJson.animation" /><i + class="skin"></i><span>Animation</span> + </label> + </div> + <table> + <thead> + <tr> + <th width="30%">Chart Type</th> + <th></th> + </tr> + </thead> -</div> - -<div ng-show=false style="min-height:500px" data-ng-init="init()"> - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Chart Type</label><BR> - <div class="form-field" att-select="chartTypes" ng-model="reportRunJson.chartTypeJSON" placeholder="Select an Option" show-input-filter="true" ng-change="actionClicked()"></div> - </div> - - - <div class="fn-ebz-container" style="position:relative; top: -8px;"> - <label class="fn-ebz-text-label">Animate</label><BR> - <div><input type="checkbox" ng-model="reportRunJson.animation" att-checkbox data-ng-value="true"></div> - </div> - <BR> - - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Width (Px)</label><BR> - <input type="text" name="chartWidth" maxlength=4 only-digits ng-model="reportRunJson.width" style="width:80px"/> - </div> - - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Height (Px)</label><BR> - <input type="text" name="chartHeight" maxlength=4 only-digits ng-model="reportRunJson.height" style="width:80px"/> - </div> - <BR> - - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Title</label><BR> - <span><input name="tle" type="radio" ng-model="reportRunJson.showTitle" data-ng-value="true"/>Show</span> - <span><input name="tle" type="radio" ng-model="reportRunJson.showTitle" data-ng-value="false"/>Hide</span> - </div> - <BR> - - - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Domain Axis</label><BR> - <div class="form-field" att-select="reportRunJson.chartColumnJSONList" ng-model="reportRunJson.domainAxisJSON" placeholder="Select an Option" show-input-filter="true"></div> - </div> - - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Category</label><BR> - <div class="form-field" att-select="reportRunJson.chartColumnJSONList" ng-model="reportRunJson.categoryAxis" placeholder="" show-input-filter="true"></div> - </div> - <BR> - -<div style="border:2px;border-style:solid;border-color:#808080;margin-bottom:9px"> -<div ng-repeat="rangeReport in reportRunJson.rangeAxisList"> - <div style="margin-left:5px"> - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Range Axis</label><BR> - <div class="form-field" att-select="reportRunJson.chartColumnJSONList" - ng-model="rangeReport.rangeAxisLabelJSON" placeholder="Select an Option" show-input-filter="true"></div> - </div> - - - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Y Axis</label><BR> - <input id="yaxs" type="text" name="yAxis" maxlength=50 ng-model=rangeReport.rangeYAxis style="width:100px"/> - </div> - - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Chart Title</label><BR> - <input type="text" name="chartTitle" maxlength=50 ng-model="rangeReport.rangeChartGroup" style="width:200px"/> - </div> - - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Color</label><BR> - <div class="form-field" att-select="rangeColors" ng-model="rangeReport.rangeColorJSON" placeholder="Select an Option" show-input-filter="true"></div> - </div> - - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Line Type</label><BR> - <div class="form-field" att-select="lineTypes" ng-model="rangeReport.rangeLineTypeJSON" placeholder="Select an Option" show-input-filter="true"></div> - </div> - - <div class="fn-ebz-container" ng-show="reportRunJson.chartTypeJSON.value=='FlexTimeChart' || - reportRunJson.chartTypeJSON.value=='AnnotationChart'" style="position:relative; top: -8px;"> - <label class="fn-ebz-text-label">Area</label><BR> - <input type="checkbox" ng-model="rangeReport.showAsArea" att-checkbox data-ng-value="true"> - </div> - - <div class="fn-ebz-container" style="position:relative; top: 25px;"> - <a href="javascript:void(0)" ng-show="{{$index==0}}" style="float: right;" att-button btn-type="secondary" size="small" att-accessibility-click="13,32" - ng-click="addRangeAxisRow(rangeReport);" >Add</a> - <a href="javascript:void(0)" ng-show="{{$index>0}}" style="float: right;" att-button btn-type="secondary" size="small" att-accessibility-click="13,32" ng-click="removeRangeAxisRow($index);" > - Remove</a> - </div> - </div> - </div> - </div> - <BR> - -<accordion close-others="true" css="att-accordion--no-box"> - <accordion-group id="additionalOptions" heading="Additional Options" child-length="10"> - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Primary Axis Label</label><BR> - <input type="text" name="prAxis" maxlength=50 ng-model="reportRunJson.primaryAxisLabel" style="width:210px"/> - </div> - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Secondary Axis Label</label><BR> - <input type="text" name="secAxis" maxlength=75 ng-model="reportRunJson.secondaryAxisLabel" style="width:210px"/> - </div> - <BR> - <div class="fn-ebz-container" > - <label class="fn-ebz-text-label">Range Axis Minimum Range</label><BR> - <input type="text" name="rAxisMinRange" only-digits ng-model="reportRunJson.minRange" style="width:210px"/> - </div> - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Maximum Range</label><BR> - <input type="text" name="rAxisMaxRange" only-digits ng-model="reportRunJson.maxRange" ng-maxLength="35" style="width:210px"/> - </div><BR> - </accordion-group> -</accordion> - - - - -<div ng-show="reportRunJson.chartType=='BarChart3D'"> - - <accordion close-others="true" css="att-accordion--no-box"> - <accordion-group id="accBar" heading="Bar Chart Options" child-length="10"> - - - <div style="border:2px;border-style:solid;border-color:#808080;margin-bottom:9px"> - <div class="fn-ebz-container" style="position:relative;margin:10px;" > - <label class="fn-ebz-text-label">Orientation</label><BR> - <span><input name="orient" type="radio" ng-model="reportRunJson.barChartOptions.verticalOrientation" data-ng-value="true"/>Vertical</span> - <span><input name="orient" type="radio" ng-model="reportRunJson.barChartOptions.verticalOrientation" data-ng-value="false"/>Horizontal</span> + <tbody> + <tr> + <td><select name="chartType" b2b-dropdown + ng-model="reportRunJson.chartType"> + <option b2b-dropdown-list option-repeat="d in chartTypeOptions" + value="{{d.value}}">{{d.text}}</option> + </select></td> + <td></td> + </tr> + </tbody> + </table> + + <table> + <thead> + <tr> + <th width="50px">Width (px)</th> + <th>Height (px)</th> + </tr> + </thead> + <tbody> + <tr> + <td><input type="text" name="displayName" + ng-model="reportRunJson.width" style="width: 100px;"></td> + <td><input type="text" name="displayName" + ng-model="reportRunJson.height" style="width: 100px;"></td> + </tr> + </tbody> + </table> + + <table> + <thead> + <tr> + <th width="50px">Title</th> + </tr> + </thead> + <tbody> + <tr> + <fieldset role="radiogroup" radio-group-accessibility> + <td><label for="optionsRadiosShowTitleTrue" class="radio"> + <input type="radio" ng-model="reportRunJson.showTitle" + id="optionsRadiosShowTitleTrue" + name="optionsRadiosShowTitleTrue" value="true"> <i + class="skin"></i> <span>Show</span> + </label></td> + <td><label for="optionsRadiosShowTitleFalse" class="radio"> + <input type="radio" ng-model="reportRunJson.showTitle" + id="optionsRadiosShowTitleFalse" + name="optionsRadiosShowTitleFalse" value="false"> <i + class="skin"></i> <span>Hide</span> + </label></td> + </fieldset> + </tr> + + </tbody> + </table> + + <table> + <thead> + <tr> + <th width="30%">Domain Axis</th> + <th width="30%">Category</th> + <th width="40%"></th> + </tr> + </thead> + <tbody> + <tr> + <td><select name="chartType" b2b-dropdown + ng-model="reportRunJson.domainAxis"> + <option b2b-dropdown-list + option-repeat="d in reportRunJson.chartColumnJSONList" + value="{{d.value}}">{{d.title}}</option> + </select></td> + <td><select name="chartType" b2b-dropdown + ng-model="reportRunJson.categoryAxis"> + <option b2b-dropdown-list + option-repeat="d in reportRunJson.chartColumnJSONList" + value="{{d.value}}">{{d.title}}</option> + </select></td> + </tr> + </tbody> + </table> + + + <div id="RangeTable"> + + <table ng-repeat="rangeReport in reportRunJson.rangeAxisList"> + <thead> + <tr> + <th width="18%">Range Axis</th> + <th width="15%">Y Axis</th> + <th width="15%">Chart Title</th> + <th width="22%">Color</th> + <th width="25%">Line Type</th> + <th></th> + </tr> + </thead> + <tbody> + <tr> + <td><select name="chartType" b2b-dropdown + ng-model="rangeReport.rangeAxisLabelJSON.value" + placeholder-text="Select" + ng-disabled="rangeReport.removed=='true'"> + <option b2b-dropdown-list + option-repeat="d in reportRunJson.chartColumnJSONList" + value="{{d.value}}">{{d.title}}</option> + </select></td> + <td><input type="text" name="displayName" + ng-model="rangeReport.rangeYAxis" + ng-disabled="rangeReport.removed=='true'" style="width: 100px;"> + </td> + <td><input type="text" name="displayName" + ng-model="rangeReport.rangeChartGroup" + ng-disabled="rangeReport.removed=='true'" style="width: 150px;"> + </td> + <td><select name="chartType" b2b-dropdown + ng-model="rangeReport.rangeColor" + ng-disabled="rangeReport.removed=='true'"> + <option b2b-dropdown-list option-repeat="d in rangeColors" + value="{{d.value}}">{{d.title}}</option> + </select></td> + <td><select name="lineType" b2b-dropdown + ng-model="rangeReport.rangeLineType" + ng-disabled="rangeReport.removed=='true'"> + <option b2b-dropdown-list option-repeat="d in lineTypes" + value="{{d.value}}">{{d.title}}</option> + </select></td> + <td><span> + <button ng-if="rangeReport.removed!='true'" type="submit" + style="width: 90px; height: 35px; margin-left: 5px;" + class="btn btn-secondary btn-small" + ng-click="removeRangeAxisRow($index)">Remove</button> + <button ng-if="rangeReport.removed=='true'" type="submit" + style="width: 90px; height: 35px; margin-left: 5px;" + class="btn btn-secondary btn-small" disabled="disabled">Removed</button> + </span></td> + </tr> + + </tbody> + </table> + <div align="right" style="margin-right:20px"> + <button type="submit" class="btn btn-secondary btn-small" ng-click="addRangeAxisRow()">Add</button> + </div> + </div> </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">Stacked</label><BR> - <span><input name="stack" type="radio" ng-model="reportRunJson.barChartOptions.stackedChart" data-ng-value="true"/>Yes</span> - <span><input name="stack" type="radio" ng-model="reportRunJson.barChartOptions.stackedChart" data-ng-value="false"/>No</span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">Show Controls</label><BR> - <span><input name="shwcontrol" type="radio" ng-model="reportRunJson.barChartOptions.displayBarControls" data-ng-value="true"/>Yes</span> - <span><input name="shwcontrol" type="radio" ng-model="reportRunJson.barChartOptions.displayBarControls" data-ng-value="false"/>No</span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">XAxis Date Type</label><BR> - <span><input name="xAxisDtype" type="radio" ng-model="reportRunJson.barChartOptions.xAxisDateType" data-ng-value="true"/>Yes</span> - <span><input name="xAxisDtype" type="radio" ng-model="reportRunJson.barChartOptions.xAxisDateType" data-ng-value="false"/>No</span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">Display less XAxis tickers</label><BR> - <span><input name="xTicker" type="radio" ng-model="reportRunJson.barChartOptions.minimizeXAxisTickers" data-ng-value="true"/>Yes</span> - <span><input name="xTicker" type="radio" ng-model="reportRunJson.barChartOptions.minimizeXAxisTickers" data-ng-value="false"/>No</span> - </div><BR> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">Is Time Axis?</label><BR> - <span><input name="timeAxis" type="radio" ng-model="reportRunJson.barChartOptions.timeAxis" data-ng-value="true"/>Yes</span> - <span><input name="timeAxis" type="radio" ng-model="reportRunJson.barChartOptions.timeAxis" data-ng-value="false"/>No</span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">Log Scale (Y Axis)</label><BR> - <span><input type="checkbox" ng-model="reportRunJson.barChartOptions.yAxisLogScale" att-checkbox data-ng-value="true"></span> - - </div> - </div> - </accordion-group> -</accordion> -</div> - {{reportRunJson.chartType}} - <div ng-show="reportRunJson.chartType=='TimeSeriesChart'"> - <accordion close-others="true" css="att-accordion--no-box"> - <accordion-group id="accTimeChart" heading="Time Series Chart Options" child-length="10"> - - <div style="border:2px;border-style:solid;border-color:#808080;margin-bottom:9px"> - <div style="margin-left:5px"> + <div ng-show=false style="min-height: 500px" data-ng-init="init()"> <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Render as</label><BR> - <span><input name="renderAs" type="radio" ng-model="reportRunJson.timeSeriesChartOptions.lineChartRenderer" value="line"/>Line</span> - <span><input name="orient" type="radio" ng-model="reportRunJson.timeSeriesChartOptions.lineChartRenderer" value="area"/>Area</span> + <label class="fn-ebz-text-label">Chart Type</label><BR> + <div class="form-field" att-select="chartTypes" + ng-model="reportRunJson.chartTypeJSON" + placeholder="Select an Option" show-input-filter="true" + ng-change="actionClicked()"></div> </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">X Axis Label</label><BR> - <span><input type="checkbox" ng-model="reportRunJson.timeSeriesChartOptions.showXAxisLabel" att-checkbox data-ng-value="true"></span> - </div><BR> - - <div class="fn-ebz-container" style="position:relative;bottom:10px;"> - <label class="fn-ebz-text-label">X Axis <br>Tickers</label><BR> - <span style="position:relative;top:10px;"><input type="checkbox" ng-model="reportRunJson.timeSeriesChartOptions.addXAxisTicker" att-checkbox data-ng-value="true"></span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:20px;"> - <label class="fn-ebz-text-label">Is Time Axis?</label><BR> - <span><input name="timeAxisChart" type="radio" ng-model="reportRunJson.timeSeriesChartOptions.nonTimeAxis" data-ng-value="true"/>Yes</span> - <span><input name="timeAxisChart" type="radio" ng-model="reportRunJson.timeSeriesChartOptions.nonTimeAxis" data-ng-value="false"/>No</span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">Multi Series?</label><BR> - <span><input name="mSeries" type="radio" ng-model="reportRunJson.timeSeriesChartOptions.multiSeries" data-ng-value="true"/>Yes</span> - <span><input name="mSeries" type="radio" ng-model="reportRunJson.timeSeriesChartOptions.multiSeries" data-ng-value="false"/>No</span> - </div> - </div> - </div> - - </accordion-group> - </accordion> - - </div> - - <div> - - <accordion close-others="true" css="att-accordion--no-box"> - <accordion-group id="accFlexTimeChart" heading="Flex Time Series Chart Options" child-length="10"> - - <div style="border:2px;border-style:solid;border-color:#808080;margin-bottom:9px"> - <div style="margin-left:5px"> - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Zoom-In Window</label><BR> - <span><input type="text" name="zWindow" only-digits maxlength=3 ng-model="reportRunJson.flexTimeSeriesChartOptions.zoomIn"></span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">Time Axis Type</label><BR> - <span><input name="timeAxisType" type="radio" ng-model="reportRunJson.flexTimeSeriesChartOptions.timeAxisType" value="weekly"/>Weekly</span> - <span><input name="timeAxisType" type="radio" ng-model="reportRunJson.flexTimeSeriesChartOptions.timeAxisType" value="daily"/>Daily</span> - <span><input name="timeAxisType" type="radio" ng-model="reportRunJson.flexTimeSeriesChartOptions.timeAxisType" value="hourly"/>Hourly</span> - <span><input name="timeAxisType" type="radio" ng-model="reportRunJson.flexTimeSeriesChartOptions.timeAxisType" value="30min"/>30 Min</span> + + + <div class="fn-ebz-container" style="position: relative; top: -8px;"> + <label class="fn-ebz-text-label">Animate</label><BR> + <div> + <input type="checkbox" ng-model="reportRunJson.animation" + att-checkbox data-ng-value="true"> + </div> + </div> + <BR> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Width (Px)</label><BR> <input + type="text" name="chartWidth" maxlength=4 only-digits + ng-model="reportRunJson.width" style="width: 80px" /> + </div> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Height (Px)</label><BR> <input + type="text" name="chartHeight" maxlength=4 only-digits + ng-model="reportRunJson.height" style="width: 80px" /> + </div> + <BR> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Title</label><BR> <span><input + name="tle" type="radio" ng-model="reportRunJson.showTitle" + data-ng-value="true" />Show</span> <span><input name="tle" + type="radio" ng-model="reportRunJson.showTitle" + data-ng-value="false" />Hide</span> + </div> + <BR> + + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Domain Axis</label><BR> + <div class="form-field" + att-select="reportRunJson.chartColumnJSONList" + ng-model="reportRunJson.domainAxisJSON" + placeholder="Select an Option" show-input-filter="true"></div> + </div> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Category</label><BR> + <div class="form-field" + att-select="reportRunJson.chartColumnJSONList" + ng-model="reportRunJson.categoryAxis" placeholder="" + show-input-filter="true"></div> + </div> + <BR> + + <div + style="border: 2px; border-style: solid; border-color: #808080; margin-bottom: 9px"> + <div ng-repeat="rangeReport in reportRunJson.rangeAxisList"> + <div style="margin-left: 5px"> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Range Axis</label><BR> + <div class="form-field" + att-select="reportRunJson.chartColumnJSONList" + ng-model="rangeReport.rangeAxisLabelJSON" + placeholder="Select an Option" show-input-filter="true"></div> + </div> + + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Y Axis</label><BR> <input + id="yaxs" type="text" name="yAxis" maxlength=50 + ng-model=rangeReport.rangeYAxis style="width: 100px" /> + </div> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Chart Title</label><BR> <input + type="text" name="chartTitle" maxlength=50 + ng-model="rangeReport.rangeChartGroup" style="width: 200px" /> + </div> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Color</label><BR> + <div class="form-field" att-select="rangeColors" + ng-model="rangeReport.rangeColorJSON" + placeholder="Select an Option" show-input-filter="true"></div> + </div> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Line Type</label><BR> + <div class="form-field" att-select="lineTypes" + ng-model="rangeReport.rangeLineTypeJSON" + placeholder="Select an Option" show-input-filter="true"></div> + </div> + + <div class="fn-ebz-container" + ng-show="reportRunJson.chartTypeJSON.value=='FlexTimeChart' || + reportRunJson.chartTypeJSON.value=='AnnotationChart'" + style="position: relative; top: -8px;"> + <label class="fn-ebz-text-label">Area</label><BR> <input + type="checkbox" ng-model="rangeReport.showAsArea" att-checkbox + data-ng-value="true"> + </div> + + <div class="fn-ebz-container" + style="position: relative; top: 25px;"> + <a href="javascript:void(0)" ng-show="{{$index==0}}" + style="float: right;" att-button btn-type="secondary" + size="small" att-accessibility-click="13,32" + ng-click="addRangeAxisRow(rangeReport);">Add</a> <a + href="javascript:void(0)" ng-show="{{$index>0}}" + style="float: right;" att-button btn-type="secondary" + size="small" att-accessibility-click="13,32" + ng-click="removeRangeAxisRow($index);"> Remove</a> + </div> + </div> + </div> + </div> + <BR> + + <accordion close-others="true" css="att-accordion--no-box"> + <accordion-group id="additionalOptions" heading="Additional Options" + child-length="10"> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Primary Axis Label</label><BR> + <input type="text" name="prAxis" maxlength=50 + ng-model="reportRunJson.primaryAxisLabel" style="width: 210px" /> + </div> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Secondary Axis Label</label><BR> + <input type="text" name="secAxis" maxlength=75 + ng-model="reportRunJson.secondaryAxisLabel" style="width: 210px" /> + </div> + <BR> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Range Axis Minimum Range</label><BR> + <input type="text" name="rAxisMinRange" only-digits + ng-model="reportRunJson.minRange" style="width: 210px" /> + </div> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Maximum Range</label><BR> <input + type="text" name="rAxisMaxRange" only-digits + ng-model="reportRunJson.maxRange" ng-maxLength="35" + style="width: 210px" /> + </div> + <BR> + </accordion-group> </accordion> + + + + + <div ng-show="reportRunJson.chartType=='BarChart3D'"> + + <accordion close-others="true" css="att-accordion--no-box"> + <accordion-group id="accBar" heading="Bar Chart Options" + child-length="10"> + + + <div + style="border: 2px; border-style: solid; border-color: #808080; margin-bottom: 9px"> + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Orientation</label><BR> <span><input + name="orient" type="radio" + ng-model="reportRunJson.barChartOptions.verticalOrientation" + data-ng-value="true" />Vertical</span> <span><input name="orient" + type="radio" + ng-model="reportRunJson.barChartOptions.verticalOrientation" + data-ng-value="false" />Horizontal</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Stacked</label><BR> <span><input + name="stack" type="radio" + ng-model="reportRunJson.barChartOptions.stackedChart" + data-ng-value="true" />Yes</span> <span><input name="stack" + type="radio" + ng-model="reportRunJson.barChartOptions.stackedChart" + data-ng-value="false" />No</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Show Controls</label><BR> <span><input + name="shwcontrol" type="radio" + ng-model="reportRunJson.barChartOptions.displayBarControls" + data-ng-value="true" />Yes</span> <span><input name="shwcontrol" + type="radio" + ng-model="reportRunJson.barChartOptions.displayBarControls" + data-ng-value="false" />No</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">XAxis Date Type</label><BR> + <span><input name="xAxisDtype" type="radio" + ng-model="reportRunJson.barChartOptions.xAxisDateType" + data-ng-value="true" />Yes</span> <span><input name="xAxisDtype" + type="radio" + ng-model="reportRunJson.barChartOptions.xAxisDateType" + data-ng-value="false" />No</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Display less XAxis + tickers</label><BR> <span><input name="xTicker" type="radio" + ng-model="reportRunJson.barChartOptions.minimizeXAxisTickers" + data-ng-value="true" />Yes</span> <span><input name="xTicker" + type="radio" + ng-model="reportRunJson.barChartOptions.minimizeXAxisTickers" + data-ng-value="false" />No</span> + </div> + <BR> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Is Time Axis?</label><BR> <span><input + name="timeAxis" type="radio" + ng-model="reportRunJson.barChartOptions.timeAxis" + data-ng-value="true" />Yes</span> <span><input name="timeAxis" + type="radio" ng-model="reportRunJson.barChartOptions.timeAxis" + data-ng-value="false" />No</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Log Scale (Y Axis)</label><BR> + <span><input type="checkbox" + ng-model="reportRunJson.barChartOptions.yAxisLogScale" + att-checkbox data-ng-value="true"></span> + + </div> + </div> + + </accordion-group> </accordion> + </div> + {{reportRunJson.chartType}} + <div ng-show="reportRunJson.chartType=='TimeSeriesChart'"> + <accordion close-others="true" css="att-accordion--no-box"> + <accordion-group id="accTimeChart" + heading="Time Series Chart Options" child-length="10"> + + <div + style="border: 2px; border-style: solid; border-color: #808080; margin-bottom: 9px"> + <div style="margin-left: 5px"> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Render as</label><BR> <span><input + name="renderAs" type="radio" + ng-model="reportRunJson.timeSeriesChartOptions.lineChartRenderer" + value="line" />Line</span> <span><input name="orient" + type="radio" + ng-model="reportRunJson.timeSeriesChartOptions.lineChartRenderer" + value="area" />Area</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">X Axis Label</label><BR> <span><input + type="checkbox" + ng-model="reportRunJson.timeSeriesChartOptions.showXAxisLabel" + att-checkbox data-ng-value="true"></span> + </div> + <BR> + + <div class="fn-ebz-container" + style="position: relative; bottom: 10px;"> + <label class="fn-ebz-text-label">X Axis <br>Tickers + </label><BR> <span style="position: relative; top: 10px;"><input + type="checkbox" + ng-model="reportRunJson.timeSeriesChartOptions.addXAxisTicker" + att-checkbox data-ng-value="true"></span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 20px;"> + <label class="fn-ebz-text-label">Is Time Axis?</label><BR> <span><input + name="timeAxisChart" type="radio" + ng-model="reportRunJson.timeSeriesChartOptions.nonTimeAxis" + data-ng-value="true" />Yes</span> <span><input + name="timeAxisChart" type="radio" + ng-model="reportRunJson.timeSeriesChartOptions.nonTimeAxis" + data-ng-value="false" />No</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Multi Series?</label><BR> <span><input + name="mSeries" type="radio" + ng-model="reportRunJson.timeSeriesChartOptions.multiSeries" + data-ng-value="true" />Yes</span> <span><input name="mSeries" + type="radio" + ng-model="reportRunJson.timeSeriesChartOptions.multiSeries" + data-ng-value="false" />No</span> + </div> + </div> + </div> + + </accordion-group> </accordion> + + </div> + + <div> + + <accordion close-others="true" css="att-accordion--no-box"> + <accordion-group id="accFlexTimeChart" + heading="Flex Time Series Chart Options" child-length="10"> + + <div + style="border: 2px; border-style: solid; border-color: #808080; margin-bottom: 9px"> + <div style="margin-left: 5px"> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Zoom-In Window</label><BR> + <span><input type="text" name="zWindow" only-digits + maxlength=3 + ng-model="reportRunJson.flexTimeSeriesChartOptions.zoomIn"></span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Time Axis Type</label><BR> + <span><input name="timeAxisType" type="radio" + ng-model="reportRunJson.flexTimeSeriesChartOptions.timeAxisType" + value="weekly" />Weekly</span> <span><input name="timeAxisType" + type="radio" + ng-model="reportRunJson.flexTimeSeriesChartOptions.timeAxisType" + value="daily" />Daily</span> <span><input name="timeAxisType" + type="radio" + ng-model="reportRunJson.flexTimeSeriesChartOptions.timeAxisType" + value="hourly" />Hourly</span> <span><input name="timeAxisType" + type="radio" + ng-model="reportRunJson.flexTimeSeriesChartOptions.timeAxisType" + value="30min" />30 Min</span> + </div> + </div> + </div> + </accordion-group> </accordion> + + </div> + + + + + + + + + <accordion close-others="true" css="att-accordion--no-box"> + <accordion-group id="accCommonOptions" heading="Common Options" + child-length="10"> + + <div + style="border: 2px; border-style: solid; border-color: #808080; margin-bottom: 9px"> + <div style="margin-left: 5px"> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Legend Angle</label><BR> <span><input + name="langle" type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + value="up45" />up 45°</span> <span><input name="langle" + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + value="up90" />up 90°</span> <span><input name="langle" + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + value="down45" />down 45°</span> <span><input name="langle" + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + value="down90" />down 90°</span> <span><input name="langle" + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + value="standard" />Standard</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 15px;"> + <label class="fn-ebz-text-label">Legend Position</label><BR> + <span><input name="lgPosition" type="radio" + ng-model="reportRunJson.commonChartOptions.legendPosition" + value="top" />Top</span> <span><input name="lgPosition" + type="radio" + ng-model="reportRunJson.commonChartOptions.legendPosition" + value="bottom" />Bottom</span> + </div> + <BR> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Legend</label><BR> <span><input + name="lgd" type="radio" + ng-model="reportRunJson.commonChartOptions.hideLegend" + data-ng-value="false" />Yes</span> <span><input name="lgd" + type="radio" + ng-model="reportRunJson.commonChartOptions.hideLegend" + data-ng-value="true" />No</span> + </div> + + <div class="fn-ebz-container" + style="position: relative; margin: 10px;"> + <label class="fn-ebz-text-label">Animation</label><BR> <span><input + name="anmtate" type="radio" + ng-model="reportRunJson.commonChartOptions.animateAnimatedChart" + data-ng-value="true" />Yes</span> <span><input name="anmtate" + type="radio" + ng-model="reportRunJson.commonChartOptions.animateAnimatedChart" + data-ng-value="false" />No</span> + </div> + <BR> + + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Top Margin</label><BR> <input + type="text" name="reportRunJson.commonChartOptions.topMargin" + only-digits maxlength=3 + ng-model="reportRunJson.commonChartOptions.topMargin" + style="width: 210px" /> + </div> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Bottom Margin</label><BR> <input + type="text" name="reportRunJson.commonChartOptions.bottomMargin" + only-digits maxlength=3 + ng-model="reportRunJson.commonChartOptions.bottomMargin" + style="width: 210px" /> + </div> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Left Margin</label><BR> <input + type="text" name="reportRunJson.commonChartOptions.leftMargin" + only-digits maxlength=3 + ng-model="reportRunJson.commonChartOptions.leftMargin" + style="width: 210px" /> + </div> + <div class="fn-ebz-container"> + <label class="fn-ebz-text-label">Right Margin</label><BR> <input + type="text" name="reportRunJson.commonChartOptions.rightMargin" + only-digits maxlength=3 + ng-model="reportRunJson.commonChartOptions.rightMargin" + style="width: 210px"> + </div> + <BR> + </div> + </div> + </accordion-group> </accordion> + <br /> + <br /> <a href="javascript:void(0)" att-button btn-type="primary" + att-accessibility-click="13,32" ng-click="saveChartData();">Save</a> + <a + href="report#/report_run/c_master={{reportRunJson.reportID}}&refresh=Y" + att-button btn-type="primary" att-accessibility-click="13,32">Run</a> </div> - </div> - </div> - </accordion-group> - </accordion> - - </div> - - - - - - - - - <accordion close-others="true" css="att-accordion--no-box"> - <accordion-group id="accCommonOptions" heading="Common Options" child-length="10"> - - <div style="border:2px;border-style:solid;border-color:#808080;margin-bottom:9px"> - <div style="margin-left:5px"> - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Legend Angle</label><BR> - <span><input name="langle" type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" value="up45"/>up 45°</span> - <span><input name="langle" type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" value="up90"/>up 90°</span> - <span><input name="langle" type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" value="down45"/>down 45°</span> - <span><input name="langle" type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" value="down90"/>down 90°</span> - <span><input name="langle" type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" value="standard"/>Standard</span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:15px;"> - <label class="fn-ebz-text-label">Legend Position</label><BR> - <span><input name="lgPosition" type="radio" ng-model="reportRunJson.commonChartOptions.legendPosition" value="top"/>Top</span> - <span><input name="lgPosition" type="radio" ng-model="reportRunJson.commonChartOptions.legendPosition" value="bottom"/>Bottom</span> - </div><BR> - - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Legend</label><BR> - <span><input name="lgd" type="radio" ng-model="reportRunJson.commonChartOptions.hideLegend" data-ng-value="false"/>Yes</span> - <span><input name="lgd" type="radio" ng-model="reportRunJson.commonChartOptions.hideLegend" data-ng-value="true"/>No</span> - </div> - - <div class="fn-ebz-container" style="position:relative;margin:10px;"> - <label class="fn-ebz-text-label">Animation</label><BR> - <span><input name="anmtate" type="radio" ng-model="reportRunJson.commonChartOptions.animateAnimatedChart" data-ng-value="true" />Yes</span> - <span><input name="anmtate" type="radio" ng-model="reportRunJson.commonChartOptions.animateAnimatedChart" data-ng-value="false"/>No</span> - </div><BR> - - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Top Margin</label><BR> - <input type="text" name="reportRunJson.commonChartOptions.topMargin" only-digits maxlength=3 ng-model="reportRunJson.commonChartOptions.topMargin" style="width:210px"/> - </div> - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Bottom Margin</label><BR> - <input type="text" name="reportRunJson.commonChartOptions.bottomMargin" only-digits maxlength=3 ng-model="reportRunJson.commonChartOptions.bottomMargin" style="width:210px"/> - </div> - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Left Margin</label><BR> - <input type="text" name="reportRunJson.commonChartOptions.leftMargin" only-digits maxlength=3 ng-model="reportRunJson.commonChartOptions.leftMargin" style="width:210px"/> - </div> - <div class="fn-ebz-container"> - <label class="fn-ebz-text-label">Right Margin</label><BR> - <input type="text" name="reportRunJson.commonChartOptions.rightMargin" only-digits maxlength=3 ng-model="reportRunJson.commonChartOptions.rightMargin" style="width:210px"> - </div><BR> - </div> - </div> - </accordion-group> -</accordion> - <br/><br/> - <a href="javascript:void(0)" att-button btn-type="primary" att-accessibility-click="13,32" ng-click="saveChartData();">Save</a> - <a href="report#/report_run/c_master={{reportRunJson.reportID}}&refresh=Y" att-button btn-type="primary" att-accessibility-click="13,32">Run</a> -</div> -<div> - <b2b-expanders class="mpc-expanders" is-open="additionalOptionOpen"> - <b2b-expander-heading> - <div class="row"> - <div class="span6"> - <div class="heading-medium b2b-blue" ng-class=" { 'b2b-toggle-header-active': !additionalOptionOpen, 'b2b-toggle-header-inactive': additionalOptionOpen } ">Additional Options</div> - <p class="p-small"> - </p> - </div> - <div style="position: absolute;right: 250px;" class="span1"> - <i class="pull-right b2b-toggle-header-icon" b2b-expander-toggle b2b-accessibility-click="13,32" expand-icon="icon-primary-collapsed" collapse-icon="icon-primary-expanded" tabindex="0" aria-posinset="1" aria-setsize="2"></i> - </div> - </div> - </b2b-expander-heading> - <b2b-expander-body> - <div> - <div id="RangeTable"> - <table> - <thead> - <tr> - <th width="30%">Primary Axis Label</th> - <th width="30%">Secondary Axis Label</th> - <th></th> - </tr> - </thead> - <tbody> - <tr> - <td> - <input type="text" name="primaryAxisLabel" ng-model="reportRunJson.primaryAxisLabel" style="width:200px;"> - </td> - <td> - <input type="text" name="secondaryAxisLabel" ng-model="reportRunJson.secondaryAxisLabel" style="width:200px;"> - </td> - </tr> - </tbody> - </table> - <table> - <thead> - <tr> - <th width="30%">Range Axis Minimum Range</th> - <th width="30%">Maximum Range</th> - <th></th> - </tr> - </thead> - <tbody> - <tr> - <td> - <input type="text" name="minRange" ng-model="reportRunJson.minRange" style="width:200px;"> - </td> - <td> - <input type="text" name="maxRange" ng-model="reportRunJson.maxRange" style="width:200px;"> - </td> - </tr> - </tbody> - </table> - </div> + <div> + <b2b-expanders class="mpc-expanders" is-open="additionalOptionOpen"> + <b2b-expander-heading> + <div class="row"> + <div class="span6"> + <div class="heading-medium b2b-blue" + ng-class=" { 'b2b-toggle-header-active': !additionalOptionOpen, 'b2b-toggle-header-inactive': additionalOptionOpen } ">Additional + Options</div> + <p class="p-small"></p> + </div> + <div style="position: absolute; right: 250px;" class="span1"> + <i class="pull-right b2b-toggle-header-icon" b2b-expander-toggle + b2b-accessibility-click="13,32" + expand-icon="icon-primary-collapsed" + collapse-icon="icon-primary-expanded" tabindex="0" + aria-posinset="1" aria-setsize="2"></i> + </div> </div> - </b2b-expander-body> - </b2b-expanders> - - <!-- BAR CHART OPTION SECTION STARTS HERE --> - <b2b-expanders ng-show="reportRunJson.chartType=='BarChart3D'" class="mpc-expanders" is-open="barChartOptionOpen"> - <b2b-expander-heading> - <div class="row"> - <div class="span6"> - <div class="heading-medium b2b-blue" ng-class=" { 'b2b-toggle-header-active': !barChartOptionOpen, 'b2b-toggle-header-inactive': barChartOptionOpen } ">Bar Chart Options</div> - <p class="p-small"> - </p> - </div> - <div style="position: absolute;right: 250px;" class="span1"> - <i class="pull-right b2b-toggle-header-icon" b2b-expander-toggle b2b-accessibility-click="13,32" expand-icon="icon-primary-collapsed" collapse-icon="icon-primary-expanded" tabindex="0" aria-posinset="1" aria-setsize="2"></i> - </div> - </div> - </b2b-expander-heading> - <b2b-expander-body> - <div> + </b2b-expander-heading> <b2b-expander-body> + <div> <div id="RangeTable"> - <table> - <thead> - <tr> - <th width="25%">Orientation</th> - <th width="18%">Stacked</th> - <th width="18%">Show Controls</th> - <th width="18%">XAxis Date Type</th> - <th width="21%">Display less XAxis tickers</th> - <th></th> - </tr> - </thead> - <tbody> - <tr> - <td> - <label for="optionsOrientationVertical" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.verticalOrientation" id="optionsOrientationVertical" name="optionsOrientationVertical" value="true"> - <i class="skin"></i> - <span>Vertical</span> - </label> - <label for="optionsOrientationHorizontal" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.verticalOrientation" id="optionsOrientationHorizontal" name="optionsOrientationHorizontal" value="false"> - <i class="skin"></i> - <span>Horizontal</span> - </label> - </td> - - <td> - <label for="optionsStackedYes" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.stackedChart" id="optionsStackedYes" name="optionsStackedYes" value="true"> - <i class="skin"></i> - <span>Yes</span> - </label> - <label for="optionsStackedNo" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.stackedChart" id="optionsStackedNo" name="optionsStackedNo" value="false"> - <i class="skin"></i> - <span>No</span> - </label> - </td> - <td> - <label for="optionsShowControlYes" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.displayBarControls" id="optionsShowControlYes" name="optionsShowControlYes" value="true"> - <i class="skin"></i> - <span>Yes</span> - </label> - <label for="optionsShowControlNo" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.displayBarControls" id="optionsShowControlNo" name="optionsShowControlNo" value="false"> - <i class="skin"></i> - <span>No</span> - </label> - </td> - <td> - <label for="optionsXAxisDateTypeYes" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.xAxisDateType" id="optionsXAxisDateTypeYes" name="optionsXAxisDateTypeYes" value="true"> - <i class="skin"></i> - <span>Yes</span> - </label> - <label for="optionsXAxisDateTypeNo" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.xAxisDateType" id="optionsXAxisDateTypeNo" name="optionsXAxisDateTypeNo" value="false"> - <i class="skin"></i> - <span>No</span> - </label> - </td> - <td> - <label for="optionsMinimizeXAxisTickersYes" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.minimizeXAxisTickers" id="optionsMinimizeXAxisTickersYes" name="optionsMinimizeXAxisTickersYes" value="true"> - <i class="skin"></i> - <span>Yes</span> - </label> - <label for="optionsMinimizeXAxisTickersNo" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.minimizeXAxisTickers" id="optionsMinimizeXAxisTickersNo" name="optionsMinimizeXAxisTickersNo" value="false"> - <i class="skin"></i> - <span>No</span> - </label> - </td> - </tr> - </tbody> - </table> - <table> - <thead> - <tr> - <th width="25%">Is Time Axis?</th> - <th width="25%">Log Scale (Y Axis)</th> - <th></th> - </tr> - </thead> - <tbody> - <tr> - <td> - <label for="optionsTimeAxisYes" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.timeAxis" id="optionsTimeAxisYes" name="optionsTimeAxisYes" value="true"> - <i class="skin"></i> - <span>Yes</span> - </label> - <label for="optionsTimeAxisNo" class="radio"> - <input type="radio" ng-model="reportRunJson.barChartOptions.timeAxis" id="optionsTimeAxisNo" name="optionsTimeAxisNo" value="false"> - <i class="skin"></i> - <span>No</span> - </label> - </td> - <td> - <label for="logScaleYAxisCheckBox" class="checkbox"> - <input id="logScaleYAxisCheckBox" type="checkbox" ng-model="reportRunJson.barChartOptions.yAxisLogScale" /><i class="skin"></i><span></span> - </label> - </td> - </tr> - </tbody> - </table> - </div> + <table> + <thead> + <tr> + <th width="30%">Primary Axis Label</th> + <th width="30%">Secondary Axis Label</th> + <th></th> + </tr> + </thead> + <tbody> + <tr> + <td><input type="text" name="primaryAxisLabel" + ng-model="reportRunJson.primaryAxisLabel" style="width: 200px;"> + </td> + <td><input type="text" name="secondaryAxisLabel" + ng-model="reportRunJson.secondaryAxisLabel" + style="width: 200px;"></td> + </tr> + </tbody> + </table> + <table> + <thead> + <tr> + <th width="30%">Range Axis Minimum Range</th> + <th width="30%">Maximum Range</th> + <th></th> + </tr> + </thead> + <tbody> + <tr> + <td><input type="text" name="minRange" + ng-model="reportRunJson.minRange" style="width: 200px;"> + </td> + <td><input type="text" name="maxRange" + ng-model="reportRunJson.maxRange" style="width: 200px;"> + </td> + </tr> + </tbody> + </table> + </div> </div> - </b2b-expander-body> - </b2b-expanders> - <!-- BAR CHART OPTION SECTION ENDS HERE --> - - <!-- TIME SERIES CHART OPTION SECTION STARTS HERE --> - <b2b-expanders ng-show="reportRunJson.chartType=='TimeSeriesChart'" class="mpc-expanders" is-open="timeSeriesChartOptionOpen"> - <b2b-expander-heading> - <div class="row"> - <div class="span6"> - <div class="heading-medium b2b-blue" ng-class=" { 'b2b-toggle-header-active': !timeSeriesChartOptionOpen, 'b2b-toggle-header-inactive': timeSeriesChartOptionOpen } ">Time Series Chart Options</div> - <p class="p-small"> - </p> - </div> - <div style="position: absolute;right: 250px;" class="span1"> - <i class="pull-right b2b-toggle-header-icon" b2b-expander-toggle b2b-accessibility-click="13,32" expand-icon="icon-primary-collapsed" collapse-icon="icon-primary-expanded" tabindex="0" aria-posinset="1" aria-setsize="2"></i> - </div> - </div> - </b2b-expander-heading> - <b2b-expander-body> - <div> - <div> - <table> - <thead> - <tr> - <th width="20%">Render as</th> - <th width="20%">X Axis Label</th> - <th width="20%">X Axis Tickers</th> - <th width="20%">Is Time Axis?</th> - <th width="20%">Multi Series</th> - </tr> - </thead> - <tbody> - <tr> - <td> - <label for="optionsLineChartRendererLine" class="radio"> - <input type="radio" ng-model="reportRunJson.timeSeriesChartOptions.lineChartRenderer" id="optionsLineChartRendererLine" name="optionsLineChartRendererLine" value="line"> - <i class="skin"></i> - <span>Line</span> - </label> - <label for="optionsLineChartRendererArea" class="radio"> - <input type="radio" ng-model="reportRunJson.timeSeriesChartOptions.lineChartRenderer" id="optionsLineChartRendererArea" name="optionsLineChartRendererArea" value="area"> - <i class="skin"></i> - <span>Area</span> - </label> - </td> - <td> - <label for="xAxisLabelCheckBox" class="checkbox"> - <input id="xAxisLabelCheckBox" type="checkbox" ng-model="reportRunJson.timeSeriesChartOptions.showXAxisLabel" /><i class="skin"></i><span></span> - </label> - </td> - <td> - <label for="addXAxisTickerCheckBox" class="checkbox"> - <input id="addXAxisTickerCheckBox" type="checkbox" ng-model="reportRunJson.timeSeriesChartOptions.addXAxisTicker" /><i class="skin"></i><span></span> - </label> - </td> - <td> - <label for="isTimeAxisCheckBox" class="checkbox"> - <input id="isTimeAxisCheckBox" type="checkbox" ng-model="reportRunJson.timeSeriesChartOptions.nonTimeAxis" /><i class="skin"></i><span></span> - </label> - </td> - <td> - <label for="multiSeriesCheckBox" class="checkbox"> - <input id="multiSeriesCheckBox" type="checkbox" ng-model="reportRunJson.timeSeriesChartOptions.multiSeries" /><i class="skin"></i><span></span> - </label> - </td> - </tr> - </tbody> - </table> - </div> + </b2b-expander-body> </b2b-expanders> + + <!-- BAR CHART OPTION SECTION STARTS HERE --> + <b2b-expanders ng-show="reportRunJson.chartType=='BarChart3D'" + class="mpc-expanders" is-open="barChartOptionOpen"> + <b2b-expander-heading> + <div class="row"> + <div class="span6"> + <div class="heading-medium b2b-blue" + ng-class=" { 'b2b-toggle-header-active': !barChartOptionOpen, 'b2b-toggle-header-inactive': barChartOptionOpen } ">Bar + Chart Options</div> + <p class="p-small"></p> + </div> + <div style="position: absolute; right: 250px;" class="span1"> + <i class="pull-right b2b-toggle-header-icon" b2b-expander-toggle + b2b-accessibility-click="13,32" + expand-icon="icon-primary-collapsed" + collapse-icon="icon-primary-expanded" tabindex="0" + aria-posinset="1" aria-setsize="2"></i> + </div> </div> - </b2b-expander-body> - </b2b-expanders> - <!-- TIME SERIES CHART OPTION SECTION ENDS HERE --> - - <b2b-expanders class="mpc-expanders" is-open="commonOptionOpen"> - <b2b-expander-heading> - <div class="row"> - <div class="span6"> - <div class="heading-medium b2b-blue" ng-class=" { 'b2b-toggle-header-active': !commonOptionOpen, 'b2b-toggle-header-inactive': commonOptionOpen } ">Common Options</div> - <p class="p-small"> - </p> - </div> - <div style="position: absolute;right: 250px;" class="span1"> - <i class="pull-right b2b-toggle-header-icon" b2b-expander-toggle b2b-accessibility-click="13,32" expand-icon="icon-primary-collapsed" collapse-icon="icon-primary-expanded" tabindex="0" aria-posinset="1" aria-setsize="2"></i> - </div> - </div> - </b2b-expander-heading> - <b2b-expander-body> - <div > - <div> - <div style="border:2px;border-style:solid;border-color:#808080;margin-bottom:9px"> - <div style="margin-left:0px"> - <table> - <thead> - <tr> - <th>Legend Angle</th> - <th>Legend Position</th> - </tr> - </thead> - <tbody> - <tr> - <fieldset role="radiogroup" radio-group-accessibility> - <td> - <label for="optionsRadios1" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" id="optionsRadios1" name="optionsRadio1" value="up45"> - <i class="skin"></i> - <span>up 45°</span> - </label> - <label for="optionsRadios2" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" id="optionsRadios2" name="optionsRadio2" value="up90"> - <i class="skin"></i> - <span>up 90°</span> - </label> - <label for="optionsRadios3" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" id="optionsRadios3" name="optionsRadio3" value="down45"> - <i class="skin"></i> - <span>down 45°</span> - </label> - <label for="optionsRadios4444" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" id="optionsRadios4444" name="optionsRadio44" value="down90"> - <i class="skin"></i> - <span>down 90°</span> - </label> - <label for="optionsRadios5555" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.legendLabelAngle" id="optionsRadios5555" name="optionsRadio55" value="standard"> - <i class="skin"></i> - <span>Standard</span> - </label> - </td> - </fieldset> - - <fieldset role="radiogroup" radio-group-accessibility> - <td> - <label for="optionsRadiosTop" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.legendPosition" id="optionsRadiosTop" name="optionsRadioTop" value="top"> - <i class="skin"></i> - <span>Top</span> - </label> - <label for="optionsRadiosBottom" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.legendPosition" id="optionsRadiosBottom" name="optionsRadioBottom" value="bottom"> - <i class="skin"></i> - <span>Bottom</span> - </label> - </td> - </fieldset> - </tr> - </tbody> - </table> - - - <table> + </b2b-expander-heading> <b2b-expander-body> + <div> + <div id="RangeTable"> + <table> <thead> - <tr> - <th width="20%">Legend</th> - <th width="20%">Animation</th> - <th></th> - </tr> + <tr> + <th width="25%">Orientation</th> + <th width="18%">Stacked</th> + <th width="18%">Show Controls</th> + <th width="18%">XAxis Date Type</th> + <th width="21%">Display less XAxis tickers</th> + <th></th> + </tr> </thead> - <tbody> - <tr> - <fieldset role="radiogroup" radio-group-accessibility> - <td> - <label for="optionsRadiosHideLegendFalse" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.hideLegend" id="optionsRadiosHideLegendFalse" name="optionsRadiosHideLegendFalse" value="false"> - <i class="skin"></i> - <span>Yes</span> - </label> - <label for="optionsRadiosHideLegendTrue" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.hideLegend" id="optionsRadiosHideLegendTrue" name="optionsRadiosHideLegendTrue" value="true"> - <i class="skin"></i> - <span>No</span> - </label> - </td> - </fieldset> - - <fieldset role="radiogroup" radio-group-accessibility> - <td> - <label for="optionsRadiosAnimateChartTrue" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.animateAnimatedChart" id="optionsRadiosAnimateChartTrue" name="optionsRadiosAnimateChartTrue" value="true"> - <i class="skin"></i> - <span>Yes</span> - </label> - <label for="optionsRadiosAnimateChartFalse" class="radio"> - <input type="radio" ng-model="reportRunJson.commonChartOptions.animateAnimatedChart" id="optionsRadiosAnimateChartFalse" name="optionsRadiosAnimateChartFalse" value="false"> - <i class="skin"></i> - <span>No</span> - </label> - </td> - </fieldset> - <td> - </td> - </tr> - </tbody> + <tbody> + <tr> + <td><label for="optionsOrientationVertical" class="radio"> + <input type="radio" + ng-model="reportRunJson.barChartOptions.verticalOrientation" + id="optionsOrientationVertical" + name="optionsOrientationVertical" value="true"> <i + class="skin"></i> <span>Vertical</span> + </label> <label for="optionsOrientationHorizontal" class="radio"> + <input type="radio" + ng-model="reportRunJson.barChartOptions.verticalOrientation" + id="optionsOrientationHorizontal" + name="optionsOrientationHorizontal" value="false"> <i + class="skin"></i> <span>Horizontal</span> + </label></td> + + <td><label for="optionsStackedYes" class="radio"> <input + type="radio" + ng-model="reportRunJson.barChartOptions.stackedChart" + id="optionsStackedYes" name="optionsStackedYes" value="true"> + <i class="skin"></i> <span>Yes</span> + </label> <label for="optionsStackedNo" class="radio"> <input + type="radio" + ng-model="reportRunJson.barChartOptions.stackedChart" + id="optionsStackedNo" name="optionsStackedNo" value="false"> + <i class="skin"></i> <span>No</span> + </label></td> + <td><label for="optionsShowControlYes" class="radio"> + <input type="radio" + ng-model="reportRunJson.barChartOptions.displayBarControls" + id="optionsShowControlYes" name="optionsShowControlYes" + value="true"> <i class="skin"></i> <span>Yes</span> + </label> <label for="optionsShowControlNo" class="radio"> <input + type="radio" + ng-model="reportRunJson.barChartOptions.displayBarControls" + id="optionsShowControlNo" name="optionsShowControlNo" + value="false"> <i class="skin"></i> <span>No</span> + </label></td> + <td><label for="optionsXAxisDateTypeYes" class="radio"> + <input type="radio" + ng-model="reportRunJson.barChartOptions.xAxisDateType" + id="optionsXAxisDateTypeYes" name="optionsXAxisDateTypeYes" + value="true"> <i class="skin"></i> <span>Yes</span> + </label> <label for="optionsXAxisDateTypeNo" class="radio"> <input + type="radio" + ng-model="reportRunJson.barChartOptions.xAxisDateType" + id="optionsXAxisDateTypeNo" name="optionsXAxisDateTypeNo" + value="false"> <i class="skin"></i> <span>No</span> + </label></td> + <td><label for="optionsMinimizeXAxisTickersYes" + class="radio"> <input type="radio" + ng-model="reportRunJson.barChartOptions.minimizeXAxisTickers" + id="optionsMinimizeXAxisTickersYes" + name="optionsMinimizeXAxisTickersYes" value="true"> <i + class="skin"></i> <span>Yes</span> + </label> <label for="optionsMinimizeXAxisTickersNo" class="radio"> + <input type="radio" + ng-model="reportRunJson.barChartOptions.minimizeXAxisTickers" + id="optionsMinimizeXAxisTickersNo" + name="optionsMinimizeXAxisTickersNo" value="false"> <i + class="skin"></i> <span>No</span> + </label></td> + </tr> + </tbody> + </table> + <table> + <thead> + <tr> + <th width="25%">Is Time Axis?</th> + <th width="25%">Log Scale (Y Axis)</th> + <th></th> + </tr> + </thead> + <tbody> + <tr> + <td><label for="optionsTimeAxisYes" class="radio"> + <input type="radio" + ng-model="reportRunJson.barChartOptions.timeAxis" + id="optionsTimeAxisYes" name="optionsTimeAxisYes" value="true"> + <i class="skin"></i> <span>Yes</span> + </label> <label for="optionsTimeAxisNo" class="radio"> <input + type="radio" ng-model="reportRunJson.barChartOptions.timeAxis" + id="optionsTimeAxisNo" name="optionsTimeAxisNo" value="false"> + <i class="skin"></i> <span>No</span> + </label></td> + <td><label for="logScaleYAxisCheckBox" class="checkbox"> + <input id="logScaleYAxisCheckBox" type="checkbox" + ng-model="reportRunJson.barChartOptions.yAxisLogScale" /><i + class="skin"></i><span></span> + </label></td> + </tr> + </tbody> </table> + </div> + </div> + </b2b-expander-body> </b2b-expanders> + <!-- BAR CHART OPTION SECTION ENDS HERE --> + <!-- TIME SERIES CHART OPTION SECTION STARTS HERE --> + <b2b-expanders ng-show="reportRunJson.chartType=='TimeSeriesChart'" + class="mpc-expanders" is-open="timeSeriesChartOptionOpen"> + <b2b-expander-heading> + <div class="row"> + <div class="span6"> + <div class="heading-medium b2b-blue" + ng-class=" { 'b2b-toggle-header-active': !timeSeriesChartOptionOpen, 'b2b-toggle-header-inactive': timeSeriesChartOptionOpen } ">Time + Series Chart Options</div> + <p class="p-small"></p> + </div> + <div style="position: absolute; right: 250px;" class="span1"> + <i class="pull-right b2b-toggle-header-icon" b2b-expander-toggle + b2b-accessibility-click="13,32" + expand-icon="icon-primary-collapsed" + collapse-icon="icon-primary-expanded" tabindex="0" + aria-posinset="1" aria-setsize="2"></i> + </div> + </div> + </b2b-expander-heading> <b2b-expander-body> + <div> + <div> <table> <thead> - <tr> - <th width="25%">Top Margin</th> - <th width="25%">Bottom Margin</th> - <th width="25%">Left Margin</th> - <th width="25%">Right Margin</th> - </tr> + <tr> + <th width="20%">Render as</th> + <th width="20%">X Axis Label</th> + <th width="20%">X Axis Tickers</th> + <th width="20%">Is Time Axis?</th> + <th width="20%">Multi Series</th> + </tr> </thead> - <tbody> - <tr> - <td> - <input type="text" name="topMargin" ng-model="reportRunJson.commonChartOptions.topMargin" style="width:200px;"> - </td> - <td> - <input type="text" name="bottomMargin" ng-model="reportRunJson.commonChartOptions.bottomMargin" style="width:200px;"> - </td> - <td> - <input type="text" name="leftMargin" ng-model="reportRunJson.commonChartOptions.leftMargin" style="width:200px;"> - </td> - <td> - <input type="text" name="rightMargin" ng-model="reportRunJson.commonChartOptions.rightMargin" style="width:200px;"> - </td> - </tr> - </tbody> + <tbody> + <tr> + <td><label for="optionsLineChartRendererLine" class="radio"> + <input type="radio" + ng-model="reportRunJson.timeSeriesChartOptions.lineChartRenderer" + id="optionsLineChartRendererLine" + name="optionsLineChartRendererLine" value="line"> <i + class="skin"></i> <span>Line</span> + </label> <label for="optionsLineChartRendererArea" class="radio"> + <input type="radio" + ng-model="reportRunJson.timeSeriesChartOptions.lineChartRenderer" + id="optionsLineChartRendererArea" + name="optionsLineChartRendererArea" value="area"> <i + class="skin"></i> <span>Area</span> + </label></td> + <td><label for="xAxisLabelCheckBox" class="checkbox"> + <input id="xAxisLabelCheckBox" type="checkbox" + ng-model="reportRunJson.timeSeriesChartOptions.showXAxisLabel" /><i + class="skin"></i><span></span> + </label></td> + <td><label for="addXAxisTickerCheckBox" class="checkbox"> + <input id="addXAxisTickerCheckBox" type="checkbox" + ng-model="reportRunJson.timeSeriesChartOptions.addXAxisTicker" /><i + class="skin"></i><span></span> + </label></td> + <td><label for="isTimeAxisCheckBox" class="checkbox"> + <input id="isTimeAxisCheckBox" type="checkbox" + ng-model="reportRunJson.timeSeriesChartOptions.nonTimeAxis" /><i + class="skin"></i><span></span> + </label></td> + <td><label for="multiSeriesCheckBox" class="checkbox"> + <input id="multiSeriesCheckBox" type="checkbox" + ng-model="reportRunJson.timeSeriesChartOptions.multiSeries" /><i + class="skin"></i><span></span> + </label></td> + </tr> + </tbody> </table> - </div> - </div> - </div> - </b2b-expander-body> - </b2b-expanders> + </div> + </div> + </b2b-expander-body> </b2b-expanders> + <!-- TIME SERIES CHART OPTION SECTION ENDS HERE --> -</div> -</div> + <b2b-expanders class="mpc-expanders" is-open="commonOptionOpen"> + <b2b-expander-heading> + <div class="row"> + <div class="span6"> + <div class="heading-medium b2b-blue" + ng-class=" { 'b2b-toggle-header-active': !commonOptionOpen, 'b2b-toggle-header-inactive': commonOptionOpen } ">Common + Options</div> + <p class="p-small"></p> + </div> + <div style="position: absolute; right: 250px;" class="span1"> + <i class="pull-right b2b-toggle-header-icon" b2b-expander-toggle + b2b-accessibility-click="13,32" + expand-icon="icon-primary-collapsed" + collapse-icon="icon-primary-expanded" tabindex="0" + aria-posinset="1" aria-setsize="2"></i> + </div> + </div> + </b2b-expander-heading> <b2b-expander-body> + <div> + <div> + <div + style="border: 2px; border-style: solid; border-color: #808080; margin-bottom: 9px"> + <div style="margin-left: 0px"> + <table> + <thead> + <tr> + <th>Legend Angle</th> + <th>Legend Position</th> + </tr> + </thead> + <tbody> + <tr> + <fieldset role="radiogroup" radio-group-accessibility> + <td><label for="optionsRadios1" class="radio"> <input + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + id="optionsRadios1" name="optionsRadio1" value="up45"> + <i class="skin"></i> <span>up 45°</span> + </label> <label for="optionsRadios2" class="radio"> <input + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + id="optionsRadios2" name="optionsRadio2" value="up90"> + <i class="skin"></i> <span>up 90°</span> + </label> <label for="optionsRadios3" class="radio"> <input + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + id="optionsRadios3" name="optionsRadio3" value="down45"> + <i class="skin"></i> <span>down 45°</span> + </label> <label for="optionsRadios4444" class="radio"> <input + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + id="optionsRadios4444" name="optionsRadio44" value="down90"> + <i class="skin"></i> <span>down 90°</span> + </label> <label for="optionsRadios5555" class="radio"> <input + type="radio" + ng-model="reportRunJson.commonChartOptions.legendLabelAngle" + id="optionsRadios5555" name="optionsRadio55" + value="standard"> <i class="skin"></i> <span>Standard</span> + </label></td> + </fieldset> + + <fieldset role="radiogroup" radio-group-accessibility> + <td><label for="optionsRadiosTop" class="radio"> + <input type="radio" + ng-model="reportRunJson.commonChartOptions.legendPosition" + id="optionsRadiosTop" name="optionsRadioTop" value="top"> + <i class="skin"></i> <span>Top</span> + </label> <label for="optionsRadiosBottom" class="radio"> <input + type="radio" + ng-model="reportRunJson.commonChartOptions.legendPosition" + id="optionsRadiosBottom" name="optionsRadioBottom" + value="bottom"> <i class="skin"></i> <span>Bottom</span> + </label></td> + </fieldset> + </tr> + </tbody> + </table> + + + <table> + <thead> + <tr> + <th width="20%">Legend</th> + <th width="20%">Animation</th> + <th></th> + </tr> + </thead> + <tbody> + <tr> + <fieldset role="radiogroup" radio-group-accessibility> + <td><label for="optionsRadiosHideLegendFalse" + class="radio"> <input type="radio" + ng-model="reportRunJson.commonChartOptions.hideLegend" + id="optionsRadiosHideLegendFalse" + name="optionsRadiosHideLegendFalse" value="false"> + <i class="skin"></i> <span>Yes</span> + </label> <label for="optionsRadiosHideLegendTrue" class="radio"> + <input type="radio" + ng-model="reportRunJson.commonChartOptions.hideLegend" + id="optionsRadiosHideLegendTrue" + name="optionsRadiosHideLegendTrue" value="true"> <i + class="skin"></i> <span>No</span> + </label></td> + </fieldset> + + <fieldset role="radiogroup" radio-group-accessibility> + <td><label for="optionsRadiosAnimateChartTrue" + class="radio"> <input type="radio" + ng-model="reportRunJson.commonChartOptions.animateAnimatedChart" + id="optionsRadiosAnimateChartTrue" + name="optionsRadiosAnimateChartTrue" value="true"> + <i class="skin"></i> <span>Yes</span> + </label> <label for="optionsRadiosAnimateChartFalse" class="radio"> + <input type="radio" + ng-model="reportRunJson.commonChartOptions.animateAnimatedChart" + id="optionsRadiosAnimateChartFalse" + name="optionsRadiosAnimateChartFalse" value="false"> + <i class="skin"></i> <span>No</span> + </label></td> + </fieldset> + <td></td> + </tr> + </tbody> + </table> + + <table> + <thead> + <tr> + <th width="25%">Top Margin</th> + <th width="25%">Bottom Margin</th> + <th width="25%">Left Margin</th> + <th width="25%">Right Margin</th> + </tr> + </thead> + <tbody> + <tr> + <td><input type="text" name="topMargin" + ng-model="reportRunJson.commonChartOptions.topMargin" + style="width: 200px;"></td> + <td><input type="text" name="bottomMargin" + ng-model="reportRunJson.commonChartOptions.bottomMargin" + style="width: 200px;"></td> + <td><input type="text" name="leftMargin" + ng-model="reportRunJson.commonChartOptions.leftMargin" + style="width: 200px;"></td> + <td><input type="text" name="rightMargin" + ng-model="reportRunJson.commonChartOptions.rightMargin" + style="width: 200px;"></td> + </tr> + </tbody> + </table> + </div> + </div> + </div> + </b2b-expander-body> </b2b-expanders> + + </div> + </div> <div> - <button type="submit" style="width: 90px; height:35px;margin-top:20px; margin-left:5px;" class="btn btn-alt btn-small" ng-click="saveChartData();">Save</button> - <a href="report#/report_run/c_master={{reportRunJson.reportID}}&refresh=Y"> - <button type="submit" style="width: 90px; height:35px;margin-top:20px; margin-left:5px;" class="btn btn-alt btn-small">Run</button> - </a> - </div> + <button type="submit" + style="width: 90px; height: 35px; margin-top: 20px; margin-left: 5px;" + class="btn btn-alt btn-small" ng-click="saveChartData();">Save</button> + <a + href="report#/report_run/c_master={{reportRunJson.reportID}}&refresh=Y"> + <button type="submit" + style="width: 90px; height: 35px; margin-top: 20px; margin-left: 5px;" + class="btn btn-alt btn-small">Run</button> + </a> + </div> </div> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-run.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-run.html index aaa1cac0..7b2c23e1 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-run.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-run.html @@ -1,96 +1,124 @@ <style> table tbody td { - border: none; + border: none; } table tbody tr { - border: none; + border: none; } -table tbody{ - border: none; +table tbody { + border: none; } table { - border: none; + border: none; } .grid { - width: 100%; - height: 400; + width: 100%; + height: 400; } + .no-rows { - position: absolute; - top: 0; - bottom: 0; - width: 100%; - background: rgba(0, 0, 0, 0.4); + position: absolute; + top: 0; + bottom: 0; + width: 100%; + background: rgba(0, 0, 0, 0.4); } .no-rows .msg { - opacity: 1; - position: absolute; - top: 20%; - left: 20%; - width: 60%; - height: 50%; - line-height: 200%; - background-color: #eee; - border-radius: 4px; - border: 1px solid #555; - text-align: center; - font-size: 24px; - display: table; + opacity: 1; + position: absolute; + top: 20%; + left: 20%; + width: 60%; + height: 50%; + line-height: 200%; + background-color: #eee; + border-radius: 4px; + border: 1px solid #555; + text-align: center; + font-size: 24px; + display: table; } .no-rows .msg span { - display: table-cell; - vertical-align: middle; + display: table-cell; + vertical-align: middle; } + .grid .ui-grid-header-cell { - text-align:center; + text-align: center; } + body { - font-size:13px; + font-size: 13px; } </style> -<div id="page-content"> - <div style="width:100%; overflow:hidden;"> - <div style="float:left;"><h1 class="heading-page">{{reportData.reportHeading}}</h1></div> - <div style="float:left; margin-left: 10px; margin-right: 10px;"> - <a style="font-size:180%;" ng-href="report#/report_wizard/{{reportData.reportID}}" class="icon-misc-pen" ng-show="reportData.allowEdit"></a> +<div id="page-content"> + <div style="width: 100%; overflow: hidden;"> + <div style="float: left;"> + <h1 class="heading-page">{{reportData.reportHeading}}</h1> + </div> + <div style="float: left; margin-left: 10px; margin-right: 10px;"> + <a style="font-size: 180%;" + ng-href="report#/report_wizard/{{reportData.reportID}}" + class="icon-misc-pen" ng-show="reportData.allowEdit"></a> + </div> + <div style="float: left; margin-left: 5px; margin-right: 10px;"> + <a style="font-size: 180%;" + ng-href="report#/report_chart/{{reportData.reportID}}" + class="icon-misc-piechart" ng-show="reportData.allowEdit"></a> </div> - <div style="float:left; margin-left: 5px; margin-right: 10px;"> - <a style="font-size:180%;" ng-href="report#/report_chart/{{reportData.reportID}}" class="icon-misc-piechart" ng-show="reportData.allowEdit"></a> + + <div ng-show="reportData.allowEdit && showFormFields" + style="margin-top: 5px;"> + <label for="checkbox1" class="checkbox"> <input + id="checkbox1" type="checkbox" ng-model="showFormFieldId.value" /><i + class="skin"></i><span>show IDs</span> + </label> </div> + </div> + <div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> + </div> + <h3 class="heading3">{{reportData.reportSubTitle}}</h3> - <div ng-show ="reportData.allowEdit && showFormFields" style="margin-top:5px;"> - <label for="checkbox1" class="checkbox"> - <input id="checkbox1" type="checkbox" ng-model="showFormFieldId.value" /><i class="skin"></i><span>show IDs</span> - </label> - </div> + <div ng-show="isInProgress" style="font-size: 50px; color: #2ca02c">Loading...</div> + + <form ng-show="showFormFields" class="row section-row" + style="margin: 10px"> + <form-builder ng-form-fields="reportData.formFieldList" + ng-show-field-id="showFormFieldId.value" + ng-num-form-cols="reportData.numFormCols" + ng-model="formFieldSelectedValues" + ng-trigger-method="triggerOtherFormFields"></form-builder> + <br> + <br> + <button type="submit" + style="width: 90px; height: 35px; margin-top: 20px; margin-left: 5px;" + class="btn btn-alt btn-small" ng-click="runReport()">Run</button> + </form> + <button type="submit" ng-show="showBackButton" + style="width: 90px; height: 35px; margin-top: 20px; margin-left: 5px;" + class="btn btn-alt btn-small" ng-click="backToParentReport()">Back</button> + <iframe id="chartiframe" ng-show="showChart" width="100%" + height="550px" style="border: none" scrolling="no"></iframe> + <div id="errorDiv"></div> + <div ng-if="showGrid"> + <div id="grid1" ui-grid="gridOptions" ui-grid-pagination + ui-grid-pinning ui-grid-resize-columns class="grid" + style="height: {{gridHeight"> + <div class="no-rows" ng-show="!gridOptions.data.length"> + <div class="msg"> + <span>{{reportData.message}}</span> + </div> + </div> + </div> </div> - <h3 class="heading3">{{reportData.reportSubTitle}} </h3> - - <div ng-show="isInProgress" style="font-size:50px;color:#2ca02c">Loading...</div> - - <form ng-show="showFormFields" class="row section-row" style="margin: 10px"> - <form-builder ng-form-fields="reportData.formFieldList" ng-show-field-id="showFormFieldId.value" ng-num-form-cols="reportData.numFormCols" ng-model="formFieldSelectedValues" ng-trigger-method="triggerOtherFormFields"></form-builder> - <br><br> - <button type="submit" style="width: 90px; height:35px;margin-top:20px; margin-left:5px;" class="btn btn-alt btn-small" ng-click="runReport()">Run</button> - </form> - <button type="submit" ng-show="showBackButton" style="width: 90px; height:35px;margin-top:20px; margin-left:5px;" class="btn btn-alt btn-small" ng-click="backToParentReport()">Back</button> - <iframe id="chartiframe" ng-show="showChart" width="100%" height="550px" style="border: none" scrolling="no"></iframe> - <div id="errorDiv"></div> - <div ng-if="showGrid"> - <div id="grid1" ui-grid="gridOptions" ui-grid-pagination ui-grid-pinning ui-grid-resize-columns class="grid" style="height: {{gridHeight}}"> - <div class="no-rows" ng-show="!gridOptions.data.length"> - <div class="msg"> - <span>{{reportData.message}}</span> - </div> - </div> - </div> - </div> - <!-- <a type="submit" ng-show="showBackButton" style="margin: 10px" ng-href="report.htm#/report_run/{{parentReportUrlParams}}" att-button btn-type="primary" size="small" title='Back'>Back</a> --> -</div> + <!-- <a type="submit" ng-show="showBackButton" style="margin: 10px" ng-href="report.htm#/report_run/{{parentReportUrlParams}}" att-button btn-type="primary" size="small" title='Back'>Back</a> --> +</div> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html index 7524acca..2fd0e436 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html @@ -29,7 +29,7 @@ body { </div> <div class="form-field form-field__glued pull-left size-onefifth" style="float:left; width:160px;margin-right: 40px;"> - <input ng-model="reportId" type="text" placeholder="Search value?" style="margin-top:5px;width:160px;"> + <input ng-model="reportId" type="text" placeholder="Search value?" style="margin-top:5px;width:160px; margin-left: 10px;"> </div> <label class="pull-left" style="float:left;margin-top: 10px;margin-right: 5px;">Report Name:</label> @@ -41,12 +41,15 @@ body { </div> <div class="form-field form-field__glued pull-left size-onefifth" style="width:13% !important;"> - <input ng-model="reportName" type="text" placeholder="Search value?" style="margin-top:5px;width:160px;"> + <input ng-model="reportName" type="text" placeholder="Search value?" style="margin-top:5px;width:160px; margin-left: 10px;"> </div> <div> <button style="margin-left:50px;margin-top:4px;" type="submit" class="btn btn-alt btn-small" ng-click="runReport();">Submit</button> </div> +<div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> </div> <br> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-step.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-step.html new file mode 100644 index 00000000..9550ac33 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-step.html @@ -0,0 +1,35 @@ +<div id="page-content" > + <br> + <div> + <b2b-tabset tab-id-selected="activeTabsId"> + <b2b-tab ng-repeat="tab in stepTabs" tab-item="tab" id="{{tab.uniqueId}}" aria-controls="{{tab.tabPanelId}}" ng-disabled="tab.disabled"> + {{tab.title}} + </b2b-tab> + </b2b-tabset> + <div class="tab-content" > + <div id="definitionTab" role="tabpanel" class="tab-pane" ng-class="{'active': 'definition'===activeTabsId}"> + <div ng-include src="'app/fusion/scripts/DS2-view-models/ds2-reports/steps/step1.html'"></div> + </div> + <div id="sqlTab" role="tabpanel" class="tab-pane" ng-class="{'active': 'sql'===activeTabsId}"> + <div ng-include src="'app/fusion/scripts/DS2-view-models/ds2-reports/steps/step2.html'"></div> + </div> + <div id="columnsTab" role="tabpanel" class="tab-pane" ng-class="{'active': 'columns'===activeTabsId}"> + <div ng-include src="'app/fusion/scripts/DS2-view-models/ds2-reports/steps/step3.html'"></div> + </div> + <div id="columnsTab" role="tabpanel" class="tab-pane" ng-class="{'active': 'formFields'===activeTabsId}"> + <div ng-include src="'app/fusion/scripts/DS2-view-models/ds2-reports/steps/step4.html'"></div> + </div> + <div id="columnsTab" role="tabpanel" class="tab-pane" ng-class="{'active': 'security'===activeTabsId}"> + <div ng-include src="'app/fusion/scripts/DS2-view-models/ds2-reports/steps/step5.html'"></div> + </div> + <div id="columnsTab" role="tabpanel" class="tab-pane" ng-class="{'active': 'log'===activeTabsId}"> + <div ng-include src="'app/fusion/scripts/DS2-view-models/ds2-reports/steps/step6.html'"></div> + </div> + <div id="columnsTab" role="tabpanel" class="tab-pane" ng-class="{'active': 'run'===activeTabsId}"> + <div ng-include src="'app/fusion/scripts/DS2-view-models/ds2-reports/steps/step7.html'"></div> + </div> + </div> + </div> +</div> + +
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step1.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step1.html new file mode 100644 index 00000000..a9baadf8 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step1.html @@ -0,0 +1,213 @@ +<h1 class="heading-page">Step 1 - Report Definition</h1> + +<div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> +</div> + +<div class="span6" ng-hide="showLoader"> + + <div class="form-row" ng-if="isEdit"> + <label for="textinputID-2a">Report ID</label> + <div class="field-group"> + <input id="textinputID-2a" ddh-reset="" class="span12" type="text" data-ng-model="definitionData.reportId" ng-disabled="true"> + </div> + </div> + + <div class="form-row" > + <label for="textinputID-2a">Report Name</label> + <div class="field-group"> + <input id="reportName" ddh-reset="" class="span12" type="text" data-ng-model="definitionData.reportName"> + </div> + </div> + <br> + <div class="form-row" > + <label for="textinputID-2a">Report Description</label> + <div class="field-group"> + <textarea b2b-reset b2b-reset-textarea ng-model="definitionData.reportDescr" ng-disabled="disabled" ng-trim="false" placeholder="{{placeholderText}}" rows="{{textAreaRows}}" maxlength="{{textAreaMaxlength}}" class="span12" id="textareaID1Tooltip1" ng-focus='showTooltip1=true' ng-blur='showTooltip1=false' aria-describedby="textareaID1TooltipContent1"></textarea> + </div> + </div> + <div class="form-row" > + <label for="textinputID-2a">Report Type</label> + <div class="field-group"> + <input id="reportType" ddh-reset="" class="span12" type="text" data-ng-model="definitionData.reportType" ng-disabled="true"> + </div> + </div> + <div class="form-row" > + <label for="textinputID-2a">Data Source</label> + <div class="field-group"> + <input id="dataSrc" ddh-reset="" class="span12" type="text" data-ng-model="definitionData.dbInfo" ng-disabled="true"> + </div> + </div> + <div class="form-row" > + <label for="textinputID-2a">Form Help Text</label> + <div class="field-group"> + <textarea b2b-reset b2b-reset-textarea ng-model="definitionData.formHelpTxt" ng-disabled="disabled" ng-trim="false" placeholder="{{placeholderText}}" rows="{{textAreaRows}}" maxlength="{{textAreaMaxlength}}" class="span12" id="textareaID1Tooltip1" ng-focus='showTooltip1=true' ng-blur='showTooltip1=false' aria-describedby="textareaID1TooltipContent1"></textarea> + </div> + </div> + <div class="form-row" > + <label for="textinputID-2a">Report Definition</label> + <div class="field-group"> + <input id="reportType" ddh-reset="" class="span12" type="text" data-ng-model="definitionData.repDefType" ng-disabled="true"> + </div> + </div> + <div class="form-row" > + <label for="pageSizeDD">Page Size</label> + <select id="pageSizeDD" name="pageSizeDD" aria-describedby="pageSizeDropdown" b2b-dropdown placeholder-text="Select Page Size" ng-model="definitionData.pageSize"> + <option b2b-dropdown-list option-repeat="d in pageSizeOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </div> + <div class="form-row"> + <div class="listbox-container"> + <label id="pageSizeDD">Display Area</label> + <div class="listbox-list" tabindex="-1"> + <b2b-list-box current-index="currentIndex1" listbox-data="definitionData.displayArea"> + <div tabindex="-1" data-index="{{$index}}" b2b-accessibility-click="13,32" ng-repeat="displayArea in definitionData.displayArea" role="option" class="b2b-list-box-item" ng-class="{'b2b-list-box-item--selected' : displayArea.selected}" ng-bind-html="displayArea.name | unsafe"></div> + </b2b-list-box> + </div> + </div> + </div> + <div class="form-row"> + <label for="hideFormFieldsRun" class="checkbox"> + <input id="hideFormFieldsRun" type="checkbox" ng-model="definitionData.hideFormFieldsAfterRun" /><i class="skin"></i><span>Hide Form fields after run?</span> + </label> + </div> + <div class="form-row" > + <label for="maxRowDD">Max Rows in Excel/CSV Download</label> + <select id="maxRowDD" name="maxRowDD" aria-describedby="maxRowOptions" b2b-dropdown placeholder-text="Select Max Row" ng-model="definitionData.maxRowsInExcelCSVDownload"> + <option b2b-dropdown-list option-repeat="d in maxRowOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </div> + <div class="form-row" > + <label for="frozenColDD">Columns to be Frozen</label> + <select id="frozenColDD" name="frozenColDD" aria-describedby="Columns to be Frozen" b2b-dropdown placeholder-text="Select Columns to be Frozen" ng-model="definitionData.frozenColumns"> + <option b2b-dropdown-list option-repeat="d in frozenColOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </div> + <div class="form-row" > + <label for="dataGridAlignDD">Data Grid Align</label> + <select id="dataGridAlignDD" name="dataGridAlignDD" aria-describedby="Data Grid Align" b2b-dropdown placeholder-text="Select Data Grid Align" ng-model="definitionData.dataGridAlign"> + <option b2b-dropdown-list option-repeat="d in dataGridAlignOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </div> + <div class="form-row" > + <label for="textinputID-2a">Empty message</label> + <div class="field-group"> + <input id="emptyMessage" ddh-reset="" class="span12" type="text" data-ng-model="definitionData.emptyMessage"> + </div> + </div> + + <div class="form-row" > + <label for="highDataContainerDD">Height of the Data Container(%)</label> + <select id="highDataContainerDD" name="highDataContainerDD" aria-describedby="Height of the Data Container" b2b-dropdown placeholder-text="Select Height of the Data Container" ng-model="definitionData.dataContainerHeight"> + <option b2b-dropdown-list option-repeat="d in dataContainerOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </div> + <div class="form-row" > + <label for="widDataContainerDD">Width of the Data Container(%)</label> + <select id="widDataContainerDD" name="widDataContainerDD" aria-describedby="Width of the Data Container" b2b-dropdown placeholder-text="Select Width of the Data Container" ng-model="definitionData.dataContainerWidth"> + <option b2b-dropdown-list option-repeat="d in dataContainerOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </div> + <div class="form-row"> + <label for="aScheduler" class="checkbox"> + <input id="aScheduler" type="checkbox" ng-model="definitionData.allowScheduler" /><i class="skin"></i><span>Allow Scheduler</span> + </label> + </div> + <div class="form-row"> + <label for="sizeByContent" class="checkbox"> + <input id="sizeByContent" type="checkbox" ng-model="definitionData.sizedByContent" /><i class="skin"></i><span>Sized By Content</span> + </label> + </div> + <br> + <label id="pageSizeDD">Display Options:</label> + <br> + <div class="form-row"> + <label for="hideFormField" class="checkbox"> + <input id="hideFormField" type="checkbox" ng-model="displayOptions.hideFormFields" /><i class="skin"></i><span>Hide Form Fields</span> + </label> + </div> + <div class="form-row"> + <label for="hideCart" class="checkbox"> + <input id="hideCart" type="checkbox" checked ng-model="displayOptions.hideChart" /><i class="skin"></i><span>Hide Chart</span> + </label> + </div> + <div class="form-row"> + <label for="hideReportData" class="checkbox"> + <input id="hideReportData" type="checkbox" checked ng-model="displayOptions.hideReportData" /><i class="skin"></i><span>Hide Report Data</span> + </label> + </div> + + <div class="form-row"> + <label for="hideExcel" class="checkbox"> + <input id="hideExcel" type="checkbox" checked ng-model="displayOptions.hideExcel" /><i class="skin"></i><span>Hide Excel</span> + </label> + </div> + <div class="form-row"> + <label for="hidePDF" class="checkbox"> + <input id="hidePDF" type="checkbox" checked ng-model="displayOptions.hidePdf" /><i class="skin"></i><span>Hide PDF</span> + </label> + </div> + + <div class="form-row"> + <label for="sortColRun" class="checkbox"> + <input id="sortColRun" type="checkbox" checked ng-model="definitionData.runtimeColSortDisabled" /><i class="skin"></i><span>Disable column sort at runtime?</span> + </label> + </div> + <div class="form-row" > + <label for="runTimeFormNumDD">Run-time Form Number Columns</label> + <select id="runTimeFormNumDD" name="runTimeFormNumDD" aria-describedby="Run-time Form Number Columns" b2b-dropdown placeholder-text="Select Run-time Form Number Columns" ng-model="definitionData.numFormCols"> + <option b2b-dropdown-list option-repeat="d in runTimeFormNumOptions" value="{{d.value}}">{{d.text}}</option> + </select> + </div> + <div class="form-row" > + <label for="reportTitle">Report Title (if blank, the Report Name will be displayed)</label> + <div class="field-group"> + <textarea b2b-reset b2b-reset-textarea ng-model="definitionData.reportTitle" ng-disabled="disabled" ng-trim="false" placeholder="{{placeholderText}}" rows="{{textAreaRows}}" maxlength="{{textAreaMaxlength}}" class="span12" id="reportTitle" ng-focus='showTooltip1=true' ng-blur='showTooltip1=false' aria-describedby="textareaID1TooltipContent1"></textarea> + </div> + </div> + <div class="form-row" > + <label for="reportSubTitle">Report Sub-Title</label> + <div class="field-group"> + <textarea b2b-reset b2b-reset-textarea ng-model="definitionData.reportSubTitle" ng-disabled="disabled" ng-trim="false" placeholder="{{placeholderText}}" rows="{{textAreaRows}}" maxlength="{{textAreaMaxlength}}" class="span12" id="reportSubTitle" ng-focus='showTooltip1=true' ng-blur='showTooltip1=false' aria-describedby="textareaID1TooltipContent1"></textarea> + </div> + </div> + <div class="form-row"> + <label for="oneTime" class="checkbox"> + <input id="oneTime" type="checkbox" ng-model="definitionData.oneTimeRec" /><i class="skin"></i><span>One Time</span> + </label> + </div> + <div class="form-row"> + <label for="hourly" class="checkbox"> + <input id="hourly" type="checkbox" checked ng-model="definitionData.hourlyRec" /><i class="skin"></i><span>Hourly</span> + </label> + </div> + <div class="form-row"> + <label for="daily" class="checkbox"> + <input id="daily" type="checkbox" ng-model="definitionData.dailyRec" /><i class="skin"></i><span>Daily</span> + </label> + </div> + <div class="form-row"> + <label for="dailyMF" class="checkbox"> + <input id="dailyMF" type="checkbox" checked ng-model="definitionData.dailyMFRec" /><i class="skin"></i><span>Daily Monday - Friday</span> + </label> + </div> + <div class="form-row"> + <label for="weekly" class="checkbox"> + <input id="weekly" type="checkbox" ng-model="definitionData.weeklyRec" /><i class="skin"></i><span>Weekly</span> + </label> + </div> + <div class="form-row"> + <label for="monthly" class="checkbox"> + <input id="monthly" type="checkbox" checked ng-model="definitionData.monthlyRec" /><i class="skin"></i><span>Monthly</span> + </label> + </div> + <br> + + <div class="form-row"> +<!-- <button class="btn btn-alt btn-small" type="button" ng-click="createDefinition()" ng-if="!isEdit">Save</button> + --> <button class="btn btn-alt btn-small" type="button" ng-click="updateDef()" >Save</button> +<!-- <button class="btn btn-alt btn-small" type="button" ng-click="next()" ng-show="$scope.isEdit" >Next</button> + --> </div> + +</div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step2.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step2.html new file mode 100644 index 00000000..e21af0c8 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step2.html @@ -0,0 +1,26 @@ +<h1 class="heading-page">Step 2 - Report SQL</h1> + +<div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> +</div> +<h2 ng-show="pageisCreating">{{pageMsg}}</h2> +<div class="" ng-hide="showLoader"> + <div class="form-row" > + <label for="textinputID-2a">Report SQL</label> + <div class="field-group" align="center"> + <textarea b2b-reset b2b-reset-textarea ng-model="sqlScript.value" ng-trim="false" placeholder="{{placeholderText}}" rows="25" class="span12" id="textareaID1Tooltip1" ng-focus='showTooltip1=true' ng-blur='showTooltip1=false' aria-describedby="textareaID1TooltipContent1"></textarea> + </div> + </div> + <div class="form-row" align="right"> + <button class="btn btn-alt btn-small" type="button" ng-click="testRunSql()" >Validate & Test Run SQL</button> + </div> + <div class="form-row"> +<!-- <button class="btn btn-alt btn-small" type="button" ng-click="previous()" >Previous</button> + --> <button class="btn btn-alt btn-small" type="button" ng-click="updateDef()" >Save</button> +<!-- <button class="btn btn-alt btn-small" type="button" ng-click="next()" >Next</button> + --> </div> + +</div> + + diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step3.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step3.html new file mode 100644 index 00000000..e1f02a1c --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step3.html @@ -0,0 +1,34 @@ +<h1 class="heading-page">Step 3 - Report Columns</h1> +<div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> +</div> +<div class="" ng-hide="showLoader"> + <div class="form-row" > + <table class="striped"> + <thead> + <tr> + <th>No</th> + <th key="id" sortable="true">ID</th> + <th>Display Name</th> + <th>Edit</th> + </tr> + </thead> + <tbody> + <tr ng-repeat = "rowData in colTableRowData"> + <td>{{$index+1}}</td> + <td>{{rowData.id}}</td> + <td>{{rowData.name}}</td> + <td><a ng-click="openColumnPopup(rowData)" class="icon-misc-pen"></a></td> + </tr> + </tbody> + </table> + </div> +<!-- <div class="form-row"> + <button class="btn btn-alt btn-small" type="button" ng-click="previous()" >Previous</button> + <button class="btn btn-alt btn-small" type="button" ng-click="next()" >Next</button> + </div> --> + +</div> + + diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step4.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step4.html new file mode 100644 index 00000000..dc3be5c8 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step4.html @@ -0,0 +1,47 @@ +<h1 class="heading-page">Step 4 - Report Form Fields</h1> +<div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> +</div> +<div ng-hide="showLoader"> + <div class="form-row" > + <h2>Report Form Fields 4</h2> + <table class="striped"> + <thead> + <tr> + <th default-sort="a" sortable="true" >Order Number</th> + <th>Field Name</th> + <th>Edit</th> + <th>Order</th> + <th>Delete</th> + </tr> + </thead> + <tbody> + <tr ng-repeat = "rowData in formFieldData"> + <td>{{rowData.orderSeq}}</td> + <td>{{rowData.name}}[{{rowData.id}}]</td> + <td><a ng-click="openFormFieldPopup(rowData,'edit')" class="icon-misc-pen"></a></td> + <td> + <span ng-if="!$first"> + <a ng-click="formFieldReOrder(rowData.id, formFieldData[$index-1].id)" class="icon-controls-upPRIMARY"></a> + </span> + <span ng-if="!$last"> + <a ng-click="formFieldReOrder(formFieldData[$index+1].id, rowData.id)" class="icon-controls-down"></a> + </span> + </td> + <td><a ng-click="deleteFormField(rowData)" class="icon-misc-trash"></a></td> + </tr> + </tbody> + </table> + </div> + <div align="right"> + <button class="btn btn-alt btn-small" type="button" ng-click="addFormField()">Add</button> + </div> +<!-- <div class="form-row"> + <button class="btn btn-alt btn-small" type="button" ng-click="previous()" >Previous</button> + <button class="btn btn-alt btn-small" type="button" ng-click="next()" >Next</button> + </div> --> + +</div> + + diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step5.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step5.html new file mode 100644 index 00000000..13278029 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step5.html @@ -0,0 +1,172 @@ +<style> +#stepView table tbody td { + border: none; +} + +#stepView table tbody tr { + border: none; +} + +.noTableBorder table tbody td { + border: none; +} + +.noTableBorder table tbody tr { + border: none; +} +</style> +<h1 class="heading-page">Step 5 - Report Security</h1> + +<div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> +</div> +<div class="" ng-hide="showLoader"> + <div class="form-row"> + <div id="stepViewSecurity"> + <div class="noTableBorder"> + <table class="striped"> + <tbody> + <tr> + <td>Created By: {{reportSecurityInfo.createdUser}}</td> + <td>Created Date: {{reportSecurityInfo.createdDate}}</td> + <tr /> + <tr> + <td>Last Updated By: {{reportSecurityInfo.updateUser}}</td> + <td>Last Updated: {{reportSecurityInfo.updatedDate}}</td> + <tr /> + <tr> + <td>Report Owner: <select name="reportOwner" b2b-dropdown + ng-model="reportSecurityInfo.ownerId"> + <option b2b-dropdown-list option-repeat="d in reportOwnerList" + value="{{d.id}}">{{d.name}}</option> + </select> + + </td> + <td>Public? (All users can run the report): <select + name="isPublic" b2b-dropdown + ng-model="reportSecurityInfo.isPublic"> + <option b2b-dropdown-list option-repeat="d in ynOptions" + value="{{d.value}}">{{d.text}}</option> + </select> + </td> + <tr /> + </tbody> + </table> + </div> + + <div style="margin-top: 20px;"> + <h1 style="margin-bottom: 5px;">Report Users</h1> + <table class="striped"> + <thead> + <tr> + <th width="10%">No</th> + <th width="45%">User Name</th> + <th width="15%">Run Access</th> + <th width="15%">Edit Access</th> + <th width="15%">Remove</th> + <tr /> + </thead> + <tbody> + <tr ng-repeat="reportUser in reportSecurityUsers"> + <td>{{$index+1}}</td> + <td>{{reportUser.name}}</td> + <td> + <label for="switch{{$index+1}}runAccess" + class="btn-switch-label"> <input type="checkbox" + role="switch" id="switch{{$index+1}}runAccess" b2b-switches + ng-model="reportUser.runAccess" ng-disabled=true aria-disabled=true aria-label=""> + </label> + </td> + <td><label for="switch{{$index+1}}" class="btn-switch-label"> + <input type="checkbox" role="switch" id="switch{{$index+1}}" + b2b-switches ng-model="reportUser.accessAllowed" + ng-click="toggleUserEditAccessActive(reportUser)" + ng-disabled=false aria-disabled=false aria-label=""> + </label></td> + <td><a class="icon-misc-trash" style="font-size: 22px;" + ng-click="removeReportSecurityUser(reportUser)"> </a></td> + </tr> + </tbody> + </table> + </div> + <div> + <h2>Grant Access To:</h2> + <div> + <select id="reportUser" name="reportUser" b2b-dropdown + ng-model="addReportUserId.id" placeholder-text="Select a User"> + <option b2b-dropdown-list option-repeat="d in reportOwnerList" + value="{{d.id}}">{{d.name}}</option> + </select> + </div> + <div> + <button class="btn btn-alt btn-small" type="button" + ng-click="addReportSecurityUser(addReportUserId.id)">Add</button> + </div> + </div> + + <div style="margin-top: 20px;"> + <h1>Report Roles</h1> + <table class="striped"> + <thead> + <tr> + <th width="10%">No</th> + <th width="45%">Role Name</th> + <th width="15%">Run Access</th> + <th width="15%">Edit Access</th> + <th width="15%">Remove</th> + <tr /> + </thead> + <tbody> + <tr ng-repeat="reportRole in reportSecurityRoles"> + <td>{{$index+1}}</td> + <td>{{reportRole.name}}</td> + <td> + <label for="switch{{$index+1}}RoleRunAccess" + class="btn-switch-label"> <input type="checkbox" + role="switch" id="switch{{$index+1}}RoleRunAccess" b2b-switches + ng-model="reportRole.runAccess" ng-disabled=true aria-disabled=true aria-label=""> + </label> + </td> + <td><label for="switch{{$index+1}}RoleEditAccess" + class="btn-switch-label"> <input type="checkbox" + role="switch" id="switch{{$index+1}}RoleEditAccess" + b2b-switches ng-model="reportRole.accessAllowed" + ng-click="toggleRoleEditAccessActive(reportRole)" + ng-disabled=false aria-disabled=false aria-label=""> + </label></td> + <td><a class="icon-misc-trash" + ng-click="removeReportSecurityRole(reportRole)" + style="font-size: 22px;"> </a></td> + </tr> + </tbody> + </table> + <div> + <h2 colspan="2">Grant Access To:</h2> + <div colspan="2"> + <select name="reportOwner" b2b-dropdown + ng-model="addReportRoleId.id" placeholder-text="Select a Role"> + <option b2b-dropdown-list option-repeat="d in reportRoleList" + value="{{d.id}}">{{d.name}}</option> + </select> + </div> + <div> + <button class="btn btn-alt btn-small" type="button" + ng-click="addReportSecurityRole(addReportRoleId.id)">Add</button> + </div> + </div> + </div> + + </div> + </div> + <div class="form-row"> +<!-- <button class="btn btn-alt btn-small" type="button" + ng-click="previous()">Previous</button> --> + <button class="btn btn-alt btn-small" type="button" + ng-click="saveReportSecurityInfo()">Save</button> +<!-- <button class="btn btn-alt btn-small" type="button" ng-click="next()">Next</button> + --> </div> + +</div> + + diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step6.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step6.html new file mode 100644 index 00000000..4849190a --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step6.html @@ -0,0 +1,34 @@ +<h1 class="heading-page">Step 6 - Report Log</h1> + +<div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> +</div> +<div ng-hide="showLoader"> + <div class="form-row" > + <h2 for="textinputID-2a">Report Logs</h2> + <table class="striped" ng-cloak> + <thead> + <tr> + <th>No</th> + <th>User Name</th> + <th>Log Time</th> + <th>Action</th> + </tr> + </thead> + <tbody> + <tr ng-repeat = "rowData in logs"> + <td>{{$index+1}}</td> + <td>{{rowData.userName}}</td> + <td>{{rowData.logTime}}</td> + <td>{{rowData.action}}</td> + </tr> + </tbody> + </table> + </div> +<!-- <div class="form-row"> + <button class="btn btn-alt btn-small" type="button" ng-click="previous()" >Previous</button> + <button class="btn btn-alt btn-small" type="button" ng-click="next()" >Next</button> + </div> --> + +</div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step7.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step7.html new file mode 100644 index 00000000..298cce8f --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step7.html @@ -0,0 +1,16 @@ +<h1 class="heading-page">Step 7 - Report Run</h1> + +<div ng-show="showLoader" class="span loader-container"> + <i class="icon-primary-spinner" role="img" + aria-label="Please wait while we load your content"></i> +</div> +<div class="" ng-hide="showLoader"> + <div class="form-row" > + <button class="btn btn-alt btn-small" type="button" ng-click="runReport()" >Run Report</button> + </div> +<!-- <div class="form-row"> + <button class="btn btn-alt btn-small" type="button" ng-click="previous()" >Previous</button> + </div> --> +</div> + + diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step1.json b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step1.json index 66562d4b..abdbd023 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step1.json +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step1.json @@ -11,7 +11,13 @@ "name": "proj_id", "displayName": "Project Id", "defaultValue": "" - }, + }, + { + "input": "text", + "name": "reportId", + "displayName": "Report ID:", + "defaultValue": "" + }, { "input": "text", "name": "reportName", @@ -75,9 +81,17 @@ "defaultValue": "no", "action": "", "action_img": "", - "checkboxes":[{"value":"homeSelected.value", "text":"HOME"}, - {"value":"customerSelected.value", "text":"CUSTOMER"}, - {"value":"reportsSelected.value", "text":"REPORTS"} + "checkboxes":[ + {"value":"homeSelected", "text":"HOME"}, + {"value":"customerSelected", "text":"CUSTOMER"}, + {"value":"reportsSelected", "text":"REPORTS"}, + {"value":"utilSelected", "text":"Utilization"}, + {"value":"tmSelected", "text":"Tunnel Management"}, + {"value":"trSelected", "text":"Tunnel Routing"}, + {"value":"cmSelected", "text":"Capacity Management"}, + {"value":"tlSelected", "text":"Traffic Loss"}, + {"value":"smSelected", "text":"System Monitoring"}, + {"value":"netOperateSelected", "text":"Network Operation Monitoring"} ] }, diff --git a/ecomp-sdk/epsdk-core/pom.xml b/ecomp-sdk/epsdk-core/pom.xml index d15b18ff..0e78c057 100644 --- a/ecomp-sdk/epsdk-core/pom.xml +++ b/ecomp-sdk/epsdk-core/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> @@ -451,7 +451,7 @@ <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> - <version>3.17</version> + <version>3.5-FINAL</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> @@ -466,7 +466,7 @@ <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> - <version>3.17</version> + <version>3.5-FINAL</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> @@ -481,7 +481,7 @@ <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> - <version>3.17</version> + <version>3.5-FINAL</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/JsonMessageTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/JsonMessageTest.java index 0e732a91..fbc95cd5 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/JsonMessageTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/JsonMessageTest.java @@ -38,6 +38,7 @@ package org.onap.portalsdk.core.web.support; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.junit.Test; @@ -66,4 +67,19 @@ public class JsonMessageTest { assertEquals(jsonMessage.getData2(), jsonMessage1.getData2()); assertEquals(jsonMessage.getData3(), jsonMessage1.getData3()); } + + @SuppressWarnings("static-access") + @Test + public void buildJsonResponseTest(){ + JsonMessage jsonMsg = mockJsonMessage(); + assertNotNull(jsonMsg.buildJsonResponse(true, "test")); + } + + @SuppressWarnings("static-access") + @Test + public void buildJsonResponseExceptionTest(){ + JsonMessage jsonMsg = mockJsonMessage(); + assertNotNull(jsonMsg.buildJsonResponse(new Exception("test exception"))); + } + } diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/MessagesListTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/MessagesListTest.java index 4d13eda1..a7951210 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/MessagesListTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/MessagesListTest.java @@ -39,6 +39,8 @@ package org.onap.portalsdk.core.web.support; import static org.junit.Assert.*; +import java.util.ArrayList; + import org.junit.Test; public class MessagesListTest { @@ -63,11 +65,14 @@ public class MessagesListTest { messagesList.setIncludeCauseInCustomExceptions(false); messagesList.setSuccessMessageDisplayed(false); messagesList.setSuccessMessages(null); - assertEquals(messagesList.getExceptionMessages(), messagesList1.getExceptionMessages()); assertEquals(messagesList.getSuccessMessages(), messagesList1.getSuccessMessages()); assertEquals(messagesList.isIncludeCauseInCustomExceptions(), messagesList1.isIncludeCauseInCustomExceptions()); assertEquals(messagesList.isSuccessMessageDisplayed(), messagesList1.isSuccessMessageDisplayed()); - + messagesList = new MessagesList(); + messagesList.addSuccessMessage(new FeedbackMessage()); + messagesList.addExceptionMessage(new FeedbackMessage()); + assertTrue(messagesList.hasExceptionMessages()); + assertTrue(messagesList.hasSuccessMessages()); } } diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/UserUtilsTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/UserUtilsTest.java new file mode 100644 index 00000000..fe63b70a --- /dev/null +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/web/support/UserUtilsTest.java @@ -0,0 +1,164 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.core.web.support; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.portalsdk.core.domain.MenuData; +import org.onap.portalsdk.core.domain.Role; +import org.onap.portalsdk.core.domain.RoleFunction; +import org.onap.portalsdk.core.domain.User; +import org.onap.portalsdk.core.util.SystemProperties; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({AppUtils.class, SystemProperties.class}) +public class UserUtilsTest { + @Mock + HttpServletRequest request; + @Mock + HttpSession session; + @Mock + User user; + @Mock + ServletContext servletContext; + + SortedSet<Role> roles; + + @Before + public void setUp() { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(SystemProperties.class); + Mockito.when(AppUtils.getSession(request)).thenReturn(session); + Mockito.when(request.getSession(true)).thenReturn(session); + Mockito.when(request.getSession()).thenReturn(session); + Mockito.when(session.getServletContext()).thenReturn(servletContext); + Mockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("user"); + Mockito.when(SystemProperties.getProperty(SystemProperties.APPLICATION_USER_ID)).thenReturn("1"); + Mockito.when(session.getAttribute("user")).thenReturn(user); + SortedSet<Role> roles = new TreeSet<>(); + Role role = new Role(); + role.setActive(true); + role.setId(1L); + Set<RoleFunction> roleFunctionSet = new HashSet<>(); + RoleFunction rf = new RoleFunction(); + rf.setName("test"); + rf.setCode("test"); + rf.setType("test"); + rf.setAction("test"); + roleFunctionSet.add(rf); + role.setRoleFunctions(roleFunctionSet); + Role childRole = new Role(); + childRole.setActive(true); + childRole.setId(1L); + HashSet childRoles = new HashSet<>(); + childRoles.add(childRole); + role.setChildRoles(childRoles); + roles.add(role); + Mockito.when(user.getRoles()).thenReturn(roles); + } + + @Test + public void testSetUserSession() { + Set set = new HashSet<>(); + MenuData menuData = new MenuData(); + menuData.setFunctionCd("test"); + set.add(menuData); + List<RoleFunction> roleFunctionList = new ArrayList<>(); + roleFunctionList.add(new RoleFunction()); + UserUtils.setUserSession(request, user, set, set, "test", roleFunctionList); + } + + @Test + public void testHasRole() { + UserUtils.hasRole(request, "1"); + } + + @Test + public void testHasRoleByUser() { + UserUtils.hasRole(user, "1"); + } + + @Test + public void testGetLoginMethod() { + UserUtils.getLoginMethod(request); + } + + @Test + public void testGetUserId() { + UserUtils.getUserId(request); + } + + @Test + public void testGetStackTrace() { + UserUtils.getStackTrace(new Exception("test exception")); + } + + @Test + public void testConvertToEcompUser() { + UserUtils.convertToEcompUser(user); + } + + @Test + public void testGetRequestId() { + Enumeration<String> headerNames = Mockito.mock(Enumeration.class); + Mockito.when(headerNames.hasMoreElements()).thenReturn(true); + Mockito.when(headerNames.nextElement()).thenReturn("X-ECOMP-RequestID"); + Mockito.when(request.getHeader("X-ECOMP-RequestID")).thenReturn("test"); + Mockito.when(request.getHeaderNames()).thenReturn(headerNames); + UserUtils.getRequestId(request); + } +} diff --git a/ecomp-sdk/epsdk-domain/pom.xml b/ecomp-sdk/epsdk-domain/pom.xml index 34a55ac4..06ef3b13 100644 --- a/ecomp-sdk/epsdk-domain/pom.xml +++ b/ecomp-sdk/epsdk-domain/pom.xml @@ -5,12 +5,12 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-domain</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> <packaging>jar</packaging> <name>ONAP Portal SDK Domain</name> diff --git a/ecomp-sdk/epsdk-fw/pom.xml b/ecomp-sdk/epsdk-fw/pom.xml index 91487ad8..e1da0300 100644 --- a/ecomp-sdk/epsdk-fw/pom.xml +++ b/ecomp-sdk/epsdk-fw/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-music/pom.xml b/ecomp-sdk/epsdk-music/pom.xml index 45ebddc3..e6296c1b 100644 --- a/ecomp-sdk/epsdk-music/pom.xml +++ b/ecomp-sdk/epsdk-music/pom.xml @@ -5,12 +5,12 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-music</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> <packaging>jar</packaging> <name>ONAP Portal SDK Music</name> @@ -28,7 +28,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> + <version>4.12</version> <scope>test</scope> </dependency> <dependency> @@ -164,6 +164,13 @@ <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency> + <!-- Jacoco for offline instrumentation --> + <dependency> + <groupId>org.jacoco</groupId> + <artifactId>org.jacoco.agent</artifactId> + <version>${jacoco.version}</version> + <classifier>runtime</classifier> + </dependency> </dependencies> <profiles> <!-- disable doclint, a new feature in Java 8, when generating javadoc --> diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/EnableMuscicHttpSession.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/EnableMuscicHttpSession.java index 586d04ad..f44cf3f3 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/EnableMuscicHttpSession.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/EnableMuscicHttpSession.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - *. + * */ package org.onap.portalapp.music.conf; diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepository.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepository.java index 4bebfc2b..f2f8fee5 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepository.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepository.java @@ -38,8 +38,8 @@ package org.onap.portalapp.music.conf; import java.time.Duration; -import java.util.Map; +import org.springframework.session.MapSession; import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.session.events.SessionDeletedEvent; diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestResponse.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestResponse.java index 5a3a7416..0326e8e0 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestResponse.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestResponse.java @@ -91,6 +91,7 @@ public class RestResponse<T> { return result; } + @SuppressWarnings("rawtypes") @Override public boolean equals(Object obj) { if (this == obj) diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java index 5aae01d0..9aae9770 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java @@ -44,7 +44,6 @@ import java.io.InputStream; import java.util.Properties; import org.onap.music.eelf.logging.EELFLoggerDelegate; -import org.onap.portalapp.music.service.MusicService; public class MusicProperties { diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java index a62c929c..15c3bb0c 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java @@ -73,6 +73,7 @@ public class MusicUtil { return sessionAttrNameSet.contains(key); } + @SuppressWarnings("unchecked") public static <T> T musicRestResponseDataParsing(ResultSet rs, String attributeName) throws Exception{ logger.debug(EELFLoggerDelegate.debugLogger, "musicRestResponseDataParsing: start"); Row row = rs.one(); @@ -85,6 +86,7 @@ public class MusicUtil { return null; } + @SuppressWarnings("unchecked") public static <T> T musicDeserialize (ByteBuffer byteBuf) throws Exception{ logger.debug(EELFLoggerDelegate.debugLogger, "musicDeserialize: start"); ByteArrayInputStream byteArr = new ByteArrayInputStream(byteBuf.array()); diff --git a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandlerTest.java b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandlerTest.java new file mode 100644 index 00000000..b5a28af8 --- /dev/null +++ b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandlerTest.java @@ -0,0 +1,103 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalapp.music.conf; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.music.datastore.PreparedQueryObject; +import org.onap.music.main.MusicCore; +import org.onap.portalapp.music.service.MusicService; +import org.onap.portalapp.music.util.MusicUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.session.Session; + +import com.datastax.driver.core.ResultSet; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({MusicUtil.class, MusicCore.class}) +public class MusicSessionRepositoryHandlerTest { + + @Mock + private MusicService musicService; + + @Mock + ResultSet resultSet; + + @Before + public void setUp() { + PowerMockito.mockStatic(MusicUtil.class); + PowerMockito.mockStatic(MusicCore.class); + Mockito.when(MusicUtil.isCached()).thenReturn(true); + MockitoAnnotations.initMocks(this); + } + + @InjectMocks + MusicSessionRepositoryHandler musicSessionRepositoryHandler = new MusicSessionRepositoryHandler(); + + MusicSession ms = new MusicSession(); + + + @SuppressWarnings("static-access") + @Test + public void getTest() throws Exception { + Mockito.when(MusicCore.get(Matchers.any(PreparedQueryObject.class))).thenReturn(resultSet); + Mockito.when(musicService.getMetaAttribute("test_id")).thenReturn(ms); + Session session = musicSessionRepositoryHandler.get("test_id"); + assertNotNull(session); + } + + @SuppressWarnings("static-access") + @Test + public void getFailWithIdTest() throws Exception { + Mockito.when(MusicCore.get(Matchers.any(PreparedQueryObject.class))).thenReturn(resultSet); + Mockito.when((musicService).getMetaAttribute("test_id")).thenThrow(new NullPointerException()); + Session session = musicSessionRepositoryHandler.get("test_id"); + assertNull(session); + } +} diff --git a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryTest.java b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryTest.java new file mode 100644 index 00000000..1f6af366 --- /dev/null +++ b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryTest.java @@ -0,0 +1,95 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalapp.music.conf; + +import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.mock; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.portalapp.music.service.MusicService; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.session.Session; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({MusicSession.class, MusicService.class, Session.class}) +public class MusicSessionRepositoryTest { + + + @Mock + MusicSessionRepositoryHandler handler; + + @Mock + Session session; + + @InjectMocks + MusicSessionRepository musicSessionRepository; + + MusicSession musSession = mock(MusicSession.class); + + @Before + public void setUp() throws Exception { + PowerMockito.mockStatic(MusicService.class); + PowerMockito.mockStatic(MusicSession.class); + PowerMockito.mockStatic(Session.class); + MockitoAnnotations.initMocks(this); + } + + @Test + public void setDefaultMaxInactiveIntervalTest() throws Exception { + PowerMockito.whenNew(MusicSessionRepositoryHandler.class).withNoArguments().thenReturn(handler); + musicSessionRepository.setDefaultMaxInactiveInterval(10); + } + + @Test + public void findByIdTest() { + assertNull(musicSessionRepository.findById("1")); + } + + @Test + public void deleteByIdTest() { + musicSessionRepository.deleteById("1"); + } + +} diff --git a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionTest.java b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionTest.java new file mode 100644 index 00000000..65290d48 --- /dev/null +++ b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionTest.java @@ -0,0 +1,262 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalapp.music.conf; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.time.Duration; +import java.time.Instant; +import java.util.Set; +import java.util.TreeSet; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.music.exceptions.MusicLockingException; +import org.onap.music.exceptions.MusicServiceException; +import org.onap.music.main.ReturnType; +import org.onap.portalapp.music.service.MusicService; +import org.onap.portalapp.music.util.MusicProperties; +import org.onap.portalapp.music.util.MusicUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.session.Session; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ MusicUtil.class, MusicProperties.class, MusicService.class }) +public class MusicSessionTest { + + @InjectMocks + MusicSession musicSession = new MusicSession(); + + @Mock + Session session; + + Duration duration = Duration.ofSeconds(100); + + @Before + public void setUp() { + PowerMockito.mockStatic(MusicUtil.class); + PowerMockito.mockStatic(MusicProperties.class); + PowerMockito.mockStatic(MusicService.class); + Mockito.when(MusicUtil.isCached()).thenReturn(true); + MockitoAnnotations.initMocks(this); + } + + @Mock + ReturnType rt; + + @Test + public void setLastAccessedTimeTest() { + Instant instant = Instant.now(); + musicSession.setLastAccessedTime(instant); + } + + @Test + public void setLastAccessedTimeNullPointerExceptionTest() throws Exception { + Instant instant = Instant.now(); + Mockito.when(MusicService.setAttribute(Matchers.anyString(), Matchers.any(Instant.class), Matchers.anyString())) + .thenThrow(new NullPointerException()); + musicSession.setLastAccessedTime(instant); + } + + @Test + public void musicSession() { + Set<String> values = new TreeSet<>(); + values.add("testAttName"); + values.add("testAttName2"); + Mockito.when(session.getId()).thenReturn("testId"); + Mockito.when(session.getAttributeNames()).thenReturn(values); + Mockito.when(session.getAttribute("testAttName")).thenReturn("testAttName"); + Mockito.when(session.getAttribute("testAttName2")).thenReturn("testAttName2"); + MusicSession musSession = new MusicSession(session); + assertNotNull(musSession); + } + + @Test + public void getCreationTimeTest() throws Exception { + Instant instant = Instant.now(); + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())) + .thenReturn(String.valueOf(instant)); + assertNotNull(musicSession.getCreationTime()); + } + + @Test + public void getCreationTimeInstantNowTest() throws Exception { + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())).thenReturn(null); + assertNotNull(musicSession.getCreationTime()); + } + + @Test + public void getCreationTimeNullPointerExceptionTest() throws Exception { + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())) + .thenThrow(new NullPointerException()); + assertNull(musicSession.getCreationTime()); + } + + @Test + public void getLastAccessedTimeTest() throws Exception { + Instant instant = Instant.now(); + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())) + .thenReturn(String.valueOf(instant)); + assertNotNull(musicSession.getCreationTime()); + } + + @Test + public void getLastAccessedTimeInstantNowTest() throws Exception { + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())).thenReturn(null); + assertNotNull(musicSession.getCreationTime()); + } + + @Test + public void getLastAccessedTimeNullPointerExceptionTest() throws Exception { + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())) + .thenThrow(new NullPointerException()); + assertNull(musicSession.getCreationTime()); + } + + @Test + public void setMaxInactiveIntervalTest() throws Exception { + Mockito.when(MusicService.setAttribute(Matchers.anyString(), Matchers.anyString(), Matchers.anyString())) + .thenReturn(rt); + musicSession.setMaxInactiveInterval(duration); + } + + @Test + public void setMaxInactiveIntervalNullPointerExceptionTest() throws Exception { + Mockito.when(MusicService.setAttribute(Matchers.anyString(), Matchers.anyString(), Matchers.anyString())) + .thenThrow(new NullPointerException()); + musicSession.setMaxInactiveInterval(duration); + } + + @Test + public void getMaxInactiveIntervalTest() throws Exception { + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())) + .thenReturn(String.valueOf(duration)); + assertNotNull(musicSession.getMaxInactiveInterval()); + } + + @Test + public void getMaxInactiveIntervalDefaultDurationIntervalTest() throws Exception { + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())).thenReturn(null); + assertNotNull(musicSession.getMaxInactiveInterval()); + } + + @Test + public void isExpiredFalseTest() throws Exception { + assertFalse(musicSession.isExpired()); + + } + + @Test + public void getAttributeTest() throws Exception { + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())).thenReturn("test"); + assertNotNull(musicSession.getAttribute("test")); + } + + @Test + public void getAttributeNullPointerExceptionTest() throws Exception { + Mockito.when(MusicService.getAttribute(Matchers.anyString(), Matchers.anyString())) + .thenThrow(new NullPointerException()); + assertNull(musicSession.getAttribute("test")); + } + + @Test + public void getAttributeNamesTest() { + Set<String> sessionAttrsDummy = new TreeSet<>(); + assertEquals(sessionAttrsDummy, musicSession.getAttributeNames()); + } + + @Test + public void setAttributeTest() throws Exception { + Mockito.when(MusicService.setAttribute(Matchers.anyString(), Matchers.any(Object.class), Matchers.anyString())) + .thenReturn(rt); + musicSession.setAttribute("test_attr_name", "test_attr_value"); + } + + @Test + public void setAttributeExceptionTest() throws Exception { + Mockito.when(MusicService.setAttribute(Matchers.anyString(), Matchers.any(Object.class), Matchers.anyString())) + .thenThrow(new NullPointerException()); + musicSession.setAttribute("test_attr_name", "test_attr_value"); + } + + @Test + public void setAttributeValueNullTest() throws Exception { + Mockito.when(MusicService.setAttribute(Matchers.anyString(), Matchers.any(Object.class), Matchers.anyString())) + .thenReturn(rt); + musicSession.setAttribute("test_attr_name", null); + } + + @Test + public void removeAttributeMusicServiceExceptionTest() throws MusicServiceException, MusicLockingException { + Mockito.when(MusicService.removeAttribute(Matchers.anyString(), Matchers.anyString())) + .thenThrow(new MusicServiceException()); + musicSession.removeAttribute("test_attr_name"); + } + + @Test + public void removeAttributeMusicLockingExceptionTest() throws MusicServiceException, MusicLockingException { + Mockito.when(MusicService.removeAttribute(Matchers.anyString(), Matchers.anyString())) + .thenThrow(new MusicLockingException()); + musicSession.removeAttribute("test_attr_name"); + } + + @Test + public void setCreationTime() { + Instant instant = Instant.now(); + musicSession.setCreationTime(instant); + } + + @Test + public void setCreationExceptionTime() throws Exception { + Instant instant = Instant.now(); + Mockito.when(MusicService.setAttribute(Matchers.anyString(), Matchers.any(Instant.class), Matchers.anyString())) + .thenThrow(new MusicLockingException()); + musicSession.setCreationTime(instant); + } +} diff --git a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/model/RestResponseTest.java b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/model/RestResponseTest.java new file mode 100644 index 00000000..2f2dfaaa --- /dev/null +++ b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/model/RestResponseTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START========================================== + * ONAP + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalapp.music.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class RestResponseTest { + + @Test + public void restResponseTest() { + RestResponse<String> expected = new RestResponse<>(); + expected.setMessage("testMessage"); + expected.setResponse("testResponse"); + expected.setStatus(RestStatusEnum.ERROR); + RestResponse<String> actual = new RestResponse<String>(RestStatusEnum.ERROR, "testMessage", "testResponse"); + assertEquals(expected, actual); + assertEquals(expected.hashCode(), actual.hashCode()); + assertTrue(actual.equals(expected)); + } +} diff --git a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/service/MusicServiceTest.java b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/service/MusicServiceTest.java new file mode 100644 index 00000000..b5479371 --- /dev/null +++ b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/service/MusicServiceTest.java @@ -0,0 +1,248 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalapp.music.service; + +import java.nio.ByteBuffer; +import java.time.Duration; +import java.time.Instant; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.music.datastore.PreparedQueryObject; +import org.onap.music.exceptions.MusicLockingException; +import org.onap.music.exceptions.MusicServiceException; +import org.onap.music.main.MusicCore; +import org.onap.music.main.ReturnType; +import org.onap.portalapp.music.util.MusicProperties; +import org.onap.portalapp.music.util.MusicUtil; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.session.Session; +import org.springframework.test.util.ReflectionTestUtils; +import org.springframework.web.client.RestTemplate; + +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.Row; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({MusicUtil.class, MusicCore.class, MusicProperties.class}) +public class MusicServiceTest { + @Mock + ReturnType returnType; + @Mock + ResultSet resultSet; + @Mock + RestTemplate restTemplate; + @Mock + Session session; + @Mock + Row row; + + @SuppressWarnings("unchecked") + @Before + public void setUp() throws MusicLockingException, MusicServiceException { + PowerMockito.mockStatic(MusicUtil.class); + PowerMockito.mockStatic(MusicCore.class); + Mockito.when(returnType.getMessage()).thenReturn("test"); + Mockito.when(row.getString(Mockito.anyString())).thenReturn("test"); + Mockito.when(resultSet.one()).thenReturn(row); + Mockito.when(MusicCore.atomicPut(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any(PreparedQueryObject.class), Mockito.any(MusicCore.Condition.class))).thenReturn(returnType); + Mockito.when(MusicCore.eventualPut(Mockito.any(PreparedQueryObject.class))).thenReturn(returnType); + Mockito.when(MusicCore.atomicGet(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any(PreparedQueryObject.class))).thenReturn(resultSet); + Mockito.when(MusicCore.get(Mockito.any(PreparedQueryObject.class))).thenReturn(resultSet); + Mockito.when(session.getAttribute(Mockito.anyString())).thenReturn("test"); + ResponseEntity<String> entityResponse = Mockito.mock(ResponseEntity.class); + Mockito.when(entityResponse.getBody()).thenReturn("Success"); + Mockito.when(restTemplate.exchange(Mockito.any(String.class), Mockito.any(HttpMethod.class), Mockito.any(HttpEntity.class), Mockito.eq(String.class))).thenReturn(entityResponse); + Mockito.when(session.getCreationTime()).thenReturn(Instant.EPOCH); + Mockito.when(session.getLastAccessedTime()).thenReturn(Instant.EPOCH); + Mockito.when(session.getMaxInactiveInterval()).thenReturn(Duration.ZERO); + Mockito.when(MusicUtil.cleanUp()).thenReturn(true); + } + + @Test + public void testSetAttribute_WhenIsMetaIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", true); + Mockito.when(MusicUtil.isSessionMetaAttr(Mockito.anyString())).thenReturn(true); + MusicService.setAttribute("test", "test", "1"); + } + + @Test + public void testSetAttribute_WhenIsMetaIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", false); + Mockito.when(MusicUtil.isSessionMetaAttr(Mockito.anyString())).thenReturn(false); + ByteBuffer bb = Mockito.mock(ByteBuffer.class); + Mockito.when(MusicUtil.musicSerialize(Mockito.anyObject())).thenReturn(bb); + MusicService.setAttribute("test", "test", "1"); + } + + @Test + public void testSetMetaAttribute_WhenIsAutomicPutIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", true); + MusicService.setMetaAttribute(session); + } + + @Test + public void testSetMetaAttribute_WhenIsAutomicPutIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", false); + + MusicService.setMetaAttribute(session); + } + + @Test + public void testGetMetaAttribute_WhenIsAutomicPutIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicGet", true); + MusicService.getMetaAttribute("test"); + } + + @Test + public void testGetMetaAttribute_WhenIsAutomicPutIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicGet", false); + MusicService.getMetaAttribute("test"); + } + + @Test + public void testGetAttribute_WhenIsAutomicPutIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicGet", true); + Mockito.when(MusicUtil.isSessionMetaAttr(Mockito.anyString())).thenReturn(true); + MusicService.getAttribute("test", "1"); + } + + @Test + public void testGetAttribute_WhenIsAutomicPutIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicGet", false); + Mockito.when(MusicUtil.isSessionMetaAttr(Mockito.anyString())).thenReturn(false); + MusicService.getAttribute("test", "1"); + } + + @Test + public void testRemoveAttribute_WhenIsMetaIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", true); + Mockito.when(MusicUtil.isSessionMetaAttr(Mockito.anyString())).thenReturn(true); + MusicService.removeAttribute("test", "1"); + } + + @Test + public void testRemoveAttribute_WhenIsMetaIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", false); + Mockito.when(MusicUtil.isSessionMetaAttr(Mockito.anyString())).thenReturn(false); + ByteBuffer bb = Mockito.mock(ByteBuffer.class); + Mockito.when(MusicUtil.musicSerialize(Mockito.anyObject())).thenReturn(bb); + MusicService.removeAttribute("test", "1"); + } + + @Test + public void testRemoveSession_WhenIsMetaIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", true); + Mockito.when(MusicUtil.isSessionMetaAttr(Mockito.anyString())).thenReturn(true); + MusicService.removeSession("1"); + } + + @Test + public void testRemoveSession_WhenIsMetaIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", false); + Mockito.when(MusicUtil.isSessionMetaAttr(Mockito.anyString())).thenReturn(false); + ByteBuffer bb = Mockito.mock(ByteBuffer.class); + Mockito.when(MusicUtil.musicSerialize(Mockito.anyObject())).thenReturn(bb); + MusicService.removeSession("1"); + } + + @Test + public void testSetAttributeAPI_WhenIsMetaIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "template", restTemplate); + MusicService.setAttributeAPI("test", "test", session, "test", "test", true); + } + + @Test + public void testSetAttributeAPI_WhenIsMetaIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "template", null); + MusicService.setAttributeAPI("test", "test", session, "test", "test", false); + } + + @Test + public void testGetAttributeAPI_WhenIsMetaIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "template", restTemplate); + MusicService.getAttributeAPI("test", session, "test", true); + } + + @Test + public void testGetAttributeAPI_WhenIsMetaIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "template", null); + MusicService.getAttributeAPI("test", session, "test", false); + } + + @Test + public void testRemoveAttributeAPI_WhenIsMetaIsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "template", restTemplate); + MusicService.removeAttributeAPI("test", "1", true); + } + + @Test + public void testRemoveAttributeAPI_WhenIsMetaIsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "template", null); + MusicService.removeAttributeAPI("test", "1", false); + } + + @Test + public void testcleanUpMusic_WhenIsAutomicFlagsTrue() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", true); + ReflectionTestUtils.setField(MusicService.class, "isAtomicGet", true); + Mockito.when(resultSet.one()).thenReturn(null); + PowerMockito.mockStatic(MusicProperties.class); + Mockito.when(MusicProperties.getProperty("music.cleanup.threshold")).thenReturn("0"); + MusicService.cleanUpMusic(); + } + + @Test + public void testcleanUpMusic_WhenIsAutomicFlagsFalse() throws Exception { + ReflectionTestUtils.setField(MusicService.class, "isAtomicPut", false); + ReflectionTestUtils.setField(MusicService.class, "isAtomicGet", false); + Mockito.when(resultSet.one()).thenReturn(null); + PowerMockito.mockStatic(MusicProperties.class); + Mockito.when(MusicProperties.getProperty("music.cleanup.threshold")).thenReturn("0"); + MusicService.cleanUpMusic(); + } + +} diff --git a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/util/MusicPropertiesTest.java b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/util/MusicPropertiesTest.java new file mode 100644 index 00000000..27f7ed6c --- /dev/null +++ b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/util/MusicPropertiesTest.java @@ -0,0 +1,53 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalapp.music.util; + +import static org.junit.Assert.assertNull; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +public class MusicPropertiesTest { + + @Test + public void getPropertyTest() { + assertNull(MusicProperties.getProperty("test")); + } +} diff --git a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/util/MusicUtilTest.java b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/util/MusicUtilTest.java new file mode 100644 index 00000000..008dcdfc --- /dev/null +++ b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/util/MusicUtilTest.java @@ -0,0 +1,145 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalapp.music.util; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalapp.music.conf.MusicSession; +import org.onap.portalapp.music.service.MusicService; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.Row; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ MusicProperties.class, MusicSession.class, MusicService.class, MusicCleanUp.class }) +public class MusicUtilTest { + + ResultSet result = Mockito.mock(ResultSet.class); + + Row rw = Mockito.mock(Row.class); + + @Before + public void setUp() throws Exception { + MusicCleanUp musCleapUp = mock(MusicCleanUp.class); + PowerMockito.mockStatic(MusicProperties.class); + PowerMockito.mockStatic(MusicSession.class); + PowerMockito.mockStatic(MusicService.class); + PowerMockito.mockStatic(MusicCleanUp.class); + Mockito.when(MusicProperties.getProperty(MusicProperties.MUSIC_ATOMIC_PUT)).thenReturn("atomic-put"); + Mockito.when(MusicProperties.getProperty(MusicProperties.MUSIC_ATOMIC_GET)).thenReturn("atomic-get"); + Mockito.when(MusicProperties.getProperty(MusicProperties.MUSIC_CACHE)).thenReturn("cache"); + Mockito.when(MusicProperties.getProperty(MusicProperties.MUSIC_EXCLUDE_API)).thenReturn("test1,test2"); + PowerMockito.when(MusicProperties.getProperty(MusicProperties.MUSIC_SERIALIZE_COMPRESS)).thenReturn("compress"); + PowerMockito.when(MusicCleanUp.getInstance()).thenReturn(musCleapUp); + PowerMockito.when(musCleapUp.getLastCleanUpTime()).thenReturn(null); + MockitoAnnotations.initMocks(this); + } + + @Test + public void isSessionMetaAttrTest() { + assertTrue(MusicUtil.isSessionMetaAttr("CREATION_TIME")); + } + + @Test + public void musicRestResponseDataParsingTest() throws Exception { + List<Row> rows = new ArrayList<Row>(); + Mockito.doReturn("creation time").when(rw).getString("CREATION_TIME"); + rows.add(rw); + Mockito.doReturn(rows.get(0)).when(result).one(); + assertNotNull(MusicUtil.musicRestResponseDataParsing(result, "CREATION_TIME")); + } + + @Test + public void getMusicExcludedAPITest() { + assertNotNull(MusicUtil.getMusicExcludedAPI()); + } + + @Test + public void isExcludedApiTest() { + assertTrue(MusicUtil.isExcludedApi("test1")); + } + + @Test + public void isExcludedApiFalseTest() { + assertFalse(MusicUtil.isExcludedApi("test3")); + } + + @Test + public void isMusicSerializeCompressReturnFalseTest() { + assertFalse(MusicUtil.isMusicSerializeCompress()); + } + + @Test + public void isAtomicPutTest() { + assertFalse(MusicUtil.isAtomicPut()); + } + + @Test + public void isAtomicGetTest() { + assertFalse(MusicUtil.isAtomicGet()); + } + + @Test + public void isCachedTest() { + assertFalse(MusicUtil.isCached()); + } + + @Test + public void convertHoursToMillSecTest() { + assertNotNull(MusicUtil.convertHoursToMillSec(1)); + } + + @Test + public void cleanUpTest() { + assertFalse(MusicUtil.cleanUp()); + } +} diff --git a/ecomp-sdk/epsdk-workflow/pom.xml b/ecomp-sdk/epsdk-workflow/pom.xml index eaac5a44..24d6b650 100644 --- a/ecomp-sdk/epsdk-workflow/pom.xml +++ b/ecomp-sdk/epsdk-workflow/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/pom.xml b/ecomp-sdk/pom.xml index 8acbdac6..4f812a90 100644 --- a/ecomp-sdk/pom.xml +++ b/ecomp-sdk/pom.xml @@ -14,7 +14,7 @@ <!-- Portal SDK Maven parent project --> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>2.4.0-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> <packaging>pom</packaging> <name>portal-sdk</name> <url>https://wiki.onap.org/display/DW/Portal</url> |