From 51d83152697da4f2ef2242471ee43f36e6b64300 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Thu, 28 Sep 2017 11:18:14 -0400 Subject: Update license; improve coverage; add docs dir Update licenses to match approved text; add where missing. Improve code coverage with additional tests. Use OParent. Drop ecomp-portal-BE-common-test entirely; tests merged to ecomp-portal-BE-common. All code from LF repo branch master_dev_amsterdam_1_3_0 Issue: PORTAL-42, PORTAL-50, PORTAL-90, PORTAL-96 Change-Id: I09d98bbf072411d2efed6fb34f378f7cc8d049ad Signed-off-by: Christopher Lott (cl778h) --- .../portalapp/command/EPLoginBeanTest.java | 80 +++++++++++ .../portalapp/command/PostSearchBeanTest.java | 149 +++++++++++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command/EPLoginBeanTest.java create mode 100644 ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command/PostSearchBeanTest.java (limited to 'ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command') diff --git a/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command/EPLoginBeanTest.java b/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command/EPLoginBeanTest.java new file mode 100644 index 00000000..e540bd85 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command/EPLoginBeanTest.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * 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============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.openecomp.portalapp.command; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; +import org.openecomp.portalapp.command.EPLoginBean; + +public class EPLoginBeanTest { + + +public EPLoginBean ePLoginBean(){ + + EPLoginBean ePLoginBean = new EPLoginBean(); + ePLoginBean.setLoginId("guestT"); + ePLoginBean.setLoginPwd("password"); + ePLoginBean.setHrid("hrId"); + ePLoginBean.setOrgUserId("guestT"); + ePLoginBean.setBusinessDirectMenu(null); + ePLoginBean.setSiteAccess("site_test"); + ePLoginBean.setLoginErrorMessage("error"); + ePLoginBean.setUser(null); + ePLoginBean.setMenu(null); + return ePLoginBean; + } + + @Test + public void ePLoginBeanTest(){ + EPLoginBean ePLoginBean = ePLoginBean(); + + assertEquals(ePLoginBean.getLoginId(), "guestT"); + assertEquals(ePLoginBean.getLoginPwd(), "password"); + assertEquals(ePLoginBean.getHrid(), "hrId"); + assertEquals(ePLoginBean.getOrgUserId(), "guestT"); + assertNull(ePLoginBean.getBusinessDirectMenu()); + assertEquals(ePLoginBean.getSiteAccess(), "site_test"); + assertEquals(ePLoginBean.getLoginErrorMessage(), "error"); + assertNull(ePLoginBean.getUser()); + assertNull(ePLoginBean.getMenu()); + + + } +} diff --git a/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command/PostSearchBeanTest.java b/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command/PostSearchBeanTest.java new file mode 100644 index 00000000..324d91d7 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/command/PostSearchBeanTest.java @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * 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============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.openecomp.portalapp.command; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.mockito.InjectMocks; +import org.openecomp.portalapp.portal.core.MockEPUser; +import org.openecomp.portalapp.portal.domain.EPUser; + +public class PostSearchBeanTest { + + @InjectMocks + PostSearchBean mockPostSearchBean = new PostSearchBean(); + + MockEPUser mockUser = new MockEPUser(); + public PostSearchBean mockPostSearchBean(){ + + PostSearchBean postSearchBean = new PostSearchBean(); + EPUser user = mockUser.mockEPUser(); + postSearchBean.setUser(user); + postSearchBean.setUserOrig(null); + postSearchBean.setSelected(null); + postSearchBean.setHrid(null); + postSearchBean.setPostUserId(null); + postSearchBean.setPostFirstName(null); + postSearchBean.setPostLastName(null); + postSearchBean.setPostOrgCode(null); + postSearchBean.setPostPhone(null); + postSearchBean.setPostEmail(null); + postSearchBean.setPostAddress1(null); + postSearchBean.setPostAddress2(null); + postSearchBean.setPostCity(null); + postSearchBean.setPostState(null); + postSearchBean.setPostZipCode(null); + postSearchBean.setPostLocationClli(null); + postSearchBean.setPostBusinessCountryCode(null); + postSearchBean.setPostBusinessCountryName(null); + postSearchBean.setPostDepartment(null); + postSearchBean.setPostDepartmentName(null); + postSearchBean.setPostBusinessUnit(null); + postSearchBean.setPostBusinessUnitName(null); + postSearchBean.setPostJobTitle(null); + postSearchBean.setOrgManagerUserId(null); + postSearchBean.setPostCommandChain(null); + postSearchBean.setPostCompanyCode(null); + postSearchBean.setPostCostCenter(null); + postSearchBean.setPostSiloStatus(null); + postSearchBean.setPostFinancialLocCode(null); + postSearchBean.setPostManagerUserId(null); + return postSearchBean; + } + + @Test + public void postSearchBeanTest() + { + PostSearchBean postSearchBean = mockPostSearchBean(); + EPUser user = mockUser.mockEPUser(); + assertEquals(postSearchBean.getUser().getActive(), user.getActive()); + assertNull(postSearchBean.getUserOrig()); + assertNull(postSearchBean.getSelected()); + assertNull(postSearchBean.getHrid()); + assertNull(postSearchBean.getPostOrgUserId()); + assertNull(postSearchBean.getPostFirstName()); + assertNull(postSearchBean.getPostLastName()); + assertNull(postSearchBean.getPostOrgCode()); + assertNull(postSearchBean.getPostPhone()); + assertNull(postSearchBean.getPostEmail()); + assertNull(postSearchBean.getPostAddress1()); + assertNull(postSearchBean.getPostAddress2()); + assertNull(postSearchBean.getPostCity()); + assertNull(postSearchBean.getPostState()); + assertNull(postSearchBean.getPostZipCode()); + assertNull(postSearchBean.getPostLocationClli()); + assertNull(postSearchBean.getPostBusinessCountryCode()); + assertNull(postSearchBean.getPostBusinessCountryName()); + assertNull(postSearchBean.getPostDepartment()); + assertNull(postSearchBean.getPostDepartmentName()); + assertNull(postSearchBean.getPostBusinessUnit()); + assertNull(postSearchBean.getPostBusinessUnitName()); + assertNull(postSearchBean.getPostJobTitle()); + assertNull(postSearchBean.getOrgManagerUserId()); + assertNull(postSearchBean.getPostCommandChain()); + assertNull(postSearchBean.getPostCompanyCode()); + assertNull(postSearchBean.getPostCostCenter()); + assertNull(postSearchBean.getPostSiloStatus()); + assertNull(postSearchBean.getPostFinancialLocCode()); + assertNull(postSearchBean.getPostManagerUserId()); + } + + @Test + public void isCriteriaUpdatedIfUserNotNullTest() + { + assertFalse(mockPostSearchBean.isCriteriaUpdated()); + } + + @Test + public void isCriteriaUpdatedIfUserNullTest() + { + mockPostSearchBean.setUser(null); + assertTrue(mockPostSearchBean.isCriteriaUpdated()); + } + + + @Test + public void isCriteriaUpdatedIfUserTest() + { + mockPostSearchBean.setUser(null); + mockPostSearchBean.setUserOrig(null); + assertFalse(mockPostSearchBean.isCriteriaUpdated()); + } + +} -- cgit 1.2.3-korg