1+ /**
2+ * Copyright 2015 Netflix, Inc.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+ * compliance with the License. You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
10+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+ * the License for the specific language governing permissions and limitations under the License.
12+ */
13+
14+ package io .reactivex ;
15+
16+ import java .util .Optional ;
17+
18+ import org .junit .*;
19+
20+ public class NotificationTest {
21+
22+ @ Test (expected = NullPointerException .class )
23+ public void testOnNextIntegerNotificationDoesNotEqualNullNotification (){
24+ final Try <Optional <Integer >> integerNotification = Notification .next (1 );
25+ final Try <Optional <Integer >> nullNotification = Notification .next (null );
26+ Assert .assertFalse (integerNotification .equals (nullNotification ));
27+ }
28+
29+ @ Test (expected = NullPointerException .class )
30+ public void testOnNextNullNotificationDoesNotEqualIntegerNotification (){
31+ final Try <Optional <Integer >> integerNotification = Notification .next (1 );
32+ final Try <Optional <Integer >> nullNotification = Notification .next (null );
33+ Assert .assertFalse (nullNotification .equals (integerNotification ));
34+ }
35+
36+ @ Test
37+ public void testOnNextIntegerNotificationsWhenEqual (){
38+ final Try <Optional <Integer >> integerNotification = Notification .next (1 );
39+ final Try <Optional <Integer >> integerNotification2 = Notification .next (1 );
40+ Assert .assertTrue (integerNotification .equals (integerNotification2 ));
41+ }
42+
43+ @ Test
44+ public void testOnNextIntegerNotificationsWhenNotEqual (){
45+ final Try <Optional <Integer >> integerNotification = Notification .next (1 );
46+ final Try <Optional <Integer >> integerNotification2 = Notification .next (2 );
47+ Assert .assertFalse (integerNotification .equals (integerNotification2 ));
48+ }
49+
50+ @ Test
51+ public void testOnErrorIntegerNotificationDoesNotEqualNullNotification (){
52+ final Try <Optional <Integer >> integerNotification = Notification .error (new Exception ());
53+ final Try <Optional <Integer >> nullNotification = Notification .error (null );
54+ Assert .assertFalse (integerNotification .equals (nullNotification ));
55+ }
56+
57+ @ Test
58+ public void testOnErrorNullNotificationDoesNotEqualIntegerNotification (){
59+ final Try <Optional <Integer >> integerNotification = Notification .error (new Exception ());
60+ final Try <Optional <Integer >> nullNotification = Notification .error (null );
61+ Assert .assertFalse (nullNotification .equals (integerNotification ));
62+ }
63+
64+ @ Test
65+ public void testOnErrorIntegerNotificationsWhenEqual (){
66+ final Exception exception = new Exception ();
67+ final Try <Optional <Integer >> onErrorNotification = Notification .error (exception );
68+ final Try <Optional <Integer >> onErrorNotification2 = Notification .error (exception );
69+ Assert .assertTrue (onErrorNotification .equals (onErrorNotification2 ));
70+ }
71+
72+ @ Test
73+ public void testOnErrorIntegerNotificationWhenNotEqual (){
74+ final Try <Optional <Integer >> onErrorNotification = Notification .error (new Exception ());
75+ final Try <Optional <Integer >> onErrorNotification2 = Notification .error (new Exception ());
76+ Assert .assertFalse (onErrorNotification .equals (onErrorNotification2 ));
77+ }
78+ }
0 commit comments