@Test void testFirstMatchingResolverMayReturnValue() throws Exception { Method equals = getClass().getMethod("equals", Object.class); final EventMessage<Object> message = GenericEventMessage.asEventMessage("test"); when(mockFactory1.createInstance(ArgumentMatchers.any(Executable.class), ArgumentMatchers.any(), ArgumentMatchers.anyInt())) .thenReturn(null); when(mockResolver2.matches(message)).thenReturn(true); when(mockResolver2.resolveParameterValue(message)).thenReturn("Resolved"); ParameterResolver factory = testSubject.createInstance(equals, equals.getParameters(), 0); assertTrue(factory.matches(message)); assertEquals("Resolved", factory.resolveParameterValue(message)); verify(mockResolver1, never()).resolveParameterValue(any(Message.class)); }
@Override public ParameterResolver createInstance(Executable executable, Parameter[] parameters, int parameterIndex) { for (ParameterResolverFactory factory : factories) { ParameterResolver resolver = factory.createInstance(executable, parameters, parameterIndex); if (resolver != null) { return resolver; } } return null; }
MultiParameterResolverFactory implements ParameterResolverFactory { @Override public ParameterResolver createInstance(Executable executable, Parameter[] parameters, int parameterIndex) { for (ParameterResolverFactory factory : factories) { ParameterResolver resolver = factory.createInstance(executable, parameters, parameterIndex); if (resolver != null) { return resolver; } } return null; } }
MultiParameterResolverFactory implements ParameterResolverFactory { @Override public ParameterResolver createInstance(Executable executable, Parameter[] parameters, int parameterIndex) { for (ParameterResolverFactory factory : factories) { ParameterResolver resolver = factory.createInstance(executable, parameters, parameterIndex); if (resolver != null) { return resolver; } } return null; } MultiParameterResolverFactory(ParameterResolverFactory... delegates);  MultiParameterResolverFactory(List<ParameterResolverFactory> delegates); }
MultiParameterResolverFactory implements ParameterResolverFactory { @Override public ParameterResolver createInstance(Executable executable, Parameter[] parameters, int parameterIndex) { for (ParameterResolverFactory factory : factories) { ParameterResolver resolver = factory.createInstance(executable, parameters, parameterIndex); if (resolver != null) { return resolver; } } return null; } MultiParameterResolverFactory(ParameterResolverFactory... delegates);  MultiParameterResolverFactory(List<ParameterResolverFactory> delegates); static MultiParameterResolverFactory ordered(ParameterResolverFactory... delegates); static MultiParameterResolverFactory ordered(List<ParameterResolverFactory> delegates); List<ParameterResolverFactory> getDelegates(); @Override ParameterResolver createInstance(Executable executable, Parameter[] parameters, int parameterIndex); }
MultiParameterResolverFactory implements ParameterResolverFactory { @Override public ParameterResolver createInstance(Executable executable, Parameter[] parameters, int parameterIndex) { for (ParameterResolverFactory factory : factories) { ParameterResolver resolver = factory.createInstance(executable, parameters, parameterIndex); if (resolver != null) { return resolver; } } return null; } MultiParameterResolverFactory(ParameterResolverFactory... delegates);  MultiParameterResolverFactory(List<ParameterResolverFactory> delegates); static MultiParameterResolverFactory ordered(ParameterResolverFactory... delegates); static MultiParameterResolverFactory ordered(List<ParameterResolverFactory> delegates); List<ParameterResolverFactory> getDelegates(); @Override ParameterResolver createInstance(Executable executable, Parameter[] parameters, int parameterIndex);  }