Skip to content

Commit

Permalink
Issue #0000 refactor:Fix getMonthRange method in api CommonUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
sowmya-dixit committed Jan 2, 2020
1 parent 117b2d5 commit 7c38e36
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ekstep.analytics.api.util

import org.ekstep.analytics.api.util.CommonUtil.monthPeriod
import org.ekstep.analytics.api.{BaseSpec, Range, ResponseCode}
import org.joda.time.format.{DateTimeFormat, DateTimeFormatter}
import org.joda.time.{DateTime, DateTimeZone, Duration}
Expand All @@ -14,7 +15,7 @@ class TestCommonUtil extends BaseSpec {
val thisYear: Int = (new DateTime).getYear
val thisMonth: Int = (new DateTime).getMonthOfYear
val thisWeekNo = (new DateTime).getWeekOfWeekyear
val monthYear = Integer.parseInt(s"$thisYear"+s"$thisMonth")
val monthYear = monthPeriod.print(new DateTime).toInt

val now = DateTime.now(DateTimeZone.UTC)
val dateInt = Integer.parseInt(dateFormat.print(now).replace("-", ""))
Expand All @@ -32,7 +33,8 @@ class TestCommonUtil extends BaseSpec {
resp3.params.status should be("successful");
resp3.result.get should be(Map("ttl" -> 24.asInstanceOf[AnyRef]));
CommonUtil.getDayRange(7) should be(Range(Integer.parseInt(dateFormat.print(now.minusDays(7)).replace("-", "")), dateInt))
CommonUtil.getMonthRange(2) should be(Range(monthYear-2, monthYear))
val startMonth = monthPeriod.print((new DateTime).minusMonths(2)).toInt
CommonUtil.getMonthRange(2) should be(Range(startMonth, monthYear))
CommonUtil.getRemainingHours() should be(remainingTime)
CommonUtil.getWeeksBetween(1451650400000L, 1454650400000L) should be(5);

Expand Down

0 comments on commit 7c38e36

Please sign in to comment.