private InvocationStrategy obtainStrategyFor(IInvokedMethodListener listenerInstance, InvokedMethodListenerMethod listenerMethod) { InvokedMethodListenerSubtype invokedMethodListenerSubtype = InvokedMethodListenerSubtype .fromListener(listenerInstance); Map<InvokedMethodListenerMethod, InvocationStrategy> strategiesForListenerType = strategies .get(invokedMethodListenerSubtype); InvocationStrategy invocationStrategy = strategiesForListenerType.get(listenerMethod); return invocationStrategy; }
public static InvokedMethodListenerSubtype fromListener(IInvokedMethodListener listenerInstance) { if (EXTENDED_LISTENER.isInstance(listenerInstance)) { return EXTENDED_LISTENER; } else if (SIMPLE_LISTENER.isInstance(listenerInstance)) { return SIMPLE_LISTENER; } throw new TestNGException("Illegal " + IInvokedMethodListener.class.getSimpleName() + " instance: " + listenerInstance.getClass().getName() + "."); } }
private InvocationStrategy obtainStrategyFor( IInvokedMethodListener listenerInstance, InvokedMethodListenerMethod listenerMethod) { InvokedMethodListenerSubtype invokedMethodListenerSubtype = InvokedMethodListenerSubtype.fromListener(listenerInstance); Map<InvokedMethodListenerMethod, InvocationStrategy> strategiesForListenerType = strategies.get(invokedMethodListenerSubtype); return strategiesForListenerType.get(listenerMethod); }
public static InvokedMethodListenerSubtype fromListener(IInvokedMethodListener listenerInstance) { if (EXTENDED_LISTENER.isInstance(listenerInstance)) { return EXTENDED_LISTENER; } else if (SIMPLE_LISTENER.isInstance(listenerInstance)) { return SIMPLE_LISTENER; } throw new TestNGException( "Illegal " + IInvokedMethodListener.class.getSimpleName() + " instance: " + listenerInstance.getClass().getName() + "."); } }
@Test public void testFromListenerUsingExtendedListenerInstance() { IInvokedMethodListener extendedListenerInstance = new ExtendedInvokedMethodListenerDummy(); InvokedMethodListenerSubtype listenerSubtype = InvokedMethodListenerSubtype.fromListener(extendedListenerInstance); Assert.assertEquals(listenerSubtype, InvokedMethodListenerSubtype.EXTENDED_LISTENER); }
@Test public void testFromListenerUsingSimpleListenerInstance() { final IInvokedMethodListener simpleListenerInstance = new SimpleInvokedMethodListenerDummy(); InvokedMethodListenerSubtype listenerSubtype = InvokedMethodListenerSubtype.fromListener(simpleListenerInstance); Assert.assertEquals(listenerSubtype, InvokedMethodListenerSubtype.SIMPLE_LISTENER); }