/**
 * Copyright (c) 2016-present, RxJava Contributors.
 *
 * 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 hu.akarnokd.rxjava2.swing;

import java.lang.reflect.*;

import org.junit.Test;

public class SwingObservableTest {

    @Test
    public void utilityClass() {
        TestHelper.checkUtilityClass(SwingObservable.class);
    }

    @Test
    public void nullChecks() throws Exception {
        for (Method m : SwingObservable.class.getMethods()) {
            if ((m.getModifiers() & Modifier.STATIC) != 0) {
                if (m.getParameterTypes().length == 1) {
                    try {
                        m.invoke(null, new Object[] { null });
                        throw new RuntimeException(m.toString());
                    } catch (InvocationTargetException ex) {
                        if (!(ex.getCause() instanceof NullPointerException)) {
                            throw new RuntimeException(m.toString(), ex);
                        }
                    }
                }

                if (m.getParameterTypes().length == 2) {
                    try {
                        Object o = null;

                        if (m.getParameterTypes()[1] == Integer.TYPE) {
                            o = 1;
                        }
                        if (m.getParameterTypes()[1] == String.class) {
                            o = "Str";
                        }

                        m.invoke(null, new Object[] { null, o });
                        throw new RuntimeException(m.toString());
                    } catch (InvocationTargetException ex) {
                        if (!(ex.getCause() instanceof NullPointerException)) {
                            throw new RuntimeException(m.toString(), ex);
                        }
                    } catch (Throwable ex) {
                        throw new RuntimeException(m.toString(), ex);
                    }
                }
            }
        }
    }
}

@@ -646,51 +646,254 @@
 ort 
-java.lang.reflect.*;%0A%0Aimport org.junit.Test
+static hu.akarnokd.rxjava2.swing.SwingObservable.actions;%0A%0Aimport java.awt.EventQueue;%0Aimport java.awt.event.ActionEvent;%0Aimport java.lang.reflect.*;%0A%0Aimport javax.swing.JButton;%0A%0Aimport org.junit.Test;%0A%0Aimport io.reactivex.observers.TestObserver
 ;%0A%0Ap
@@ -2666,11 +2666,770 @@
  %7D%0A    %7D
+%0A%0A    @Test%0A    public void abstractButtonAction() %7B%0A        EventQueue.invokeLater(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                JButton button = new JButton();%0A%0A                TestObserver%3CActionEvent%3E to = actions(button)%0A                .test();%0A%0A                button.doClick();%0A%0A                to%0A                  .assertSubscribed()%0A                  .assertValueCount(1)%0A                  .assertNotTerminated();%0A%0A                button.doClick(3);%0A%0A                to.assertValueCount(4)%0A                .assertNotTerminated();%0A%0A                to.dispose();%0A%0A                button.doClick();%0A%0A                to.assertValueCount(4)%0A                .assertNotTerminated();%0A            %7D%0A        %7D);%0A    %7D
 %0A%7D%0A

Add first event test.