From: Sunder Tattavarada Date: Wed, 22 Jan 2020 15:31:34 +0000 (+0000) Subject: Merge "Added Widget-Onboarding and dependent Services" X-Git-Tag: 3.2.0~44 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=16c3ddbf7f9f644adc23b8f834e6453c5260ada6;hp=358189e316549ac39a5f239cd2be27e116ec8c11;p=portal.git Merge "Added Widget-Onboarding and dependent Services" --- diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java index f0f0af5a..4d81c6d0 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java @@ -43,38 +43,36 @@ import org.glassfish.jersey.client.ClientResponse; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; public class SchedulerAuxUtil { - - private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerAuxUtil.class); - public static SchedulerAuxResponseWrapper wrapResponse ( String body, int statusCode ) { - - SchedulerAuxResponseWrapper w = new SchedulerAuxResponseWrapper(); - w.setStatus (statusCode); - w.setEntity(body); - - return w; - } - - public static SchedulerAuxResponseWrapper wrapResponse (ClientResponse cres) { - String resp_str = ""; - if ( cres != null ) { - resp_str = cres.readEntity(String.class); - } - int statuscode = cres.getStatus(); - SchedulerAuxResponseWrapper w = SchedulerAuxUtil.wrapResponse ( resp_str, statuscode ); - return (w); - } - - public static SchedulerAuxResponseWrapper wrapResponse (RestObject rs) { - String resp_str = ""; - int status = 0; - if ( rs != null ) { - resp_str = rs.get(); - status = rs.getStatusCode(); - } - SchedulerAuxResponseWrapper w = SchedulerAuxUtil.wrapResponse ( resp_str, status ); - return (w); - } - - + public static SchedulerAuxResponseWrapper wrapResponse(String body, int statusCode) { + + SchedulerAuxResponseWrapper w = new SchedulerAuxResponseWrapper(); + w.setStatus(statusCode); + w.setEntity(body); + + return w; + } + + public static SchedulerAuxResponseWrapper wrapResponse(ClientResponse cres) { + String respStr = ""; + int statuscode = 0; + if (cres != null) { + respStr = cres.readEntity(String.class); + statuscode = cres.getStatus(); + } + SchedulerAuxResponseWrapper w = SchedulerAuxUtil.wrapResponse(respStr, statuscode); + return (w); + } + + public static SchedulerAuxResponseWrapper wrapResponse(RestObject rs) { + String respStr = ""; + int status = 0; + if (rs != null) { + respStr = rs.get(); + status = rs.getStatusCode(); + } + SchedulerAuxResponseWrapper w = SchedulerAuxUtil.wrapResponse(respStr, status); + return (w); + } + } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java index 92cbe90e..5d38317a 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java @@ -43,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; @@ -61,146 +60,155 @@ import org.onap.portalsdk.core.service.DataAccessService; @EnableAspectJAutoProxy @EPMetricsLog public class EPRoleServiceImpl implements EPRoleService { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPRoleServiceImpl.class); - - @Autowired - private DataAccessService dataAccessService; - - @Autowired - ExternalAccessRolesService externalAccessRolesService; - - @SuppressWarnings("unchecked") - public List getRoleFunctions() { - // List msgDB = getDataAccessService().getList(Profile.class, null); - return getDataAccessService().getList(RoleFunction.class, null); - } - - @SuppressWarnings("unchecked") - public List getAvailableChildRoles(Long roleId) { - List availableChildRoles = (List) getDataAccessService().getList(EPRole.class, null); - if (roleId == null || roleId == 0) { - return availableChildRoles; - } - - EPRole currentRole = (EPRole) getDataAccessService().getDomainObject(EPRole.class, roleId, null); - Set allParentRoles = new TreeSet(); - allParentRoles = getAllParentRolesAsList(currentRole, allParentRoles); - - Iterator availableChildRolesIterator = availableChildRoles.iterator(); - while (availableChildRolesIterator.hasNext()) { - EPRole role = availableChildRolesIterator.next(); - if (!role.getActive() || allParentRoles.contains(role) || role.getId().equals(roleId)) { - availableChildRolesIterator.remove(); - } - } - return availableChildRoles; - } - - private Set getAllParentRolesAsList(EPRole role, Set allParentRoles) { - Set parentRoles = role.getParentRoles(); - allParentRoles.addAll(parentRoles); - Iterator parentRolesIterator = parentRoles.iterator(); - while (parentRolesIterator.hasNext()) { - getAllParentRolesAsList(parentRolesIterator.next(), allParentRoles); - } - return allParentRoles; - } - - public RoleFunction getRoleFunction(String code) { - return (RoleFunction) getDataAccessService().getDomainObject(RoleFunction.class, code, null); - } - - public void saveRoleFunction(RoleFunction domainRoleFunction) { - getDataAccessService().saveDomainObject(domainRoleFunction, null); - } - - public void deleteRoleFunction(RoleFunction domainRoleFunction) { - getDataAccessService().deleteDomainObject(domainRoleFunction, null); - } - - public EPRole getRole(Long id) { - return (EPRole) getDataAccessService().getDomainObject(EPRole.class, id, null); - } - - // TODO: refactor - private static final String getAppRoleSqlFormat = "SELECT * FROM fn_role where APP_ID = %s AND APP_ROLE_ID = %s"; - - @SuppressWarnings("unchecked") - public EPRole getRole(Long appId, Long appRoleid) { - if (appId == null || appRoleid == null) { - logger.error(EELFLoggerDelegate.errorLogger, String.format( - "getRole does not support null appId or roleId. appRoleid=%s, appRoleid=%s", appId, appRoleid)); - return null; - } - - String sql = String.format(getAppRoleSqlFormat, appId, appRoleid); - - List roles = (List) dataAccessService.executeSQLQuery(sql, EPRole.class, null); - int resultsCount = roles.size(); - if (resultsCount > 1) { - logger.error(EELFLoggerDelegate.errorLogger, - String.format( - "search by appId=%s, appRoleid=%s should have returned 0 or 1 results. Got %d. This is an internal server error.", - appId, appRoleid, resultsCount)); - logger.error(EELFLoggerDelegate.errorLogger, - "Trying to recover from duplicates by returning the first search result. This issue should be treated, it is probably not critical because duplicate roles should be similar."); - return roles.get(0); - } else if (resultsCount == 1) { - return roles.get(0); - } - return null; - } - - @SuppressWarnings("unchecked") - public EPRole getAppRole(String roleName, Long appId) { - - final Map params = new HashMap(); - final Map portalParams = new HashMap(); - List roles = null; - params.put("appId", appId.toString()); - params.put("roleName", roleName); - portalParams.put("appRoleName", roleName); - - List roleList = externalAccessRolesService.getPortalAppRoleInfo(PortalConstants.ACCOUNT_ADMIN_ROLE_ID); - EPRole role = new EPRole(); - if(roleList.size()>0){ - role = roleList.get(0);} - logger.debug(EELFLoggerDelegate.debugLogger, "Requested RoleName is "+role.getName()); - - if (appId == 1 || roleName.equals(role.getName())) { - roles = (List) dataAccessService.executeNamedQuery("getPortalAppRoles", portalParams, null); - } else if (appId != 1 && !roleName.equals(role.getName())) { - roles = (List) dataAccessService.executeNamedQuery("getAppRoles", params, null); - } - int resultsCount = (roles == null ? 0 : roles.size()); - if (resultsCount > 1) { - logger.error(EELFLoggerDelegate.errorLogger, - "Trying to recover from duplicates by returning the first search result. This issue should be treated, it is probably not critical because duplicate roles should be similar."); - return roles.get(0); - } else if (resultsCount == 1) { - return roles.get(0); - } - return null; - } - - public void saveRole(EPRole domainRole) { - getDataAccessService().saveDomainObject(domainRole, null); - } - - public void deleteRole(EPRole domainRole) { - getDataAccessService().deleteDomainObject(domainRole, null); - } - - @SuppressWarnings("unchecked") - public List getAvailableRoles() { - return getDataAccessService().getList(EPRole.class, null); - } - - public DataAccessService getDataAccessService() { - return dataAccessService; - } - - public void setDataAccessService(DataAccessService dataAccessService) { - this.dataAccessService = dataAccessService; - } + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPRoleServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + @Autowired + ExternalAccessRolesService externalAccessRolesService; + + @SuppressWarnings("unchecked") + public List getRoleFunctions() { + return getDataAccessService().getList(RoleFunction.class, null); + } + + @SuppressWarnings("unchecked") + public List getAvailableChildRoles(Long roleId) { + List availableChildRoles = + (List) getDataAccessService().getList(EPRole.class, null); + if (roleId == null || roleId == 0) { + return availableChildRoles; + } + + EPRole currentRole = + (EPRole) getDataAccessService().getDomainObject(EPRole.class, roleId, null); + Set allParentRoles = new TreeSet<>(); + allParentRoles = getAllParentRolesAsList(currentRole, allParentRoles); + + Iterator availableChildRolesIterator = availableChildRoles.iterator(); + while (availableChildRolesIterator.hasNext()) { + EPRole role = availableChildRolesIterator.next(); + if (!role.getActive() || allParentRoles.contains(role) || role.getId().equals(roleId)) { + availableChildRolesIterator.remove(); + } + } + return availableChildRoles; + } + + private Set getAllParentRolesAsList(EPRole role, Set allParentRoles) { + Set parentRoles = role.getParentRoles(); + allParentRoles.addAll(parentRoles); + Iterator parentRolesIterator = parentRoles.iterator(); + while (parentRolesIterator.hasNext()) { + getAllParentRolesAsList(parentRolesIterator.next(), allParentRoles); + } + return allParentRoles; + } + + public RoleFunction getRoleFunction(String code) { + return (RoleFunction) getDataAccessService().getDomainObject(RoleFunction.class, code, + null); + } + + public void saveRoleFunction(RoleFunction domainRoleFunction) { + getDataAccessService().saveDomainObject(domainRoleFunction, null); + } + + public void deleteRoleFunction(RoleFunction domainRoleFunction) { + getDataAccessService().deleteDomainObject(domainRoleFunction, null); + } + + public EPRole getRole(Long id) { + return (EPRole) getDataAccessService().getDomainObject(EPRole.class, id, null); + } + + // TODO: refactor + private static final String GET_APP_ROLE_SQL_FORMAT = + "SELECT * FROM fn_role where APP_ID = %s AND APP_ROLE_ID = %s"; + + @SuppressWarnings("unchecked") + public EPRole getRole(Long appId, Long appRoleid) { + if (appId == null || appRoleid == null) { + logger.error(EELFLoggerDelegate.errorLogger, String.format( + "getRole does not support null appId or roleId. appRoleid=%s, appRoleid=%s", + appId, appRoleid)); + return null; + } + + String sql = String.format(GET_APP_ROLE_SQL_FORMAT, appId, appRoleid); + + List roles = + (List) dataAccessService.executeSQLQuery(sql, EPRole.class, null); + int resultsCount = roles.size(); + if (resultsCount > 1) { + logger.error(EELFLoggerDelegate.errorLogger, String.format( + "search by appId=%s, appRoleid=%s should have returned 0 or 1 results. Got %d. This is an internal server error.", + appId, appRoleid, resultsCount)); + logger.error(EELFLoggerDelegate.errorLogger, + "Trying to recover from duplicates by returning the first search result. This issue should be treated, it is probably not critical because duplicate roles should be similar."); + return roles.get(0); + } else if (resultsCount == 1) { + return roles.get(0); + } + return null; + } + + @SuppressWarnings("unchecked") + public EPRole getAppRole(String roleName, Long appId) { + + final Map params = new HashMap<>(); + final Map portalParams = new HashMap<>(); + List roles = null; + params.put("appId", appId.toString()); + params.put("roleName", roleName); + portalParams.put("appRoleName", roleName); + + List roleList = externalAccessRolesService + .getPortalAppRoleInfo(PortalConstants.ACCOUNT_ADMIN_ROLE_ID); + EPRole role = new EPRole(); + if (!roleList.isEmpty()) { + role = roleList.get(0); + } + logger.debug(EELFLoggerDelegate.debugLogger, "Requested RoleName is " + role.getName()); + + if (appId == 1 || roleName.equals(role.getName())) { + roles = (List) dataAccessService.executeNamedQuery("getPortalAppRoles", + portalParams, null); + } else if (appId != 1 && !roleName.equals(role.getName())) { + roles = (List) dataAccessService.executeNamedQuery("getAppRoles", params, null); + } + int resultsCount = (roles == null ? 0 : roles.size()); + if (resultsCount > 1) { + logger.error(EELFLoggerDelegate.errorLogger, + "Trying to recover from duplicates by returning the first search result. This issue should be treated, it is probably not critical because duplicate roles should be similar."); + if (roles != null) { + return roles.get(0); + } + } else if (resultsCount == 1) { + return roles.get(0); + } + return null; + } + + public void saveRole(EPRole domainRole) { + getDataAccessService().saveDomainObject(domainRole, null); + } + + public void deleteRole(EPRole domainRole) { + getDataAccessService().deleteDomainObject(domainRole, null); + } + + @SuppressWarnings("unchecked") + public List getAvailableRoles() { + return getDataAccessService().getList(EPRole.class, null); + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/DeleteDomainObjectFailedExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/DeleteDomainObjectFailedExceptionTest.java new file mode 100644 index 00000000..fa511cf5 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/DeleteDomainObjectFailedExceptionTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 IBM 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.portal.exceptions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.portalapp.portal.exceptions.DeleteDomainObjectFailedException; + +public class DeleteDomainObjectFailedExceptionTest { + + @Test + public void Test1() + { + String s1 = "Value1"; + String s2 = "value2"; + try { + if (!s1.equalsIgnoreCase(s2)) { + throw new DeleteDomainObjectFailedException("org.onap.portalapp.widget.excetpion.DeleteDomainObjectFailedException"); + } + } catch (DeleteDomainObjectFailedException mde) { + assertEquals(mde.getMessage(),"org.onap.portalapp.widget.excetpion.DeleteDomainObjectFailedException"); + } + } + +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InactiveApplicationExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InactiveApplicationExceptionTest.java new file mode 100644 index 00000000..582a9dbb --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InactiveApplicationExceptionTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 IBM 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.portal.exceptions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class InactiveApplicationExceptionTest { + + @Test + public void TestException2() { + String s1 = "Value1"; + String s2 = "value2"; + try { + if (!s1.equalsIgnoreCase(s2)) { + throw new InactiveApplicationException("Exception occured.."); + } + } catch (InactiveApplicationException mde) { + assertEquals(mde.getMessage(),"Exception occured.."); + } + + } +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidApplicationExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidApplicationExceptionTest.java new file mode 100644 index 00000000..a82831d4 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidApplicationExceptionTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 IBM 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.portal.exceptions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class InvalidApplicationExceptionTest { + + @Test + public void TestException2() { + String s1 = "Value1"; + String s2 = "value2"; + try { + if (!s1.equalsIgnoreCase(s2)) { + throw new InvalidApplicationException("Exception occured.."); + } + } catch (InvalidApplicationException mde) { + assertEquals(mde.getMessage(),"Exception occured.."); + } + + } + +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidRoleExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidRoleExceptionTest.java new file mode 100644 index 00000000..07a93d93 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidRoleExceptionTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 IBM 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.portal.exceptions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class InvalidRoleExceptionTest { + + @Test + public void TestException2() { + String s1 = "Value1"; + String s2 = "value2"; + try { + if (!s1.equalsIgnoreCase(s2)) { + throw new InvalidRoleException("Exception occured.."); + } + } catch (InvalidRoleException mde) { + assertEquals(mde.getMessage(),"Exception occured.."); + } + + } + + +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidUserExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidUserExceptionTest.java new file mode 100644 index 00000000..152093e5 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/InvalidUserExceptionTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 IBM 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.portal.exceptions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class InvalidUserExceptionTest { + + @Test + public void TestException2() { + String s1 = "Value1"; + String s2 = "value2"; + try { + if (!s1.equalsIgnoreCase(s2)) { + throw new InvalidUserException("Exception occured.."); + } + } catch (InvalidUserException mde) { + assertEquals(mde.getMessage(),"Exception occured.."); + } + + } +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NonCentralizedAppExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NonCentralizedAppExceptionTest.java new file mode 100644 index 00000000..7109b2d0 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NonCentralizedAppExceptionTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 IBM 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.portal.exceptions; + +import org.junit.Test; + +public class NonCentralizedAppExceptionTest { + + @Test + public void TestException2() { + String s1 = "Value1"; + NonCentralizedAppException nca = new NonCentralizedAppException(s1); + } +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/SyncUserRolesExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/SyncUserRolesExceptionTest.java new file mode 100644 index 00000000..84708cb9 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/SyncUserRolesExceptionTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 IBM 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.portal.exceptions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class SyncUserRolesExceptionTest { + + @Test + public void TestException2() { + String s1 = "Value1"; + String s2 = "value2"; + try { + if (!s1.equalsIgnoreCase(s2)) { + throw new SyncUserRolesException("Exception occured.."); + } + } catch (SyncUserRolesException mde) { + assertEquals(mde.getMessage(),"Exception occured.."); + } + + } + + +}