<commit_before>package org.motechproject.scheduler.builder;

import org.apache.commons.lang.time.DateUtils;
import org.joda.time.LocalDate;
import org.junit.Ignore;
import org.junit.Test;
import org.motechproject.model.Time;
import org.motechproject.util.DateUtil;
import org.quartz.CronExpression;

import static org.junit.Assert.assertEquals;

public class CronJobSimpleExpressionBuilderTest {
    @Test
    public void testBuild() {
        CronJobSimpleExpressionBuilder builder = new CronJobSimpleExpressionBuilder(new Time(10, 25));
        assertEquals("0 25 10 * * ?", builder.build());
    }

    @Test
    public void shouldBuildValidCronExpressionWithDayRepeat() {
        String expression = new CronJobSimpleExpressionBuilder(new Time(10, 25)).withRepeatIntervalInDays(7).build();
        assertEquals("0 25 10 */7 * ?", expression);
    }

    @Ignore
    @Test
    public void shouldScheduleJobEvery7Days() throws Exception {
        CronExpression cronExpression = new CronExpression("0 0 0 */7 * ?");
        LocalDate today = DateUtil.today();
        LocalDate nextDate = today.plusDays(7);
        LocalDate nextToNextDate = nextDate.plusDays(7);
        System.out.println(cronExpression.getNextValidTimeAfter(DateUtils.addHours(today.toDate(), -1)));
        System.out.println(cronExpression.getNextValidTimeAfter(DateUtils.addHours(nextDate.toDate(), -1)));
        assertEquals(nextDate.toDate(), cronExpression.getNextValidTimeAfter(DateUtils.addHours(today.toDate(), -1)));
        assertEquals(nextToNextDate.toDate(), cronExpression.getNextValidTimeAfter(DateUtils.addHours(nextDate.toDate(), -1)));
    }
}<commit_msg>Mingle-64|Modified the test for scheduling jobs every 7 days. <Raja|Sanchit><commit_after>package org.motechproject.scheduler.builder;

import org.joda.time.Duration;
import org.joda.time.LocalDate;
import org.junit.Test;
import org.motechproject.model.Time;
import org.motechproject.util.DateUtil;
import org.quartz.SimpleTrigger;

import static org.junit.Assert.assertEquals;

public class CronJobSimpleExpressionBuilderTest {
    @Test
    public void testBuild() {
        CronJobSimpleExpressionBuilder builder = new CronJobSimpleExpressionBuilder(new Time(10, 25));
        assertEquals("0 25 10 * * ?", builder.build());
    }

    @Test
    public void shouldBuildValidCronExpressionWithDayRepeat() {
        String expression = new CronJobSimpleExpressionBuilder(new Time(10, 25)).withRepeatIntervalInDays(7).build();
        assertEquals("0 25 10 */7 * ?", expression);
    }

    @Test
    public void shouldScheduleJobEverySevenDays() {
        SimpleTrigger trigger = new SimpleTrigger("triggerName", "groupName", DateUtil.today().toDate(), null, SimpleTrigger.REPEAT_INDEFINITELY, Duration.standardDays(7).getMillis());
        LocalDate today = DateUtil.today();
        LocalDate nextDate = today.plusDays(7);
        LocalDate nextToNextDate = nextDate.plusDays(7);

        assertEquals(nextDate.toDate(), trigger.getFireTimeAfter(today.toDate()));
        assertEquals(nextToNextDate.toDate(), trigger.getFireTimeAfter(nextDate.toDate()));
    }

}
{'fraction_non_alphanumeric': 0.11428571428571428, 'fraction_numerical': 0.018298555377207062, 'mean_word_length': 4.476274165202109, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3409320', 'n_tokens_mistral': 958, 'n_tokens_neox': 883, 'n_words': 168}