use of ru.sbtqa.tag.pagefactory.annotations.ActionTitles in project page-factory-2 by sbtqa.
the class PageFactoryUtils method isRequiredAction.
/**
* Check whether given method has {@link ActionTitle} or
* {@link ActionTitles} annotation with required title
*
* @param method method to check
* @param title required title
* @return true|false
*/
public static Boolean isRequiredAction(Method method, final String title) {
ActionTitle actionTitle = method.getAnnotation(ActionTitle.class);
ActionTitles actionTitles = method.getAnnotation(ActionTitles.class);
List<ActionTitle> actionList = new ArrayList<>();
if (actionTitles != null) {
actionList.addAll(Arrays.asList(actionTitles.value()));
}
if (actionTitle != null) {
actionList.add(actionTitle);
}
for (ActionTitle action : actionList) {
String actionValue = action.value();
try {
I18N i18n = I18N.getI18n(method.getDeclaringClass(), TagCucumber.getFeature().getI18n().getLocale());
actionValue = i18n.get(action.value());
} catch (I18NRuntimeException e) {
LOG.debug("There is no bundle for translation class. Leave it as is", e);
}
if (actionValue.equals(title)) {
return true;
}
}
return false;
}
use of ru.sbtqa.tag.pagefactory.annotations.ActionTitles in project page-factory-2 by sbtqa.
the class DefaultReflection method isRequiredAction.
@Override
public Boolean isRequiredAction(Method method, String title) {
ActionTitle actionTitle = method.getAnnotation(ActionTitle.class);
ActionTitles actionTitles = method.getAnnotation(ActionTitles.class);
List<ActionTitle> actionList = new ArrayList<>();
if (actionTitles != null) {
actionList.addAll(Arrays.asList(actionTitles.value()));
}
if (actionTitle != null) {
actionList.add(actionTitle);
}
for (ActionTitle action : actionList) {
if (action.value().equals(title)) {
return true;
}
}
return false;
}
Aggregations