### Question:
SubmissionTimePolicy implements DeliveryPolicy { @Override public boolean isAllowed() { long timeSinceSubmission = System.currentTimeMillis() - lastSubmittedTime; return timeSinceSubmission > waitInterval; } SubmissionTimePolicy(AnalyticsContext context, Long waitInterval); @Override boolean isAllowed(); @Override void handleDeliveryAttempt(boolean successful);  }### Answer:
@Test public void isAllowed_notEnoughTimeHasPassed_policyIsFalse() { when(mockPreferences.getLong("SubmissionTimePolicy.submissionTime", 0)).thenReturn( System.currentTimeMillis() - 500l); SubmissionTimePolicy target = new SubmissionTimePolicy(mockContext, 1000l); assertThat(target.isAllowed(), is(false)); }
@Test public void isAllowed_enoughTimeHasPassed_policyIsTrue() { when(mockPreferences.getLong("SubmissionTimePolicy.submissionTime", 0)).thenReturn( System.currentTimeMillis() - 2000l); SubmissionTimePolicy target = new SubmissionTimePolicy(mockContext, 1000l); assertThat(target.isAllowed(), is(true)); }