mirror of https://github.com/apache/cloudstack.git
Fix failing tests
This commit is contained in:
parent
54ce551db6
commit
cc7db602fe
|
|
@ -23,9 +23,7 @@ import static org.mockito.ArgumentMatchers.nullable;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
|
||||
import org.apache.cloudstack.api.response.QuotaResponseBuilder;
|
||||
import org.apache.cloudstack.quota.QuotaService;
|
||||
|
|
@ -78,22 +76,12 @@ public class QuotaCreditsCmdTest extends TestCase {
|
|||
AccountVO acc = new AccountVO();
|
||||
acc.setId(2L);
|
||||
|
||||
Mockito.when(accountService.getActiveAccountByName(nullable(String.class), nullable(Long.class))).thenReturn(acc);
|
||||
|
||||
Mockito.when(responseBuilder.addQuotaCredits(cmd)).thenReturn(new QuotaCreditsResponse());
|
||||
|
||||
// No value provided test
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (ServerApiException e) {
|
||||
assertTrue(e.getErrorCode().equals(ApiErrorCode.PARAM_ERROR));
|
||||
}
|
||||
|
||||
// With value provided test
|
||||
cmd.setValue(11.80);
|
||||
cmd.execute();
|
||||
Mockito.verify(quotaService, Mockito.times(0)).setLockAccount(anyLong(), anyBoolean());
|
||||
Mockito.verify(quotaService, Mockito.times(1)).setMinBalance(anyLong(), anyDouble());
|
||||
|
||||
Mockito.verify(responseBuilder, Mockito.times(1)).addQuotaCredits(cmd);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1303,11 +1303,13 @@ public class QuotaResponseBuilderImplTest extends TestCase {
|
|||
record1.setStartDate(now);
|
||||
record1.setEndDate(now);
|
||||
record1.setQuotaUsed(null);
|
||||
record1.setUsageItemId(10L);
|
||||
|
||||
QuotaUsageJoinVO record2 = new QuotaUsageJoinVO();
|
||||
record2.setStartDate(new Date(now.getTime() + 1000));
|
||||
record2.setEndDate(new Date(now.getTime() + 1000));
|
||||
record2.setQuotaUsed(BigDecimal.valueOf(10));
|
||||
record2.setUsageItemId(11L);
|
||||
|
||||
usageRecords.add(record1);
|
||||
usageRecords.add(record2);
|
||||
|
|
@ -1330,22 +1332,25 @@ public class QuotaResponseBuilderImplTest extends TestCase {
|
|||
record1.setStartDate(now);
|
||||
record1.setEndDate(new Date(now.getTime() + 1000));
|
||||
record1.setQuotaUsed(BigDecimal.valueOf(5));
|
||||
record1.setUsageItemId(10L);
|
||||
|
||||
QuotaUsageJoinVO record2 = new QuotaUsageJoinVO();
|
||||
record2.setStartDate(new Date(now.getTime() + 2000));
|
||||
record2.setEndDate(new Date(now.getTime() + 3000));
|
||||
record2.setQuotaUsed(BigDecimal.valueOf(15));
|
||||
record2.setUsageItemId(11L);
|
||||
|
||||
QuotaUsageJoinVO record3 = new QuotaUsageJoinVO();
|
||||
record3.setStartDate(new Date(now.getTime() + 2000));
|
||||
record3.setEndDate(new Date(now.getTime() + 3000));
|
||||
record3.setQuotaUsed(BigDecimal.valueOf(5));
|
||||
record3.setUsageItemId(11L);
|
||||
|
||||
usageRecords.add(record1);
|
||||
usageRecords.add(record2);
|
||||
usageRecords.add(record3);
|
||||
|
||||
BigDecimal totalQuotaUsed = BigDecimal.valueOf(20);
|
||||
BigDecimal totalQuotaUsed = BigDecimal.valueOf(25);
|
||||
|
||||
List<QuotaStatementItemHistoryResponse> result = quotaResponseBuilderSpy.createQuotaConsumptionHistory(usageRecords, totalQuotaUsed);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue