<commit_before>package com.openxc.sinks;

import java.util.HashMap;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import com.openxc.remote.RawMeasurement;
import com.openxc.remote.VehicleServiceListenerInterface;

public class RemoteCallbackSinkTest {
    Map<String, RawMeasurement> measurements;
    RemoteCallbackSink notifier;
    VehicleServiceListenerInterface listener;
    String measurementId = "the_measurement";
    String receivedId = null;

    @Before
    public void setUp() {
        // TODO what are the contractual guarantees that this class says about
        // this measurements map?
        measurements = new HashMap<String, RawMeasurement>();
        notifier = new RemoteCallbackSink();
        notifier.setMeasurements(measurements);
        listener = new VehicleServiceListenerInterface.Stub() {
            public void receive(String measurementId, RawMeasurement value) {
                receivedId = measurementId;
            }
        };
    }

    @Test
    public void testRegister() {
        assertThat(notifier.getListenerCount(), equalTo(0));
        notifier.register(listener);
        assertThat(notifier.getListenerCount(), equalTo(1));
    }

    @Test
    public void testUnregisterInvalid() {
        // this just shouldn't explode, it should ignore it...or should it?
        // failing silently is usually a bad thing
        assertThat(notifier.getListenerCount(), equalTo(0));
        notifier.unregister(listener);
        assertThat(notifier.getListenerCount(), equalTo(0));
    }

    @Test
    public void testUnregisterValid() {
        notifier.register(listener);
        assertThat(notifier.getListenerCount(), equalTo(1));
        notifier.unregister(listener);
        assertThat(notifier.getListenerCount(), equalTo(0));
    }

    @Test
    public void testReceiveCorrectId() {
        notifier.register(listener);
        assertThat(receivedId, equalTo(null));
        notifier.receive(measurementId, new RawMeasurement(1));
        assertThat(receivedId, equalTo(measurementId));
    }
}<commit_msg>Enable a test case that was overlooked.<commit_after>package com.openxc.sinks;

import java.util.HashMap;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import com.openxc.remote.RawMeasurement;
import com.openxc.remote.VehicleServiceListenerInterface;

import android.test.AndroidTestCase;

import android.test.suitebuilder.annotation.SmallTest;

public class RemoteCallbackSinkTest extends AndroidTestCase {
    Map<String, RawMeasurement> measurements;
    RemoteCallbackSink notifier;
    VehicleServiceListenerInterface listener;
    String measurementId = "the_measurement";
    String receivedId = null;

    @Before
    public void setUp() {
        // TODO what are the contractual guarantees that this class says about
        // this measurements map?
        measurements = new HashMap<String, RawMeasurement>();
        notifier = new RemoteCallbackSink();
        notifier.setMeasurements(measurements);
        listener = new VehicleServiceListenerInterface.Stub() {
            public void receive(String measurementId, RawMeasurement value) {
                receivedId = measurementId;
            }
        };
    }

    @SmallTest
    public void testRegister() {
        assertThat(notifier.getListenerCount(), equalTo(0));
        notifier.register(listener);
        assertThat(notifier.getListenerCount(), equalTo(1));
    }

    @SmallTest
    public void testUnregisterInvalid() {
        // this just shouldn't explode, it should ignore it...or should it?
        // failing silently is usually a bad thing
        assertThat(notifier.getListenerCount(), equalTo(0));
        notifier.unregister(listener);
        assertThat(notifier.getListenerCount(), equalTo(0));
    }

    @SmallTest
    public void testUnregisterValid() {
        notifier.register(listener);
        assertThat(notifier.getListenerCount(), equalTo(1));
        notifier.unregister(listener);
        assertThat(notifier.getListenerCount(), equalTo(0));
    }

    @SmallTest
    public void testReceiveCorrectId() {
        notifier.register(listener);
        assertThat(receivedId, equalTo(null));
        notifier.receive(measurementId, new RawMeasurement(1));
        assertThat(receivedId, equalTo(measurementId));
    }
}
{'fraction_non_alphanumeric': 0.09449339207048459, 'fraction_numerical': 0.0030837004405286344, 'mean_word_length': 3.3083491461100567, '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': '533620', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1201, 'n_words': 272}