/** * Reads action path from the action method. */ protected String[] readMethodActionPath(final String methodName, final ActionAnnotationValues annotationValues, final ActionConfig actionConfig) { // read annotation String methodActionPath = annotationValues != null ? annotationValues.value() : null; if (methodActionPath == null) { methodActionPath = methodName; } else { if (methodActionPath.equals(Action.NONE)) { return ArraysUtil.array(null, null); } } // check for defaults for (String path : actionConfig.getActionMethodNames()) { if (methodActionPath.equals(path)) { methodActionPath = null; break; } } return ArraysUtil.array(methodName, methodActionPath); }
@Test void testCustomActionAnnotation() throws NoSuchMethodException { final AnnotationParser annotationParser = parserFor(CustomAction.class); Method method = this.getClass().getMethod("hello3"); ActionAnnotationValues annotationValues = ActionAnnotationValues.of(annotationParser, method); assertEquals("ALIAS", annotationValues.alias()); assertNull(annotationValues.value()); method = this.getClass().getMethod("hello4"); annotationValues = ActionAnnotationValues.of(annotationParser, method); assertEquals("ALIAS", annotationValues.alias()); assertNull(annotationValues.value()); }
@Test void testMiscActionAnnotation() throws NoSuchMethodException { final AnnotationParser annotationParser = parserFor(MiscAnnotation.class); Method method = this.getClass().getMethod("hello5"); ActionAnnotationValues annotationValues = ActionAnnotationValues.of(annotationParser, method); assertNull(annotationValues.alias()); assertEquals("VAL", annotationValues.value()); method = this.getClass().getMethod("hello6"); annotationValues = ActionAnnotationValues.of(annotationParser, method); assertNull(annotationValues.alias()); assertEquals("VAL", annotationValues.value()); }
@Test void testActionAnnotationOnly() throws NoSuchMethodException { Method method = this.getClass().getMethod("hello"); ActionAnnotationValues annotationValues = annValueOf(method); assertNull(annotationValues.alias()); assertNull(annotationValues.value()); method = this.getClass().getMethod("hello2"); annotationValues = annValueOf(method); assertEquals("alias", annotationValues.alias); assertEquals("value.ext", annotationValues.value); }