Search in sources :

Example 1 with Mutator

use of ru.sbtqa.tag.api.annotation.Mutator in project page-factory-2 by sbtqa.

the class MutatorApplicator method getMutator.

private Method getMutator(EndpointEntry endpoint, Field field) {
    Mutator mutator = field.getAnnotation(Mutator.class);
    Class container = mutator.clazz() == EmptyClass.class ? endpoint.getClass() : mutator.clazz();
    Method setter = Arrays.stream(container.getMethods()).filter(method -> Objects.equals(method.getName(), mutator.method())).findFirst().orElseThrow(() -> new RestPluginException(format("Mutator method \"%s\" is not found", mutator.method())));
    setter.setAccessible(true);
    return setter;
}
Also used : Mutator(ru.sbtqa.tag.api.annotation.Mutator) EmptyClass(ru.sbtqa.tag.api.utils.EmptyClass) EmptyClass(ru.sbtqa.tag.api.utils.EmptyClass) Method(java.lang.reflect.Method) RestPluginException(ru.sbtqa.tag.api.exception.RestPluginException)

Aggregations

Method (java.lang.reflect.Method)1 Mutator (ru.sbtqa.tag.api.annotation.Mutator)1 RestPluginException (ru.sbtqa.tag.api.exception.RestPluginException)1 EmptyClass (ru.sbtqa.tag.api.utils.EmptyClass)1