Search in sources :

Example 1 with QuotaStatementResponse

use of org.apache.cloudstack.api.response.QuotaStatementResponse in project cloudstack by apache.

the class QuotaStatementCmdTest method testQuotaStatementCmd.

@Test
public void testQuotaStatementCmd() throws NoSuchFieldException, IllegalAccessException {
    QuotaStatementCmd cmd = new QuotaStatementCmd();
    cmd.setAccountName("admin");
    Field rbField = QuotaStatementCmd.class.getDeclaredField("_responseBuilder");
    rbField.setAccessible(true);
    rbField.set(cmd, responseBuilder);
    List<QuotaUsageVO> quotaUsageVOList = new ArrayList<QuotaUsageVO>();
    Mockito.when(responseBuilder.getQuotaUsage(Mockito.eq(cmd))).thenReturn(quotaUsageVOList);
    Mockito.when(responseBuilder.createQuotaStatementResponse(Mockito.eq(quotaUsageVOList))).thenReturn(new QuotaStatementResponse());
    cmd.execute();
    Mockito.verify(responseBuilder, Mockito.times(1)).getQuotaUsage(Mockito.eq(cmd));
}
Also used : Field(java.lang.reflect.Field) QuotaStatementResponse(org.apache.cloudstack.api.response.QuotaStatementResponse) ArrayList(java.util.ArrayList) QuotaUsageVO(org.apache.cloudstack.quota.vo.QuotaUsageVO) Test(org.junit.Test)

Example 2 with QuotaStatementResponse

use of org.apache.cloudstack.api.response.QuotaStatementResponse in project cloudstack by apache.

the class QuotaStatementCmd method execute.

@Override
public void execute() {
    List<QuotaUsageVO> quotaUsage = _responseBuilder.getQuotaUsage(this);
    QuotaStatementResponse response = _responseBuilder.createQuotaStatementResponse(quotaUsage);
    response.setStartDate(startDate == null ? null : new Date(startDate.getTime()));
    response.setEndDate(endDate == null ? null : new Date(endDate.getTime()));
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : QuotaStatementResponse(org.apache.cloudstack.api.response.QuotaStatementResponse) Date(java.util.Date) QuotaUsageVO(org.apache.cloudstack.quota.vo.QuotaUsageVO)

Aggregations

QuotaStatementResponse (org.apache.cloudstack.api.response.QuotaStatementResponse)2 QuotaUsageVO (org.apache.cloudstack.quota.vo.QuotaUsageVO)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1