@Test public void should_return_true_if_surveys_count_is_equal_to_threshold_and_difference_time_is_equal_to_threshold() { List<Survey> surveys = givenThereAre30SurveysIn2Hours(); SurveysThresholds surveyThreshold = new SurveysThresholdBuilder() .withCount(30) .withTimeHour(2) .build(); boolean isOverLimit = OverLimitSurveysDomainService.isSurveysOverLimit(surveys, surveyThreshold); assertThat(isOverLimit, is(true)); }
public static boolean isSurveysOverLimit(List<Survey> surveys, SurveysThresholds surveysThresholds) { if (surveysThresholds.getCount() > 0 && surveysThresholds.getTimeHours() > 0 && surveys.size() >= surveysThresholds.getCount()) { sortSurveysByDate(surveys); long firstSurveyDate = surveys.get(0).getSurveyDate().getTime(); long lastSurveyDate = surveys.get(surveys.size() - 1).getSurveyDate().getTime(); long timeDifference = TimeUnit.MILLISECONDS.toHours(lastSurveyDate - firstSurveyDate); return (timeDifference <= surveysThresholds.getTimeHours()); } return false; }
OverLimitSurveysDomainService { public static boolean isSurveysOverLimit(List<Survey> surveys, SurveysThresholds surveysThresholds) { if (surveysThresholds.getCount() > 0 && surveysThresholds.getTimeHours() > 0 && surveys.size() >= surveysThresholds.getCount()) { sortSurveysByDate(surveys); long firstSurveyDate = surveys.get(0).getSurveyDate().getTime(); long lastSurveyDate = surveys.get(surveys.size() - 1).getSurveyDate().getTime(); long timeDifference = TimeUnit.MILLISECONDS.toHours(lastSurveyDate - firstSurveyDate); return (timeDifference <= surveysThresholds.getTimeHours()); } return false; } }
OverLimitSurveysDomainService { public static boolean isSurveysOverLimit(List<Survey> surveys, SurveysThresholds surveysThresholds) { if (surveysThresholds.getCount() > 0 && surveysThresholds.getTimeHours() > 0 && surveys.size() >= surveysThresholds.getCount()) { sortSurveysByDate(surveys); long firstSurveyDate = surveys.get(0).getSurveyDate().getTime(); long lastSurveyDate = surveys.get(surveys.size() - 1).getSurveyDate().getTime(); long timeDifference = TimeUnit.MILLISECONDS.toHours(lastSurveyDate - firstSurveyDate); return (timeDifference <= surveysThresholds.getTimeHours()); } return false; }  }
OverLimitSurveysDomainService { public static boolean isSurveysOverLimit(List<Survey> surveys, SurveysThresholds surveysThresholds) { if (surveysThresholds.getCount() > 0 && surveysThresholds.getTimeHours() > 0 && surveys.size() >= surveysThresholds.getCount()) { sortSurveysByDate(surveys); long firstSurveyDate = surveys.get(0).getSurveyDate().getTime(); long lastSurveyDate = surveys.get(surveys.size() - 1).getSurveyDate().getTime(); long timeDifference = TimeUnit.MILLISECONDS.toHours(lastSurveyDate - firstSurveyDate); return (timeDifference <= surveysThresholds.getTimeHours()); } return false; }  static boolean isSurveysOverLimit(List<Survey> surveys,
            SurveysThresholds surveysThresholds); }
OverLimitSurveysDomainService { public static boolean isSurveysOverLimit(List<Survey> surveys, SurveysThresholds surveysThresholds) { if (surveysThresholds.getCount() > 0 && surveysThresholds.getTimeHours() > 0 && surveys.size() >= surveysThresholds.getCount()) { sortSurveysByDate(surveys); long firstSurveyDate = surveys.get(0).getSurveyDate().getTime(); long lastSurveyDate = surveys.get(surveys.size() - 1).getSurveyDate().getTime(); long timeDifference = TimeUnit.MILLISECONDS.toHours(lastSurveyDate - firstSurveyDate); return (timeDifference <= surveysThresholds.getTimeHours()); } return false; }  static boolean isSurveysOverLimit(List<Survey> surveys,
            SurveysThresholds surveysThresholds);  }