MinimumCountRule implements IEventBasedRule<Integer> { @Override public boolean shouldAllowFeedbackPrompt(@NonNull final Integer cachedEventValue) { return cachedEventValue >= minimumCount; } MinimumCountRule(final int minimumCount); @Override boolean shouldAllowFeedbackPromptByDefault(); @Override boolean shouldAllowFeedbackPrompt(@NonNull final Integer cachedEventValue); @NonNull @Override String getDescription();  }
@SuppressLint("Assert") @SuppressWarnings({"ConstantConditions", "UnnecessaryLocalVariable"}) @Test public void testThatRuleAllowsPromptAtCountThreshold() { final int minimumEventCount = 7; final int currentEventCount = minimumEventCount; final MinimumCountRule minimumCountRule = new MinimumCountRule(minimumEventCount); final boolean ruleShouldAllowFeedbackPrompt = minimumCountRule.shouldAllowFeedbackPrompt(currentEventCount); assertTrue( "Feedback prompt should be allowed at the count threshold.", ruleShouldAllowFeedbackPrompt); }
@SuppressLint("Assert") @SuppressWarnings("ConstantConditions") @Test public void testThatRuleAllowsPromptIfCountThresholdHasBeenExceeded() { final int minimumEventCount = 7; final int currentEventCount = 9; assert currentEventCount > minimumEventCount; final MinimumCountRule minimumCountRule = new MinimumCountRule(minimumEventCount); final boolean ruleShouldAllowFeedbackPrompt = minimumCountRule.shouldAllowFeedbackPrompt(currentEventCount); assertTrue( "Feedback prompt should be allowed if the count threshold has been exceeded", ruleShouldAllowFeedbackPrompt); }
@SuppressLint("Assert") @SuppressWarnings("ConstantConditions") @Test public void testThatRuleBlocksPromptIfCountThresholdHasNotBeenExceeded() { final int minimumEventCount = 7; final int currentEventCount = 2; assert currentEventCount < minimumEventCount; final MinimumCountRule minimumCountRule = new MinimumCountRule(minimumEventCount); final boolean ruleShouldAllowFeedbackPrompt = minimumCountRule.shouldAllowFeedbackPrompt(currentEventCount); assertFalse( "Feedback prompt should be blocked if the count threshold is not met or exceeded", ruleShouldAllowFeedbackPrompt); }