<commit_before>package org.motechproject.aggregator.aggregation;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.Trigger;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.initMocks;

public class AggregationSchedulerTest {
    public static final String JOB_NAME = "REAPER";
    public static final String JOB_GROUP = "REAPER-GROUP";
    @Mock
    private SchedulerFactoryBean schedulerFactoryBean;
    @Mock
    private Trigger trigger;
    @Mock
    private JobDetail reaperJob;
    @Mock
    private Scheduler scheduler;

    @Before
    public void setUp() throws Exception {
        initMocks(this);
        when(schedulerFactoryBean.getScheduler()).thenReturn(scheduler);
        when(reaperJob.getKey()).thenReturn(new JobKey(JOB_NAME, JOB_GROUP));
    }

    @Test
    public void shouldRemoveOldScheduleJobWhenItExists() throws Exception {
        JobKey jobKey = new JobKey(JOB_NAME, JOB_GROUP);
        when(scheduler.getJobDetail(jobKey)).thenReturn(reaperJob);

        new AggregationScheduler(schedulerFactoryBean, trigger, reaperJob);

        verify(scheduler).deleteJob(jobKey);
    }

    @Test
    public void shouldNotTryAndRemoveOldScheduleJobWhenItDoesNotExist() throws Exception {
        JobKey jobKey = new JobKey(JOB_NAME, JOB_GROUP);
        when(scheduler.getJobDetail(jobKey)).thenReturn(null);

        new AggregationScheduler(schedulerFactoryBean, trigger, reaperJob);

        verify(scheduler, times(0)).deleteJob(jobKey);
    }

    @Test
    public void shouldScheduleANewRepeatingJob() throws Exception {
        JobKey jobKey = new JobKey(JOB_NAME, JOB_GROUP);
        when(scheduler.getJobDetail(jobKey)).thenReturn(reaperJob);

        new AggregationScheduler(schedulerFactoryBean, trigger, reaperJob);

        verify(scheduler).deleteJob(jobKey);
        verify(scheduler).scheduleJob(reaperJob, trigger);
    }
}<commit_msg>Fixed compilation issues. modified quartz schema.<commit_after>package org.motechproject.aggregator.aggregation;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.Trigger;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.initMocks;

public class AggregationSchedulerTest {
    public static final String JOB_NAME = "REAPER";
    public static final String JOB_GROUP = "REAPER-GROUP";
    @Mock
    private SchedulerFactoryBean schedulerFactoryBean;
    @Mock
    private Trigger trigger;
    @Mock
    private JobDetail reaperJob;
    @Mock
    private Scheduler scheduler;
    private JobKey jobKey;

    @Before
    public void setUp() throws Exception {
        initMocks(this);
        jobKey = new JobKey(JOB_NAME, JOB_GROUP);

        when(schedulerFactoryBean.getScheduler()).thenReturn(scheduler);
        when(reaperJob.getKey()).thenReturn(jobKey);
    }

    @Test
    public void shouldRemoveOldScheduleJobWhenItExists() throws Exception {
        when(scheduler.getJobDetail(jobKey)).thenReturn(reaperJob);

        new AggregationScheduler(schedulerFactoryBean, trigger, reaperJob);

        verify(scheduler).deleteJob(jobKey);
    }

    @Test
    public void shouldNotTryAndRemoveOldScheduleJobWhenItDoesNotExist() throws Exception {
        when(scheduler.getJobDetail(jobKey)).thenReturn(null);

        new AggregationScheduler(schedulerFactoryBean, trigger, reaperJob);

        verify(scheduler, times(0)).deleteJob(jobKey);
    }

    @Test
    public void shouldScheduleANewRepeatingJob() throws Exception {
        when(scheduler.getJobDetail(jobKey)).thenReturn(reaperJob);

        new AggregationScheduler(schedulerFactoryBean, trigger, reaperJob);

        verify(scheduler).deleteJob(jobKey);
        verify(scheduler).scheduleJob(reaperJob, trigger);
    }
}
{'fraction_non_alphanumeric': 0.0899368011667477, 'fraction_numerical': 0.0004861448711716091, 'mean_word_length': 4.176100628930818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3639405', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1192, 'n_words': 235}