Skip to content

Commit 592f1cb

Browse files
committed
Remove unused method + fix tests
1 parent a146047 commit 592f1cb

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,24 +228,6 @@ protected Pair<List<QuotaSummaryResponse>, Integer> getQuotaSummaryResponseWithL
228228
return getQuotaSummaryResponse(accountId, keyword, domainId, domainPath, cmd);
229229
}
230230

231-
232-
protected Long getAccountIdByAccountName(String accountName, Long domainId, Account caller) {
233-
if (ObjectUtils.anyNull(accountName, domainId)) {
234-
return null;
235-
}
236-
237-
Domain domain = domainDao.findByIdIncludingRemoved(domainId);
238-
_accountMgr.checkAccess(caller, domain);
239-
240-
Account account = _accountDao.findAccountIncludingRemoved(accountName, domainId);
241-
242-
if (account == null) {
243-
throw new InvalidParameterValueException(String.format("Account name [%s] or domain id [%s] is invalid.", accountName, domainId));
244-
}
245-
246-
return account.getAccountId();
247-
}
248-
249231
/**
250232
* Retrieves the domain path of the caller's domain (if the caller is Domain Admin) for filtering in the quota summary query.
251233
* @return null if the caller is an Admin or the domain path of the caller's domain if the caller is a Domain Admin.

plugins/database/quota/src/test/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImplTest.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,6 @@ public void createQuotaSummaryResponseTestNotListAllAndAllAccountTypesReturnsSin
554554

555555
for (Account.Type type : Account.Type.values()) {
556556
Mockito.doReturn(type).when(accountMock).getType();
557-
Mockito.doReturn("ROOT").when(quotaResponseBuilderSpy).getDomainPathByDomainIdForDomainAdmin(accountMock);
558557

559558
Pair<List<QuotaSummaryResponse>, Integer> result = quotaResponseBuilderSpy.createQuotaSummaryResponse(cmd);
560559
Assert.assertEquals(quotaSummaryResponseMock1, result);
@@ -650,37 +649,6 @@ public void getQuotaEmailConfigurationVoTestExistingConfiguration() {
650649
assertFalse(result.isEnabled());
651650
}
652651

653-
@Test
654-
public void getAccountIdByAccountNameTestAccountNameIsNullReturnsNull() {
655-
Assert.assertNull(quotaResponseBuilderSpy.getAccountIdByAccountName(null, 1l, accountMock));
656-
}
657-
658-
@Test
659-
public void getAccountIdByAccountNameTestDomainIdIsNullReturnsNull() {
660-
Assert.assertNull(quotaResponseBuilderSpy.getAccountIdByAccountName("test", null, accountMock));
661-
}
662-
663-
@Test(expected = InvalidParameterValueException.class)
664-
public void getAccountIdByAccountNameTestAccountIsNullThrowsInvalidParameterValueException() {
665-
Mockito.lenient().doNothing().when(accountManagerMock).checkAccess(Mockito.any(Account.class), Mockito.any(Domain.class));
666-
Mockito.doReturn(null).when(accountDaoMock).findAccountIncludingRemoved(Mockito.anyString(), Mockito.anyLong());
667-
668-
quotaResponseBuilderSpy.getAccountIdByAccountName("test", 1l, accountMock);
669-
}
670-
671-
@Test
672-
public void getAccountIdByAccountNameTestAccountIsNotNullReturnsAccountId() {
673-
Long expected = 61l;
674-
675-
Mockito.lenient().doNothing().when(accountManagerMock).checkAccess(Mockito.any(Account.class), Mockito.any(Domain.class));
676-
Mockito.doReturn(accountMock).when(accountDaoMock).findAccountIncludingRemoved(Mockito.anyString(), Mockito.anyLong());
677-
Mockito.doReturn(expected).when(accountMock).getAccountId();
678-
679-
Long result = quotaResponseBuilderSpy.getAccountIdByAccountName("test", 1l, accountMock);
680-
681-
Assert.assertEquals(expected, result);
682-
}
683-
684652
@Test
685653
public void validatePositionOnCreatingNewQuotaTariffTestNullValueDoNothing() {
686654
quotaResponseBuilderSpy.validatePositionOnCreatingNewQuotaTariff(quotaTariffVoMock, null);

0 commit comments

Comments
 (0)