diff options
author | Manoop Talasila <talasila@research.att.com> | 2019-08-19 14:49:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-08-19 14:49:22 +0000 |
commit | 7ce177cd99096772ff42ef89d8820070c687fd9b (patch) | |
tree | 277991e9d0784049936e7742587af6f67963a24c | |
parent | f71707238ebabd9911277af55673b1d42ac1495f (diff) | |
parent | 31e135a9ffb7e20fa146f841c5e3a2782f8131a5 (diff) |
Merge "Reduce number of parameters in constructor"
4 files changed, 423 insertions, 92 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java index 786ad429..d5a873a2 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java @@ -3469,22 +3469,31 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic cua.setRole(role); userApps.add(cua); } - return new CentralUser(cenV2User.getId(), cenV2User.getCreated(), cenV2User.getModified(), - cenV2User.getCreatedId(), cenV2User.getModifiedId(), cenV2User.getRowNum(), cenV2User.getOrgId(), - cenV2User.getManagerId(), cenV2User.getFirstName(), cenV2User.getMiddleInitial(), - cenV2User.getLastName(), cenV2User.getPhone(), cenV2User.getFax(), cenV2User.getCellular(), - cenV2User.getEmail(), cenV2User.getAddressId(), cenV2User.getAlertMethodCd(), cenV2User.getHrid(), - cenV2User.getOrgUserId(), cenV2User.getOrgCode(), cenV2User.getAddress1(), cenV2User.getAddress2(), - cenV2User.getCity(), cenV2User.getState(), cenV2User.getZipCode(), cenV2User.getCountry(), - cenV2User.getOrgManagerUserId(), cenV2User.getLocationClli(), cenV2User.getBusinessCountryCode(), - cenV2User.getBusinessCountryName(), cenV2User.getBusinessUnit(), cenV2User.getBusinessUnitName(), - cenV2User.getDepartment(), cenV2User.getDepartmentName(), cenV2User.getCompanyCode(), - cenV2User.getCompany(), cenV2User.getZipCodeSuffix(), cenV2User.getJobTitle(), - cenV2User.getCommandChain(), cenV2User.getSiloStatus(), cenV2User.getCostCenter(), - cenV2User.getFinancialLocCode(), cenV2User.getLoginId(), cenV2User.getLoginPwd(), - cenV2User.getLastLoginDate(), cenV2User.isActive(), cenV2User.isInternal(), - cenV2User.getSelectedProfileId(), cenV2User.getTimeZoneId(), cenV2User.isOnline(), - cenV2User.getChatId(), userApps); + return new CentralUser.CentralUserBuilder().setId(cenV2User.getId()).setCreated(cenV2User.getCreated()) + .setModified(cenV2User.getModified()).setCreatedId(cenV2User.getCreatedId()) + .setModifiedId(cenV2User.getModifiedId()).setRowNum(cenV2User.getRowNum()) + .setOrgId(cenV2User.getOrgId()).setManagerId(cenV2User.getManagerId()) + .setFirstName(cenV2User.getFirstName()).setMiddleInitial(cenV2User.getMiddleInitial()) + .setLastName(cenV2User.getLastName()).setPhone(cenV2User.getPhone()).setFax(cenV2User.getFax()) + .setCellular(cenV2User.getCellular()).setEmail(cenV2User.getEmail()) + .setAddressId(cenV2User.getAddressId()).setAlertMethodCd(cenV2User.getAlertMethodCd()) + .setHrid(cenV2User.getHrid()).setOrgUserId(cenV2User.getOrgUserId()).setOrgCode(cenV2User.getOrgCode()) + .setAddress1(cenV2User.getAddress1()).setAddress2(cenV2User.getAddress2()).setCity(cenV2User.getCity()) + .setState(cenV2User.getState()).setZipCode(cenV2User.getZipCode()).setCountry(cenV2User.getCountry()) + .setOrgManagerUserId(cenV2User.getOrgManagerUserId()).setLocationClli(cenV2User.getLocationClli()) + .setBusinessCountryCode(cenV2User.getBusinessCountryCode()) + .setBusinessCountryName(cenV2User.getBusinessCountryName()).setBusinessUnit(cenV2User.getBusinessUnit()) + .setBusinessUnitName(cenV2User.getBusinessUnitName()).setDepartment(cenV2User.getDepartment()) + .setDepartmentName(cenV2User.getDepartmentName()).setCompanyCode(cenV2User.getCompanyCode()) + .setCompany(cenV2User.getCompany()).setZipCodeSuffix(cenV2User.getZipCodeSuffix()) + .setJobTitle(cenV2User.getJobTitle()).setCommandChain(cenV2User.getCommandChain()) + .setSiloStatus(cenV2User.getSiloStatus()).setCostCenter(cenV2User.getCostCenter()) + .setFinancialLocCode(cenV2User.getFinancialLocCode()).setLoginId(cenV2User.getLoginId()) + .setLoginPwd(cenV2User.getLoginPwd()).setLastLoginDate(cenV2User.getLastLoginDate()) + .setActive(cenV2User.isActive()).setInternal(cenV2User.isInternal()) + .setSelectedProfileId(cenV2User.getSelectedProfileId()).setTimeZoneId(cenV2User.getTimeZoneId()) + .setOnline(cenV2User.isOnline()).setChatId(cenV2User.getChatId()).setUserApps(userApps) + .createCentralUser(); } @Override diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CentralUser.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CentralUser.java index 1485af61..c4a12a99 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CentralUser.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CentralUser.java @@ -102,69 +102,379 @@ public class CentralUser implements Serializable { private Set<CentralUserApp> userApps = new TreeSet<>(); private Set<CentralRole> pseudoRoles = new TreeSet<>(); - public CentralUser(Long id, Date created, Date modified, Long createdId, Long modifiedId, Long rowNum, Long orgId, - Long managerId, String firstName, String middleInitial, String lastName, String phone, String fax, - String cellular, String email, Long addressId, String alertMethodCd, String hrid, String orgUserId, - String orgCode, String address1, String address2, String city, String state, String zipCode, String country, - String orgManagerUserId, String locationClli, String businessCountryCode, String businessCountryName, - String businessUnit, String businessUnitName, String department, String departmentName, String companyCode, - String company, String zipCodeSuffix, String jobTitle, String commandChain, String siloStatus, - String costCenter, String financialLocCode, String loginId, String loginPwd, Date lastLoginDate, - boolean active, boolean internal, Long selectedProfileId, Long timeZoneId, boolean online, String chatId, - Set<CentralUserApp> userApps) { + public CentralUser(CentralUserBuilder builder) { super(); - this.id = id; - this.created = created; - this.modified = modified; - this.createdId = createdId; - this.modifiedId = modifiedId; - this.rowNum = rowNum; - this.orgId = orgId; - this.managerId = managerId; - this.firstName = firstName; - this.middleInitial = middleInitial; - this.lastName = lastName; - this.phone = phone; - this.fax = fax; - this.cellular = cellular; - this.email = email; - this.addressId = addressId; - this.alertMethodCd = alertMethodCd; - this.hrid = hrid; - this.orgUserId = orgUserId; - this.orgCode = orgCode; - this.address1 = address1; - this.address2 = address2; - this.city = city; - this.state = state; - this.zipCode = zipCode; - this.country = country; - this.orgManagerUserId = orgManagerUserId; - this.locationClli = locationClli; - this.businessCountryCode = businessCountryCode; - this.businessCountryName = businessCountryName; - this.businessUnit = businessUnit; - this.businessUnitName = businessUnitName; - this.department = department; - this.departmentName = departmentName; - this.companyCode = companyCode; - this.company = company; - this.zipCodeSuffix = zipCodeSuffix; - this.jobTitle = jobTitle; - this.commandChain = commandChain; - this.siloStatus = siloStatus; - this.costCenter = costCenter; - this.financialLocCode = financialLocCode; - this.loginId = loginId; - this.loginPwd = loginPwd; - this.lastLoginDate = lastLoginDate; - this.active = active; - this.internal = internal; - this.selectedProfileId = selectedProfileId; - this.timeZoneId = timeZoneId; - this.online = online; - this.chatId = chatId; - this.userApps = userApps; + this.id = builder.id; + this.created = builder.created; + this.modified = builder.modified; + this.createdId = builder.createdId; + this.modifiedId = builder.modifiedId; + this.rowNum = builder.rowNum; + this.orgId = builder.orgId; + this.managerId = builder.managerId; + this.firstName = builder.firstName; + this.middleInitial = builder.middleInitial; + this.lastName = builder.lastName; + this.phone = builder.phone; + this.fax = builder.fax; + this.cellular = builder.cellular; + this.email = builder.email; + this.addressId = builder.addressId; + this.alertMethodCd = builder.alertMethodCd; + this.hrid = builder.hrid; + this.orgUserId = builder.orgUserId; + this.orgCode = builder.orgCode; + this.address1 = builder.address1; + this.address2 = builder.address2; + this.city = builder.city; + this.state = builder.state; + this.zipCode = builder.zipCode; + this.country = builder.country; + this.orgManagerUserId = builder.orgManagerUserId; + this.locationClli = builder.locationClli; + this.businessCountryCode = builder.businessCountryCode; + this.businessCountryName = builder.businessCountryName; + this.businessUnit = builder.businessUnit; + this.businessUnitName = builder.businessUnitName; + this.department = builder.department; + this.departmentName = builder.departmentName; + this.companyCode = builder.companyCode; + this.company = builder.company; + this.zipCodeSuffix = builder.zipCodeSuffix; + this.jobTitle = builder.jobTitle; + this.commandChain = builder.commandChain; + this.siloStatus = builder.siloStatus; + this.costCenter = builder.costCenter; + this.financialLocCode = builder.financialLocCode; + this.loginId = builder.loginId; + this.loginPwd = builder.loginPwd; + this.lastLoginDate = builder.lastLoginDate; + this.active = builder.active; + this.internal = builder.internal; + this.selectedProfileId = builder.selectedProfileId; + this.timeZoneId = builder.timeZoneId; + this.online = builder.online; + this.chatId = builder.chatId; + this.userApps = builder.userApps; + } + + public static class CentralUserBuilder { + private Long id; + private Date created; + private Date modified; + private Long createdId; + private Long modifiedId; + private Long rowNum; + private Long orgId; + private Long managerId; + private String firstName; + private String middleInitial; + private String lastName; + private String phone; + private String fax; + private String cellular; + private String email; + private Long addressId; + private String alertMethodCd; + private String hrid; + private String orgUserId; + private String orgCode; + private String address1; + private String address2; + private String city; + private String state; + private String zipCode; + private String country; + private String orgManagerUserId; + private String locationClli; + private String businessCountryCode; + private String businessCountryName; + private String businessUnit; + private String businessUnitName; + private String department; + private String departmentName; + private String companyCode; + private String company; + private String zipCodeSuffix; + private String jobTitle; + private String commandChain; + private String siloStatus; + private String costCenter; + private String financialLocCode; + private String loginId; + private String loginPwd; + private Date lastLoginDate; + private boolean active; + private boolean internal; + private Long selectedProfileId; + private Long timeZoneId; + private boolean online; + private String chatId; + private Set<CentralUserApp> userApps; + + public CentralUserBuilder setId(Long id) { + this.id = id; + return this; + } + + public CentralUserBuilder setCreated(Date created) { + this.created = created; + return this; + } + + public CentralUserBuilder setModified(Date modified) { + this.modified = modified; + return this; + } + + public CentralUserBuilder setCreatedId(Long createdId) { + this.createdId = createdId; + return this; + } + + public CentralUserBuilder setModifiedId(Long modifiedId) { + this.modifiedId = modifiedId; + return this; + } + + public CentralUserBuilder setRowNum(Long rowNum) { + this.rowNum = rowNum; + return this; + } + + public CentralUserBuilder setOrgId(Long orgId) { + this.orgId = orgId; + return this; + } + + public CentralUserBuilder setManagerId(Long managerId) { + this.managerId = managerId; + return this; + } + + public CentralUserBuilder setFirstName(String firstName) { + this.firstName = firstName; + return this; + } + + public CentralUserBuilder setMiddleInitial(String middleInitial) { + this.middleInitial = middleInitial; + return this; + } + + public CentralUserBuilder setLastName(String lastName) { + this.lastName = lastName; + return this; + } + + public CentralUserBuilder setPhone(String phone) { + this.phone = phone; + return this; + } + + public CentralUserBuilder setFax(String fax) { + this.fax = fax; + return this; + } + + public CentralUserBuilder setCellular(String cellular) { + this.cellular = cellular; + return this; + } + + public CentralUserBuilder setEmail(String email) { + this.email = email; + return this; + } + + public CentralUserBuilder setAddressId(Long addressId) { + this.addressId = addressId; + return this; + } + + public CentralUserBuilder setAlertMethodCd(String alertMethodCd) { + this.alertMethodCd = alertMethodCd; + return this; + } + + public CentralUserBuilder setHrid(String hrid) { + this.hrid = hrid; + return this; + } + + public CentralUserBuilder setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + return this; + } + + public CentralUserBuilder setOrgCode(String orgCode) { + this.orgCode = orgCode; + return this; + } + + public CentralUserBuilder setAddress1(String address1) { + this.address1 = address1; + return this; + } + + public CentralUserBuilder setAddress2(String address2) { + this.address2 = address2; + return this; + } + + public CentralUserBuilder setCity(String city) { + this.city = city; + return this; + } + + public CentralUserBuilder setState(String state) { + this.state = state; + return this; + } + + public CentralUserBuilder setZipCode(String zipCode) { + this.zipCode = zipCode; + return this; + } + + public CentralUserBuilder setCountry(String country) { + this.country = country; + return this; + } + + public CentralUserBuilder setOrgManagerUserId(String orgManagerUserId) { + this.orgManagerUserId = orgManagerUserId; + return this; + } + + public CentralUserBuilder setLocationClli(String locationClli) { + this.locationClli = locationClli; + return this; + } + + public CentralUserBuilder setBusinessCountryCode(String businessCountryCode) { + this.businessCountryCode = businessCountryCode; + return this; + } + + public CentralUserBuilder setBusinessCountryName(String businessCountryName) { + this.businessCountryName = businessCountryName; + return this; + } + + public CentralUserBuilder setBusinessUnit(String businessUnit) { + this.businessUnit = businessUnit; + return this; + } + + public CentralUserBuilder setBusinessUnitName(String businessUnitName) { + this.businessUnitName = businessUnitName; + return this; + } + + public CentralUserBuilder setDepartment(String department) { + this.department = department; + return this; + } + + public CentralUserBuilder setDepartmentName(String departmentName) { + this.departmentName = departmentName; + return this; + } + + public CentralUserBuilder setCompanyCode(String companyCode) { + this.companyCode = companyCode; + return this; + } + + public CentralUserBuilder setCompany(String company) { + this.company = company; + return this; + } + + public CentralUserBuilder setZipCodeSuffix(String zipCodeSuffix) { + this.zipCodeSuffix = zipCodeSuffix; + return this; + } + + public CentralUserBuilder setJobTitle(String jobTitle) { + this.jobTitle = jobTitle; + return this; + } + + public CentralUserBuilder setCommandChain(String commandChain) { + this.commandChain = commandChain; + return this; + } + + public CentralUserBuilder setSiloStatus(String siloStatus) { + this.siloStatus = siloStatus; + return this; + } + + public CentralUserBuilder setCostCenter(String costCenter) { + this.costCenter = costCenter; + return this; + } + + public CentralUserBuilder setFinancialLocCode(String financialLocCode) { + this.financialLocCode = financialLocCode; + return this; + } + + public CentralUserBuilder setLoginId(String loginId) { + this.loginId = loginId; + return this; + } + + public CentralUserBuilder setLoginPwd(String loginPwd) { + this.loginPwd = loginPwd; + return this; + } + + public CentralUserBuilder setLastLoginDate(Date lastLoginDate) { + this.lastLoginDate = lastLoginDate; + return this; + } + + public CentralUserBuilder setActive(boolean active) { + this.active = active; + return this; + } + + public CentralUserBuilder setInternal(boolean internal) { + this.internal = internal; + return this; + } + + public CentralUserBuilder setSelectedProfileId(Long selectedProfileId) { + this.selectedProfileId = selectedProfileId; + return this; + } + + public CentralUserBuilder setTimeZoneId(Long timeZoneId) { + this.timeZoneId = timeZoneId; + return this; + } + + public CentralUserBuilder setOnline(boolean online) { + this.online = online; + return this; + } + + public CentralUserBuilder setChatId(String chatId) { + this.chatId = chatId; + return this; + } + + public CentralUserBuilder setUserApps(Set<CentralUserApp> userApps) { + this.userApps = userApps; + return this; + } + + public CentralUser createCentralUser() { + return new CentralUser(this); + } } /** diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java index 3373ef92..3d30f9f5 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java @@ -68,11 +68,7 @@ import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; import org.onap.portalapp.portal.framework.MockitoTestSuite; import org.onap.portalapp.portal.service.ExternalAccessRolesService; import org.onap.portalapp.portal.service.ExternalAccessRolesServiceImpl; -import org.onap.portalapp.portal.transport.CentralRole; -import org.onap.portalapp.portal.transport.CentralRoleFunction; -import org.onap.portalapp.portal.transport.CentralUser; -import org.onap.portalapp.portal.transport.CentralV2Role; -import org.onap.portalapp.portal.transport.ExternalRequestFieldsValidator; +import org.onap.portalapp.portal.transport.*; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalapp.portal.utils.PortalConstants; @@ -151,11 +147,20 @@ public class ExternalAccessRolesControllerTest { @Test public void getUserTest() throws Exception { - CentralUser expectedCentralUser = new CentralUser(null, null, null, null, null, null, null, null, loginId, - loginId, loginId, loginId, loginId, loginId, loginId, null, loginId, loginId, loginId, loginId, loginId, - loginId, loginId, loginId, loginId, loginId, loginId, loginId, loginId, loginId, loginId, loginId, - loginId, loginId, loginId, loginId, loginId, loginId, loginId, loginId, loginId, loginId, loginId, - loginId, null, false, false, null, null, false, loginId, null); + CentralUser expectedCentralUser = + new CentralUser.CentralUserBuilder().setId(null).setCreated(null).setModified(null).setCreatedId(null) + .setModifiedId(null).setRowNum(null).setOrgId(null).setManagerId(null).setFirstName(loginId) + .setMiddleInitial(loginId).setLastName(loginId).setPhone(loginId).setFax(loginId) + .setCellular(loginId).setEmail(loginId).setAddressId(null).setAlertMethodCd(loginId) + .setHrid(loginId).setOrgUserId(loginId).setOrgCode(loginId).setAddress1(loginId) + .setAddress2(loginId).setCity(loginId).setState(loginId).setZipCode(loginId).setCountry(loginId) + .setOrgManagerUserId(loginId).setLocationClli(loginId).setBusinessCountryCode(loginId) + .setBusinessCountryName(loginId).setBusinessUnit(loginId).setBusinessUnitName(loginId) + .setDepartment(loginId).setDepartmentName(loginId).setCompanyCode(loginId).setCompany(loginId) + .setZipCodeSuffix(loginId).setJobTitle(loginId).setCommandChain(loginId).setSiloStatus(loginId) + .setCostCenter(loginId).setFinancialLocCode(loginId).setLoginId(loginId).setLoginPwd(loginId) + .setLastLoginDate(null).setActive(false).setInternal(false).setSelectedProfileId(null) + .setTimeZoneId(null).setOnline(false).setChatId(loginId).setUserApps(null).createCentralUser(); String loginId = "test"; StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java index b8c019b0..28292ba6 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserTest.java @@ -44,13 +44,20 @@ import java.util.HashSet; import java.util.Set; import org.junit.Test; -import org.onap.portalapp.portal.transport.CentralV2Role; -import org.onap.portalapp.portal.transport.CentralV2User; -import org.onap.portalapp.portal.transport.CentralV2UserApp; public class CentralUserTest { - CentralUser centralUser=new CentralUser(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, false, null, null, false, null, null); + CentralUser centralUser = new CentralUser.CentralUserBuilder().setId(null).setCreated(null).setModified(null) + .setCreatedId(null).setModifiedId(null).setRowNum(null).setOrgId(null).setManagerId(null).setFirstName(null) + .setMiddleInitial(null).setLastName(null).setPhone(null).setFax(null).setCellular(null).setEmail(null) + .setAddressId(null).setAlertMethodCd(null).setHrid(null).setOrgUserId(null).setOrgCode(null) + .setAddress1(null).setAddress2(null).setCity(null).setState(null).setZipCode(null).setCountry(null) + .setOrgManagerUserId(null).setLocationClli(null).setBusinessCountryCode(null).setBusinessCountryName(null) + .setBusinessUnit(null).setBusinessUnitName(null).setDepartment(null).setDepartmentName(null) + .setCompanyCode(null).setCompany(null).setZipCodeSuffix(null).setJobTitle(null).setCommandChain(null) + .setSiloStatus(null).setCostCenter(null).setFinancialLocCode(null).setLoginId(null).setLoginPwd(null) + .setLastLoginDate(null).setActive(false).setInternal(false).setSelectedProfileId(null).setTimeZoneId(null) + .setOnline(false).setChatId(null).setUserApps(null).createCentralUser(); public CentralV2User mockCentralUser(){ Set<CentralV2UserApp> userApps = new HashSet<CentralV2UserApp>(); |