### Question:
Signal { public void subscribe(SignalInterface sender, Object receiver, Method method) { synchronized (currentIterator) { if (Arrays.equals(method.getParameterTypes(), argumentTypes)) { Subscription sub = new Subscription(); sub.sender = sender; sub.receiver = receiver; sub.method = method; subscriptions.add(sub); } } } Signal(String name, Class<?>... argumentTypes); void emit(SignalInterface sender, Object... arguments); Class<?>[] getArgumentTypes(); String getName(); void subscribe(SignalInterface sender, Object receiver, Method method); void unsubscribe(Object receiver);  }### Answer:
@Test public void testSignalWithStringMethod() throws SecurityException, NoSuchMethodException { SignalTestClass emittingObject = new SignalTestClass(); Receiver receiver = new Receiver(); emittingObject.subscribe("test", receiver, "onTest"); emittingObject.doSomething("hello"); if (!gotSignal) { fail("Did not get a signal"); } gotSignal = false; }
@Test public void testSignalWithoutArguments() throws SecurityException, NoSuchMethodException { SignalTestClass emittingObject = new SignalTestClass(); Receiver receiver = new Receiver(); emittingObject.subscribe("clicked", receiver, "onClick"); emittingObject.click(); if (!gotSignal) { fail("Did not get a signal"); } gotSignal = false; }