<commit_before>package satellite.util;

import org.junit.Test;
import org.mockito.Mockito;

import rx.Notification;
import rx.exceptions.OnErrorNotImplementedException;
import rx.functions.Action0;
import rx.functions.Action1;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

public class RxNotificationTest {

    @Test
    public void testSplit1() throws Exception {
        Action1<Integer> onNext = Mockito.mock(Action1.class);
        RxNotification.split(onNext).call(Notification.createOnNext(1));
        RxNotification.split(onNext).call(Notification.<Integer>createOnCompleted());
        verify(onNext, times(1)).call(1);
        verifyNoMoreInteractions(onNext);
    }

    @Test(expected = OnErrorNotImplementedException.class)
    public void testSplit1OnError() throws Exception {
        Action1<Integer> onNext = Mockito.mock(Action1.class);
        RxNotification.split(onNext).call(Notification.<Integer>createOnError(new RuntimeException()));
    }

    @Test
    public void testSplit2() throws Exception {
        Action1<Integer> onNext = Mockito.mock(Action1.class);
        Action1<Throwable> onError = Mockito.mock(Action1.class);

        Action1<Notification<Integer>> split = RxNotification.split(onNext, onError);

        split.call(Notification.createOnNext(1));
        RuntimeException exception = new RuntimeException();
        split.call(Notification.<Integer>createOnError(exception));
        split.call(Notification.<Integer>createOnCompleted());
        verify(onNext, times(1)).call(1);
        verify(onError, times(1)).call(exception);
        verifyNoMoreInteractions(onNext, onError);
    }

    @Test
    public void testSplit3() throws Exception {
        Action1<Integer> onNext = Mockito.mock(Action1.class);
        Action1<Throwable> onError = Mockito.mock(Action1.class);

        Action0 onCompleted = Mockito.mock(Action0.class);
        Action1<Notification<Integer>> split = RxNotification.split(onNext, onError, onCompleted);

        split.call(Notification.createOnNext(1));
        RuntimeException exception = new RuntimeException();
        split.call(Notification.<Integer>createOnError(exception));
        split.call(Notification.<Integer>createOnCompleted());
        verify(onNext, times(1)).call(1);
        verify(onError, times(1)).call(exception);
        verify(onCompleted, times(1)).call();
        verifyNoMoreInteractions(onNext, onError, onCompleted);
    }

    @Test
    public void testNull() throws Exception {
        Action1<Notification<Integer>> split = RxNotification.split(null, null, null);
        split.call(Notification.createOnNext(1));
        split.call(Notification.<Integer>createOnCompleted());
        split.call(Notification.<Integer>createOnError(null));
    }
}<commit_msg>OnErrorNotImplemented test<commit_after>package satellite.util;

import org.junit.Test;
import org.mockito.Mockito;

import rx.Notification;
import rx.exceptions.OnErrorNotImplementedException;
import rx.functions.Action0;
import rx.functions.Action1;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

public class RxNotificationTest {

    @Test
    public void testSplit1() throws Exception {
        Action1<Integer> onNext = Mockito.mock(Action1.class);
        RxNotification.split(onNext).call(Notification.createOnNext(1));
        RxNotification.split(onNext).call(Notification.<Integer>createOnCompleted());
        verify(onNext, times(1)).call(1);
        verifyNoMoreInteractions(onNext);
    }

    @Test(expected = OnErrorNotImplementedException.class)
    public void testSplit1OnError() throws Exception {
        Action1<Integer> onNext = Mockito.mock(Action1.class);
        RxNotification.split(onNext).call(Notification.<Integer>createOnError(new RuntimeException()));
    }

    @Test
    public void testSplit2() throws Exception {
        Action1<Integer> onNext = Mockito.mock(Action1.class);
        Action1<Throwable> onError = Mockito.mock(Action1.class);

        Action1<Notification<Integer>> split = RxNotification.split(onNext, onError);

        split.call(Notification.createOnNext(1));
        RuntimeException exception = new RuntimeException();
        split.call(Notification.<Integer>createOnError(exception));
        split.call(Notification.<Integer>createOnCompleted());
        verify(onNext, times(1)).call(1);
        verify(onError, times(1)).call(exception);
        verifyNoMoreInteractions(onNext, onError);
    }

    @Test
    public void testSplit3() throws Exception {
        Action1<Integer> onNext = Mockito.mock(Action1.class);
        Action1<Throwable> onError = Mockito.mock(Action1.class);

        Action0 onCompleted = Mockito.mock(Action0.class);
        Action1<Notification<Integer>> split = RxNotification.split(onNext, onError, onCompleted);

        split.call(Notification.createOnNext(1));
        RuntimeException exception = new RuntimeException();
        split.call(Notification.<Integer>createOnError(exception));
        split.call(Notification.<Integer>createOnCompleted());
        verify(onNext, times(1)).call(1);
        verify(onError, times(1)).call(exception);
        verify(onCompleted, times(1)).call();
        verifyNoMoreInteractions(onNext, onError, onCompleted);
    }

    @Test
    public void testNull() throws Exception {
        Action1<Notification<Integer>> split = RxNotification.split(null, null, null);
        split.call(Notification.createOnNext(1));
        split.call(Notification.<Integer>createOnCompleted());
    }

    @Test(expected = OnErrorNotImplementedException.class)
    public void testOnErrorNotImplemented() throws Exception {
        Action1<Notification<Integer>> split = RxNotification.split(null, null, null);
        split.call(Notification.<Integer>createOnError(null));
    }
}
{'fraction_non_alphanumeric': 0.11589348517836208, 'fraction_numerical': 0.012225757829509295, 'mean_word_length': 4.108639863130881, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, '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': '1086901', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1623, 'n_words': 275}