protected void executeStateChanges(final RequestResponseInteraction interaction, final TestClass testClass, final Object target) { if (!interaction.getProviderStates().isEmpty()) { for (final ProviderState state : interaction.getProviderStates()) { Arrays.stream(testClass.getMethods(State.class)) .filter(method -> ArrayUtils.contains(method.getAnnotation(State.class).value(), state.getName())) .forEach(method -> { if (method.getParameterCount() == 1) { executeMethod(method, target, state.getParams()); } else { executeMethod(method, target); } }); } } }
protected void executeStateChanges(final RequestResponseInteraction interaction, final TestClass testClass, final Object target) { if (!interaction.getProviderStates().isEmpty()) { for (final ProviderState state : interaction.getProviderStates()) { Arrays.stream(testClass.getMethods(State.class)) .filter(method -> ArrayMatcher.matches( method.getAnnotation(State.class).value(), state.getName())) .forEach(method -> { if (isStateMethodWithMapParameter(method)) { executeMethod(method, target, state.getParams()); } else { if (method.getParameterCount() > 0) { // Use regular expressions to pass parameters. executeStateMethodWithRegExp(method, state, target); } else { executeMethod(method, target); } } }); } } }
private void invokeStateChangeMethods(StateChangeAction action) throws Throwable { for (Pair<FrameworkMethod, State> pair : methods) { if (pair.getSecond().action() == action) { if (pair.getFirst().getMethod().getParameterCount() == 1) { pair.getFirst().invokeExplosively(target, providerState.getParams()); } else { pair.getFirst().invokeExplosively(target); } } } } }