/**
* Copyright 2016 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package rx;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
import java.util.*;
import org.junit.*;
import rx.exceptions.TestException;
public class NotificationTest {
@Test
public void testOnNextIntegerNotificationDoesNotEqualNullNotification(){
final Notification integerNotification = Notification.createOnNext(1);
final Notification nullNotification = Notification.createOnNext(null);
assertFalse(integerNotification.equals(nullNotification));
}
@Test
public void testOnNextNullNotificationDoesNotEqualIntegerNotification(){
final Notification integerNotification = Notification.createOnNext(1);
final Notification nullNotification = Notification.createOnNext(null);
assertFalse(nullNotification.equals(integerNotification));
}
@Test
public void testOnNextIntegerNotificationsWhenEqual(){
final Notification integerNotification = Notification.createOnNext(1);
final Notification integerNotification2 = Notification.createOnNext(1);
assertTrue(integerNotification.equals(integerNotification2));
}
@Test
public void testOnNextIntegerNotificationsWhenNotEqual(){
final Notification integerNotification = Notification.createOnNext(1);
final Notification integerNotification2 = Notification.createOnNext(2);
assertFalse(integerNotification.equals(integerNotification2));
}
@Test
public void testOnErrorIntegerNotificationDoesNotEqualNullNotification(){
final Notification integerNotification = Notification.createOnError(new Exception());
final Notification nullNotification = Notification.createOnError(null);
assertFalse(integerNotification.equals(nullNotification));
}
@Test
public void testOnErrorNullNotificationDoesNotEqualIntegerNotification(){
final Notification integerNotification = Notification.createOnError(new Exception());
final Notification nullNotification = Notification.createOnError(null);
assertFalse(nullNotification.equals(integerNotification));
}
@Test
public void testOnErrorIntegerNotificationsWhenEqual(){
final Exception exception = new Exception();
final Notification onErrorNotification = Notification.createOnError(exception);
final Notification onErrorNotification2 = Notification.createOnError(exception);
assertTrue(onErrorNotification.equals(onErrorNotification2));
}
@Test
public void testOnErrorIntegerNotificationWhenNotEqual(){
final Notification onErrorNotification = Notification.createOnError(new Exception());
final Notification onErrorNotification2 = Notification.createOnError(new Exception());
assertFalse(onErrorNotification.equals(onErrorNotification2));
}
@Test
public void createWithClass() {
@SuppressWarnings("deprecation")
Notification n = Notification.createOnCompleted(Integer.class);
assertTrue(n.isOnCompleted());
assertFalse(n.hasThrowable());
assertFalse(n.hasValue());
}
@Test
public void accept() {
@SuppressWarnings("unchecked")
Observer