Skip to content

Commit

Permalink
framework/quota: fix checkstyle issue
Browse files Browse the repository at this point in the history
Fixes enum name to supress checkstyle failure due to the latest checkstyle
version

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
  • Loading branch information
rohityadavcloud committed Apr 22, 2016
1 parent bb29b1d commit 770aa01
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -87,7 +87,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
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;
}

Expand Down Expand Up @@ -265,7 +265,7 @@ public Calendar[] getCurrentStatementTime() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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;
Expand Down Expand Up @@ -85,12 +85,12 @@ public void testStatementPeriodBIMONTHLY() {

//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]));
Expand All @@ -100,12 +100,12 @@ public void testStatementPeriodBIMONTHLY() {
//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]));
Expand All @@ -128,12 +128,12 @@ public void testStatementPeriodMONTHLY() {
//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]));
Expand All @@ -157,7 +157,7 @@ public void testStatementPeriodQUATERLY() {
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]));
Expand All @@ -182,7 +182,7 @@ public void testStatementPeriodHALFYEARLY() {
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]));
Expand All @@ -207,7 +207,7 @@ public void testStatementPeriodYEARLY() {
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]));
Expand Down Expand Up @@ -244,7 +244,7 @@ public void testSendStatement() throws UnsupportedEncodingException, MessagingEx

// 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));
}
Expand Down

0 comments on commit 770aa01

Please sign in to comment.