private static MetaHolder.Builder setFallbackMethod(MetaHolder.Builder builder, Class<?> declaringClass, Method commandMethod) { FallbackMethod fallbackMethod = MethodProvider.getInstance().getFallbackMethod(declaringClass, commandMethod); if (fallbackMethod.isPresent()) { fallbackMethod.validateReturnType(commandMethod); builder .fallbackMethod(fallbackMethod.getMethod()) .fallbackExecutionType(ExecutionType.getExecutionType(fallbackMethod.getMethod().getReturnType())); } return builder; }
public void testGetFallbackForExtendedCommandV2_extendedParameterFalse() throws NoSuchMethodException { // given Method extFallback = Service.class.getDeclaredMethod("extCommandV2", String.class, Integer.class, Throwable.class); // when Method fallback = MethodProvider.getInstance().getFallbackMethod(Service.class, extFallback, false).getMethod(); // then assertNull(fallback); }
public void testGetFallbackForExtendedCommandV2() throws NoSuchMethodException { // given Method extFallback = Service.class.getDeclaredMethod("extCommandV2", String.class, Integer.class, Throwable.class); // when Method fallback = MethodProvider.getInstance().getFallbackMethod(Service.class, extFallback, true).getMethod(); // then assertParamsTypes(fallback, String.class, Integer.class); }
@Test public void testGetExtendedFallback() throws NoSuchMethodException { // given Method command = Service.class.getDeclaredMethod("command", String.class, Integer.class); // when Method extFallback = MethodProvider.getInstance().getFallbackMethod(Service.class, command).getMethod(); // then assertParamsTypes(extFallback, String.class, Integer.class, Throwable.class); }
@Test @DataProvider({"true", "false"}) public void testGetFallbackForExtendedCommand(boolean extended) throws NoSuchMethodException { // given Method extFallback = Service.class.getDeclaredMethod("extCommand", String.class, Integer.class, Throwable.class); // when Method fallback = MethodProvider.getInstance().getFallbackMethod(Service.class, extFallback, extended).getMethod(); // then assertParamsTypes(fallback, String.class, Integer.class, Throwable.class); }
if (fallbackMethod.isPresent()) { Method fMethod = fallbackMethod.getMethod(); Object[] args = fallbackMethod.isDefault() ? new Object[0] : metaHolder.getArgs(); if (fallbackMethod.isCommand()) {
private static MetaHolder.Builder setFallbackMethod(MetaHolder.Builder builder, Class<?> declaringClass, Method commandMethod) { FallbackMethod fallbackMethod = MethodProvider.getInstance().getFallbackMethod(declaringClass, commandMethod); if (fallbackMethod.isPresent()) { fallbackMethod.validateReturnType(commandMethod); builder .fallbackMethod(fallbackMethod.getMethod()) .fallbackExecutionType(ExecutionType.getExecutionType(fallbackMethod.getMethod().getReturnType())); } return builder; }
if (fallbackMethod.isPresent()) { Method fMethod = fallbackMethod.getMethod(); Object[] args = fallbackMethod.isDefault() ? new Object[0] : metaHolder.getArgs(); if (fallbackMethod.isCommand()) {