<commit_before>package org.motechproject.testing.utils;

import org.ektorp.BulkDeleteDocument;
import org.ektorp.CouchDbConnector;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.motechproject.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
public abstract class SpringIntegrationTest extends BaseUnitTest{

    @Autowired
    protected CouchDbConnector dbConnector;

    protected ArrayList<BulkDeleteDocument> toDelete;

    @Before
    public void before() {
        toDelete = new ArrayList<BulkDeleteDocument>();
    }

    @After
    public void after() {
        deleteAll();
    }

    protected void deleteAll() {
        if (toDelete.size() > 0)
            dbConnector.executeBulk(toDelete);
        toDelete.clear();<commit_msg><NAME> | #25(WHP) | Templatizing couchdb connector as we could not autowire<commit_after>package org.motechproject.testing.utils;

import org.ektorp.BulkDeleteDocument;
import org.ektorp.CouchDbConnector;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.motechproject.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
public abstract class SpringIntegrationTest extends BaseUnitTest{

    private CouchDbConnector dbConnector;

    protected ArrayList<BulkDeleteDocument> toDelete;

    @Before
    public void before() {
        toDelete = new ArrayList<BulkDeleteDocument>();
        dbConnector = getDBConnector();
    }

    @After
    public void after() {
        deleteAll();
    }

    public abstract CouchDbConnector getDBConnector() ;

    protected void deleteAll() {
        if (toDelete.size() > 0)
            dbConnector.executeBulk(toDelete);
        toDelete.clear();
{'fraction_non_alphanumeric': 0.09276879162702188, 'fraction_numerical': 0.004757373929590866, 'mean_word_length': 4.179802955665025, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, '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': '1094421', 'n_tokens_mistral': 615, 'n_tokens_neox': 613, 'n_words': 125}