mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	framework/quota: fix checkstyle issue
Fixes enum name to supress checkstyle failure due to the latest checkstyle version Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
		
							parent
							
								
									bb29b1d063
								
							
						
					
					
						commit
						770aa0133e
					
				@ -59,11 +59,11 @@ public class QuotaStatementImpl extends ManagerBase implements QuotaStatement {
 | 
			
		||||
 | 
			
		||||
    final public static int s_LAST_STATEMENT_SENT_DAYS = 6; //ideally should be less than 7 days
 | 
			
		||||
 | 
			
		||||
    public enum STATEMENT_PERIODS {
 | 
			
		||||
    public enum QuotaStatementPeriods {
 | 
			
		||||
        BIMONTHLY, MONTHLY, QUATERLY, HALFYEARLY, YEARLY
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    private STATEMENT_PERIODS _period = STATEMENT_PERIODS.MONTHLY;
 | 
			
		||||
    private QuotaStatementPeriods _period = QuotaStatementPeriods.MONTHLY;
 | 
			
		||||
 | 
			
		||||
    public QuotaStatementImpl() {
 | 
			
		||||
        super();
 | 
			
		||||
@ -87,7 +87,7 @@ public class QuotaStatementImpl extends ManagerBase implements QuotaStatement {
 | 
			
		||||
        String period_str = configs.get(QuotaConfig.QuotaStatementPeriod.key());
 | 
			
		||||
        int period = period_str == null ? 1 : Integer.parseInt(period_str);
 | 
			
		||||
 | 
			
		||||
        STATEMENT_PERIODS _period = STATEMENT_PERIODS.values()[period];
 | 
			
		||||
        QuotaStatementPeriods _period = QuotaStatementPeriods.values()[period];
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -265,7 +265,7 @@ public class QuotaStatementImpl extends ManagerBase implements QuotaStatement {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Calendar[] statementTime(final Calendar today, final STATEMENT_PERIODS period) {
 | 
			
		||||
    public Calendar[] statementTime(final Calendar today, final QuotaStatementPeriods period) {
 | 
			
		||||
        //check if it is statement time
 | 
			
		||||
        int day_of_month = today.get(Calendar.DAY_OF_MONTH);
 | 
			
		||||
        int month_of_year = today.get(Calendar.MONTH);
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ import com.cloud.user.dao.AccountDao;
 | 
			
		||||
import com.cloud.utils.db.TransactionLegacy;
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 | 
			
		||||
import org.apache.cloudstack.quota.QuotaStatementImpl.STATEMENT_PERIODS;
 | 
			
		||||
import org.apache.cloudstack.quota.QuotaStatementImpl.QuotaStatementPeriods;
 | 
			
		||||
import org.apache.cloudstack.quota.dao.QuotaAccountDao;
 | 
			
		||||
import org.apache.cloudstack.quota.dao.QuotaUsageDao;
 | 
			
		||||
import org.apache.cloudstack.quota.vo.QuotaAccountVO;
 | 
			
		||||
@ -85,12 +85,12 @@ public class QuotaStatementTest extends TestCase {
 | 
			
		||||
 | 
			
		||||
        //BIMONTHLY - first statement of month
 | 
			
		||||
        date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, QuotaStatementPeriods.BIMONTHLY);
 | 
			
		||||
        assertTrue(period == null);
 | 
			
		||||
 | 
			
		||||
        //1 of this month
 | 
			
		||||
        date.set(Calendar.DATE, 1);
 | 
			
		||||
        period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY);
 | 
			
		||||
        period = quotaStatement.statementTime(date, QuotaStatementPeriods.BIMONTHLY);
 | 
			
		||||
        assertTrue(period != null);
 | 
			
		||||
        assertTrue(period.length == 2);
 | 
			
		||||
        assertTrue(period[0].toString(), period[0].before(period[1]));
 | 
			
		||||
@ -100,12 +100,12 @@ public class QuotaStatementTest extends TestCase {
 | 
			
		||||
        //BIMONTHLY - second statement of month
 | 
			
		||||
        date = Calendar.getInstance();
 | 
			
		||||
        date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 16);
 | 
			
		||||
        period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY);
 | 
			
		||||
        period = quotaStatement.statementTime(date, QuotaStatementPeriods.BIMONTHLY);
 | 
			
		||||
        assertTrue(period == null);
 | 
			
		||||
 | 
			
		||||
        //17 of this month
 | 
			
		||||
        date.set(Calendar.DATE, 17);
 | 
			
		||||
        period = quotaStatement.statementTime(date, STATEMENT_PERIODS.BIMONTHLY);
 | 
			
		||||
        period = quotaStatement.statementTime(date, QuotaStatementPeriods.BIMONTHLY);
 | 
			
		||||
        assertTrue(period != null);
 | 
			
		||||
        assertTrue(period.length == 2);
 | 
			
		||||
        assertTrue(period[0].toString(), period[0].before(period[1]));
 | 
			
		||||
@ -128,12 +128,12 @@ public class QuotaStatementTest extends TestCase {
 | 
			
		||||
        //MONTHLY
 | 
			
		||||
        date = Calendar.getInstance();
 | 
			
		||||
        date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.MONTHLY);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, QuotaStatementPeriods.MONTHLY);
 | 
			
		||||
        assertTrue(period == null);
 | 
			
		||||
 | 
			
		||||
        //1 of this month
 | 
			
		||||
        date.set(Calendar.DATE, QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS - 1);
 | 
			
		||||
        period = quotaStatement.statementTime(date, STATEMENT_PERIODS.MONTHLY);
 | 
			
		||||
        period = quotaStatement.statementTime(date, QuotaStatementPeriods.MONTHLY);
 | 
			
		||||
        assertTrue(period != null);
 | 
			
		||||
        assertTrue(period.length == 2);
 | 
			
		||||
        assertTrue(period[0].toString(), period[0].before(period[1]));
 | 
			
		||||
@ -157,7 +157,7 @@ public class QuotaStatementTest extends TestCase {
 | 
			
		||||
        date = Calendar.getInstance();
 | 
			
		||||
        date.set(Calendar.MONTH, Calendar.JANUARY); // 1 Jan
 | 
			
		||||
        date.set(Calendar.DATE, 1);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.QUATERLY);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, QuotaStatementPeriods.QUATERLY);
 | 
			
		||||
        assertTrue(period != null);
 | 
			
		||||
        assertTrue(period.length == 2);
 | 
			
		||||
        assertTrue("period[0].before(period[1])" + period[0].toString(), period[0].before(period[1]));
 | 
			
		||||
@ -182,7 +182,7 @@ public class QuotaStatementTest extends TestCase {
 | 
			
		||||
        date = Calendar.getInstance();
 | 
			
		||||
        date.set(Calendar.MONTH, Calendar.JANUARY); // 1 Jan
 | 
			
		||||
        date.set(Calendar.DATE, 1);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.HALFYEARLY);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, QuotaStatementPeriods.HALFYEARLY);
 | 
			
		||||
        assertTrue(period != null);
 | 
			
		||||
        assertTrue(period.length == 2);
 | 
			
		||||
        assertTrue("period[0].before(period[1])" + period[0].toString(), period[0].before(period[1]));
 | 
			
		||||
@ -207,7 +207,7 @@ public class QuotaStatementTest extends TestCase {
 | 
			
		||||
        date = Calendar.getInstance();
 | 
			
		||||
        date.set(Calendar.MONTH, Calendar.JANUARY); // 1 Jan
 | 
			
		||||
        date.set(Calendar.DATE, 1);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.YEARLY);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, QuotaStatementPeriods.YEARLY);
 | 
			
		||||
        assertTrue("period != null", period != null);
 | 
			
		||||
        assertTrue(period.length == 2);
 | 
			
		||||
        assertTrue("period[0].before(period[1])" + period[0].toString(), period[0].before(period[1]));
 | 
			
		||||
@ -244,7 +244,7 @@ public class QuotaStatementTest extends TestCase {
 | 
			
		||||
 | 
			
		||||
        // call real method on send monthly statement
 | 
			
		||||
        quotaStatement.sendStatement();
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, STATEMENT_PERIODS.MONTHLY);
 | 
			
		||||
        Calendar period[] = quotaStatement.statementTime(date, QuotaStatementPeriods.MONTHLY);
 | 
			
		||||
        if (period != null){
 | 
			
		||||
            Mockito.verify(alertManager, Mockito.times(1)).sendQuotaAlert(Mockito.any(QuotaAlertManagerImpl.DeferredQuotaEmail.class));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user