<commit_before>package com.punchthrough.bean.sdk;

import android.test.AndroidTestCase;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

import com.punchthrough.bean.sdk.TestingUtils.LooperRunner;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Integration tests for the BeanManager.
 * Note: This requires an actual bean nearby to pass!
 */
public class TestBeanManager extends AndroidTestCase {

    private LooperRunner lr = new LooperRunner();
    private Thread lrThread = new Thread(lr);
    private BeanManager bm;

    protected void setUp() {
        this.bm = BeanManager.getInstance();
        lrThread.start();
    }

    protected void tearDown() {
        /*
        * "Speaking very generally, never quit() your looper threads. That method exists
        * mostly for historical and testing reasons. In Real Life™, I recommend that you
        * continue to reuse the same looper thread(s) for the life of the process rather
        * than creating/quitting them."
        * */
//        lr.quit();
//        lrThread.join();
    }

    public void testDiscovery() throws InterruptedException {
        final CountDownLatch beanLatch = new CountDownLatch(1);
        final List<Bean> beans = new ArrayList<>();

        BeanDiscoveryListener listener = new BeanDiscoveryListener() {
            @Override
            public void onBeanDiscovered(Bean bean, int rssi) {
                beans.add(bean);
                beanLatch.countDown();
            }

            @Override
            public void onDiscoveryComplete() {
                beanLatch.countDown();
            }
        };

        boolean startedOK = this.bm.startDiscovery(listener);
        assertThat(startedOK).isTrue();
        beanLatch.await();
        assertThat(beans.size()).isGreaterThan(0);
    }
}<commit_msg>tests: fix issue when running all tests together<commit_after>package com.punchthrough.bean.sdk;

import android.test.AndroidTestCase;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

import com.punchthrough.bean.sdk.TestingUtils.LooperRunner;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Integration tests for the BeanManager.
 * Note: This requires an actual bean nearby to pass!
 */
public class TestBeanManager extends AndroidTestCase {

    private LooperRunner lr = new LooperRunner();
    private Thread lrThread = new Thread(lr);
    private BeanManager bm;

    protected void setUp() {
        this.bm = BeanManager.getInstance();
        lrThread.start();
    }

    protected void tearDown() {
        /*
        * "Speaking very generally, never quit() your looper threads. That method exists
        * mostly for historical and testing reasons. In Real Life™, I recommend that you
        * continue to reuse the same looper thread(s) for the life of the process rather
        * than creating/quitting them."
        * */
//        lr.quit();
//        lrThread.join();
    }

    public void testDiscovery() throws InterruptedException {
        final CountDownLatch beanLatch = new CountDownLatch(1);
        final List<Bean> beans = new ArrayList<>();

        BeanDiscoveryListener listener = new BeanDiscoveryListener() {
            @Override
            public void onBeanDiscovered(Bean bean, int rssi) {
                beans.add(bean);
                beanLatch.countDown();
            }

            @Override
            public void onDiscoveryComplete() {
                beanLatch.countDown();
            }
        };

        boolean startedOK = this.bm.startDiscovery(listener);
        assertThat(startedOK).isTrue();
        beanLatch.await();
        assertThat(beans.size()).isGreaterThan(0);
        this.bm.cancelDiscovery();
        for (Bean bean : beans) {
            if (bean.isConnected()) {
                bean.disconnect();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09429657794676806, 'fraction_numerical': 0.0010139416983523447, 'mean_word_length': 2.4164502164502166, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3836689', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1027, 'n_words': 291}