<commit_before>package org.sagebionetworks.bridge.services.backfill;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.junit.Test;
import org.sagebionetworks.bridge.dao.DistributedLockDao;
import org.sagebionetworks.bridge.models.BackfillRecord;
import org.sagebionetworks.bridge.models.BackfillTask;

public class AsyncBackfillTemplateTest {

    @Test
    public void test() throws Exception {
        AsyncBackfillTemplate backfillTemplate = new TestBackfillService();
        DistributedLockDao lockDao = mock(DistributedLockDao.class);
        when(lockDao.acquireLock(TestBackfillService.class, TestBackfillService.class.getSimpleName()))
                .thenReturn("abc");
        backfillTemplate.setDistributedLockDao(lockDao);
        BackfillCallback callback = mock(BackfillCallback.class);
        backfillTemplate.backfill("test user", "test backfill", callback);
        Thread.sleep(1000L);
        verify(callback, times(1)).start(any(BackfillTask.class));
        verify(callback, times(1)).newRecords(any(BackfillRecord.class));
        verify(callback, times(1)).newRecords(any(BackfillRecord.class), any(BackfillRecord.class));
        verify(callback, times(1)).done();
    }
}<commit_msg>Fix test failure<commit_after>package org.sagebionetworks.bridge.services.backfill;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.Test;
import org.sagebionetworks.bridge.dao.BackfillDao;
import org.sagebionetworks.bridge.dao.DistributedLockDao;
import org.sagebionetworks.bridge.models.BackfillRecord;
import org.sagebionetworks.bridge.models.BackfillStatus;
import org.sagebionetworks.bridge.models.BackfillTask;

public class AsyncBackfillTemplateTest {

    @Test
    public void test() throws Exception {

        AsyncBackfillTemplate backfillTemplate = new TestBackfillService();
        DistributedLockDao lockDao = mock(DistributedLockDao.class);
        when(lockDao.acquireLock(TestBackfillService.class, TestBackfillService.class.getSimpleName()))
                .thenReturn("abc");
        backfillTemplate.setDistributedLockDao(lockDao);

        BackfillTask backfillTask = new BackfillTask() {
            @Override
            public String getId() {
                return "taskId";
            }
            @Override
            public long getTimestamp() {
                return DateTime.now(DateTimeZone.UTC).getMillis();
            }
            @Override
            public String getName() {
                return "test backfill";
            }
            @Override
            public String getUser() {
                return "test user";
            }
            @Override
            public String getStatus() {
                return BackfillStatus.SUBMITTED.name();
            }
        };
        BackfillDao backfillDao = mock(BackfillDao.class);
        when(backfillDao.createTask("test backfill", "test user")).thenReturn(backfillTask);
        backfillTemplate.setBackfillDao(backfillDao);

        BackfillCallback callback = mock(BackfillCallback.class);
        backfillTemplate.backfill("test user", "test backfill", callback);
        Thread.sleep(1000L);
        verify(callback, times(1)).start(any(BackfillTask.class));
        verify(callback, times(1)).newRecords(any(BackfillRecord.class));
        verify(callback, times(1)).newRecords(any(BackfillRecord.class), any(BackfillRecord.class));
        verify(callback, times(1)).done();
    }
}
{'fraction_non_alphanumeric': 0.10380078636959371, 'fraction_numerical': 0.0041939711664482305, 'mean_word_length': 3.361142857142857, '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': '6964287', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1084, 'n_words': 180}