Search in sources :

Example 1 with Survey

use of org.eyeseetea.malariacare.domain.entity.Survey in project pictureapp by EyeSeeTea.

the class SurveyLocalDataSource method getLastSentSurveys.

@Override
public List<Survey> getLastSentSurveys(int count) {
    List<Survey> surveys = new ArrayList<>();
    List<org.eyeseetea.malariacare.data.database.model.Survey> surveysInDB = org.eyeseetea.malariacare.data.database.model.Survey.getAllHideAndSentSurveys(count);
    for (org.eyeseetea.malariacare.data.database.model.Survey surveyDB : surveysInDB) {
        Survey survey = new Survey(surveyDB.getEventDate());
        surveys.add(survey);
    }
    return surveys;
}
Also used : Survey(org.eyeseetea.malariacare.domain.entity.Survey) ArrayList(java.util.ArrayList)

Example 2 with Survey

use of org.eyeseetea.malariacare.domain.entity.Survey in project pictureapp by EyeSeeTea.

the class OverLimitSurveysDomainServiceTest method should_return_false_if_surveys_count_is_under_threshold_and_difference_time_is_over_threshold.

@Test
public void should_return_false_if_surveys_count_is_under_threshold_and_difference_time_is_over_threshold() {
    List<Survey> surveys = givenThereAre30SurveysIn2Hours();
    SurveysThresholds surveyThreshold = new SurveysThresholdBuilder().withCount(40).withTimeHour(1).build();
    boolean isOverLimit = OverLimitSurveysDomainService.isSurveysOverLimit(surveys, surveyThreshold);
    assertThat(isOverLimit, is(false));
}
Also used : Survey(org.eyeseetea.malariacare.domain.entity.Survey) SurveysThresholds(org.eyeseetea.malariacare.domain.usecase.push.SurveysThresholds) Test(org.junit.Test)

Example 3 with Survey

use of org.eyeseetea.malariacare.domain.entity.Survey in project pictureapp by EyeSeeTea.

the class OverLimitSurveysDomainServiceTest method should_return_false_if_time_hours_threshold_is_equal_to_0.

@Test
public void should_return_false_if_time_hours_threshold_is_equal_to_0() {
    List<Survey> surveys = givenThereAre30SurveysIn2Hours();
    SurveysThresholds surveyThreshold = new SurveysThresholdBuilder().withCount(20).withTimeHour(0).build();
    boolean isOverLimit = OverLimitSurveysDomainService.isSurveysOverLimit(surveys, surveyThreshold);
    assertThat(isOverLimit, is(false));
}
Also used : Survey(org.eyeseetea.malariacare.domain.entity.Survey) SurveysThresholds(org.eyeseetea.malariacare.domain.usecase.push.SurveysThresholds) Test(org.junit.Test)

Example 4 with Survey

use of org.eyeseetea.malariacare.domain.entity.Survey in project pictureapp by EyeSeeTea.

the class OverLimitSurveysDomainServiceTest method should_return_false_if_count_threshold_is_equal_to_0.

@Test
public void should_return_false_if_count_threshold_is_equal_to_0() {
    List<Survey> surveys = givenThereAre30SurveysIn2Hours();
    SurveysThresholds surveyThreshold = new SurveysThresholdBuilder().withCount(0).withTimeHour(1).build();
    boolean isOverLimit = OverLimitSurveysDomainService.isSurveysOverLimit(surveys, surveyThreshold);
    assertThat(isOverLimit, is(false));
}
Also used : Survey(org.eyeseetea.malariacare.domain.entity.Survey) SurveysThresholds(org.eyeseetea.malariacare.domain.usecase.push.SurveysThresholds) Test(org.junit.Test)

Example 5 with Survey

use of org.eyeseetea.malariacare.domain.entity.Survey in project pictureapp by EyeSeeTea.

the class OverLimitSurveysDomainServiceTest method should_return_true_if_surveys_count_is_equal_to_threshold_and_difference_time_is_equal_to_threshold.

@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));
}
Also used : Survey(org.eyeseetea.malariacare.domain.entity.Survey) SurveysThresholds(org.eyeseetea.malariacare.domain.usecase.push.SurveysThresholds) Test(org.junit.Test)

Aggregations

Survey (org.eyeseetea.malariacare.domain.entity.Survey)10 SurveysThresholds (org.eyeseetea.malariacare.domain.usecase.push.SurveysThresholds)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)2 Date (java.util.Date)1