<commit_before>package edu.northwestern.bioinformatics.studycalendar.osgi.providers;

import edu.northwestern.bioinformatics.studycalendar.dataproviders.api.SiteProvider;
import edu.northwestern.bioinformatics.studycalendar.dataproviders.mock.MockDataProviderTools;
import edu.northwestern.bioinformatics.studycalendar.domain.Fixtures;
import edu.northwestern.bioinformatics.studycalendar.domain.Site;
import edu.northwestern.bioinformatics.studycalendar.osgi.OsgiLayerIntegratedTestCase;
import static edu.northwestern.bioinformatics.studycalendar.osgi.OsgiLayerIntegratedTestHelper.*;
import edu.northwestern.bioinformatics.studycalendar.service.SiteService;
import edu.northwestern.bioinformatics.studycalendar.service.dataproviders.SiteConsumer;
import gov.nih.nci.cabig.ctms.testing.MoreJUnitAssertions;

import java.util.Date;

/**
 * @author <NAME>
 */
public class SiteConsumerIntegratedTest extends OsgiLayerIntegratedTestCase {
    private static final String MOCK_PROVIDERS_SYMBOLIC_NAME = "edu.northwestern.bioinformatics.psc-providers-mock";
    private Site site;

    public void setUp() throws Exception {
        super.setUp();
        site = Fixtures.createSite("Iowa Lutheran Hospital", "IA030");
        site.setProvider(MockDataProviderTools.PROVIDER_TOKEN);
        getSiteService().createOrUpdateSite(site);
        startBundle(MOCK_PROVIDERS_SYMBOLIC_NAME, SiteProvider.class.getName());

        dumpBundles();
    }

    public void tearDown() throws Exception {
        stopBundle(MOCK_PROVIDERS_SYMBOLIC_NAME);

        getSiteService().removeSite(site);
        super.tearDown();
    }

    public void testRefreshDoesNotFail() throws Exception {
        Site refreshed = getSiteConsumer().refresh(site);
        assertEquals("Iowa Lutheran Hospital", refreshed.getName());
        assertNotNull("Could not find test site", refreshed);
        assertNotNull("Test site not refreshed", refreshed.getLastRefresh());
        MoreJUnitAssertions.assertDatesClose("Not refreshed recently", new Date(), refreshed.getLastRefresh(), 5000);
    }

    ////// HELPERS

    private SiteService getSiteService() {
        return ((SiteService) getApplicationContext().getBean("siteService"));
    }

    private SiteConsumer getSiteConsumer() {
        return (SiteConsumer) getApplicationContext().getBean("siteConsumer");
    }
}<commit_msg>Port r6505: Widen definition of "close" for slow CI server.<commit_after>package edu.northwestern.bioinformatics.studycalendar.osgi.providers;

import edu.northwestern.bioinformatics.studycalendar.dataproviders.api.SiteProvider;
import edu.northwestern.bioinformatics.studycalendar.dataproviders.mock.MockDataProviderTools;
import edu.northwestern.bioinformatics.studycalendar.domain.Fixtures;
import edu.northwestern.bioinformatics.studycalendar.domain.Site;
import edu.northwestern.bioinformatics.studycalendar.osgi.OsgiLayerIntegratedTestCase;
import static edu.northwestern.bioinformatics.studycalendar.osgi.OsgiLayerIntegratedTestHelper.*;
import edu.northwestern.bioinformatics.studycalendar.service.SiteService;
import edu.northwestern.bioinformatics.studycalendar.service.dataproviders.SiteConsumer;
import gov.nih.nci.cabig.ctms.testing.MoreJUnitAssertions;

import java.util.Date;

/**
 * @author <NAME>
 */
public class SiteConsumerIntegratedTest extends OsgiLayerIntegratedTestCase {
    private static final String MOCK_PROVIDERS_SYMBOLIC_NAME = "edu.northwestern.bioinformatics.psc-providers-mock";
    private Site site;

    public void setUp() throws Exception {
        super.setUp();
        site = Fixtures.createSite("Iowa Lutheran Hospital", "IA030");
        site.setProvider(MockDataProviderTools.PROVIDER_TOKEN);
        getSiteService().createOrUpdateSite(site);
        startBundle(MOCK_PROVIDERS_SYMBOLIC_NAME, SiteProvider.class.getName());

        dumpBundles();
    }

    public void tearDown() throws Exception {
        stopBundle(MOCK_PROVIDERS_SYMBOLIC_NAME);

        getSiteService().removeSite(site);
        super.tearDown();
    }

    public void testRefreshDoesNotFail() throws Exception {
        Site refreshed = getSiteConsumer().refresh(site);
        assertEquals("Iowa Lutheran Hospital", refreshed.getName());
        assertNotNull("Could not find test site", refreshed);
        assertNotNull("Test site not refreshed", refreshed.getLastRefresh());
        MoreJUnitAssertions.assertDatesClose("Not refreshed recently", new Date(), refreshed.getLastRefresh(), 15000);
    }

    ////// HELPERS

    private SiteService getSiteService() {
        return ((SiteService) getApplicationContext().getBean("siteService"));
    }

    private SiteConsumer getSiteConsumer() {
        return (SiteConsumer) getApplicationContext().getBean("siteConsumer");
    }
}
{'fraction_non_alphanumeric': 0.09943360604153556, 'fraction_numerical': 0.003985735263268303, 'mean_word_length': 4.835985312117503, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3027485', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1289, 'n_words': 221}