Github user agneya2001 commented on the pull request:
https://github.com/apache/cloudstack/pull/1350#issuecomment-175931632
This code that was suggested:
private AccountVO createAccountVoForType(short type) {
AccountVO accountVO = new AccountVO();
accountVO.setType(type);
return accountVO;
}
@Test
public void testAdminLockableAccount() {
AccountVO accountVO =
createAccountVoForType(Account.ACCOUNT_TYPE_ADMIN);
assertFalse(quotaManager.isLockable(accountVO));
}
@Test
public void testAdminLockableAccount() {
AccountVO accountVO =
createAccountVoForType(Account.ACCOUNT_TYPE_ADMIN);
assertFalse(quotaManager.isLockable(accountVO));
}
and this code that will otherwise be:
@Test
public void testResourceDomainAdminLockableAccount() {
AccountVO accountVO = new AccountVO();
accountVO.setType(Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN);
assertFalse(quotaManager.isLockable(accountVO));
}
@Test
public void testProjectLockableAccount() {
AccountVO accountVO = new AccountVO();
accountVO.setType(Account.ACCOUNT_TYPE_PROJECT);
assertFalse(quotaManager.isLockable(accountVO));
}
@rafaelweingartner To me the code below looks simple and more readable.
(In general if this was not the test code some of this code will be in
constructor. Coming to constructors, there is much more repeatable code there
in many cloudstack classes.) Now this might not look good to you and some
others too. I suggest if that is the case take some effort and put up a code
style guideline or at least adopt a guideline that already exists so that we
donot have to go thru this. This will also be food for further cleanup as
findbug and code style check already are CC: @bhaisaab @remibergsma
@DaanHoogland @cristofolini. Till then this stands as it is.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---