@SuppressLint("Assert") @SuppressWarnings("ConstantConditions") @Test public void testThatRuleBlocksPromptIfCooldownPeriodHasNotPassed() { final int cooldownTimeDays = 7; final int daysSinceLastEvent = 2; assert daysSinceLastEvent < cooldownTimeDays; final CooldownDaysRule cooldownDaysRule = new CooldownDaysRule(cooldownTimeDays); final long lastEventTime = SystemTimeUtil.currentTimeMillis() - TimeUnit.DAYS.toMillis(daysSinceLastEvent); final boolean ruleShouldAllowFeedbackPrompt = cooldownDaysRule.shouldAllowFeedbackPrompt(lastEventTime); assertFalse( "Feedback prompt should be blocked if the cooldown period has not passed", ruleShouldAllowFeedbackPrompt); }
@Override public boolean shouldAllowFeedbackPrompt(@NonNull final Long cachedEventValue) { return (SystemTimeUtil.currentTimeMillis() - cachedEventValue) >= DAYS.toMillis(cooldownPeriodDays); }
CooldownDaysRule implements IEventBasedRule<Long> { @Override public boolean shouldAllowFeedbackPrompt(@NonNull final Long cachedEventValue) { return (SystemTimeUtil.currentTimeMillis() - cachedEventValue) >= DAYS.toMillis(cooldownPeriodDays); } }
CooldownDaysRule implements IEventBasedRule<Long> { @Override public boolean shouldAllowFeedbackPrompt(@NonNull final Long cachedEventValue) { return (SystemTimeUtil.currentTimeMillis() - cachedEventValue) >= DAYS.toMillis(cooldownPeriodDays); } CooldownDaysRule(final long cooldownPeriodDays); }
CooldownDaysRule implements IEventBasedRule<Long> { @Override public boolean shouldAllowFeedbackPrompt(@NonNull final Long cachedEventValue) { return (SystemTimeUtil.currentTimeMillis() - cachedEventValue) >= DAYS.toMillis(cooldownPeriodDays); } CooldownDaysRule(final long cooldownPeriodDays); @Override boolean shouldAllowFeedbackPromptByDefault(); @Override boolean shouldAllowFeedbackPrompt(@NonNull final Long cachedEventValue); @NonNull @Override String getDescription(); }
CooldownDaysRule implements IEventBasedRule<Long> { @Override public boolean shouldAllowFeedbackPrompt(@NonNull final Long cachedEventValue) { return (SystemTimeUtil.currentTimeMillis() - cachedEventValue) >= DAYS.toMillis(cooldownPeriodDays); } CooldownDaysRule(final long cooldownPeriodDays); @Override boolean shouldAllowFeedbackPromptByDefault(); @Override boolean shouldAllowFeedbackPrompt(@NonNull final Long cachedEventValue); @NonNull @Override String getDescription();  }